shopify

package module
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 16 Imported by: 1

README

go-shopify-graphql

A simple Shopify client using the Shopify's GraphQL Admin API.

Getting started

A Hello World example

0. Setup
export STORE_API_KEY=<private_app_api_key>
export STORE_PASSWORD=<private_app_password>
export STORE_NAME=<store_name>
1. Program
package main

import (
    "fmt"

    shopify "github.com/r0busta/go-shopify-graphql/v2"
)

func main() {
    // Create client
    client := shopify.NewDefaultClient()

    // Get all collections
    collections, err := client.Collection.ListAll()
    if err != nil {
        panic(err)
    }

    // Print out the result
    for _, c := range collections {
        fmt.Println(c.Handle)
    }
}
3. Run
go run .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkOperationService

type BulkOperationService interface {
	BulkQuery(query string, v interface{}) error

	PostBulkQuery(query string) (graphql.ID, error)
	GetCurrentBulkQuery() (CurrentBulkOperation, error)
	GetCurrentBulkQueryResultURL() (string, error)
	WaitForCurrentBulkQuery(interval time.Duration) (CurrentBulkOperation, error)
	ShouldGetBulkQueryResultURL(id graphql.ID) (string, error)
	CancelRunningBulkQuery() error
}

type BulkOperationServiceOp

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

func (*BulkOperationServiceOp) BulkQuery

func (s *BulkOperationServiceOp) BulkQuery(query string, out interface{}) error

func (*BulkOperationServiceOp) CancelRunningBulkQuery added in v2.0.2

func (s *BulkOperationServiceOp) CancelRunningBulkQuery() (err error)

func (*BulkOperationServiceOp) GetCurrentBulkQuery added in v2.0.2

func (s *BulkOperationServiceOp) GetCurrentBulkQuery() (CurrentBulkOperation, error)

func (*BulkOperationServiceOp) GetCurrentBulkQueryResultURL added in v2.0.2

func (s *BulkOperationServiceOp) GetCurrentBulkQueryResultURL() (url string, err error)

func (*BulkOperationServiceOp) PostBulkQuery added in v2.0.2

func (s *BulkOperationServiceOp) PostBulkQuery(query string) (graphql.ID, error)

func (*BulkOperationServiceOp) ShouldGetBulkQueryResultURL added in v2.0.2

func (s *BulkOperationServiceOp) ShouldGetBulkQueryResultURL(id graphql.ID) (url string, err error)

func (*BulkOperationServiceOp) WaitForCurrentBulkQuery added in v2.0.5

func (s *BulkOperationServiceOp) WaitForCurrentBulkQuery(interval time.Duration) (CurrentBulkOperation, error)

type Client

type Client struct {
	Product       ProductService
	Variant       VariantService
	Inventory     InventoryService
	Collection    CollectionService
	Order         OrderService
	Fulfillment   FulfillmentService
	Location      LocationService
	Metafield     MetafieldService
	BulkOperation BulkOperationService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string, password string, storeName string) *Client

func NewDefaultClient

func NewDefaultClient() (shopClient *Client)

func (*Client) GraphQLClient

func (c *Client) GraphQLClient() *graphql.Client

type CollectionBase

type CollectionBase struct {
	ID            graphql.ID     `json:"id,omitempty"`
	Handle        graphql.String `json:"handle,omitempty"`
	Title         graphql.String `json:"title,omitempty"`
	ProductsCount graphql.Int    `json:"productsCount,omitempty"`
}

type CollectionBulkResult

type CollectionBulkResult struct {
	CollectionBase

	Products []ProductBulkResult `json:"products,omitempty"`
}

type CollectionCreate

type CollectionCreate struct {
	CollectionInput CollectionInput
}

type CollectionCreateResult

type CollectionCreateResult struct {
	Collection struct {
		ID graphql.ID `json:"id,omitempty"`
	}
	UserErrors []UserErrors
}

type CollectionInput

type CollectionInput struct {
	// The description of the collection, in HTML format.
	DescriptionHTML graphql.String `json:"descriptionHtml,omitempty"`

	// A unique human-friendly string for the collection. Automatically generated from the collection's title.
	Handle graphql.String `json:"handle,omitempty"`

	// Specifies the collection to update or create a new collection if absent.
	ID graphql.ID `json:"id,omitempty"`

	// The image associated with the collection.
	Image *ImageInput `json:"image,omitempty"`

	// The metafields to associate with this collection.
	Metafields []MetafieldInput `json:"metafields,omitempty"`

	// Initial list of collection products. Only valid with productCreate and without rules.
	Products []graphql.ID `json:"products,omitempty"`

	// Indicates whether a redirect is required after a new handle has been provided. If true, then the old handle is redirected to the new one automatically.
	RedirectNewHandle graphql.Boolean `json:"redirectNewHandle,omitempty"`

	//	The rules used to assign products to the collection.
	RuleSet *CollectionRuleSetInput `json:"ruleSet,omitempty"`

	// SEO information for the collection.
	SEO *SEOInput `json:"seo,omitempty"`

	// The order in which the collection's products are sorted.
	SortOrder *CollectionSortOrder `json:"sortOrder,omitempty"`

	// The theme template used when viewing the collection in a store.
	TemplateSuffix graphql.String `json:"templateSuffix,omitempty"`

	// Required for creating a new collection.
	Title graphql.String `json:"title,omitempty"`
}

