Documentation ¶
Overview ¶
Package utilities provides various utility functions and helpers for common operations. Copyright (c) APIMatic. All rights reserved.
Index ¶
- Constants
- func DecodeResults[T any](decoder *json.Decoder) (T, error)
- func JsonDecoderToBooleanSlice(dec *json.Decoder) ([]bool, error)
- func JsonDecoderToIntSlice(dec *json.Decoder) ([]int, error)
- func JsonDecoderToString(dec *json.Decoder) (string, error)
- func JsonDecoderToStringSlice(dec *json.Decoder) ([]string, error)
- func MapAdditionalProperties(destinationMap additionalProperties, sourceMap additionalProperties)
- func NullableTimeToStringMap(dict map[string]*time.Time, format string) map[string]*string
- func ObjMapToTimeMap[T TimeTypes](objMap map[string]T) map[string]time.Time
- func ObjSliceToTimeSlice[T TimeTypes](objSlice []T) []time.Time
- func PrepareQueryParams(queryParams url.Values, data map[string]any) url.Values
- func TimeMapToObjMap[T TimeTypes](timeMap map[string]time.Time) map[string]T
- func TimeSliceToObjSlice[T TimeTypes](timeSlice []time.Time) []T
- func TimeToStringMap(dict map[string]time.Time, format string) map[string]string
- func TimeToStringSlice(slice []time.Time, format string) []string
- func ToNullableTimeMap(dict any, format string) (map[string]*time.Time, error)
- func ToTimeMap(dict any, format string) (map[string]time.Time, error)
- func ToTimeSlice(slice any, format string) ([]time.Time, error)
- func UnmarshalAdditionalProperties(input []byte, keysToRemove ...string) (map[string]any, error)
- func UnmarshallAnyOf(data []byte, types ...*TypeHolder) (any, error)
- func UnmarshallAnyOfWithDiscriminator(data []byte, discField string, types ...*TypeHolder) (any, error)
- func UnmarshallOneOf(data []byte, types ...*TypeHolder) (any, error)
- func UnmarshallOneOfWithDiscriminator(data []byte, discField string, types ...*TypeHolder) (any, error)
- func UpdateUserAgent(userAgent string) string
- type Atom
- type Bike
- type Car
- type DefaultTime
- type MarshalError
- type RFC1123Time
- type RFC3339Time
- type TimeTypes
- type Truck
- type TypeHolder
- type UnixDateTime
Constants ¶
const DEFAULT_DATE = "2006-01-02"
Variables ¶
This section is empty.
Functions ¶
func DecodeResults ¶
DecodeResults decodes JSON data from the provided json.Decoder into a given type T.
func JsonDecoderToBooleanSlice ¶
JsonDecoderToBooleanSlice decodes a JSON array from the provided json.Decoder into a bool slice.
func JsonDecoderToIntSlice ¶
JsonDecoderToIntSlice decodes a JSON array from the provided json.Decoder into an int slice.
func JsonDecoderToString ¶
JsonDecoderToString decodes a JSON value from the provided json.Decoder into a string.
func JsonDecoderToStringSlice ¶
JsonDecoderToStringSlice decodes a JSON array from the provided json.Decoder into a string slice.
func MapAdditionalProperties ¶ added in v0.0.19
func MapAdditionalProperties(destinationMap additionalProperties, sourceMap additionalProperties)
MapAdditionalProperties append additional properties to destination struct map
func NullableTimeToStringMap ¶
NullableTimeToStringMap converts a map with nullable time.Time values to a map with nullable strings using the specified format.
func ObjMapToTimeMap ¶ added in v0.0.19
func ObjSliceToTimeSlice ¶ added in v0.0.19
func PrepareQueryParams ¶
PrepareQueryParams adds key-value pairs from the data map to the existing URL query parameters.
func TimeMapToObjMap ¶ added in v0.0.19
func TimeSliceToObjSlice ¶ added in v0.0.19
func TimeToStringMap ¶
TimeToStringMap converts a map with time.Time values to a map with strings using the specified format.
func TimeToStringSlice ¶
TimeToStringSlice converts a slice of time.Time values to a slice of strings using the specified format.
func ToNullableTimeMap ¶
ToNullableTimeMap converts a map with nullable string or int64 values to a map with nullable time.Time values using the specified format.
func ToTimeMap ¶
ToTimeMap converts a map with string or int64 values to a map with time.Time values using the specified format.
func ToTimeSlice ¶
ToTimeSlice converts a slice of strings or int64 values to a slice of time.Time values using the specified format.
func UnmarshalAdditionalProperties ¶ added in v0.0.19
UnmarshalAdditionalProperties unmarshals additional properties and remove fields that exists on parent struct
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 ¶
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
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
type Car ¶ added in v0.0.17
func (*Car) UnmarshalJSON ¶ added in v0.0.17
type DefaultTime ¶ added in v0.0.19
DefaultTime is a struct that implements time.Time with custom formatting.
func NewDefaultTime ¶ added in v0.0.19
func NewDefaultTime(t time.Time) DefaultTime
func (DefaultTime) MarshalJSON ¶ added in v0.0.19
func (t DefaultTime) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller interface to customize JSON marshaling for DefaultTime objects.
func (DefaultTime) String ¶ added in v0.0.19
func (t DefaultTime) String() string
String returns DefaultTime as string value by following its defined format.
func (*DefaultTime) UnmarshalJSON ¶ added in v0.0.19
func (t *DefaultTime) UnmarshalJSON(input []byte) (err error)
UnmarshalJSON implements json.Unmarshaler interface to customize JSON unmarshalling for DefaultTime objects.
func (DefaultTime) Value ¶ added in v0.0.19
func (t DefaultTime) Value() time.Time
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 RFC1123Time ¶ added in v0.0.19
RFC1123Time is a struct that implements time.Time with custom formatting.
func NewRFC1123Time ¶ added in v0.0.19
func NewRFC1123Time(t time.Time) RFC1123Time
func (RFC1123Time) MarshalJSON ¶ added in v0.0.19
func (t RFC1123Time) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller interface to customize JSON marshaling for RFC1123Time objects.
func (RFC1123Time) String ¶ added in v0.0.19
func (t RFC1123Time) String() string
String returns RFC1123Time as a string following the RFC1123 standard.
func (*RFC1123Time) UnmarshalJSON ¶ added in v0.0.19
func (t *RFC1123Time) UnmarshalJSON(input []byte) (err error)
UnmarshalJSON implements json.Unmarshaler interface to customize JSON unmarshalling for RFC1123Time objects.
func (RFC1123Time) Value ¶ added in v0.0.19
func (t RFC1123Time) Value() time.Time
type RFC3339Time ¶ added in v0.0.19
RFC3339Time is a struct that implements time.Time with custom formatting.
func NewRFC3339Time ¶ added in v0.0.19
func NewRFC3339Time(t time.Time) RFC3339Time
func (RFC3339Time) MarshalJSON ¶ added in v0.0.19
func (t RFC3339Time) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller interface to customize JSON marshaling for RFC3339Time objects.
func (RFC3339Time) String ¶ added in v0.0.19
func (t RFC3339Time) String() string
String returns RFC3339Time as a string following the RFC3339 standard.
func (*RFC3339Time) UnmarshalJSON ¶ added in v0.0.19
func (t *RFC3339Time) UnmarshalJSON(input []byte) (err error)
UnmarshalJSON implements json.Unmarshaler interface to customize JSON unmarshalling for RFC3339Time objects.
func (RFC3339Time) Value ¶ added in v0.0.19
func (t RFC3339Time) Value() time.Time
type TimeTypes ¶ added in v0.0.19
type TimeTypes interface { RFC1123Time | RFC3339Time | UnixDateTime | DefaultTime Value() time.Time }
type Truck ¶ added in v0.0.17
func (*Truck) UnmarshalJSON ¶ added in v0.0.17
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
type UnixDateTime ¶ added in v0.0.19
UnixDateTime is a struct that implements time.Time with custom formatting.
func NewUnixDateTime ¶ added in v0.0.19
func NewUnixDateTime(t time.Time) UnixDateTime
func (UnixDateTime) MarshalJSON ¶ added in v0.0.19
func (u UnixDateTime) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller interface to customize JSON marshaling for UnixDateTime objects.
func (UnixDateTime) String ¶ added in v0.0.19
func (u UnixDateTime) String() string
String returns UnixDateTime as a string following the Unix standard.
func (*UnixDateTime) UnmarshalJSON ¶ added in v0.0.19
func (u *UnixDateTime) UnmarshalJSON(input []byte) error
UnmarshalJSON implements json.Unmarshaler interface to customize JSON unmarshalling for UnixDateTime objects.
func (UnixDateTime) Value ¶ added in v0.0.19
func (t UnixDateTime) Value() time.Time