Documentation
¶
Index ¶
- type Address
- type Admin
- type Client
- func (c *Client) Get(path string) (int, []byte, error)
- func (c *Client) ListCustomers(path string, params url.Values) ([]Customer, error)
- func (c *Client) Login(endpoint string, email string, password string) error
- func (c *Client) Post(path string, v any) (int, []byte, error)
- func (c *Client) PostCustomer(path string, customer *Customer) error
- func (c *Client) SetPublishableAPIKey(k *PublishableAPIKey)
- type Customer
- type Group
- type JWTToken
- type PublishableAPIKey
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { ID string `json:"id,omitempty"` AddressName string `json:"address_name,omitempty"` IsDefaultShipping bool `json:"is_default_shipping,omitempty"` IsDefaultBilling bool `json:"is_default_billing,omitempty"` CustomerID string `json:"customer_id,omitempty"` Company string `json:"company,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Address1 string `json:"address_1,omitempty"` Address2 string `json:"address_2,omitempty"` City string `json:"city,omitempty"` CountryCode string `json:"country_code,omitempty"` Province string `json:"province,omitempty"` PostalCode string `json:"postal_code,omitempty"` Phone string `json:"phone,omitempty"` Metadata map[string]json.RawMessage `json:"metadata,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
func (*Admin) GetCustomerByEmail ¶
GetCustomerByEmail returns the customer with the given email.
If no customer found, returns nil.
func (*Admin) ListCustomers ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Get ¶
Get do a HTTP GET request to the backend url + path.
Returns the response status code and the body bytes.
func (*Client) ListCustomers ¶
func (*Client) Login ¶
Login obtains a JWT token to send authenticated requests with ObtainJWTToken.
func (*Client) Post ¶
Post do a HTTP POST request to the backend url + path.
The JSON encoded v is set to request body.
Returns the response status code and the body bytes.
func (*Client) PostCustomer ¶
PostCustomer creates or updates a customer's details based on the API endpoint path.
The API returns the customer's object which will be used to overwrite the given customer arg.
func (*Client) SetPublishableAPIKey ¶
func (c *Client) SetPublishableAPIKey(k *PublishableAPIKey)
type Customer ¶
type Customer struct { ID string `json:"id,omitempty"` HasAccount bool `json:"has_account,omitempty"` Groups []Group `json:"groups,omitempty"` Email string `json:"email,omitempty"` DefaultBillingAddressID string `json:"default_billing_address_id,omitempty"` DefaultShippingAddressID string `json:"default_shipping_address_id,omitempty"` CompanyName string `json:"company_name,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Addresses []Address `json:"addresses,omitempty"` Phone string `json:"phone,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` CreatedBy string `json:"created_by,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *time.Time `json:"deleted_at,omitempty"` }
func (*Customer) AddMetadata ¶
AddMetadata adds a key/value to the Metadata field.
type Group ¶
type Group struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Customers []struct{} `json:"customers,omitempty"` Metadata map[string]json.RawMessage `json:"metadata,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
type JWTToken ¶
type JWTToken struct { Email string `json:"email"` Password string `json:"password"` Token string `json:"token"` }
func ObtainJWTToken ¶
ObtainJWTToken obtains a JWT token from path with the given credentials.
type PublishableAPIKey ¶
type PublishableAPIKey string
func NewPublishableAPIKey ¶
func NewPublishableAPIKey(k string) *PublishableAPIKey
func (PublishableAPIKey) SetHeader ¶
func (k PublishableAPIKey) SetHeader(r *http.Request)
func (PublishableAPIKey) String ¶
func (k PublishableAPIKey) String() string
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) RegisterCustomer ¶
func (*Store) SetPublishableAPIKey ¶
func (s *Store) SetPublishableAPIKey(k *PublishableAPIKey)