type CollectionQueryResult

type CollectionQueryResult struct {
	CollectionBase

	Products struct {
		Edges []struct {
			Product ProductQueryResult `json:"node,omitempty"`
			Cursor  string             `json:"cursor,omitempty"`
		} `json:"edges,omitempty"`
		PageInfo PageInfo `json:"pageInfo,omitempty"`
	} `json:"products,omitempty"`
}

type CollectionRuleColumn

type CollectionRuleColumn string

CollectionRuleColumn string enum VENDOR The vendor attribute. TAG The tag attribute. TITLE The title attribute. TYPE The type attribute. VARIANT_COMPARE_AT_PRICE The variant_compare_at_price attribute. VARIANT_INVENTORY The variant_inventory attribute. VARIANT_PRICE The variant_price attribute. VARIANT_TITLE The variant_title attribute. VARIANT_WEIGHT The variant_weight attribute. IS_PRICE_REDUCED The is_price_reduced attribute.

type CollectionRuleInput

type CollectionRuleInput struct {
	// The attribute that the rule focuses on (for example, title or product_type).
	Column CollectionRuleColumn `json:"column,omitempty"` // REQUIRED

	// The value that the operator is applied to (for example, Hats).
	Condition graphql.String `json:"condition,omitempty"` // REQUIRED

	// The type of operator that the rule is based on (for example, equals, contains, or not_equals).
	Relation CollectionRuleRelation `json:"relation,omitempty"` // REQUIRED
}

type CollectionRuleRelation

type CollectionRuleRelation string

CollectionRuleRelation enum STARTS_WITH The attribute starts with the condition. ENDS_WITH The attribute ends with the condition. EQUALS The attribute is equal to the condition. GREATER_THAN The attribute is greater than the condition. IS_NOT_SET The attribute is not set. IS_SET The attribute is set. LESS_THAN The attribute is less than the condition. NOT_CONTAINS The attribute does not contain the condition. NOT_EQUALS The attribute does not equal the condition. CONTAINS The attribute contains the condition.

type CollectionRuleSetInput

type CollectionRuleSetInput struct {
	// Whether products must match any or all of the rules to be included in the collection. If true, then products must match one or more of the rules to be included in the collection. If false, then products must match all of the rules to be included in the collection.
	AppliedDisjunctively graphql.Boolean `json:"appliedDisjunctively"` // REQUIRED

	// The rules used to assign products to the collection.
	Rules []CollectionRuleInput `json:"rules,omitempty"`
}

type CollectionService

type CollectionService interface {
	ListAll() ([]*CollectionBulkResult, error)

	Get(id graphql.ID) (*CollectionQueryResult, error)

	Create(collection *CollectionCreate) (graphql.ID, error)
	CreateBulk(collections []*CollectionCreate) error

	Update(collection *CollectionCreate) error
}

type CollectionServiceOp

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

func (*CollectionServiceOp) Create

func (s *CollectionServiceOp) Create(collection *CollectionCreate) (graphql.ID, error)

func (*CollectionServiceOp) CreateBulk

func (s *CollectionServiceOp) CreateBulk(collections []*CollectionCreate) error

func (*CollectionServiceOp) Get

func (*CollectionServiceOp) ListAll

func (s *CollectionServiceOp) ListAll() ([]*CollectionBulkResult, error)

func (*CollectionServiceOp) Update

func (s *CollectionServiceOp) Update(collection *CollectionCreate) error

type CollectionSortOrder

type CollectionSortOrder string

CollectionSortOrder enum PRICE_DESC By price, in descending order (highest - lowest). ALPHA_DESC Alphabetically, in descending order (Z - A). BEST_SELLING By best-selling products. CREATED By date created, in ascending order (oldest - newest). CREATED_DESC By date created, in descending order (newest - oldest). MANUAL In the order set manually by the merchant. PRICE_ASC By price, in ascending order (lowest - highest). ALPHA_ASC Alphabetically, in ascending order (A - Z).

type CountryCode added in v2.0.4

type CountryCode string

CountryCode enum ISO 3166-1 alpha-2 country codes with some differences.

type CreateMediaInput

type CreateMediaInput struct {
	Alt              graphql.String   `json:"alt,omitempty"`
	MediaContentType MediaContentType `json:"mediaContentType,omitempty"` // REQUIRED
	OriginalSource   graphql.String   `json:"originalSource,omitempty"`   // REQUIRED
}

type CurrencyCode

type CurrencyCode string

CurrencyCode enum USD United States Dollars (USD). EUR Euro GBP British Pound ... see more at https://shopify.dev/docs/admin-api/graphql/reference/common-objects/currencycode

type CurrentBulkOperation added in v2.0.2

type CurrentBulkOperation struct {
	ID             graphql.ID     `json:"id"`
	Status         graphql.String `json:"status"`
	ErrorCode      graphql.String `json:"errorCode"`
	CreatedAt      graphql.String `json:"createdAt"`
	CompletedAt    graphql.String `json:"completedAt"`
	ObjectCount    graphql.String `json:"objectCount"`
	FileSize       graphql.String `json:"fileSize"`
	URL            graphql.String `json:"url"`
	PartialDataURL graphql.String `json:"partialDataUrl"`
	Query          graphql.String `json:"query"`
}

