api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2016 License: MIT Imports: 27 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

This section is empty.

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, paypal *paypalsdk.Client, mailer *mailer.Mailer) *API

func NewAPIWithVersion added in v1.0.0

func NewAPIWithVersion(config *conf.Configuration, db *gorm.DB, paypal *paypalsdk.Client, mailer *mailer.Mailer, version string) *API

NewAPIWithVersion instantiates a new REST API

func (*API) AddressDelete added in v0.2.0

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

AddressDelete will soft delete the address associated with that user. It requires admin access return errors or 200 and no body

func (*API) AddressList added in v0.2.0

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

AddressList will return the addresses for a given user

func (*API) AddressView added in v0.2.0

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

AddressView will return a particular address for a given user

func (*API) ClaimOrders added in v1.0.0

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

ClaimOrders will look for any

func (*API) CreateNewAddress added in v0.2.0

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

CreateNewAddress will create an address associated with that user

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)

OrderList can query based on

  • orders since &from=iso8601 - default = 0
  • orders before &to=iso8601 - default = now
  • sort asc or desc &sort=[asc | desc] - default = desc

func (*API) OrderUpdate added in v0.2.0

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

OrderUpdate will allow an ADMIN only to update the details of a record it is also important to note that it will not let modification of an order if the order is no longer pending. Addresses can be made by posting a new one directly, OR by referencing one by ID. If both are provided, the one that is made by ID will win out and the other will be ignored. There are also blocks to changing certain fields after the state has been locked

func (*API) OrderView

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

OrderView will request a specific order using the 'id' parameter. Only the owner of the order, an admin, or an anon order are allowed to be seen

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 will list all the payments that meet the criteria. It is only available to admins

func (*API) PaymentListForOrder added in v0.2.0

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

PaymentListForOrder is the endpoint for listing transactions for an order. You must be the owner of the order (user_id) or an admin. Listing the payments for an anon order.

func (*API) PaymentListForUser added in v0.2.0

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

PaymentListForUser is the endpoint for listing transactions for a user. The ID in the claim and the ID in the path must match (or have admin override)

func (*API) PaymentRefund added in v0.2.0

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

func (*API) PaymentView added in v0.2.0

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

func (*API) PaypalCreatePayment added in v1.0.0

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

PaypalCreatePayment creates a new payment that can be authorized in the browser

func (*API) PaypalGetPayment added in v1.0.0

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

PaypalGetPayment retrieves information on an authorized paypal payment, including the shipping address

func (*API) UserDelete added in v0.2.0

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

UserDelete will soft delete the user. It requires admin access return errors or 200 and no body

func (*API) UserList added in v0.2.0

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

UserList will return all of the users. It requires admin access. It supports the filters: since iso8601 date before iso8601 date email email user_id id limit # of records to return (max)

func (*API) UserView added in v0.2.0

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

UserView will return the user specified. If you're an admin you can request a user that is not your self

func (*API) VatnumberLookup

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

type ChargerType added in v1.0.0

type ChargerType string
const PaypalChargerType ChargerType = "paypal"
const StripeChargerType ChargerType = "stripe"

type Experience added in v1.0.0

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

type HTTPError

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

HTTPError is an error with a message

func (HTTPError) Error added in v0.2.0

func (e HTTPError) Error() string

type JWTClaims

type JWTClaims struct {
	ID     string   `json:"id"`
	Email  string   `json:"email"`
	Groups []string `json:"groups"`
	*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"`
	PaypalID     string `json:"paypal_payment_id"`
	PaypalUserID string `json:"paypal_user_id"`
}

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