api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MaxConcurrentLookups = 10

MaxConcurrentLookups controls the number of simultaneous HTTP Order lookups

Variables

This section is empty.

Functions

func BadRequestError

func BadRequestError(w http.ResponseWriter, message string)

BadRequestError is simple Error Wrapper

func InternalServerError

func InternalServerError(w http.ResponseWriter, message string)

InternalServerError is simple Error Wrapper

func NotFoundError

func NotFoundError(w http.ResponseWriter, message string)

NotFoundError is simple Error Wrapper

func UnauthorizedError

func UnauthorizedError(w http.ResponseWriter, message string)

UnauthorizedError is simple Error Wrapper

func UnprocessableEntity

func UnprocessableEntity(w http.ResponseWriter, message string)

UnprocessableEntity is simple Error Wrapper

Types

type API

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

API is the main REST API

func NewAPI

func NewAPI(config *conf.Configuration, db *gorm.DB, mailer *mailer.Mailer) *API

NewAPI instantiates a new REST API

func (*API) Index

func (a *API) Index(ctx context.Context, w http.ResponseWriter, r *http.Request)

Index endpoint

func (*API) ListenAndServe

func (a *API) ListenAndServe(hostAndPort string) error

ListenAndServe starts the REST API

func (*API) OrderCreate

func (a *API) OrderCreate(ctx context.Context, w http.ResponseWriter, r *http.Request)

OrderCreate endpoint

func (*API) OrderList

func (a *API) OrderList(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) OrderView

func (a *API) OrderView(ctx context.Context, w http.ResponseWriter, r *http.Request)

func (*API) PaymentCreate

func (a *API) PaymentCreate(ctx context.Context, w http.ResponseWriter, r *http.Request)

PaymentCreate is the endpoint for creating a payment for an order

func (*API) PaymentList

func (a *API) PaymentList(ctx context.Context, w http.ResponseWriter, r *http.Request)

PaymentList is the endpoint for listing transactions for an order

func (*API) VatnumberLookup

func (a *API) VatnumberLookup(ctx context.Context, w http.ResponseWriter, r *http.Request)

type HTTPError

type HTTPError struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
}

HTTPError is an error with a message

type JWTClaims

type JWTClaims struct {
	ID    string `json:"id"`
	Email string `json:"email"`
	*jwt.StandardClaims
}

type OrderLineItem

type OrderLineItem struct {
	SKU      string `json:sku`
	Path     string `json:"path"`
	Quantity uint64 `json:"quantity"`
}

type OrderParams

type OrderParams struct {
	SessionID string `json:"session_id"`

	Email string `json:"email"`

	ShippingAddressID string          `json:"shipping_address_id"`
	ShippingAddress   *models.Address `json:"shipping_address"`

	BillingAddressID string          `json:"billing_address_id"`
	BillingAddress   *models.Address `json:"billing_address"`

	VATNumber string `json:"vatnumber"`

	Data map[string]interface{} `json:"data"`

	LineItems []*OrderLineItem `json:"line_items"`

	Currency string `json:"currency"`
}

type PaymentParams

type PaymentParams struct {
	Amount      uint64 `json:"amount"`
	Currency    string `json:"currency"`
	StripeToken string `json:"stripe_token"`
}

PaymentParams holds the parameters for creating a payment

Jump to

Keyboard shortcuts

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