type Customer

type Customer struct {
	ID               graphql.ID     `json:"id,omitempty"`
	LegacyResourceID graphql.String `json:"legacyResourceId,omitempty"`
	FirstName        graphql.String `json:"firstName,omitempty"`
	DisplayName      graphql.String `json:"displayName,omitempty"`
	Email            graphql.String `json:"email,omitempty"`
}

type DateTime

type DateTime string

type Decimal

type Decimal string // Serialized decimal.Decimal

type FulfillmentCreateV2Result added in v2.0.4

type FulfillmentCreateV2Result struct {
	UserErrors []UserErrors `json:"userErrors,omitempty"`
}

type FulfillmentOrder added in v2.0.4

type FulfillmentOrder struct {
	ID                        graphql.ID                 `json:"id,omitempty"`
	Status                    FulfillmentOrderStatus     `json:"status,omitempty"`
	FulfillmentOrderLineItems []FulfillmentOrderLineItem `json:"lineItems,omitempty"`
}

type FulfillmentOrderLineItem added in v2.0.4

type FulfillmentOrderLineItem struct {
	ID                graphql.ID  `json:"id,omitempty"`
	RemainingQuantity graphql.Int `json:"remainingQuantity"`
	TotalQuantity     graphql.Int `json:"totalQuantity"`
	LineItem          LineItem    `json:"lineItem,omitempty"`
}

type FulfillmentOrderLineItemInput added in v2.0.4

type FulfillmentOrderLineItemInput struct {
	ID       graphql.ID  `json:"id,omitempty"`
	Quantity graphql.Int `json:"quantity,omitempty"`
}

type FulfillmentOrderLineItemsInput added in v2.0.4

type FulfillmentOrderLineItemsInput struct {
	FulfillmentOrderID        graphql.ID                      `json:"fulfillmentOrderId,omitempty"`
	FulfillmentOrderLineItems []FulfillmentOrderLineItemInput `json:"fulfillmentOrderLineItems,omitempty"`
}

type FulfillmentOrderStatus added in v2.0.4

type FulfillmentOrderStatus string

type FulfillmentService added in v2.0.4

type FulfillmentService interface {
	Create(input FulfillmentV2Input) error
}

type FulfillmentServiceOp added in v2.0.4

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

func (*FulfillmentServiceOp) Create added in v2.0.4

func (s *FulfillmentServiceOp) Create(fulfillment FulfillmentV2Input) error

type FulfillmentTrackingInput added in v2.0.4

type FulfillmentTrackingInput struct {
	Company graphql.String `json:"company,omitempty"`
	Number  graphql.String `json:"number,omitempty"`
	URL     URL            `json:"url,omitempty"`
}

type FulfillmentV2Input added in v2.0.4

type FulfillmentV2Input struct {
	LineItemsByFulfillmentOrder []FulfillmentOrderLineItemsInput `json:"lineItemsByFulfillmentOrder,omitempty"`
	NotifyCustomer              graphql.Boolean                  `json:"notifyCustomer,omitempty"`
	TrackingInfo                FulfillmentTrackingInput         `json:"trackingInfo,omitempty"`
}

type ImageInput

type ImageInput struct {
	AltText graphql.String `json:"altText,omitempty"`
	ID      graphql.ID     `json:"id,omitempty"`
	Src     graphql.String `json:"src,omitempty"`
}

type InventoryActivateResult added in v2.0.4

type InventoryActivateResult struct {
	UserErrors []UserErrors `json:"userErrors,omitempty"`
}

type InventoryAdjustItemInput added in v2.0.4

type InventoryAdjustItemInput struct {
	InventoryItemID graphql.ID  `json:"inventoryItemId,omitempty"`
	AvailableDelta  graphql.Int `json:"availableDelta,omitempty"`
}

type InventoryBulkAdjustQuantityAtLocationResult added in v2.0.4

type InventoryBulkAdjustQuantityAtLocationResult struct {
	UserErrors []UserErrors `json:"userErrors,omitempty"`
}

type InventoryItem

type InventoryItem struct {
	ID               graphql.ID     `json:"id,omitempty"`
	LegacyResourceID graphql.String `json:"legacyResourceId,omitempty"`
	SKU              graphql.String `json:"sku,omitempty"`
}

type InventoryItemInput

type InventoryItemInput struct {
	// Unit cost associated with the inventory item, the currency is the shop's default currency.
	Cost Decimal `json:"cost,omitempty"`
	// Whether the inventory item is tracked. If true, then inventory quantity changes are tracked by Shopify.
	Tracked graphql.Boolean `json:"tracked,omitempty"`
}

type InventoryItemUpdateInput added in v2.0.4

type InventoryItemUpdateInput struct {
	Cost graphql.Float `json:"cost,omitempty"`
}

type InventoryItemUpdateResult added in v2.0.4

type InventoryItemUpdateResult struct {
	UserErrors []UserErrors `json:"userErrors,omitempty"`
}

type InventoryLevel added in v2.0.4

type InventoryLevel struct {
	UpdatedAt graphql.String `json:"updatedAt,omitempty"`
	Available graphql.Int    `json:"available,omitempty"`
	Item      InventoryItem  `json:"item,omitempty"`
}

type InventoryLevelInput

