Documentation
¶
Index ¶
- Constants
- func CheckResponseError(r *http.Response) error
- func ShopBaseUrl(name string) string
- func ShopFullName(name string) string
- func ShopShortName(name string) string
- type Address
- type App
- func (app App) AuthorizeUrl(shopName string, state string) string
- func (app App) GetAccessToken(shopName string, code string) (string, error)
- func (app App) VerifyAuthorizationURL(u *url.URL) bool
- func (app App) VerifyMessage(message, messageMAC string) bool
- func (app App) VerifyWebhookMessage(message, messageMAC string) bool
- type Asset
- type AssetOptions
- type AssetResource
- type AssetService
- type AssetsResource
- type Client
- func (c *Client) Count(path string, options interface{}) (int, error)
- func (c *Client) CreateAndDo(method, path string, data, options, resource interface{}) error
- func (c *Client) Delete(path string, data, resource interface{}) error
- func (c *Client) Do(req *http.Request, v interface{}) error
- func (c *Client) Get(path string, resource, options interface{}) error
- func (c *Client) NewRequest(method, urlStr string, body, options interface{}) (*http.Request, error)
- func (c *Client) Post(path string, data, resource interface{}) error
- func (c *Client) Put(path string, data, resource interface{}) error
- type CountOptions
- type Customer
- type CustomerResource
- type CustomerService
- type CustomerServiceOp
- type CustomersResource
- type DiscountCode
- type LineItem
- type LineItemProperty
- type ListOptions
- type MetaField
- type NoteAttribute
- type Order
- type OrderListOptions
- type OrderResource
- type OrderService
- type OrderServiceOp
- type OrdersResource
- type Page
- type PageResource
- type PageService
- type PagesResource
- type Product
- type ProductImage
- type ProductOption
- type ProductResource
- type ProductService
- type ProductServiceOp
- type ProductsResource
- type RecurringApplicationCharge
- type RecurringApplicationChargeResource
- type RecurringApplicationChargeService
- func (s *RecurringApplicationChargeService) Activate(charge RecurringApplicationCharge) (*RecurringApplicationCharge, error)
- func (s *RecurringApplicationChargeService) Create(charge RecurringApplicationCharge) (*RecurringApplicationCharge, error)
- func (s *RecurringApplicationChargeService) CustomizeCap(charge RecurringApplicationCharge) (*RecurringApplicationCharge, error)
- func (s *RecurringApplicationChargeService) Delete(chargeID int, options interface{}) (*RecurringApplicationCharge, error)
- func (s *RecurringApplicationChargeService) Get(chargeID int, options interface{}) (*RecurringApplicationCharge, error)
- type ResponseError
- type Shop
- type ShopResource
- type ShopService
- type ShopServiceOp
- type Theme
- type ThemeResource
- type ThemeService
- type ThemesResource
- type Variant
- type Webhook
- type WebhookOptions
- type WebhookResource
- type WebhookService
- type WebhookServiceOp
- func (s *WebhookServiceOp) Count(options interface{}) (int, error)
- func (s *WebhookServiceOp) Create(webhook Webhook) (*Webhook, error)
- func (s *WebhookServiceOp) Get(webhookdID int, options interface{}) (*Webhook, error)
- func (s *WebhookServiceOp) List(options interface{}) ([]Webhook, error)
- func (s *WebhookServiceOp) Update(webhook Webhook) (*Webhook, error)
- type WebhooksResource
Constants ¶
const (
UserAgent = "goshopify/0.2.0"
)
Variables ¶
This section is empty.
Functions ¶
func CheckResponseError ¶
func ShopFullName ¶
Return the full shop name, including .myshopify.com
func ShopShortName ¶
Return the short shop name, excluding .myshopify.com
Types ¶
type Address ¶
type Address struct {
ID int `json:"id"`
Address1 string `json:"address1"`
Address2 string `json:"address2"`
City string `json:"city"`
Company string `json:"company"`
Country string `json:"country"`
CountryCode string `json:"country_code"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Name string `json:"name"`
Phone string `json:"phone"`
Province string `json:"province"`
ProvinceCode string `json:"province_code"`
Zip string `json:"zip"`
}
type App ¶
Basic app settings such as Api key, secret, scope, and redirect url. See oauth.go for OAuth related helper functions.
func (App) AuthorizeUrl ¶
Returns a Shopify oauth authorization url for the given shopname and state.
State is a unique value that can be used to check the authenticity during a callback from Shopify.
func (App) GetAccessToken ¶
func (App) VerifyAuthorizationURL ¶
Verifying URL callback parameters.
func (App) VerifyMessage ¶
Verify a message against a message HMAC
func (App) VerifyWebhookMessage ¶
Verify a message against a message HMAC
type Asset ¶
type Asset struct {
ThemeID int `json:"theme_id"`
Key string `json:"key"`
Value string `json:"value"`
PublicUrl string `json:"public_url"`
Source string `json:"source"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
ContentType string `json:"content_type"`
Attachment string `json:"attachment"`
Size int `json:"size"`
}
Asset represents a Shopify asset
type AssetOptions ¶
type AssetResource ¶
type AssetResource struct {
Asset *Asset `json:"asset"`
}
Represents the result from the assets/X.json endpoint
type AssetService ¶
type AssetService struct {
// contains filtered or unexported fields
}
AssetService handles communication with the asset related methods of the Shopify API.
func (*AssetService) Delete ¶
func (s *AssetService) Delete(asset *Asset) (*Asset, error)
Update an existing asset.
func (*AssetService) Get ¶
func (s *AssetService) Get(themeID int, key string) (*Asset, error)
Get individual asset
type AssetsResource ¶
type AssetsResource struct {
Assets []Asset `json:"assets"`
}
Represents the result from the assets.json endpoint
type Client ¶
type Client struct {
// Services used for communicating with the API
Product ProductService
Customer CustomerService
Order OrderService
Shop ShopService
Webhook WebhookService
Theme *ThemeService
Page *PageService
Asset *AssetService
RecurringApplicationCharge *RecurringApplicationChargeService
// contains filtered or unexported fields
}
Client manages communication with the Shopify API.
func (*Client) CreateAndDo ¶
func (*Client) Delete ¶
Perform a DELETE request for the given path and save the result in the given resource.
func (*Client) Do ¶
Do sends an API request and populates the given interface with the parsed response. It does not make much sense to call Do without a prepared interface instance.
func (*Client) Get ¶
Perform a Get request for the given path and save the result in the given resource.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, urlStr string, body, options interface{}) (*http.Request, error)
Creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type CountOptions ¶
type CountOptions struct {
CreatedAtMin time.Time `url:"created_at_min,omitempty"`
CreatedAtMax time.Time `url:"created_at_max,omitempty"`
}
General count options that can be used for most collection counts.
type Customer ¶
type Customer struct {
ID int `json:"id"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
Customer represents a Shopify customer
type CustomerResource ¶
type CustomerResource struct {
Customer *Customer `json:"customer"`
}
Represents the result from the customers/X.json endpoint
type CustomerService ¶
type CustomerService interface {
List(interface{}) ([]Customer, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*Customer, error)
}
CustomerService is an interface for interfacing with the customers endpoints of the Shopify API. See: https://help.shopify.com/api/reference/customer
type CustomerServiceOp ¶
type CustomerServiceOp struct {
// contains filtered or unexported fields
}
CustomerServiceOp handles communication with the product related methods of the Shopify API.
func (*CustomerServiceOp) Count ¶
func (s *CustomerServiceOp) Count(options interface{}) (int, error)
Count customers
func (*CustomerServiceOp) Get ¶
func (s *CustomerServiceOp) Get(customerID int, options interface{}) (*Customer, error)
Get customer
func (*CustomerServiceOp) List ¶
func (s *CustomerServiceOp) List(options interface{}) ([]Customer, error)
List customers
type CustomersResource ¶
type CustomersResource struct {
Customers []Customer `json:"customers"`
}
Represents the result from the customers.json endpoint
type DiscountCode ¶
type LineItem ¶
type LineItem struct {
ID int `json:"id"`
ProductID int `json:"product_id"`
VariantID int `json:"variant_id"`
Quantity int `json:"quantity"`
Price *decimal.Decimal `json:"price"`
TotalDiscount *decimal.Decimal `json:"total_discount"`
Title string `json:"title"`
VariantTitle string `json:"variant_title"`
Name string `json:"name"`
SKU string `json:"sku"`
Vendor string `json:"vendor"`
GiftCard bool `json:"gift_card"`
Taxable bool `json:"taxable"`
}
type LineItemProperty ¶
type LineItemProperty struct {
Message string `json:"message"`
}
type ListOptions ¶
type ListOptions struct {
Page int `url:"page,omitempty"`
Limit int `url:"limit,omitempty"`
SinceID int `url:"since_id,omitempty"`
CreatedAtMin time.Time `url:"created_at_min,omitempty"`
CreatedAtMax time.Time `url:"created_at_max,omitempty"`
}
General list options that can be used for most collections of entities.
type NoteAttribute ¶
type NoteAttribute struct {
Name string `json:"Name"`
Value interface{} `json:"Value"`
}
type Order ¶
type Order struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at"`
ProcessedAt *time.Time `json:"processed_at"`
Customer *Customer `json:"customer"`
BillingAddress *Address `json:"billing_address"`
ShippingAddress *Address `json:"shipping_address"`
Currency string `json:"currency"`
TotalPrice *decimal.Decimal `json:"total_price"`
SubtotalPrice *decimal.Decimal `json:"subtotal_price"`
TotalDiscounts *decimal.Decimal `json:"total_discounts"`
TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price"`
TotalTax *decimal.Decimal `json:"total_tax"`
TotalWeight int `json:"total_weight"`
FinancialStatus string `json:"financial_status"`
FulfillmentStatus string `json:"fulfillment_status"`
Token string `json:"token"`
CartToken string `json:"cart_token"`
Number int `json:"number"`
OrderNumber int `json:"order_number"`
Note string `json:"note"`
Test bool `json:"test"`
BrowserIp string `json:"browser_ip"`
BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing"`
CancelReason string `json:"cancel_reason"`
NoteAttributes []NoteAttribute `json:"note_attributes"`
DiscountCodes []DiscountCode `json:"discount_codes"`
LineItems []LineItem `json:"line_items"`
}
Order represents a Shopify order
type OrderListOptions ¶
type OrderListOptions struct {
Page int `url:"page,omitempty"`
Limit int `url:"limit,omitempty"`
SinceID int `url:"since_id,omitempty"`
Status string `url:"status,omitempty"`
FinancialStatus string `url:"financial_status,omitempty"`
FulfillmentStatus string `url:"fulfillment_status,omitempty"`
CreatedAtMin time.Time `url:"created_at_min,omitempty"`
CreatedAtMax time.Time `url:"created_at_max,omitempty"`
UpdatedAtMin time.Time `url:"updated_at_min,omitempty"`
UpdatedAtMax time.Time `url:"updated_at_max,omitempty"`
ProcessedAtMin time.Time `url:"processed_at_min,omitempty"`
ProcessedAtMax time.Time `url:"processed_at_max,omitempty"`
Fields string `url:"fields,omitempty"`
}
A struct for all available order list options. See: https://help.shopify.com/api/reference/order#index
type OrderResource ¶
type OrderResource struct {
Order *Order `json:"order"`
}
Represents the result from the orders/X.json endpoint
type OrderService ¶
type OrderService interface {
List(interface{}) ([]Order, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*Order, error)
}
OrderService is an interface for interfacing with the orders endpoints of the Shopify API. See: https://help.shopify.com/api/reference/order
type OrderServiceOp ¶
type OrderServiceOp struct {
// contains filtered or unexported fields
}
OrderServiceOp handles communication with the order related methods of the Shopify API.
func (*OrderServiceOp) Count ¶
func (s *OrderServiceOp) Count(options interface{}) (int, error)
Count orders
func (*OrderServiceOp) Get ¶
func (s *OrderServiceOp) Get(orderID int, options interface{}) (*Order, error)
Get individual order
func (*OrderServiceOp) List ¶
func (s *OrderServiceOp) List(options interface{}) ([]Order, error)
List orders
type OrdersResource ¶
type OrdersResource struct {
Orders []Order `json:"orders"`
}
Represents the result from the orders.json endpoint
type Page ¶
type Page struct {
Author string `json:"author"`
Title string `json:"title"`
BodyHTML string `json:"body_html"`
Handle string `json:"handle"`
ID int `json:"id"`
Metafield []MetaField `json:"metafield"`
ShopID int `json:"shop_id"`
Published *bool `json:"published, omitempty"` // Used for creating a page
TemplateSuffix *string `json:"template_suffix, omitempty"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
}
type PageResource ¶
type PageResource struct {
Page *Page `json:"page"`
}
Represents the result from the pages/X.json endpoint
type PageService ¶
type PageService struct {
// contains filtered or unexported fields
}
PageService handles communication with the page related methods of the Shopify API.
func (*PageService) Create ¶
func (s *PageService) Create(page Page) (*Page, error)
Create a new page
func (*PageService) Get ¶
func (s *PageService) Get(id int, options interface{}) (*Page, error)
Get individual page
func (*PageService) List ¶
func (s *PageService) List(options interface{}) ([]Page, error)
List pages
type PagesResource ¶
type PagesResource struct {
Pages []Page `json:"pages"`
}
Represents the result from the pages.json endpoint
type Product ¶
type Product struct {
ID int `json:"id"`
Title string `json:"title"`
BodyHTML string `json:"body_html"`
Vendor string `json:"vendor"`
Images []ProductImage `json:"images"`
ProductType string `json:"product_type"`
Handle string `json:"handle"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
PublishedAt *time.Time `json:"published_at"`
PublishedScope string `json:"published_scope"`
Tags string `json:"tags"`
Options []ProductOption `json:"options"`
Variants []Variant `json:"variants"`
}
Product represents a Shopify product
type ProductImage ¶
type ProductImage struct {
Src string `json:"src"`
}
type ProductOption ¶
type ProductOption struct {
ID int `json:"id"`
ProductID int `json:"product_id"`
Name string `json:"name"`
Position int `json:"position"`
Values []string `json:"values"`
}
The options provided by Shopify
type ProductResource ¶
type ProductResource struct {
Product *Product `json:"product"`
}
Represents the result from the products/X.json endpoint
type ProductService ¶
type ProductService interface {
List(interface{}) ([]Product, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*Product, error)
}
ProductService is an interface for interfacing with the product endpoints of the Shopify API. See: https://help.shopify.com/api/reference/product
type ProductServiceOp ¶
type ProductServiceOp struct {
// contains filtered or unexported fields
}
ProductServiceOp handles communication with the product related methods of the Shopify API.
func (*ProductServiceOp) Count ¶
func (s *ProductServiceOp) Count(options interface{}) (int, error)
Count products
func (*ProductServiceOp) Get ¶
func (s *ProductServiceOp) Get(productID int, options interface{}) (*Product, error)
Get individual product
func (*ProductServiceOp) List ¶
func (s *ProductServiceOp) List(options interface{}) ([]Product, error)
List products
type ProductsResource ¶
type ProductsResource struct {
Products []Product `json:"products"`
}
Represents the result from the products.json endpoint
type RecurringApplicationCharge ¶
type RecurringApplicationCharge struct {
CappedAmount decimal.Decimal `json:"capped_amount"`
ConfirmationUrl string `json:"confirmation_url"`
ReturnUrl string `json:"return_url"`
DecoratedReturnUrl string `json:"decorated_return_url"`
UpdateCappedAmountUrl string `json:"update_capped_amount_url,omitempty"`
Name string `json:"name"`
Price decimal.Decimal `json:"price"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Id int `json:"id"`
Status string `json:"status"`
Terms string `json:"terms"`
Test bool `json:"test,omitempty"`
}
Theme represents a Shopify theme
type RecurringApplicationChargeResource ¶
type RecurringApplicationChargeResource struct {
RecurringApplicationCharge *RecurringApplicationCharge `json:"recurring_application_charge"`
}
Represents the result from the themes/X.json endpoint
type RecurringApplicationChargeService ¶
type RecurringApplicationChargeService struct {
// contains filtered or unexported fields
}
ThemeService handles communication with the theme related methods of the Shopify API.
func (*RecurringApplicationChargeService) Activate ¶
func (s *RecurringApplicationChargeService) Activate(charge RecurringApplicationCharge) (*RecurringApplicationCharge, error)
func (*RecurringApplicationChargeService) Create ¶
func (s *RecurringApplicationChargeService) Create(charge RecurringApplicationCharge) (*RecurringApplicationCharge, error)
func (*RecurringApplicationChargeService) CustomizeCap ¶
func (s *RecurringApplicationChargeService) CustomizeCap(charge RecurringApplicationCharge) (*RecurringApplicationCharge, error)
func (*RecurringApplicationChargeService) Delete ¶
func (s *RecurringApplicationChargeService) Delete(chargeID int, options interface{}) (*RecurringApplicationCharge, error)
Get individual order
func (*RecurringApplicationChargeService) Get ¶
func (s *RecurringApplicationChargeService) Get(chargeID int, options interface{}) (*RecurringApplicationCharge, error)
Get individual order
type ResponseError ¶
A general response error that follows a similar layout to Shopify's response errors, i.e. either a single message or a list of messages.
func (ResponseError) Error ¶
func (e ResponseError) Error() string
type Shop ¶
type Shop struct {
ID int `json:"id"`
Name string `json:"name"`
ShopOwner string `json:"shop_owner"`
Email string `json:"email"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Address1 string `json:"address1"`
City string `json:"city"`
Country string `json:"country"`
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
Currency string `json:"currency"`
Domain string `json:"domain"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Phone string `json:"phone"`
Province string `json:"province"`
ProvinceCode string `json:"province_code"`
Zip string `json:"zip"`
MoneyFormat string `json:"money_format"`
MoneyWithCurrencyFormat string `json:"money_with_currency_format"`
MyshopifyDomain string `json:"myshopify_domain"`
PlanName string `json:"plan_name"`
PlanDisplayName string `json:"plan_display_name"`
PasswordEnabled bool `json:"password_enabled"`
PrimaryLocale string `json:"primary_locale"`
Timezone string `json:"timezone"`
IanaTimezone string `json:"iana_timezone"`
ForceSSL bool `json:"force_ssl"`
HasStorefront bool `json:"has_storefront"`
HasDiscounts bool `json:"has_discounts"`
HasGiftcards bool `json:"has_gift_cards"`
SetupRequire bool `json:"setup_required"`
CountyTaxes bool `json:"county_taxes"`
}
Shop represents a Shopify shop
type ShopResource ¶
type ShopResource struct {
Shop *Shop `json:"shop"`
}
Represents the result from the admin/shop.json endpoint
type ShopService ¶
ShopService is an interface for interfacing with the shop endpoint of the Shopify API. See: https://help.shopify.com/api/reference/shop
type ShopServiceOp ¶
type ShopServiceOp struct {
// contains filtered or unexported fields
}
ShopServiceOp handles communication with the shop related methods of the Shopify API.
func (*ShopServiceOp) Get ¶
func (s *ShopServiceOp) Get(options interface{}) (*Shop, error)
Get shop
type Theme ¶
type Theme struct {
ID int `json:"id"`
Name string `json:"name"`
Role string `json:"role"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Previewable bool `json:"previewable"`
Processing bool `json:"processing"`
}
Theme represents a Shopify theme
type ThemeResource ¶
type ThemeResource struct {
Theme *Theme `json:"theme"`
}
Represents the result from the themes/X.json endpoint
type ThemeService ¶
type ThemeService struct {
// contains filtered or unexported fields
}
ThemeService handles communication with the theme related methods of the Shopify API.
func (*ThemeService) Get ¶
func (s *ThemeService) Get(id int, options interface{}) (*Theme, error)
Get individual theme
func (*ThemeService) List ¶
func (s *ThemeService) List(options interface{}) ([]Theme, error)
List themes
type ThemesResource ¶
type ThemesResource struct {
Themes []Theme `json:"themes"`
}
Represents the result from the themes.json endpoint
type Variant ¶
type Variant struct {
ID int `json:"id"`
ProductID int `json:"product_id"`
Title string `json:"title"`
Sku string `json:"sku"`
Position int `json:"position"`
Grams int `json:"grams"`
InventoryPolicy string `json:"inventory_policy"`
Price *decimal.Decimal `json:"price"`
CompareAtPrice *decimal.Decimal `json:"compare_at_price"`
FulfillmentService string `json:"fulfillment_service"`
InventoryManagement string `json:"inventory_management"`
Option1 string `json:"option1"`
Option2 string `json:"option2"`
Option3 string `json:"option3"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Taxable bool `json:"taxable"`
Barcode string `json:"barcode"`
ImageID int `json:"image_id"`
InventoryQuantity int `json:"inventory_quantity"`
Weight *decimal.Decimal `json:"weight"`
WeightUnit string `json:"weight_unit"`
OldInventoryQuantity int `json:"old_inventory_quantity"`
RequireShipping bool `json:"requires_shipping"`
}
Variant represents a Shopify variant
type Webhook ¶
type Webhook struct {
ID int `json:"id"`
Address string `json:"address"`
Topic string `json:"topic"`
Format string `json:"format"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
Fields []string `json:"fields"`
MetafieldNamespaces []string `json:"metafield_namespaces"`
}
Webhook represents a Shopify webhook
type WebhookOptions ¶
type WebhookResource ¶
type WebhookResource struct {
Webhook *Webhook `json:"webhook"`
}
Represents the result from the admin/shop.json endpoint
type WebhookService ¶
type WebhookService interface {
List(interface{}) ([]Webhook, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*Webhook, error)
Create(Webhook) (*Webhook, error)
Update(Webhook) (*Webhook, error)
}
WebhookService is an interface for interfacing with the webhook endpoints of the Shopify API. See: https://help.shopify.com/api/reference/webhook
type WebhookServiceOp ¶
type WebhookServiceOp struct {
// contains filtered or unexported fields
}
ShopServiceOp handles communication with the shop related methods of the Shopify API.
func (*WebhookServiceOp) Count ¶
func (s *WebhookServiceOp) Count(options interface{}) (int, error)
Count webhooks
func (*WebhookServiceOp) Create ¶
func (s *WebhookServiceOp) Create(webhook Webhook) (*Webhook, error)
Create a new webhook
func (*WebhookServiceOp) Get ¶
func (s *WebhookServiceOp) Get(webhookdID int, options interface{}) (*Webhook, error)
Get individual webhook
func (*WebhookServiceOp) List ¶
func (s *WebhookServiceOp) List(options interface{}) ([]Webhook, error)
List webhooks
type WebhooksResource ¶
type WebhooksResource struct {
Webhooks []Webhook `json:"webhooks"`
}