domain

package
v0.0.0-...-0268f66 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidApiErrorType = errors.New("not a valid ApiErrorType")
View Source
var ErrInvalidPropulsionType = errors.New("not a valid PropulsionType")
View Source
var ErrInvalidVehicleType = errors.New("not a valid VehicleType")

Functions

func Stringify

func Stringify[T fmt.Stringer](items []T) []string

func ValidateVehicle

func ValidateVehicle(value any) []string

Types

type ApiError

type ApiError struct {
	Type    ApiErrorType
	Details []string
}

func (ApiError) Description

func (res ApiError) Description() string

func (ApiError) Error

func (res ApiError) Error() string

func (ApiError) MarshalJSON

func (res ApiError) MarshalJSON() ([]byte, error)

type ApiErrorType

type ApiErrorType int

ENUM(unknown, bad_param, missing_param, already_registered, unregistered)

const (
	// ApiErrorTypeUnknown is a ApiErrorType of type Unknown.
	ApiErrorTypeUnknown ApiErrorType = iota
	// ApiErrorTypeBadParam is a ApiErrorType of type Bad_param.
	ApiErrorTypeBadParam
	// ApiErrorTypeMissingParam is a ApiErrorType of type Missing_param.
	ApiErrorTypeMissingParam
	// ApiErrorTypeAlreadyRegistered is a ApiErrorType of type Already_registered.
	ApiErrorTypeAlreadyRegistered
	// ApiErrorTypeUnregistered is a ApiErrorType of type Unregistered.
	ApiErrorTypeUnregistered
)

func ParseApiErrorType

func ParseApiErrorType(name string) (ApiErrorType, error)

ParseApiErrorType attempts to convert a string to a ApiErrorType.

func (ApiErrorType) IsValid

func (x ApiErrorType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ApiErrorType) MarshalText

func (x ApiErrorType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (*ApiErrorType) Scan

func (x *ApiErrorType) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (ApiErrorType) String

func (x ApiErrorType) String() string

String implements the Stringer interface.

func (*ApiErrorType) UnmarshalText

func (x *ApiErrorType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

func (ApiErrorType) Value

func (x ApiErrorType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type AuthInfo

type AuthInfo struct {
	ProviderID uuid.UUID `json:"provider_id"`
}

type BulkApiResponse

type BulkApiResponse[T any] struct {
	Success  int
	Total    int
	Failures []FailureDetails[T]
}

func (BulkApiResponse[T]) MarshalJSON

func (response BulkApiResponse[T]) MarshalJSON() ([]byte, error)

type FailureDetails

type FailureDetails[T any] struct {
	ApiError
	Item T
}

func (FailureDetails[T]) MarshalJSON

func (failure FailureDetails[T]) MarshalJSON() ([]byte, error)

KLUDGE:

 Because we are embedding ApiError in FailureDetails, and ApiError has a overridden
	Marshaler implementation which gets promoted to FailureDetails by embedding, if
	we do not manually serializel FailureDetails here the Item field will never be output
	because the promoted Mashaler implementation knows nothing about FailureDetails fields.

type FetchVehicleParams

type FetchVehicleParams struct {
	VehicleID  uuid.UUID
	ProviderID uuid.UUID
}

type ListVehiclesParams

type ListVehiclesParams struct {
	ProviderID uuid.UUID
	Offset     int32
	Limit      int32
}

type Page

type Page[T any] struct {
	Items []T
	Total int64
}

type PaginatedResponse

type PaginatedResponse struct {
	Version string          `json:"version"`
	Links   PaginationLinks `json:"links"`
}

type PaginatedVehiclesResponse

type PaginatedVehiclesResponse struct {
	PaginatedResponse
	Vehicles []Vehicle `json:"vehicles"`
}
type PaginationLinks struct {
	First string `json:"first,omitempty"`
	Last  string `json:"last,omitempty"`
	Prev  string `json:"prev,omitempty"`
	Next  string `json:"next,omitempty"`
}

type PropulsionType

type PropulsionType int

ENUM(unknown, human, electric_assist, electric, combustion, combustion_diesel, hybrid, hydrogen_fuel_cell, plug_in_hybrid)

const (
	// PropulsionTypeUnknown is a PropulsionType of type Unknown.
	PropulsionTypeUnknown PropulsionType = iota
	// PropulsionTypeHuman is a PropulsionType of type Human.
	PropulsionTypeHuman
	// PropulsionTypeElectricAssist is a PropulsionType of type Electric_assist.
	PropulsionTypeElectricAssist
	// PropulsionTypeElectric is a PropulsionType of type Electric.
	PropulsionTypeElectric
	// PropulsionTypeCombustion is a PropulsionType of type Combustion.
	PropulsionTypeCombustion
	// PropulsionTypeCombustionDiesel is a PropulsionType of type Combustion_diesel.
	PropulsionTypeCombustionDiesel
	// PropulsionTypeHybrid is a PropulsionType of type Hybrid.
	PropulsionTypeHybrid
	// PropulsionTypeHydrogenFuelCell is a PropulsionType of type Hydrogen_fuel_cell.
	PropulsionTypeHydrogenFuelCell
	// PropulsionTypePlugInHybrid is a PropulsionType of type Plug_in_hybrid.
	PropulsionTypePlugInHybrid
)

func ParsePropulsionType

func ParsePropulsionType(name string) (PropulsionType, error)

ParsePropulsionType attempts to convert a string to a PropulsionType.

func (PropulsionType) IsValid

func (x PropulsionType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (PropulsionType) MarshalText

func (x PropulsionType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (*PropulsionType) Scan

func (x *PropulsionType) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (PropulsionType) String

func (x PropulsionType) String() string

String implements the Stringer interface.

func (*PropulsionType) UnmarshalText

func (x *PropulsionType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

func (PropulsionType) Value

func (x PropulsionType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Record

type Record struct {
	Entries map[string]any
}

func (Record) MarshalJSON

func (rec Record) MarshalJSON() ([]byte, error)

func (*Record) UnmarshalJSON

func (rec *Record) UnmarshalJSON(data []byte) error

func (Record) Value

func (rec Record) Value() (driver.Value, error)

type Set

type Set[T constraints.Ordered] []T

func NewSet

func NewSet[T constraints.Ordered](items ...T) Set[T]

func (*Set[T]) UnmarshalJSON

func (pts *Set[T]) UnmarshalJSON(data []byte) (err error)

type URL

type URL struct {
	*url.URL
}

func ParseURL

func ParseURL(text string) (u URL, err error)

func (*URL) Clone

func (u *URL) Clone() URL

func (URL) MarshalJSON

func (u URL) MarshalJSON() (text []byte, err error)

func (*URL) ModifyQuery

func (u *URL) ModifyQuery(mod func(query *url.Values)) URL

func (*URL) String

func (u *URL) String() string

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(text []byte) (err error)

type Vehicle

type Vehicle struct {
	DeviceID                uuid.UUID           `json:"device_id"`
	ProviderID              uuid.UUID           `json:"provider_id"`
	DataProviderID          uuid.UUID           `json:"data_provider_id,omitempty"`
	VehicleID               string              `json:"vehicle_id"`
	VehicleType             VehicleType         `json:"vehicle_type"`
	VehicleAttributes       Record              `json:"vehicle_attributes"`
	PropulsionTypes         Set[PropulsionType] `json:"propulsion_types"`
	AccessibilityAttributes Record              `json:"accessibility_attributes,omitempty"`
	BatteryCapacity         int                 `json:"battery_capacity,omitempty"`
	FuelCapacity            int                 `json:"fuel_capacity,omitempty"`
	MaximumSpeed            int                 `json:"maximum_speed"`
}

type VehicleRepository

type VehicleRepository interface {
	FetchVehicle(ctx context.Context, params FetchVehicleParams) (Vehicle, error)
	ListVehicles(ctx context.Context, params ListVehiclesParams) (Page[Vehicle], error)
	InsertVehicle(ctx context.Context, vehicle Vehicle) error
	UpdateVehicle(ctx context.Context, vehicle Vehicle) error
}

type VehicleType

type VehicleType int

ENUM(other, bicycle, bus, cargo_bicycle, car, delivery_robot, moped, scooter_standing, scooter_seated, truck)

const (
	// VehicleTypeOther is a VehicleType of type Other.
	VehicleTypeOther VehicleType = iota
	// VehicleTypeBicycle is a VehicleType of type Bicycle.
	VehicleTypeBicycle
	// VehicleTypeBus is a VehicleType of type Bus.
	VehicleTypeBus
	// VehicleTypeCargoBicycle is a VehicleType of type Cargo_bicycle.
	VehicleTypeCargoBicycle
	// VehicleTypeCar is a VehicleType of type Car.
	VehicleTypeCar
	// VehicleTypeDeliveryRobot is a VehicleType of type Delivery_robot.
	VehicleTypeDeliveryRobot
	// VehicleTypeMoped is a VehicleType of type Moped.
	VehicleTypeMoped
	// VehicleTypeScooterStanding is a VehicleType of type Scooter_standing.
	VehicleTypeScooterStanding
	// VehicleTypeScooterSeated is a VehicleType of type Scooter_seated.
	VehicleTypeScooterSeated
	// VehicleTypeTruck is a VehicleType of type Truck.
	VehicleTypeTruck
)

func ParseVehicleType

func ParseVehicleType(name string) (VehicleType, error)

ParseVehicleType attempts to convert a string to a VehicleType.

func (VehicleType) IsValid

func (x VehicleType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (VehicleType) MarshalText

func (x VehicleType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (*VehicleType) Scan

func (x *VehicleType) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (VehicleType) String

func (x VehicleType) String() string

String implements the Stringer interface.

func (*VehicleType) UnmarshalText

func (x *VehicleType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

func (VehicleType) Value

func (x VehicleType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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