type InventoryLevelInput struct {
	AvailableQuantity graphql.Int `json:"availableQuantity"`
	LocationID        graphql.ID  `json:"locationId"`
}

type InventoryService added in v2.0.4

type InventoryService interface {
	Update(id graphql.ID, input InventoryItemUpdateInput) error
	Adjust(locationID graphql.ID, input []InventoryAdjustItemInput) error
	ActivateInventory(locationID graphql.ID, id graphql.ID) error
}

type InventoryServiceOp added in v2.0.4

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

func (*InventoryServiceOp) ActivateInventory added in v2.0.4

func (s *InventoryServiceOp) ActivateInventory(locationID graphql.ID, id graphql.ID) error

func (*InventoryServiceOp) Adjust added in v2.0.4

func (s *InventoryServiceOp) Adjust(locationID graphql.ID, input []InventoryAdjustItemInput) error

func (*InventoryServiceOp) Update added in v2.0.4

type LineItem

type LineItem struct {
	ID                     graphql.ID      `json:"id,omitempty"`
	SKU                    graphql.String  `json:"sku,omitempty"`
	Quantity               graphql.Int     `json:"quantity,omitempty"`
	FulfillableQuantity    graphql.Int     `json:"fulfillableQuantity,omitempty"`
	FulfillmentStatus      graphql.String  `json:"fulfillmentStatus,omitempty"`
	Vendor                 graphql.String  `json:"vendor,omitempty"`
	Title                  graphql.String  `json:"title,omitempty"`
	VariantTitle           graphql.String  `json:"variantTitle,omitempty"`
	Product                LineItemProduct `json:"product,omitempty"`
	Variant                LineItemVariant `json:"variant,omitempty"`
	OriginalTotalSet       MoneyBag        `json:"originalTotalSet,omitempty"`
	OriginalUnitPriceSet   MoneyBag        `json:"originalUnitPriceSet,omitempty"`
	DiscountedUnitPriceSet MoneyBag        `json:"discountedUnitPriceSet,omitempty"`
	DiscountedTotalSet     MoneyBag        `json:"discountedTotalSet,omitempty"`
}

type LineItemProduct

type LineItemProduct struct {
	ID               graphql.ID     `json:"id,omitempty"`
	LegacyResourceID graphql.String `json:"legacyResourceId,omitempty"`
}

type LineItemVariant

type LineItemVariant struct {
	ID               graphql.ID       `json:"id,omitempty"`
	LegacyResourceID graphql.String   `json:"legacyResourceId,omitempty"`
	SelectedOptions  []SelectedOption `json:"selectedOptions,omitempty"`
}

type ListOptions added in v2.0.13

type ListOptions struct {
	Query   string
	First   int
	Last    int
	After   string
	Before  string
	Reverse bool
}

type Location added in v2.0.4

type Location struct {
	ID   graphql.ID     `json:"id,omitempty"`
	Name graphql.String `json:"name,omitempty"`
}

type LocationService added in v2.0.4

type LocationService interface {
	Get(id graphql.ID) (*Location, error)
}

type LocationServiceOp added in v2.0.4

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

func (*LocationServiceOp) Get added in v2.0.4

func (s *LocationServiceOp) Get(id graphql.ID) (*Location, error)

type MailingAddress added in v2.0.4

type MailingAddress struct {
	// The first line of the address. Typically the street address or PO Box number.
	Address1 graphql.String `json:"address1,omitempty"`

	// The second line of the address. Typically the number of the apartment, suite, or unit.
	Address2 graphql.String `json:"address2,omitempty"`

	// The name of the city, district, village, or town.
	City graphql.String `json:"city,omitempty"`

	// The name of the customer's company or organization.
	Company graphql.String `json:"company,omitempty"`

	// The name of the country.
	Country graphql.String `json:"country,omitempty"`

	// The two-letter code for the country of the address. For example, US.
	CountryCodeV2 CountryCode `json:"countryCodeV2,omitempty"`

	// The first name of the customer.
	FirstName graphql.String `json:"firstName,omitempty"`

	// A formatted version of the address, customized by the provided arguments.
	Formatted []graphql.String `json:"formatted,omitempty"`

	// Whether to include the customer's company in the formatted address.
	// Default value: true
	WithCompany graphql.Boolean `json:"withCompany,omitempty"`

	// Whether to include the customer's name in the formatted address.
	// Default value: false
	WithName graphql.Boolean `json:"withName,omitempty"`

	// A comma-separated list of the values for city, province, and country.
	FormattedArea graphql.String `json:"formattedArea,omitempty"`

	// Globally unique identifier.
	ID graphql.ID `json:"id,omitempty"`

	// The last name of the customer.
	LastName graphql.String `json:"lastName,omitempty"`

	// The latitude coordinate of the customer address.
	Latitude graphql.Float `json:"latitude,omitempty"`

	// The longitude coordinate of the customer address.
	Longitude graphql.Float `json:"longitude,omitempty"`

	// The full name of the customer, based on firstName and lastName.
	Name graphql.String `json:"name,omitempty"`

	// A unique phone number for the customer.
	// Formatted using E.164 standard. For example, +16135551111.
	Phone graphql.String `json:"phone,omitempty"`

	// The region of the address, such as the province, state, or district.
	Province graphql.String `json:"province,omitempty"`

	// The two-letter code for the region.
	// For example, ON.
	ProvinceCode graphql.String `json:"provinceCode,omitempty"`

	// The zip or postal code of the address.
	Zip graphql.String `json:"zip,omitempty"`
}

