order_fulfillment

package
v0.0.0-...-6e54b07 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(r *mux.Router) mux.MiddlewareFunc

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

Types

type DefaultApiController

type DefaultApiController struct {
	// contains filtered or unexported fields
}

A DefaultApiController binds http requests to an api service and writes the service results to the http response

func (*DefaultApiController) GetOrders

func (c *DefaultApiController) GetOrders(w http.ResponseWriter, r *http.Request)

GetOrders - Your GET endpoint

func (*DefaultApiController) GetStatus

func (c *DefaultApiController) GetStatus(w http.ResponseWriter, r *http.Request)

GetStatus - Your GET endpoint

func (*DefaultApiController) PostOrders

func (c *DefaultApiController) PostOrders(w http.ResponseWriter, r *http.Request)

PostOrders -

func (*DefaultApiController) Routes

func (c *DefaultApiController) Routes() Routes

Routes returns all of the api route for the DefaultApiController

type DefaultApiRouter

type DefaultApiRouter interface {
	GetOrders(http.ResponseWriter, *http.Request)
	GetStatus(http.ResponseWriter, *http.Request)
	PostOrders(http.ResponseWriter, *http.Request)
}

DefaultApiRouter defines the required methods for binding the api requests to a responses for the DefaultApi The DefaultApiRouter implementation should parse necessary information from the http request, pass the data to a DefaultApiServicer to perform the required actions, then write the service results to the http response.

type DefaultApiService

type DefaultApiService struct {
}

DefaultApiService is a service that implents the logic for the DefaultApiServicer This service should implement the business logic for every endpoint for the DefaultApi API. Include any external packages or services that will be required by this service.

func (*DefaultApiService) GetOrders

func (s *DefaultApiService) GetOrders(ctx context.Context, orderId string) (ImplResponse, error)

GetOrders - Your GET endpoint

func (*DefaultApiService) GetStatus

func (s *DefaultApiService) GetStatus(ctx context.Context) (ImplResponse, error)

GetStatus - Your GET endpoint

func (*DefaultApiService) PostOrders

func (s *DefaultApiService) PostOrders(ctx context.Context, order Order) (ImplResponse, error)

PostOrders -

type DefaultApiServicer

type DefaultApiServicer interface {
	GetOrders(context.Context, string) (ImplResponse, error)
	GetStatus(context.Context) (ImplResponse, error)
	PostOrders(context.Context, Order) (ImplResponse, error)
}

DefaultApiServicer defines the api actions for the DefaultApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

func NewDefaultApiService

func NewDefaultApiService() DefaultApiServicer

NewDefaultApiService creates a default api service

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

Implementation response defines an error code with the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type Order

type Order struct {
	Items []OrderItems `json:"items"`

	Customer OrderCustomer `json:"customer"`

	Payment OrderPayment `json:"payment,omitempty"`

	// Order ID for future reference
	OrderId string `json:"order_id,omitempty"`

	// Description of order, useful metadata such as presale that occurred, etc.
	Description string `json:"description"`

	// Order status (i.e. awaiting payment, queued, refunded, ...)
	OrderStatus string `json:"order_status,omitempty"`

	// Expiry time of reservation. The order will no longer be payable after this time.
	ReservationExpiry string `json:"reservation_expiry,omitempty"`
}

Order - Describes a single order

type OrderCreated

type OrderCreated struct {
	OrderId string `json:"order_id"`
}

OrderCreated - Response after an order is made

type OrderCustomer

type OrderCustomer struct {

	// Address to deliver tokens to
	DeliveryAddress string `json:"delivery_address"`
}

type OrderItems

type OrderItems struct {
	ProductId string `json:"product_id"`

	Quantity int32 `json:"quantity"`
}

type OrderPayment

type OrderPayment struct {

	// Address to deposit currency
	PaymentAddress string `json:"payment_address,omitempty"`

	// Policy ID of currency
	PriceCurrencyId string `json:"price_currency_id"`

	// Amount due in currency. Use `number` for fiat, but ADA is lovelace integral
	PriceAmount float32 `json:"price_amount"`

	// Payment status (i.e. waiting, received, ...)
	PaymentStatus string `json:"payment_status,omitempty"`

	// Actual amount paid (for partial payments)
	ActuallyPaid float32 `json:"actually_paid,omitempty"`
}

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
}

Router defines the required methods for retrieving api routes

func NewDefaultApiController

func NewDefaultApiController(s DefaultApiServicer) Router

NewDefaultApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

type Status

type Status struct {

	// kill-switch to tell users that the backend is not working correctly / is under maintenance
	Maintenance bool `json:"maintenance"`

	// Status string. \"UP\" if everything is fine.
	Status string `json:"status"`

	// List of errors for bad statuses
	Errors []string `json:"errors,omitempty"`
}

Status - Status of microservice, indicating service availabilities

Jump to

Keyboard shortcuts

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