shopify

package module
v8.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 20 Imported by: 0

README

go-shopify-graphql

A simple client using the Shopify GraphQL Admin API.

Getting started

Hello World example

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

import (
	"context"
	"fmt"

	shopify "github.com/bluettipower/go-shopify-graphql/v8"
)

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

	// Get all collections
	collections, err := client.Collection.ListAll(context.Background())
	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(ctx context.Context, query string, v interface{}) error

	PostBulkQuery(ctx context.Context, query string) (*string, error)
	GetCurrentBulkQuery(ctx context.Context) (*model.BulkOperation, error)
	GetCurrentBulkQueryResultURL(ctx context.Context) (*string, error)
	WaitForCurrentBulkQuery(ctx context.Context, interval time.Duration) (*model.BulkOperation, error)
	ShouldGetBulkQueryResultURL(ctx context.Context, id *string) (*string, error)
	CancelRunningBulkQuery(ctx context.Context) error
}

type BulkOperationServiceOp

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

func (*BulkOperationServiceOp) BulkQuery

func (s *BulkOperationServiceOp) BulkQuery(ctx context.Context, query string, out interface{}) error

func (*BulkOperationServiceOp) CancelRunningBulkQuery

func (s *BulkOperationServiceOp) CancelRunningBulkQuery(ctx context.Context) error

func (*BulkOperationServiceOp) GetCurrentBulkQuery

func (s *BulkOperationServiceOp) GetCurrentBulkQuery(ctx context.Context) (*model.BulkOperation, error)

func (*BulkOperationServiceOp) GetCurrentBulkQueryResultURL

func (s *BulkOperationServiceOp) GetCurrentBulkQueryResultURL(ctx context.Context) (*string, error)

func (*BulkOperationServiceOp) PostBulkQuery

func (s *BulkOperationServiceOp) PostBulkQuery(ctx context.Context, query string) (*string, error)

func (*BulkOperationServiceOp) ShouldGetBulkQueryResultURL

func (s *BulkOperationServiceOp) ShouldGetBulkQueryResultURL(ctx context.Context, id *string) (*string, error)

func (*BulkOperationServiceOp) WaitForCurrentBulkQuery