type MediaContentType

type MediaContentType string

MediaContentType enum EXTERNAL_VIDEO An externally hosted video. IMAGE A Shopify hosted image. MODEL_3D A 3d model. VIDEO A Shopify hosted video.

type Metafield

type Metafield struct {
	// The date and time when the metafield was created.
	CreatedAt DateTime `json:"createdAt,omitempty"`
	// The description of a metafield.
	Description graphql.String `json:"description,omitempty"`
	// Globally unique identifier.
	ID graphql.ID `json:"id,omitempty"`
	// The key name for a metafield.
	Key graphql.String `json:"key,omitempty"`
	// The ID of the corresponding resource in the REST Admin API.
	LegacyResourceID graphql.String `json:"legacyResourceId,omitempty"`
	// The namespace for a metafield.
	Namespace graphql.String `json:"namespace,omitempty"`
	// Owner type of a metafield visible to the Storefront API.
	OwnerType graphql.String `json:"ownerType,omitempty"`
	// The date and time when the metafield was updated.
	UpdatedAt DateTime `json:"updatedAt,omitempty"`
	// The value of a metafield.
	Value graphql.String `json:"value,omitempty"`
	// Represents the metafield value type.
	ValueType MetafieldValueType `json:"valueType,omitempty"`
}

type MetafieldDeleteInput

type MetafieldDeleteInput struct {
	// The ID of the metafield to delete.
	ID graphql.ID `json:"id,omitempty"`
}

type MetafieldInput

type MetafieldInput struct {
	ID        graphql.ID         `json:"id,omitempty"`
	Namespace graphql.String     `json:"namespace,omitempty"`
	Key       graphql.String     `json:"key,omitempty"`
	Value     graphql.String     `json:"value,omitempty"`
	ValueType MetafieldValueType `json:"valueType,omitempty"`
}

type MetafieldService

type MetafieldService interface {
	ListAllShopMetafields() ([]*Metafield, error)
	ListShopMetafieldsByNamespace(namespace string) ([]*Metafield, error)

	GetShopMetafieldByKey(namespace, key string) (Metafield, error)

	Delete(metafield MetafieldDeleteInput) error
	DeleteBulk(metafield []MetafieldDeleteInput) error
}

type MetafieldServiceOp

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

func (*MetafieldServiceOp) Delete

func (s *MetafieldServiceOp) Delete(metafield MetafieldDeleteInput) error

func (*MetafieldServiceOp) DeleteBulk

func (s *MetafieldServiceOp) DeleteBulk(metafields []MetafieldDeleteInput) error

func (*MetafieldServiceOp) GetShopMetafieldByKey

func (s *MetafieldServiceOp) GetShopMetafieldByKey(namespace, key string) (Metafield, error)

func (*MetafieldServiceOp) ListAllShopMetafields

func (s *MetafieldServiceOp) ListAllShopMetafields() ([]*Metafield, error)

func (*MetafieldServiceOp) ListShopMetafieldsByNamespace

func (s *MetafieldServiceOp) ListShopMetafieldsByNamespace(namespace string) ([]*Metafield, error)

type MetafieldValueType

type MetafieldValueType string

MetafieldValueType enum INTEGER An integer. JSON_STRING A JSON string. STRING A string.

type Money

type Money string // Serialized and truncated to 2 decimals decimal.Decimal

type MoneyBag

type MoneyBag struct {
	PresentmentMoney MoneyV2 `json:"presentmentMoney,omitempty"`
	ShopMoney        MoneyV2 `json:"shopMoney,omitempty"`
}

type MoneyV2

type MoneyV2 struct {
	Amount       Decimal      `json:"amount,omitempty"`
	CurrencyCode CurrencyCode `json:"currencyCode,omitempty"`
}

type Order

type Order struct {
	OrderBase

	LineItems         []LineItem         `json:"lineItems,omitempty"`
	FulfillmentOrders []FulfillmentOrder `json:"fulfillmentOrders,omitempty"`
}

type OrderBase added in v2.0.8

type OrderBase struct {
	ID                       graphql.ID         `json:"id,omitempty"`
	LegacyResourceID         graphql.String     `json:"legacyResourceId,omitempty"`
	Name                     graphql.String     `json:"name,omitempty"`
	CreatedAt                DateTime           `json:"createdAt,omitempty"`
	Closed                   graphql.Boolean    `json:"closed,omitempty"`
	Customer                 Customer           `json:"customer,omitempty"`
	ClientIP                 graphql.String     `json:"clientIp,omitempty"`
	TaxLines                 []TaxLine          `json:"taxLines,omitempty"`
	TotalReceivedSet         MoneyBag           `json:"totalReceivedSet,omitempty"`
	ShippingAddress          MailingAddress     `json:"shippingAddress,omitempty"`
	ShippingLine             ShippingLine       `json:"shippingLine,omitempty"`
	Note                     graphql.String     `json:"note,omitempty"`
	Tags                     []graphql.String   `json:"tags,omitempty"`
	DisplayFinancialStatus   graphql.String     `json:"displayFinancialStatus,omitempty"`
	DisplayFulfillmentStatus graphql.String     `json:"displayFulfillmentStatus,omitempty"`
	Transactions             []OrderTransaction `json:"transactions,omitempty"`
}

type OrderInput added in v2.0.4

type OrderInput struct {
	ID   graphql.ID       `json:"id,omitempty"`
	Tags []graphql.String `json:"tags,omitempty"`
	Note graphql.String   `json:"note,omitempty"`
}

type OrderLineItemNode

type OrderLineItemNode struct {
	Node LineItem `json:"node,omitempty"`
}

type OrderQueryResult added in v2.0.8

type OrderQueryResult struct {
	OrderBase

	LineItems struct {
		Edges []struct {
			LineItem LineItem `json:"node,omitempty"`
		} `json:"edges,omitempty"`
	} `json:"lineItems,omitempty"`

	FulfillmentOrders struct {
		Edges []struct {
			FulfillmentOrder struct {
				ID                        graphql.ID             `json:"id,omitempty"`
				Status                    FulfillmentOrderStatus `json:"status,omitempty"`
				FulfillmentOrderLineItems struct {
					Edges []struct {
						LineItem FulfillmentOrderLineItem `json:"node,omitempty"`
					} `json:"edges,omitempty"`
				} `json:"lineItems,omitempty"`
			} `json:"node,omitempty"`
		} `json:"edges,omitempty"`
	} `json:"fulfillmentOrders,omitempty"`
}

type OrderService

type OrderService interface {
	Get(id graphql.ID) (*OrderQueryResult, error)

	List(opts ListOptions) ([]*Order, error)
	ListAll() ([]*Order, error)

	ListAfterCursor(opts ListOptions) ([]*OrderQueryResult, string, string, error)

	Update(input OrderInput) error

	GetFulfillmentOrdersAtLocation(orderID graphql.ID, locationID graphql.ID) ([]FulfillmentOrder, error)
}

type OrderServiceOp

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

func (*OrderServiceOp) Get added in v2.0.8

func (*OrderServiceOp) GetFulfillmentOrdersAtLocation added in v2.0.4

func (s *OrderServiceOp) GetFulfillmentOrdersAtLocation(orderID graphql.ID, locationID graphql.ID) ([]FulfillmentOrder, error)

func (*OrderServiceOp) List

func (s *OrderServiceOp) List(opts ListOptions) ([]*Order, error)

func (*OrderServiceOp) ListAfterCursor added in v2.0.12

func (s *OrderServiceOp) ListAfterCursor(opts ListOptions) ([]*OrderQueryResult, string, string, error)

func (*OrderServiceOp) ListAll

func (s *OrderServiceOp) ListAll() ([]*Order, error)

func (*OrderServiceOp) Update added in v2.0.4

func (s *OrderServiceOp) Update(input OrderInput) error

type OrderTransaction added in v2.1.4

type OrderTransaction struct {
	ProcessedAt DateTime               `json:"processedAt,omitempty"`
	Status      OrderTransactionStatus `json:"status,omitempty"`
	Kind        OrderTransactionKind   `json:"kind,omitempty"`
	Test        graphql.Boolean        `json:"test,omitempty"`
	AmountSet   *MoneyBag              `json:"amountSet,omitempty"`
}

type OrderTransactionKind added in v2.1.4

type OrderTransactionKind string

type OrderTransactionStatus added in v2.1.4

type OrderTransactionStatus string

type OrderUpdateResult added in v2.0.4

type OrderUpdateResult struct {
	UserErrors []UserErrors `json:"userErrors"`
}

type PageInfo

type PageInfo struct {
	// Indicates if there are more pages to fetch.
	HasNextPage graphql.Boolean `json:"hasNextPage"`
	// Indicates if there are any pages prior to the current page.
	HasPreviousPage graphql.Boolean `json:"hasPreviousPage"`
}

type ProductBase

type ProductBase struct {
	ID               graphql.ID           `json:"id,omitempty"`
	LegacyResourceID graphql.String       `json:"legacyResourceId,omitempty"`
	Handle           graphql.String       `json:"handle,omitempty"`
	Options          []ProductOption      `json:"options,omitempty"`
	Tags             []graphql.String     `json:"tags,omitempty"`
	Description      graphql.String       `json:"description,omitempty"`
	Title            graphql.String       `json:"title,omitempty"`
	PriceRangeV2     *ProductPriceRangeV2 `json:"priceRangeV2,omitempty"`
	ProductType      graphql.String       `json:"productType,omitempty"`
	Vendor           graphql.String       `json:"vendor,omitempty"`
	TotalInventory   graphql.Int          `json:"totalInventory,omitempty"`
	OnlineStoreURL   graphql.String       `json:"onlineStoreUrl,omitempty"`
	DescriptionHTML  graphql.String       `json:"descriptionHtml,omitempty"`
	SEO              *SEOInput            `json:"seo,omitempty"`
	TemplateSuffix   graphql.String       `json:"templateSuffix,omitempty"`
}

type ProductBulkResult

type ProductBulkResult struct {
	ProductBase

	Metafields      []Metafield      `json:"metafields,omitempty"`
	ProductVariants []ProductVariant `json:"variants,omitempty"`
}

type ProductCreate

type ProductCreate struct {
	ProductInput ProductInput
	MediaInput   []CreateMediaInput
}

type ProductDelete

type ProductDelete struct {
	ProductInput ProductDeleteInput
}

type ProductDeleteInput

type ProductDeleteInput struct {
	ID graphql.ID `json:"id,omitempty"`
}

type ProductInput

type ProductInput struct {
	// The IDs of the collections that this product will be added to.
	CollectionsToJoin []graphql.ID `json:"collectionsToJoin,omitempty"`

	// The IDs of collections that will no longer include the product.
	CollectionsToLeave []graphql.ID `json:"collectionsToLeave,omitempty"`

	// The description of the product, complete with HTML formatting.
	DescriptionHTML graphql.String `json:"descriptionHtml,omitempty"`

	// Whether the product is a gift card.
	GiftCard graphql.Boolean `json:"giftCard,omitempty"`

	// The theme template used when viewing the gift card in a store.
	GiftCardTemplateSuffix graphql.String `json:"giftCardTemplateSuffix,omitempty"`

	// A unique human-friendly string for the product. Automatically generated from the product's title.
	Handle graphql.String `json:"handle,omitempty"`

	// Specifies the product to update in productUpdate or creates a new product if absent in productCreate.
	ID graphql.ID `json:"id,omitempty"`

	// The images to associate with the product.
	Images []ImageInput `json:"images,omitempty"`

	// The metafields to associate with this product.
	Metafields []MetafieldInput `json:"metafields,omitempty"`

	// List of custom product options (maximum of 3 per product).
	Options []graphql.String `json:"options,omitempty"`

	// The product type specified by the merchant.
	ProductType graphql.String `json:"productType,omitempty"`

	// Whether a redirect is required after a new handle has been provided. If true, then the old handle is redirected to the new one automatically.
	RedirectNewHandle graphql.Boolean `json:"redirectNewHandle,omitempty"`

	// The SEO information associated with the product.
	SEO *SEOInput `json:"seo,omitempty"`

	// A comma separated list tags that have been added to the product.
	Tags []graphql.String `json:"tags,omitempty"`

	// The theme template used when viewing the product in a store.
	TemplateSuffix graphql.String `json:"templateSuffix,omitempty"`

	// The title of the product.
	Title graphql.String `json:"title,omitempty"`

	// A list of variants associated with the product.
	Variants []ProductVariantInput `json:"variants,omitempty"`

	// The name of the product's vendor.
	Vendor graphql.String `json:"vendor,omitempty"`
}

type ProductOption

type ProductOption struct {
	Name   graphql.String   `json:"name,omitempty"`
	Values []graphql.String `json:"values,omitempty"`
}

type ProductPriceRangeV2

type ProductPriceRangeV2 struct {
	MinVariantPrice MoneyV2 `json:"minVariantPrice,omitempty"`
	MaxVariantPrice MoneyV2 `json:"maxVariantPrice,omitempty"`
}

type ProductQueryResult

type ProductQueryResult struct {
	ProductBase

	ProductVariants struct {
		Edges []struct {
			Variant ProductVariant `json:"node,omitempty"`
			Cursor  string         `json:"cursor,omitempty"`
		} `json:"edges,omitempty"`
		PageInfo PageInfo `json:"pageInfo,omitempty"`
	} `json:"variants,omitempty"`
}

type ProductService

type ProductService interface {
	List(query string) ([]*ProductBulkResult, error)
	ListAll() ([]*ProductBulkResult, error)

	Get(gid graphql.ID) (*ProductQueryResult, error)

	Create(product *ProductCreate) error
	CreateBulk(products []*ProductCreate) error

	Update(product *ProductUpdate) error
	UpdateBulk(products []*ProductUpdate) error

	Delete(product *ProductDelete) error
	DeleteBulk(products []*ProductDelete) error
}

type ProductServiceOp

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

func (*ProductServiceOp) Create

func (s *ProductServiceOp) Create(product *ProductCreate) error

func (*ProductServiceOp) CreateBulk

func (s *ProductServiceOp) CreateBulk(products []*ProductCreate) error

func (*ProductServiceOp) Delete

func (s *ProductServiceOp) Delete(product *ProductDelete) error

func (*ProductServiceOp) DeleteBulk

func (s *ProductServiceOp) DeleteBulk(products []*ProductDelete) error

func (*ProductServiceOp) Get

func (*ProductServiceOp) List

func (s *ProductServiceOp) List(query string) ([]*ProductBulkResult, error)

func (*ProductServiceOp) ListAll

func (s *ProductServiceOp) ListAll() ([]*ProductBulkResult, error)

func (*ProductServiceOp) Update

func (s *ProductServiceOp) Update(product *ProductUpdate) error

func (*ProductServiceOp) UpdateBulk

func (s *ProductServiceOp) UpdateBulk(products []*ProductUpdate) error

type ProductShort

type ProductShort struct {
	ID     graphql.ID       `json:"id,omitempty"`
	Handle graphql.String   `json:"handle,omitempty"`
	Tags   []graphql.String `json:"tags,omitempty"`
}

type ProductUpdate

type ProductUpdate struct {
	ProductInput ProductInput
}

type ProductVariant

