dto

package
v0.0.0-...-bcf6333 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownTypeToTransform = errors.New("dto: unknown type to transform")

ErrUnknownTypeToTransform is a sentinel error indicating that a type requested to be transformed by this package is not known by this package.

Functions

func Client

func Client(v interface{}) interface{}

Create transforms a single *client.Client to a *ClientOutput.

func Clients

func Clients(v interface{}) interface{}

Clients transforms a []*client.Client to a []*ClientOutput. It delegates to Client.

func Transform

func Transform(v interface{}) (interface{}, error)

Transform attempts to transform v via a known TransformerFunc and return the result.

ErrUnknownTypeToTransform is returned if v is an unknown type.

func User

func User(v interface{}) interface{}

User transforms a *user.User to a *UserOutput.

func Users

func Users(v interface{}) interface{}

Users transforms a []*user.User to a []*UserOutput. It delegates to User.

Types

type ClientOutput

type ClientOutput struct {
	Id        data.Id   `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ClientOutput is a marshalable type that should be used for external representations of client.Client(s) outside the API.

type CreateClient

type CreateClient struct {
	Name string `json:"name" valid:"required"`
}

CreateClient is a form type that should be used for incoming create client requests to the API.

type CreateUser

type CreateUser struct {
	Email     string    `json:"email" valid:"required,email"`
	Enabled   bool      `json:"enabled"`
	ClientIds []data.Id `json"client_ids"`
}

CreateUser is a form type that should be used for incoming create user requests to the API.

type TransformerFunc

type TransformerFunc func(interface{}) interface{}

TransformerFunc is a type that can convert from type to another. Ideally it is used to convert domain types to output, marshalable types.

type UpdateClient

type UpdateClient struct {
	Name *string `json:"name" valid:"omitempty,required"`
}

UpdateClient is a form type that should be used for incoming update client requests to the API.

type UpdateUser

type UpdateUser struct {
	Email     *string    `json:"email" valid:"omitempty,email"`
	Enabled   *bool      `json:"enabled"`
	ClientIds *[]data.Id `json:"client_ids"`
}

UpdateUser is a form type that should be used for incoming udpate user requests to the API.

type UserOutput

type UserOutput struct {
	Id        data.Id   `json:"id"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Enabled   bool      `json:"enabled"`
	ClientIds []data.Id `json:"client_ids"`
}

UserOutput is a marshalable type that should be used to represent a User outside of the API.

Jump to

Keyboard shortcuts

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