func (s *BulkOperationServiceOp) WaitForCurrentBulkQuery(ctx context.Context, interval time.Duration) (*model.BulkOperation, 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(opts ...Option) *Client

func NewClientWithToken

func NewClientWithToken(accessToken string, storeName string, opts ...Option) *Client

func NewDefaultClient

func NewDefaultClient() *Client

func (*Client) GraphQLClient

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

type CollectionService

type CollectionService interface {
	ListAll(ctx context.Context) ([]model.Collection, error)

	Get(ctx context.Context, id string) (*model.Collection, error)

	Create(ctx context.Context, collection model.CollectionInput) (*string, error)
	CreateBulk(ctx context.Context, collections []model.CollectionInput) error

	Update(ctx context.Context, collection model.CollectionInput) error
}

type CollectionServiceOp

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

func (*CollectionServiceOp) Create

func (s *CollectionServiceOp) Create(ctx context.Context, collection model.CollectionInput) (*string, error)

func (*CollectionServiceOp) CreateBulk

func (s *CollectionServiceOp) CreateBulk(ctx context.Context, collections []model.CollectionInput) error

func (*CollectionServiceOp) Get

func (*CollectionServiceOp) ListAll

func (*CollectionServiceOp) Update

func (s *CollectionServiceOp) Update(ctx context.Context, collection model.CollectionInput) error

type FulfillmentService

type FulfillmentService interface {
	// Create(ctx context.Context, input model.FulfillmentV2Input) (*model.Fulfillment, error)
	Create(ctx context.Context, query string, input model.FulfillmentV2Input) (*model.Fulfillment, error)
	Update(ctx context.Context, query string, input FulfillmentTrackingInfoUpdateV2Input) error
}

type FulfillmentServiceOp

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

func (*FulfillmentServiceOp) Create

func (s *FulfillmentServiceOp) Create(ctx context.Context, query string, fulfillment model.FulfillmentV2Input) (*model.Fulfillment, error)

func (*FulfillmentServiceOp) Update

type FulfillmentTrackingInfoUpdateV2Input

type FulfillmentTrackingInfoUpdateV2Input struct {
	FulfillmentID     string             `json:"fulfillmentId,omitempty"`
	NotifyCustomer    *bool              `json:"notifyCustomer,omitempty,omitempty"`
	TrackingInfoInput *TrackingInfoInput `json:"trackingInfoInput,omitempty"`
}

type InventoryService

type InventoryService interface {
	Update(ctx context.Context, id string, input model.InventoryItemUpdateInput) error
	Adjust(ctx context.Context, locationID string, input []model.InventoryAdjustItemInput) error
	ActivateInventory(ctx context.Context, locationID string, id string) error
}

type InventoryServiceOp

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

func (*InventoryServiceOp) ActivateInventory

func (s *InventoryServiceOp) ActivateInventory(ctx context.Context, locationID string, id string) error

func (*InventoryServiceOp) Adjust

func (s *InventoryServiceOp) Adjust(ctx context.Context, locationID string, input []model.InventoryAdjustItemInput) error

func (*InventoryServiceOp) Update

type ListOptions

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

type LocationService

type LocationService interface {
	Get(ctx context.Context, id string) (*model.Location, error)
}

type LocationServiceOp

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

func (*LocationServiceOp) Get

type MetafieldService

type MetafieldService interface {
	ListAllShopMetafields(ctx context.Context) ([]model.Metafield, error)
	ListShopMetafieldsByNamespace(ctx context.Context, namespace string) ([]model.Metafield, error)

	GetShopMetafieldByKey(ctx context.Context, namespace, key string) (*model.Metafield, error)

	Delete(ctx context.Context, metafield model.MetafieldDeleteInput) error
	DeleteBulk(ctx context.Context, metafield []model.MetafieldDeleteInput) error
}

type MetafieldServiceOp

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

func (*MetafieldServiceOp) Delete

func (*MetafieldServiceOp) DeleteBulk

func (s *MetafieldServiceOp) DeleteBulk(ctx context.Context, metafields []model.MetafieldDeleteInput) error

func (*MetafieldServiceOp) GetShopMetafieldByKey

func (s *MetafieldServiceOp) GetShopMetafieldByKey(ctx context.Context, namespace, key string) (*model.Metafield, error)

func (*MetafieldServiceOp) ListAllShopMetafields

func (s *MetafieldServiceOp) ListAllShopMetafields(ctx context.Context) ([]model.Metafield, error)

func (*MetafieldServiceOp) ListShopMetafieldsByNamespace

func (s *MetafieldServiceOp) ListShopMetafieldsByNamespace(ctx context.Context, namespace string) ([]model.Metafield, error)

type Option

type Option func(shopClient *Client)

func WithGraphQLClient

func WithGraphQLClient(gql graphql.GraphQL) Option

type OrderService

type OrderService interface {
	Get(ctx context.Context, id graphql.ID) (*model.Order, error)

	List(ctx context.Context, opts ListOptions) ([]model.Order, error)
	ListAll(ctx context.Context) ([]model.Order, error)

	ListAfterCursor(ctx context.Context, opts ListOptions) ([]model.Order, *string, *string, error)

	Update(ctx context.Context, input model.OrderInput) error
}

type OrderServiceOp

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

func (*OrderServiceOp) Get

func (s *OrderServiceOp) Get(ctx context.Context, id graphql.ID) (*model.Order, error)

func (*OrderServiceOp) List

func (s *OrderServiceOp) List(ctx context.Context, opts ListOptions) ([]model.Order, error)

func (*OrderServiceOp) ListAfterCursor

func (s *OrderServiceOp) ListAfterCursor(ctx context.Context, opts ListOptions) ([]model.Order, *string, *string, error)

func (*OrderServiceOp) ListAll

func (s *OrderServiceOp) ListAll(ctx context.Context) ([]model.Order, error)

func (*OrderServiceOp) Update

func (s *OrderServiceOp) Update(ctx context.Context, input model.OrderInput) error

type ProductService

type ProductService interface {
	List(ctx context.Context, query string) ([]model.Product, error)
	ListAll(ctx context.Context) ([]model.Product, error)

	Get(ctx context.Context, id string) (*model.Product, error)

	Create(ctx context.Context, product model.ProductInput) (*string, error)

	Update(ctx context.Context, product model.ProductInput) error

	Delete(ctx context.Context, product model.ProductDeleteInput) error

	VariantsBulkCreate(ctx context.Context, id string, input []model.ProductVariantsBulkInput) error
	VariantsBulkUpdate(ctx context.Context, id string, input []model.ProductVariantsBulkInput) error
	VariantsBulkReorder(ctx context.Context, id string, input []model.ProductVariantPositionInput) error
}

type ProductServiceOp

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

func (*ProductServiceOp) Create

func (s *ProductServiceOp) Create(ctx context.Context, product model.ProductInput) (*string, error)

func (*ProductServiceOp) Delete

func (*ProductServiceOp) Get

func (*ProductServiceOp) List

func (s *ProductServiceOp) List(ctx context.Context, query string) ([]model.Product, error)

func (*ProductServiceOp) ListAll

func (s *ProductServiceOp) ListAll(ctx context.Context) ([]model.Product, error)

func (*ProductServiceOp) Update

func (s *ProductServiceOp) Update(ctx context.Context, product model.ProductInput) error

func (*ProductServiceOp) VariantsBulkCreate

func (s *ProductServiceOp) VariantsBulkCreate(ctx context.Context, id string, input []model.ProductVariantsBulkInput) error

func (*ProductServiceOp) VariantsBulkReorder

func (s *ProductServiceOp) VariantsBulkReorder(ctx context.Context, id string, input []model.ProductVariantPositionInput) error

func (*ProductServiceOp) VariantsBulkUpdate

func (s *ProductServiceOp) VariantsBulkUpdate(ctx context.Context, id string, input []model.ProductVariantsBulkInput) error

type TrackingInfoInput

type TrackingInfoInput struct {
	Company *string  `json:"company,omitempty"`
	Number  *string  `json:"number,omitempty"`
	Numbers []string `json:"numbers,omitempty"`
	Url     *string  `json:"url,omitempty"`
	Urls    []string `json:"urls,omitempty"`
}

type VariantService

type VariantService interface {
	Update(ctx context.Context, variant model.ProductVariantInput) error
}

type VariantServiceOp

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

func (*VariantServiceOp) Update

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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