type ProductVariant struct {
	ID                graphql.ID       `json:"id,omitempty"`
	LegacyResourceID  graphql.String   `json:"legacyResourceId,omitempty"`
	SKU               graphql.String   `json:"sku,omitempty"`
	SelectedOptions   []SelectedOption `json:"selectedOptions,omitempty"`
	CompareAtPrice    Money            `json:"compareAtPrice,omitempty"`
	Price             Money            `json:"price,omitempty"`
	InventoryQuantity graphql.Int      `json:"inventoryQuantity,omitempty"`
	InventoryItem     InventoryItem    `json:"inventoryItem,omitempty"`
}

type ProductVariantInput

type ProductVariantInput struct {
	// The value of the barcode associated with the product.
	Barcode graphql.String `json:"barcode,omitempty"`

	// The compare-at price of the variant.
	CompareAtPrice *Money `json:"compareAtPrice"`

	// The ID of the fulfillment service associated with the variant.
	FulfillmentServiceID graphql.ID `json:"fulfillmentServiceId,omitempty"`

	// The Harmonized System Code (or HS Tariff Code) for the variant.
	HarmonizedSystemCode graphql.String `json:"harmonizedSystemCode,omitempty"`

	// Specifies the product variant to update or create a new variant if absent.
	ID graphql.ID `json:"id,omitempty"`

	// The ID of the image that's associated with the variant.
	ImageID graphql.ID `json:"imageId,omitempty"`

	// The URL of an image to associate with the variant. This field can only be used through mutations that create product images and must match one of the URLs being created on the product.
	ImageSrc graphql.String `json:"imageSrc,omitempty"`

	// Inventory Item associated with the variant, used for unit cost.
	InventoryItem *InventoryItemInput `json:"inventoryItem,omitempty"`

	// Whether customers are allowed to place an order for the product variant when it's out of stock.
	InventoryPolicy ProductVariantInventoryPolicy `json:"inventoryPolicy,omitempty"`

	// Create only field. The inventory quantities at each location where the variant is stocked.
	InventoryQuantities []InventoryLevelInput `json:"inventoryQuantities,omitempty"`

	// The ID of the corresponding resource in the REST Admin API.
	LegacyResourceID graphql.String `json:"legacyResourceId,omitempty"`

	// Additional customizable information about the product variant.
	Metafields []MetafieldInput `json:"metafields,omitempty"`

	// The custom properties that a shop owner uses to define product variants.
	Options []graphql.String `json:"options,omitempty"`

	// The order of the product variant in the list of product variants. The first position in the list is 1.
	Position graphql.Int `json:"position,omitempty"`

	// The price of the variant.
	Price Money `json:"price,omitempty"`

	// Create only required field. Specifies the product on which to create the variant.
	ProductID graphql.ID `json:"productId,omitempty"`

	// Whether the variant requires shipping.
	RequiresShipping graphql.Boolean `json:"requiresShipping,omitempty"`

	// The SKU for the variant.
	SKU graphql.String `json:"sku,omitempty"`

	// This parameter applies only to the stores that have the Avalara AvaTax app installed. Specifies the Avalara tax code for the product variant.
	TaxCode graphql.String `json:"taxCode,omitempty"`

	// Whether the variant is taxable.
	Taxable graphql.Boolean `json:"taxable,omitempty"`

	// This argument is deprecated: Variant title is not a writable field; it is generated from the selected variant options.
	Title graphql.String `json:"title,omitempty"`

	// The weight of the variant.
	Weight graphql.Float `json:"weight,omitempty"`

	// The unit of weight that's used to measure the variant.
	WeightUnit WeightUnit `json:"weightUnit,omitempty"`
}

type ProductVariantInventoryPolicy

type ProductVariantInventoryPolicy string

ProductVariantInventoryPolicy String enum: CONTINUE, DENY

type ProductVariantPricePair

type ProductVariantPricePair struct {
	CompareAtPrice Money `json:"compareAtPrice,omitempty"`
	Price          Money `json:"price,omitempty"`
}

type ProductVariantUpdate

type ProductVariantUpdate struct {
	ProductVariantInput ProductVariantInput
}

type SEOInput

type SEOInput struct {
	Description graphql.String `json:"description,omitempty"`
	Title       graphql.String `json:"title,omitempty"`
}

type SelectedOption

type SelectedOption struct {
	Name  graphql.String `json:"name,omitempty"`
	Value graphql.String `json:"value,omitempty"`
}

type ShippingLine added in v2.0.4

type ShippingLine struct {
	Title            graphql.String `json:"title,omitempty"`
	OriginalPriceSet MoneyBag       `json:"originalPriceSet,omitempty"`
}

type TaxLine

type TaxLine struct {
	PriceSet       MoneyBag       `json:"priceSet,omitempty"`
	Rate           graphql.Float  `json:"rate,omitempty"`
	RatePercentage graphql.Float  `json:"ratePercentage,omitempty"`
	Title          graphql.String `json:"title,omitempty"`
}

type URL added in v2.0.4

type URL string

URL An RFC 3986 and RFC 3987 compliant URI string.

Example value: "https://johns-apparel.myshopify.com".

type UserErrors

type UserErrors struct {
	Field   []graphql.String
	Message graphql.String
}

type VariantService

type VariantService interface {
	Update(variant *ProductVariantUpdate) error
}

type VariantServiceOp

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

func (*VariantServiceOp) Update

func (s *VariantServiceOp) Update(variant *ProductVariantUpdate) error

type WeightUnit

type WeightUnit string

WeightUnit String enum: GRAMS, KILOGRAMS, OUNCES, POUNDS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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