core

package
v0.0.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringifyJSON added in v0.0.35

func StringifyJSON(value interface{}) (string, error)

StringifyJSON returns a pretty JSON string representation of the given value.

func WriteMultipartJSON added in v0.0.35

func WriteMultipartJSON(writer *multipart.Writer, field string, value interface{}) error

WriteMultipartJSON writes the given value as a JSON part. This is used to serialize non-primitive multipart properties (i.e. lists, objects, etc).

Types

type APIError

type APIError struct {
	StatusCode int `json:"-"`
	// contains filtered or unexported fields
}

APIError is a lightweight wrapper around the standard error interface that preserves the status code from the RPC, if any.

func NewAPIError

func NewAPIError(statusCode int, err error) *APIError

NewAPIError constructs a new API error.

func (*APIError) Error

func (a *APIError) Error() string

Error returns the API error's message.

func (*APIError) Unwrap

func (a *APIError) Unwrap() error

Unwrap returns the underlying error. This also makes the error compatible with errors.As and errors.Is.

type CallParams added in v0.0.35

type CallParams struct {
	URL                string
	Method             string
	Headers            http.Header
	Request            interface{}
	Response           interface{}
	ResponseIsOptional bool
	ErrorDecoder       ErrorDecoder
}

CallParams represents the parameters used to issue an API call.

type Caller added in v0.0.35

type Caller struct {
	// contains filtered or unexported fields
}

Caller calls APIs and deserializes their response, if any.

func NewCaller added in v0.0.35

func NewCaller(client HTTPClient) *Caller

NewCaller returns a new *Caller backed by the given HTTP client.

func (*Caller) Call added in v0.0.35

func (c *Caller) Call(ctx context.Context, params *CallParams) error

Call issues an API call according to the given call parameters.

type ClientOption

type ClientOption func(*ClientOptions)

ClientOption adapts the behavior of the generated client.

type ClientOptions

type ClientOptions struct {
	BaseURL    string
	HTTPClient HTTPClient
	HTTPHeader http.Header
	ApiKey     string
}

ClientOptions defines all of the possible client options. This type is primarily used by the generated code and is not meant to be used directly; use ClientOption instead.

func NewClientOptions

func NewClientOptions() *ClientOptions

NewClientOptions returns a new *ClientOptions value. This function is primarily used by the generated code and is not meant to be used directly; use ClientOption instead.

func (*ClientOptions) ToHeader

func (c *ClientOptions) ToHeader() http.Header

ToHeader maps the configured client options into a http.Header issued on every request.

type ErrorDecoder

type ErrorDecoder func(statusCode int, body io.Reader) error

ErrorDecoder decodes *http.Response errors and returns a typed API error (e.g. *APIError).

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is an interface for a subset of the *http.Client.

type Optional added in v0.0.28

type Optional[T any] struct {
	Value T
	Null  bool
}

Optional is a wrapper used to distinguish zero values from null or omitted fields.

To instantiate an Optional, use the `Optional()` and `Null()` helpers exported from the root package.

func (*Optional[T]) MarshalJSON added in v0.0.28

func (o *Optional[T]) MarshalJSON() ([]byte, error)

func (*Optional[T]) String added in v0.0.28

func (o *Optional[T]) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL