dto

package
v0.0.0-...-3356bae Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: LGPL-2.1 Imports: 0 Imported by: 0

README

This package / folder holds data transfer objects.

Also holds the struct used by a mapper for IN & OUT request and responses structs / objects

Documentation

Index

Constants

View Source
const (
	RegexpMedicationName  = "^[a-zA-Z0-9_-]*$" // allowed only letters, numbers, ‘-‘, ‘_’
	RegexpMedicationCode  = "^[A-Z0-9_]*$"     // allowed only upper case letters, underscore and numbers
	MaxSerialNumberLength = "100"              // serial number (100 characters max)
	WeightLimitDrone      = 500                // weight limit (500gr max)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenData

type AccessTokenData struct {
	Scope  []string
	Claims InjectedParam
}

AccessTokenData using by this REST Api (HLF client node) to grant access to the resources

type Claims

type Claims struct {
	Sub string
	Rol string
}

Claims user claims

type ConfigDB

type ConfigDB struct {
	IsPopulated bool `json:"isPopulated"`
}

type Drone

type Drone struct {
	SerialNumber    string     `json:"serialNumber" valid:"maxstringlength(100)"`
	Model           DroneModel `json:"model" valid:"drone_enum_validation~unknown drone model"`
	WeightLimit     float64    `` /* 130-byte string literal not displayed */
	BatteryCapacity float64    `json:"batteryCapacity" valid:"range(0|100)"`
	State           DroneState `json:"state" valid:"drone_enum_validation~unknown drone state"`
}

Drone model @Description Drone item information

type DroneBatteryLevel

type DroneBatteryLevel struct {
	SerialNumber    string  `json:"serialNumber"`
	BatteryCapacity float64 `json:"batteryCapacity"`
}

type DroneModel

type DroneModel uint
const (
	Lightweight DroneModel = iota
	Middleweight
	Cruiserweight
	Heavyweight
)

func (DroneModel) String

func (droneModel DroneModel) String() string

type DroneState

type DroneState uint
const (
	IDLE DroneState = iota
	LOADING
	LOADED
	DELIVERING
	DELIVERED
	RETURNING
)

func (DroneState) String

func (droneState DroneState) String() string

type GrantIntentResponse

type GrantIntentResponse struct {
	Identifier string // if we use `json:"<source_name>"` we can map any source to a common particular / internal struct field as Identifier used here
	DID        string
}

type InjectedParam

type InjectedParam struct {
	Did      string
	Username string
}

type LogEvent

type LogEvent struct {
	Created             string              `json:"created"`
	UUID                string              `json:"uuid"`
	DronesBatteryLevels []DroneBatteryLevel `json:"dronesBatteryLevels"`
}

type Medication

type Medication struct {
	Name   string  `json:"name" valid:"medication_name_validation~invalid name (allowed only letters - numbers - ‘-‘ - ‘_’)"`
	Weight float64 `json:"weight"`
	Code   string  `json:"code" valid:"medication_code_validation~invalid code (allowed only upper case letters - underscore and numbers)"` // we assume that the code is unique
	Image  string  `json:"image" valid:"base64"`
}

Medication model @Description Medication item information

type Problem

type Problem struct {
	Status uint   `example:"503"`
	Title  string `example:"err_code"`
	Detail string `example:"Some error details"`
}

Problem api documentation

func NewProblem

func NewProblem(s uint, t string, d string) *Problem

NewProblem construct a new api error struct and return a pointer to it

- s [uint] ~ HTTP status tu respond

- t [string] ~ Title of the error

- d [string] ~ Description or detail of the error

type RequestDrone

type RequestDrone struct {
	SerialNumber    string     `json:"serialNumber" valid:"maxstringlength(100)"`
	Model           DroneModel `json:"model" valid:"drone_enum_validation~unknown drone model"`
	BatteryCapacity float64    `json:"batteryCapacity" valid:"range(0|100)"`
	State           DroneState `json:"state" valid:"drone_enum_validation~unknown drone state"`
}

RequestDrone model @Description drone model without the weightLimit, it is used for endpoint request @Description the weight limit is calculated from the drone's model (Lightweight, Middleweight, Cruiserweight, Heavyweight)

type StatusMsg

type StatusMsg struct {
	OK bool `json:"ok"`
}

type User

type User struct {
	Username   string `json:"username"`
	Passphrase string `json:"passphrase"`
	Name       string `json:"name"`
}

User struct

type UserCredIn

type UserCredIn struct {
	Username string `example:"richard.sargon@meinermail.com" validate:"required,ascii,gte=3,lte=60"`
	Password string `example:"password1" validate:"required,ascii,gte=3,lte=20"`
}

UserCredIn Is a example declaring the validation for tech struct. It will be used when the struct is in the endpoint parameters

Jump to

Keyboard shortcuts

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