openapi

package
v0.0.0-...-14d7d22 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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

Types

type Address

type Address struct {

	// The name of the person, company or similar.
	Name string `json:"name"`

	// The ISO 3166-1 alpha-2 country code.
	Country string `json:"country"`

	// The postal code code.
	PostalCode string `json:"postalCode"`

	// The city.
	City string `json:"city"`

	// The street name, number and any suffixes.
	Street string `json:"street"`
}

Address - An address of a person, company or similar.

type Cart

type Cart struct {

	// The UUID of the cart.
	ID string `json:"id"`

	Positions []Position `json:"positions"`

	// Whether the cart is locked.
	Locked bool `json:"locked,omitempty"`
}

Cart - A cart containing products.

type CartsAPI

type CartsAPI struct {
	Authenticator     *authentication.Authenticator
	CartController    *controller.Cart
	ProductController *controller.Product
}

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

func (*CartsAPI) DeleteCart

func (c *CartsAPI) DeleteCart(w http.ResponseWriter, r *http.Request)

DeleteCart - Delete a cart

func (*CartsAPI) GetAllCarts

func (c *CartsAPI) GetAllCarts(w http.ResponseWriter, r *http.Request)

GetAllCarts - Get all carts

func (*CartsAPI) GetCart

func (c *CartsAPI) GetCart(w http.ResponseWriter, r *http.Request)

GetCart - Get a cart

func (*CartsAPI) Routes

func (c *CartsAPI) Routes() Routes

Routes returns all of the api route for the CartsApiController

func (*CartsAPI) StoreCart

func (c *CartsAPI) StoreCart(w http.ResponseWriter, r *http.Request)

StoreCart - Store a cart

type CartsAPIRouter

type CartsAPIRouter interface {
	DeleteCart(http.ResponseWriter, *http.Request)
	GetAllCarts(http.ResponseWriter, *http.Request)
	GetCart(http.ResponseWriter, *http.Request)
	StoreCart(http.ResponseWriter, *http.Request)
}

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

type Coupon

type Coupon struct {

	// The coupon display text.
	Name string `json:"name"`

	// The case-insensitive coupon code.
	Code string `json:"code"`

	// The discount in percent on the product price.
	Discount int32 `json:"discount"`

	Product Product `json:"product"`

	// The time when this coupon exires. If omitted the server chooses a time in the future.
	ExpiresAt time.Time `json:"expiresAt,omitempty"`
}

Coupon - A coupon for a product that can be used during checkout.

type LoginForm

type LoginForm struct {
	Name string `json:"name"`

	Password string `json:"password"`
}

LoginForm - Login form

type MalformedInputError

type MalformedInputError struct {

	// A human-readable message about what went wrong.
	Message string `json:"message"`

	// A JSON Pointer to the incorrect input value.
	Pointer string `json:"pointer"`
}

MalformedInputError - The input is invalid.

type Order

type Order struct {

	// The UUID of the order.
	ID string `json:"id"`

	// The status of the order.
	Status string `json:"status"`

	// The total price of this order.
	Price float32 `json:"price"`

	Buyer Address `json:"buyer"`

	Recipient Address `json:"recipient"`

	Coupons []string `json:"coupons,omitempty"`

	Positions []Position `json:"positions"`
}

Order - An order.

type OrdersAPI

type OrdersAPI struct {
	Authenticator     *authentication.Authenticator
	OrderController   *controller.Order
	CartController    *controller.Cart
	ProductController *controller.Product
}

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

func (*OrdersAPI) CreateOrderFromCart

func (c *OrdersAPI) CreateOrderFromCart(w http.ResponseWriter, r *http.Request)

CreateOrderFromCart - Create order from cart

func (*OrdersAPI) PlaceOrder

func (c *OrdersAPI) PlaceOrder(w http.ResponseWriter, r *http.Request)

PlaceOrder - Place order

func (*OrdersAPI) Routes

func (c *OrdersAPI) Routes() Routes

Routes returns all of the api route for the OrdersApiController

type OrdersAPIRouter

type OrdersAPIRouter interface {
	CreateOrderFromCart(http.ResponseWriter, *http.Request)
	PlaceOrder(http.ResponseWriter, *http.Request)
}

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

type Position

type Position struct {

	// The quantity of the position.
	Quantity int32 `json:"quantity"`

	Product Product `json:"product"`

	// The total price of this position.
	Price float32 `json:"price"`

	// The total savings of this position.
	SavedPrice float32 `json:"savedPrice,omitempty"`
}

Position - A position in a cart.

type Product

type Product struct {

	// The UUID of the product. If a product has no id it is a virtual product, like a discount, and only for displaying purposes.
	ID string `json:"id,omitempty"`

	// The display name of the product.
	Name string `json:"name"`

	// The price of a single item of the product.
	Price float32 `json:"price,omitempty"`
}

Product - A product of the shop.

type ProductsAPI

type ProductsAPI struct {
	Authenticator     *authentication.Authenticator
	ProductController *controller.Product
}

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

func (*ProductsAPI) GetAllProducts

func (c *ProductsAPI) GetAllProducts(w http.ResponseWriter, r *http.Request)

GetAllProducts - Get all products

func (*ProductsAPI) Routes

func (c *ProductsAPI) Routes() Routes

Routes returns all of the api route for the ProductsApiController

func (*ProductsAPI) StoreCouponForProduct

func (c *ProductsAPI) StoreCouponForProduct(w http.ResponseWriter, r *http.Request)

StoreCouponForProduct - Create product coupon

type ProductsAPIRouter

type ProductsAPIRouter interface {
	GetAllProducts(http.ResponseWriter, *http.Request)
	StoreCouponForProduct(http.ResponseWriter, *http.Request)
}

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

type Route

type Route struct {
	Name        string
	Method      string
	Path        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

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

type User

type User struct {

	// The UUID of the user.
	ID string `json:"id"`

	// The unique name of the user.
	Name string `json:"name"`

	// The plain text password of the user.
	Password string `json:"password,omitempty"`
}

User - A user of the shop.

type UsersAPI

type UsersAPI struct {
	UserController *controller.User
}

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

func (*UsersAPI) Login

func (c *UsersAPI) Login(w http.ResponseWriter, r *http.Request)

Login - Login a user

func (*UsersAPI) Register

func (c *UsersAPI) Register(w http.ResponseWriter, r *http.Request)

Register - Register a user

func (*UsersAPI) Routes

func (c *UsersAPI) Routes() Routes

Routes returns all of the api route for the UsersApiController

type UsersAPIRouter

type UsersAPIRouter interface {
	Login(http.ResponseWriter, *http.Request)
	Register(http.ResponseWriter, *http.Request)
}

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

Jump to

Keyboard shortcuts

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