quote

package
v0.0.0-...-2e5e463 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientSchema

type ClientSchema struct {
	Quote string `json:"quote"`
}

ClientSchema is the schema the data from the client will be marshalled into

func (ClientSchema) DumpBody

func (cs ClientSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

type CreationSchema

type CreationSchema struct {
	ClientSchema
	// Ignore these fields in user input, they will be filled automatically by the API
	CreatedAt time.Time `json:"createdAt"`
	DeletedAt float64   `json:"deletedAt"`
	Token     string    `json:"token"`
	QuoteID   int       `json:"quoteId"`
	Enabled   bool      `json:"enabled"`
}

CreationSchema is all the data required for a new quote to be created

func (CreationSchema) DumpBody

func (cs CreationSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

func (CreationSchema) GetAPITag

func (cs CreationSchema) GetAPITag(lookup string) string

GetAPITag allows each of these types to implement the JSONAPISchema interface

type Quote

type Quote struct {
	Conn  *rethink.Connection // The RethinkDB connection
	Table string              // The database table we're using
}

Quote is the struct that implements the handler interface for the quote resource

func (*Quote) Create

func (q *Quote) Create(ctx *gin.Context)

Create creates a new record

func (*Quote) Delete

func (q *Quote) Delete(ctx *gin.Context)

Delete soft-deletes a record

func (*Quote) GetAll

func (q *Quote) GetAll(ctx *gin.Context)

GetAll returns all records associated with the token

func (*Quote) GetRandom

func (q *Quote) GetRandom(ctx *gin.Context)

GetRandom retrieves a random quote if any exist

func (*Quote) GetSingle

func (q *Quote) GetSingle(ctx *gin.Context)

GetSingle returns a single record

func (*Quote) ReturnOne

func (q *Quote) ReturnOne(filter map[string]interface{}) (ResponseSchema, error)

ReturnOne retrieves a single record given the filter provided

func (*Quote) Routes

func (q *Quote) Routes() []types.RouteDetails

Routes returns the routing information for this endpoint

func (*Quote) Update

func (q *Quote) Update(ctx *gin.Context)

Update handles the updating of a record if the record exists

type ResponseSchema

type ResponseSchema struct {
	ID        string `jsonapi:"primary,quote"`
	CreatedAt string `jsonapi:"meta,createdAt"`
	Enabled   bool   `jsonapi:"attr,enabled"`
	QuoteID   int    `jsonapi:"attr,quoteId"`
	Quote     string `jsonapi:"attr,quote"`
	Token     string `jsonapi:"meta,token"`
}

ResponseSchema is the schema for the data that will be sent out to the client

func (ResponseSchema) DumpBody

func (rs ResponseSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

func (ResponseSchema) GetAPITag

func (rs ResponseSchema) GetAPITag(lookup string) string

GetAPITag allows each of these types to implement the JSONAPISchema interface

func (ResponseSchema) JSONAPIMeta

func (rs ResponseSchema) JSONAPIMeta() *types.Meta

JSONAPIMeta returns a meta object for the response

type UpdateSchema

type UpdateSchema struct {
	Quote   string `json:"quote,omitempty"`
	Enabled bool   `json:"enabled,omitempty"`
}

UpdateSchema is ClientSchema that is used when updating

func (UpdateSchema) DumpBody

func (us UpdateSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

func (UpdateSchema) GetAPITag

func (us UpdateSchema) GetAPITag(lookup string) string

GetAPITag allows each of these types to implement the JSONAPISchema interface

Jump to

Keyboard shortcuts

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