utilities

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 12 Imported by: 6 modules, 10 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

Overview

Package utilities provides various utility functions and helpers for common operations. Copyright (c) APIMatic. All rights reserved.

Index

Constants

View Source
const DEFAULT_DATE = "2006-01-02"

Variables

This section is empty.

Functions

func AssertEquals added in v0.0.15

func AssertEquals[T comparable](t *testing.T, expected, actual T)

Asserts that both values are equal. This may not apply to all types.

func AssertError added in v0.0.15

func AssertError(t *testing.T, err error)

Asserts that an error is returned (i.e. not nil).

func AssertNoError added in v0.0.15

func AssertNoError(t *testing.T, err error)

Asserts that no error is returned (i.e. nil).

func DecodeResults

func DecodeResults[T any](decoder *json.Decoder) (T, error)

DecodeResults decodes JSON data from the provided json.Decoder into a given type T.

func JsonDecoderToBooleanSlice

func JsonDecoderToBooleanSlice(dec *json.Decoder) ([]bool, error)

JsonDecoderToBooleanSlice decodes a JSON array from the provided json.Decoder into a bool slice.

func JsonDecoderToIntSlice

func JsonDecoderToIntSlice(dec *json.Decoder) ([]int, error)

JsonDecoderToIntSlice decodes a JSON array from the provided json.Decoder into an int slice.

func JsonDecoderToString

func JsonDecoderToString(dec *json.Decoder) (string, error)

JsonDecoderToString decodes a JSON value from the provided json.Decoder into a string.

func JsonDecoderToStringSlice

func JsonDecoderToStringSlice(dec *json.Decoder) ([]string, error)

JsonDecoderToStringSlice decodes a JSON array from the provided json.Decoder into a string slice.

func NullableTimeToStringMap

func NullableTimeToStringMap(dict map[string]*time.Time, format string) map[string]*string

NullableTimeToStringMap converts a map with nullable time.Time values to a map with nullable strings using the specified format.

func PrepareQueryParams

func PrepareQueryParams(queryParams url.Values, data map[string]interface{}) url.Values

PrepareQueryParams adds key-value pairs from the data map to the existing URL query parameters.

func TimeToStringMap

func TimeToStringMap(dict map[string]time.Time, format string) map[string]string

TimeToStringMap converts a map with time.Time values to a map with strings using the specified format.

func TimeToStringSlice

func TimeToStringSlice(slice []time.Time, format string) []string

TimeToStringSlice converts a slice of time.Time values to a slice of strings using the specified format.

func ToNullableTimeMap

func ToNullableTimeMap(dict interface{}, format string) (map[string]*time.Time, error)

ToNullableTimeMap converts a map with nullable string or int64 values to a map with nullable time.Time values using the specified format.

func ToTimeMap

func ToTimeMap(dict interface{}, format string) (map[string]time.Time, error)

ToTimeMap converts a map with string or int64 values to a map with time.Time values using the specified format.

func ToTimeSlice

func ToTimeSlice(slice interface{}, format string) ([]time.Time, error)

ToTimeSlice converts a slice of strings or int64 values to a slice of time.Time values using the specified format.

func UnmarshallAnyOf added in v0.0.17

func UnmarshallAnyOf(data []byte, types ...*TypeHolder) (any, error)

UnmarshallAnyOf tries to unmarshal the data into each of the provided types as an AnyOf group and return the converted value

func UnmarshallAnyOfWithDiscriminator added in v0.0.17

func UnmarshallAnyOfWithDiscriminator(data []byte, discField string, types ...*TypeHolder) (any, error)

UnmarshallAnyOfWithDiscriminator tries to unmarshal the data into each of the provided types as an AnyOf group with discriminators and return the converted value

func UnmarshallOneOf added in v0.0.17

func UnmarshallOneOf(data []byte, types ...*TypeHolder) (any, error)

UnmarshallOneOf tries to unmarshal the data into each of the provided types as a OneOf group and return the converted value

func UnmarshallOneOfWithDiscriminator added in v0.0.17

func UnmarshallOneOfWithDiscriminator(data []byte, discField string, types ...*TypeHolder) (any, error)

UnmarshallOneOfWithDiscriminator tries to unmarshal the data into each of the provided types as a OneOf group with discriminators and return the converted value

func UpdateUserAgent

func UpdateUserAgent(userAgent string) string

UpdateUserAgent replaces placeholders in the user agent string with the actual values.

Types

type Atom added in v0.0.17

type Atom struct {
	NumberOfElectrons int `json:"number_of_electrons"`
	NumberOfProtons   int `json:"number_of_protons"`
}

func (*Atom) UnmarshalJSON added in v0.0.17

func (a *Atom) UnmarshalJSON(input []byte) error

type Bike added in v0.0.17

type Bike struct {
	Id       int                  `json:"id"`
	Roof     *string              `json:"roof"`
	AirLevel types.Optional[Atom] `json:"air_level"`
	Type     *string              `json:"type"`
}

func (*Bike) UnmarshalJSON added in v0.0.17

func (b *Bike) UnmarshalJSON(input []byte) error

type Car added in v0.0.17

type Car struct {
	Id   int     `json:"id"`
	Roof *string `json:"roof"`
	Type *string `json:"type"`
}

func (*Car) UnmarshalJSON added in v0.0.17

func (c *Car) UnmarshalJSON(input []byte) error

type MarshalError added in v0.0.17

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

func NewMarshalError added in v0.0.17

func NewMarshalError(structName string, err error) MarshalError

func (MarshalError) Error added in v0.0.17

func (a MarshalError) Error() string

Error implements the Error function for the error interface. It returns a string representation of the MarshalError instance when used in an error context.

type Truck added in v0.0.17

type Truck struct {
	Id     int     `json:"id"`
	Weight string  `json:"weight"`
	Roof   *string `json:"roof"`
}

func (*Truck) UnmarshalJSON added in v0.0.17

func (c *Truck) UnmarshalJSON(input []byte) error

type TypeHolder added in v0.0.17

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

func NewTypeHolder added in v0.0.17

func NewTypeHolder(val any, isNullableType bool, isSelected *bool) *TypeHolder

func NewTypeHolderDiscriminator added in v0.0.17

func NewTypeHolderDiscriminator(val any, isNullableType bool, isSelected *bool, discriminator string) *TypeHolder

Jump to

Keyboard shortcuts

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