api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2017 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const CacheTime = 1 * time.Minute
View Source
const DEFAULT_PER_PAGE = 50
View Source
const MaxConcurrentLookups = 10

MaxConcurrentLookups controls the number of simultaneous HTTP Order lookups

View Source
const MaxIPsPerDay = 50

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, store assetstores.Store) *API

func NewAPIWithVersion added in v1.0.0

func NewAPIWithVersion(config *conf.Configuration, db *gorm.DB, paypal *paypalsdk.Client, mailer *mailer.Mailer, assets assetstores.Store, 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 orders with no user id belonging to an email and claim them

func (*API) CouponView added in v1.1.0

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

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) DownloadList added in v1.1.0

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

func (*API) DownloadURL added in v1.1.0

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

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) 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) ProductsReport added in v1.1.0

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

ProductsReport list the products sold within a period

func (*API) ResendOrderReceipt added in v1.1.0

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

func (*API) SalesReport added in v1.1.0

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

SalesReport lists the sales numbers for a period

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 CouponApplyParams added in v1.1.0

type CouponApplyParams struct {
	OrderID string `json:"order_id"`
	JWT     string `json:"jwt"`
}

type CouponCache added in v1.1.0

type CouponCache interface {
	Lookup(string) (*models.Coupon, error)
}

func NewCouponCacheFromUrl added in v1.1.0

func NewCouponCacheFromUrl(config *conf.Configuration) CouponCache

type CouponCacheFromURL added in v1.1.0

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

func (*CouponCacheFromURL) Lookup added in v1.1.0

func (c *CouponCacheFromURL) Lookup(code string) (*models.Coupon, error)

type CouponNotFound added in v1.1.0

type CouponNotFound struct{}

func (CouponNotFound) Error added in v1.1.0

func (CouponNotFound) Error() string

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"`
	AppMetaData  map[string]interface{} `json:"app_metadata"`
	UserMetaData map[string]interface{} `json:"user_metadata"`
	*jwt.StandardClaims
}

type OrderAddon added in v1.1.0

type OrderAddon struct {
	Sku string `json:"sku"`
}

type OrderLineItem

type OrderLineItem struct {
	Sku      string                 `json:"sku"`
	Path     string                 `json:"path"`
	Quantity uint64                 `json:"quantity"`
	Addons   []OrderAddon           `json:"addons"`
	MetaData map[string]interface{} `json:"meta"`
}

type OrderParams

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

	Email string `json:"email"`

	IP string `json:"ip"`

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

	MetaData map[string]interface{} `json:"meta"`

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

	Currency string `json:"currency"`

	FulfillmentState string `json:"fulfillment_state"`

	CouponCode string `json:"coupon"`
}

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

type ProductsRow added in v1.1.0

type ProductsRow struct {
	Sku      string `json:"sku"`
	Path     string `json:"path"`
	Total    uint64 `json:"total"`
	Currency string `json:"currency"`
}

type ReceiptParams added in v1.1.0

type ReceiptParams struct {
	Email string `json:"email"`
}

type SalesRow added in v1.1.0

type SalesRow struct {
	Total    uint64 `json:"total"`
	SubTotal uint64 `json:"subtotal"`
	Taxes    uint64 `json:"taxes"`
	Currency string `json:"currency"`
}

Jump to

Keyboard shortcuts

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