api

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 40 Imported by: 1

Documentation

Index

Constants

View Source
const MaxConcurrentLookups = 10

MaxConcurrentLookups controls the number of simultaneous HTTP Order lookups

Variables

This section is empty.

Functions

func WithInstanceConfig added in v1.1.2

func WithInstanceConfig(ctx context.Context, smtp conf.SMTPConfiguration, config *conf.Configuration, instanceID string) (context.Context, error)

Types

type API

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

API is the main REST API

func NewAPI

func NewAPI(globalConfig *conf.GlobalConfiguration, log logrus.FieldLogger, db *gorm.DB) *API

NewAPI instantiates a new REST API using the default version.

func NewAPIWithVersion added in v1.0.0

func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfiguration, log logrus.FieldLogger, db *gorm.DB, version string) *API

NewAPIWithVersion instantiates a new REST API.

func (*API) AddressDelete added in v0.2.0

func (a *API) AddressDelete(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

AddressList will return the addresses for a given user

func (*API) AddressView added in v0.2.0

func (a *API) AddressView(w http.ResponseWriter, r *http.Request) error

AddressView will return a particular address for a given user

func (*API) ClaimOrders added in v1.0.0

func (a *API) ClaimOrders(w http.ResponseWriter, r *http.Request) error

ClaimOrders will look for any orders with no user id belonging to an email and claim them

func (*API) CouponList added in v1.2.1

func (a *API) CouponList(w http.ResponseWriter, r *http.Request) error

CouponList returns all the coupons for the site. Requires admin permissions

func (*API) CouponView added in v1.1.0

func (a *API) CouponView(w http.ResponseWriter, r *http.Request) error

CouponView returns information about a single coupon code.

func (*API) CreateInstance added in v1.1.2

func (a *API) CreateInstance(w http.ResponseWriter, r *http.Request) error

func (*API) CreateNewAddress added in v0.2.0

func (a *API) CreateNewAddress(w http.ResponseWriter, r *http.Request) error

CreateNewAddress will create an address associated with that user

func (*API) DB added in v1.7.2

func (a *API) DB(r *http.Request) *gorm.DB

DB provides callers with a database instance configured for request logging

func (*API) DeleteInstance added in v1.1.2

func (a *API) DeleteInstance(w http.ResponseWriter, r *http.Request) error

func (*API) DownloadList added in v1.1.0

func (a *API) DownloadList(w http.ResponseWriter, r *http.Request) error

DownloadList lists all purchased downloads for an order or a user.

func (*API) DownloadRefresh added in v1.7.2

func (a *API) DownloadRefresh(w http.ResponseWriter, r *http.Request) error

DownloadRefresh makes sure downloads are up to date

func (*API) DownloadURL added in v1.1.0

func (a *API) DownloadURL(w http.ResponseWriter, r *http.Request) error

DownloadURL returns a signed URL to download a purchased asset.

func (*API) GetAppManifest added in v1.1.2

func (a *API) GetAppManifest(w http.ResponseWriter, r *http.Request) error

func (*API) GetInstance added in v1.1.2

func (a *API) GetInstance(w http.ResponseWriter, r *http.Request) error

func (*API) HealthCheck added in v1.1.2

func (a *API) HealthCheck(w http.ResponseWriter, r *http.Request) error

HealthCheck endpoint

func (*API) ListenAndServe

func (a *API) ListenAndServe(hostAndPort string)

ListenAndServe starts the REST API.

func (*API) OrderCreate

func (a *API) OrderCreate(w http.ResponseWriter, r *http.Request) error

OrderCreate endpoint

func (*API) OrderList

func (a *API) OrderList(w http.ResponseWriter, r *http.Request) error

OrderList lists orders selected by the query parameters provided.

func (*API) OrderUpdate added in v0.2.0

func (a *API) OrderUpdate(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

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) PaymentConfirm added in v1.7.1

func (a *API) PaymentConfirm(w http.ResponseWriter, r *http.Request) error

PaymentConfirm allows client to confirm if a pending transaction has been completed. Updates transaction and order

func (*API) PaymentCreate

func (a *API) PaymentCreate(w http.ResponseWriter, r *http.Request) error

PaymentCreate is the endpoint for creating a payment for an order

func (*API) PaymentList

func (a *API) PaymentList(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

PaymentRefund refunds a transaction for a specific amount. This allows partial refunds if desired. It is only available to admins.

func (*API) PaymentView added in v0.2.0

func (a *API) PaymentView(w http.ResponseWriter, r *http.Request) error

PaymentView returns information about a single payment. It is only available to admins.

func (*API) PreauthorizePayment added in v1.1.2

func (a *API) PreauthorizePayment(w http.ResponseWriter, r *http.Request) error

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

func (*API) ProductsReport added in v1.1.0

func (a *API) ProductsReport(w http.ResponseWriter, r *http.Request) error

ProductsReport list the products sold within a period

func (*API) ReceiptView added in v1.1.2

func (a *API) ReceiptView(w http.ResponseWriter, r *http.Request) error

ReceiptView renders an HTML receipt for an order

func (*API) ResendOrderReceipt added in v1.1.0

func (a *API) ResendOrderReceipt(w http.ResponseWriter, r *http.Request) error

ResendOrderReceipt resends the email receipt for an order

func (*API) SalesReport added in v1.1.0

func (a *API) SalesReport(w http.ResponseWriter, r *http.Request) error

SalesReport lists the sales numbers for a period

func (*API) UpdateInstance added in v1.1.2

func (a *API) UpdateInstance(w http.ResponseWriter, r *http.Request) error

func (*API) UserBulkDelete added in v1.5.0

func (a *API) UserBulkDelete(w http.ResponseWriter, r *http.Request) error

func (*API) UserDelete added in v0.2.0

func (a *API) UserDelete(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

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(w http.ResponseWriter, r *http.Request) error

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

func (*API) VatNumberLookup added in v1.1.2

func (a *API) VatNumberLookup(w http.ResponseWriter, r *http.Request) error

VatNumberLookup looks up information on a VAT number

func (*API) ViewSettings added in v1.2.1

func (a *API) ViewSettings(w http.ResponseWriter, r *http.Request) error

type HTTPError

type HTTPError struct {
	Code            int    `json:"code"`
	Message         string `json:"msg"`
	InternalError   error  `json:"-"`
	InternalMessage string `json:"-"`
	ErrorID         string `json:"error_id,omitempty"`
}

HTTPError is an error with a message and an HTTP status code.

func (*HTTPError) Cause added in v1.1.2

func (e *HTTPError) Cause() error

Cause returns the root cause error

func (*HTTPError) Error added in v0.2.0

func (e *HTTPError) Error() string

func (*HTTPError) WithInternalError added in v1.1.2

func (e *HTTPError) WithInternalError(err error) *HTTPError

WithInternalError adds internal error information to the error

func (*HTTPError) WithInternalMessage added in v1.1.2

func (e *HTTPError) WithInternalMessage(fmtString string, args ...interface{}) *HTTPError

WithInternalMessage adds internal message information to the error

type InstanceRequestParams added in v1.1.2

type InstanceRequestParams struct {
	UUID       string              `json:"uuid"`
	BaseConfig *conf.Configuration `json:"config"`
}

type InstanceResponse added in v1.1.2

type InstanceResponse struct {
	models.Instance
	Endpoint string `json:"endpoint"`
	State    string `json:"state"`
}

type NetlifyMicroserviceClaims added in v1.1.2

type NetlifyMicroserviceClaims struct {
	SiteURL    string `json:"site_url"`
	InstanceID string `json:"id"`
	NetlifyID  string `json:"netlify_id"`
	jwt.StandardClaims
}

type PaymentParams

type PaymentParams struct {
	Amount       uint64 `json:"amount"`
	Currency     string `json:"currency"`
	ProviderType string `json:"provider"`
	Description  string `json:"description"`
}

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