Documentation ¶
Overview ¶
Package sendowl provides a client for the Sendowl API.
Note: This package is a work-in-progress. Backwards-incompatible changes should be expected.
Index ¶
- Constants
- Variables
- func Signature(signingKey, signingKeySecret string, vs url.Values) string
- func SigningKey(signingKey, signingKeySecret string) string
- func SigningText(signingKeySecret string, vs url.Values) string
- func VerifySignatureFromRequest(signingKey, signingKeySecret string, r *http.Request) bool
- type Client
- func (c Client) CreateProduct(ctx context.Context, req CreateProductRequest) (*CreateProductResponse, error)
- func (c Client) DeleteProduct(ctx context.Context, req DeleteProductRequest) (*DeleteProductResponse, error)
- func (c Client) GetProduct(ctx context.Context, req GetProductRequest) (*GetProductResponse, error)
- func (c Client) ListProducts(ctx context.Context, req ListProductsRequest) (*ListProductsResponse, error)
- func (c Client) OrderProduct(ctx context.Context, req OrderProductRequest) (*OrderProductResponse, error)
- func (c Client) UpdateProduct(ctx context.Context, req UpdateProductRequest) (*UpdateProductResponse, error)
- func (c *Client) WithEndpoint(e *url.URL) *Client
- func (c *Client) WithLogger(l *log.Logger) *Client
- func (c *Client) WithTransportFunc(f TransportFunc) *Client
- type CreateProductRequest
- type CreateProductResponse
- type DeleteProductRequest
- type DeleteProductResponse
- type GetProductRequest
- type GetProductResponse
- type ListProductsRequest
- type ListProductsResponse
- type ListProductsResponseItem
- type Order
- type OrderID
- type OrderProductRequest
- type OrderProductResponse
- type Price
- type Product
- type ProductID
- type ProductOrder
- type ProductType
- type ResponseNotJSONError
- type TransportFunc
- type UpdateProductRequest
- type UpdateProductResponse
Constants ¶
const DefaultEndpoint = "https://www.sendowl.com/api/v1/"
DefaultEndpoint is the default root API endpoint.
const SignatureQueryParam = "signature"
Variables ¶
var ErrNotFound = errors.New("sendowl: not found")
Functions ¶
func SigningKey ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a type which makes requests to Sendowl.
func (Client) CreateProduct ¶
func (c Client) CreateProduct(ctx context.Context, req CreateProductRequest) (*CreateProductResponse, error)
CreateProduct uses req to create a new product, returning a CreateProductResponse and non-nil error if there was a problem.
func (Client) DeleteProduct ¶
func (c Client) DeleteProduct(ctx context.Context, req DeleteProductRequest) (*DeleteProductResponse, error)
DeleteProduct uses req to delete a product, returning a DeleteProductResponse and non-nil error if there was a problem.
func (Client) GetProduct ¶
func (c Client) GetProduct(ctx context.Context, req GetProductRequest) (*GetProductResponse, error)
GetProduct uses req to get a product, returning a GetProductResponse and non-nil error if there was a problem.
func (Client) ListProducts ¶
func (c Client) ListProducts(ctx context.Context, req ListProductsRequest) (*ListProductsResponse, error)
ListProducts uses req to list a products, returning a ListProductsResponse and non-nil error if there was a problem.
func (Client) OrderProduct ¶
func (c Client) OrderProduct(ctx context.Context, req OrderProductRequest) (*OrderProductResponse, error)
OrderProduct uses req to issue a new order, returning a OrderProductResponse and non-nil error if there was a problem.
func (Client) UpdateProduct ¶
func (c Client) UpdateProduct(ctx context.Context, req UpdateProductRequest) (*UpdateProductResponse, error)
UpdateProduct uses req to update a product, returning a UpdateProductResponse and non-nil error if there was a problem.
func (*Client) WithTransportFunc ¶
func (c *Client) WithTransportFunc(f TransportFunc) *Client
type CreateProductRequest ¶
type CreateProductRequest struct { Name string // Name of the product. Type ProductType // Type of the product. Price Price // Price of the product. Attachment io.Reader Filename string // Filename of the file to attach. PDFStamping bool // SelfHostedURL is the url of the file to be issued at download (only // useable when the product is self hosted). SelfHostedURL string }
CreateProductRequest is an API representation of a create product request.
type CreateProductResponse ¶
type CreateProductResponse struct {
Product Product `json:"product"`
}
CreateProductResponse is an API representation of a create product response.
type DeleteProductRequest ¶
type DeleteProductRequest struct {
ProductID `json:"-"` // ProductID of the product to delete.
}
DeleteProductRequest is an API representation of a delete product request.
type DeleteProductResponse ¶
type DeleteProductResponse struct{}
DeleteProductResponse is an API representation of a delete product response.
type GetProductRequest ¶
type GetProductRequest struct {
ID ProductID
}
GetProductRequest is an API representation of a get product request.
type GetProductResponse ¶
type GetProductResponse struct {
Product `json:"product"`
}
GetProductResponse is an API representation of a get product response.
type ListProductsRequest ¶
ListProductsRequest is an API representation of a list products request.
type ListProductsResponse ¶
type ListProductsResponse []ListProductsResponseItem
ListProductsResponse is an API representation of a list products response.
func (*ListProductsResponse) Items ¶
func (r *ListProductsResponse) Items() []ListProductsResponseItem
type ListProductsResponseItem ¶
type ListProductsResponseItem struct {
Product `json:"product"`
}
type Order ¶
type Order struct { ID OrderID `json:"id"` // ID of the order. BuyerEmail string `json:"buyer_email"` BuyerName string `json:"buyer_name"` Cart struct { Items []struct { Item struct { ProductID `json:"product_id"` PackageID int `json:"package_id"` Quantity int `json:"quantity"` PriceAtCheckout Price `json:"price_at_checkout"` ValidUntil *time.Time `json:"valid_until"` DownloadAttempts int `json:"download_attempts"` } `json:"cart_item"` Product Product `json:"product"` Quantity int `json:"quantity"` ValidUntil *time.Time `json:"valid_until"` DownloadAttempts int `json:"download_attempts"` } `json:"cart_items"` CompletedCheckoutAt time.Time `json:"completed_checkout_at"` StartedCheckoutAt time.Time `json:"started_checkout_at"` } `json:"cart"` }
type OrderID ¶
type OrderID int
func OrderIDFromInt ¶
func OrderIDFromString ¶
func (*OrderID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type OrderProductRequest ¶
type OrderProductRequest struct { ProductID `json:"-"` // ProductID of the product to order. Order ProductOrder `json:"order"` // Order details. }
OrderProductRequest is an API representation of an order product request.
type OrderProductResponse ¶
type OrderProductResponse struct {
Order `json:"order"`
}
OrderProductResponse is an API representation of an order product response.
type Price ¶
type Price float64
func PriceFromFloat64 ¶
func (*Price) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Product ¶
type Product struct { // ID of the product. ID ProductID `json:"id"` // Name of the product. Name string `json:"name"` // Type of the product. Type ProductType `json:"product_type"` // Price of the product (in dollars and cents). Price Price `json:"price"` // InstantBuyURL for purchasing the product. InstantBuyURL string `json:"instant_buy_url"` PDFStamping bool `json:"pdf_stamping"` // SelfHostedURL is the url of the file to be issued at download (only // useable when the product is self hosted). SelfHostedURL string `json:"self_hosted_url"` }
type ProductID ¶
type ProductID int
func ProductIDFromInt ¶
func ProductIDFromString ¶
func (*ProductID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type ProductOrder ¶
type ProductOrder struct { BuyerEmail string `json:"buyer_email"` BuyerName string `json:"buyer_name"` BuyerID string `json:"buyer_id,omitempty"` BuyerStatus string `json:"buyer_status,omitempty"` BuyerAddress1 string `json:"buyer_address1,omitempty"` BuyerAddress2 string `json:"buyer_address2,omitempty"` BuyerCity string `json:"buyer_city,omitempty"` BuyerRegion string `json:"buyer_region,omitempty"` BuyerPostCode string `json:"buyer_postcode,omitempty"` BuyerCountry string `json:"buyer_country,omitempty"` BuyerIPAddress string `json:"buyer_ip_address,omitempty"` CanMarketToBuyer bool `json:"can_market_to_buyer"` Quantity int `json:"quantity,omitempty"` DispatchedAt *time.Time `json:"dispatched_at,omitempty"` Tag string `json:"tag,omitempty"` }
ProductOrder is an API representation of the order details for an order product request.
type ResponseNotJSONError ¶
func (*ResponseNotJSONError) Error ¶
func (e *ResponseNotJSONError) Error() string
type TransportFunc ¶
type TransportFunc func(context.Context) http.RoundTripper
type UpdateProductRequest ¶
type UpdateProductRequest struct { ProductID `json:"-"` // ProductID of the product to update. Name string // Name of the product. Type ProductType // Type of the product. Price Price // Price of the product. Attachment io.Reader Filename string // Filename of the file to attach. PDFStamping bool // SelfHostedURL is the url of the file to be issued at download (only // useable when the product is self hosted). SelfHostedURL string }
UpdateProductRequest is an API representation of an update product request.
type UpdateProductResponse ¶
type UpdateProductResponse struct{}
UpdateProductResponse is an API representation of an update product response.