goshopee

package module
v0.0.0-...-3e280c0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 16 Imported by: 0

README

go-shopee

shopee open api with golang

https://open.shopee.com/documents?module=63&type=2&id=51

How to use

Initialize Client And request order list

  app := goshopee.App{
		PartnerID:  xxxxxxxx,
		PartnerKey: yyyyyyyyyy,
		APIURL:     https://api.shopee.com,
	}

	client := goshopee.NewClient(app)

  // fetch order list
  client.Order.ListWithPagination(sid, 0, 100, nil)

Documentation

Overview

Package goshopee provides methods for making requests to Shopee's Open API.

Index

Constants

View Source
const (
	LevelError = iota + 1
	LevelWarn
	LevelInfo
	LevelDebug
)
View Source
const (
	UserAgent = "goshopee/1.0.0"
)

Variables

This section is empty.

Functions

func CheckResponseError

func CheckResponseError(r *http.Response) error

func MakeAuthToken

func MakeAuthToken(url, requestBody, pKey string) string

func ToMapData

func ToMapData(in interface{}) (map[string]interface{}, error)

func VerifyPushMsg

func VerifyPushMsg(url, requestBody, pKey, authorization string) (result bool)

Types

type AddVariationsReponse

type AddVariationsReponse struct {
	ItemID       uint64      `json:"item_id"`
	ModifiedTime uint32      `json:"modified_time"`
	Variations   []Variation `json:"variations"`
	RequestID    string      `json:"request_id"`
}

type AddVariationsRequest

type AddVariationsRequest struct {
	ItemID     uint64      `json:"item_id"`
	Variations []Variation `json:"variations"`
	ShopID     uint64      `json:"shop_id"`
}

type Address

type Address struct {
}

type App

type App struct {
	PartnerID   int    // `env:"SHOPEE_PARTNER_ID"`
	PartnerKey  string // `env:"SHOPEE_PARTNER_KEY"`
	AuthURL     string // `env:"SHOPEE_AUTH_URL"`
	RedirectURL string // `env:"SHOPEE_REDIRECT_URL"`
	APIURL      string // `env:"SHOPEE_API_URL"`
	Client      *Client
}

App represents basic app settings such as Api key, secret, scope, and redirect url. See oauth.go for OAuth related helper functions.

type Attribute

type Attribute struct {
	ID    uint64 `json:"attributes_id"`
	Value string `json:"value"`
}

type AttributeAdded

type AttributeAdded struct {
	ID          uint64 `json:"attribute_id"`
	Name        string `json:"attribute_name"`
	IsMandatory bool   `json:"is_mandatory"`
	Type        string `json:"attribute_type"`
	Value       string `json:"attribute_value"`
}

type Branch

type Branch struct {
}

type Client

type Client struct {
	Client *http.Client

	RateLimits RateLimitInfo

	// Services used for communicating with the API
	Shop          ShopService
	Item          ItemService
	Variation     VariationService
	ItemCategory  ItemCategoryService
	ItemAttribute ItemAttributeService
	Order         OrderService
	Logistic      LogisticService
	Discount      DiscountService
	// contains filtered or unexported fields
}

Client manages communication with the Shopify API.

func NewClient

func NewClient(app App, opts ...Option) *Client

NewClient returns a new Shopify API client with an already authenticated shopname and token. The shopName parameter is the shop's myshopify domain, e.g. "theshop.myshopify.com", or simply "theshop" a.NewClient(shopName, token, opts) is equivalent to NewClient(a, shopName, token, opts)

func (*Client) AuthURL

func (c *Client) AuthURL() string

func (*Client) CreateAndDo

func (c *Client) CreateAndDo(method, relPath string, data, options, resource interface{}) error

CreateAndDo performs a web request to Shopify with the given method (GET, POST, PUT, DELETE) and relative path (e.g. "/admin/orders.json"). The data, options and resource arguments are optional and only relevant in certain situations. If the data argument is non-nil, it will be used as the body of the request for POST and PUT requests. The options argument is used for specifying request options such as search parameters like created_at_min Any data returned from Shopify will be marshalled into resource argument.

func (*Client) Delete

func (c *Client) Delete(path string) error

Delete performs a DELETE request for the given path

func (*Client) Get

func (c *Client) Get(path string, resource, options interface{}) error

Get performs a GET request for the given path and saves the result in the given resource.

func (*Client) NewRequest

func (c *Client) NewRequest(method, relPath 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.

func (*Client) Post

func (c *Client) Post(path string, data, resource interface{}) error

Post performs a POST request for the given path and saves the result in the given resource.

func (*Client) Put

func (c *Client) Put(path string, data, resource interface{}) error

Put performs a PUT request for the given path and saves the result in the given resource.

func (*Client) Token

func (c *Client) Token() string

type DaysToShipLimits

type DaysToShipLimits struct {
	Min int `json:"min_limit"`
	Max int `json:"max_limit"`
}

type DeleteVariationRequest

type DeleteVariationRequest struct {
	ItemID      uint64 `json:"item_id"`
	VariationID uint64 `json:"variation_id"`
	ShopID      uint64 `json:"shopid"`
}

type DeleteVariationResponse

type DeleteVariationResponse struct {
	ItemID       uint64 `json:"item_id"`
	VariationID  uint64 `json:"variation_id"`
	ModifiedTime uint32 `json:"modified_time"`
	RequestID    string `json:"request_id"`
}

type Discount

type Discount struct {
	ID        uint64 `json:"discount_id"`
	Name      string `json:"discount_name"`
	StartTime int64  `json:"start_time"`
	EndTime   int64  `json:"end_time"`
	Status    string `json:"status"`
}

type DiscountActionResponse

type DiscountActionResponse struct {
	DiscountID  uint64 `json:"discount_id"`
	RequestID   string `json:"request_id"`
	ItemID      uint64 `json:"item_id"`
	VariationID uint64 `json:"variation_id"`
	ModifyTime  int64  `json:"modify_time"`
}

type DiscountItem

type DiscountItem struct {
	ID                     uint64              `json:"item_id"`
	Name                   string              `json:"item_name"`
	PurchaseLimit          uint32              `json:"purchase_limit"`
	OriginalPrice          float64             `json:"item_original_price"`
	PromotionPrice         float64             `json:"item_promotion_price"`
	Stock                  uint32              `json:"stock"`
	InflatedOriginalPrice  float64             `json:"item_inflated_original_price"`
	InflatedPromotionPrice float64             `json:"item_inflated_promotion_price"`
	Variations             []DiscountVariation `json:"variations"`
}

type DiscountResponse

type DiscountResponse struct {
	DiscountID uint64                  `json:"discount_id"`
	Count      uint32                  `json:"count"`
	Warning    string                  `json:"warning"`
	RequestID  string                  `json:"request_id"`
	Errors     []DiscountResponseError `json:"errors"`
}

type DiscountResponseError

type DiscountResponseError struct {
	ItemID      uint64 `json:"item_id"`
	VariationID uint64 `json:"variation_id"`
	ErrorMsg    string `json:"error_msg"`
}

type DiscountService

type DiscountService interface {
	AddDiscount(uint64, map[string]interface{}) (*DiscountResponse, error)
	DeleteDiscount(uint64, uint64) (*DiscountActionResponse, error)
	AddDiscountItem(uint64, uint64, map[string]interface{}) (*DiscountResponse, error)
	DeleteDiscountItem(uint64, uint64, uint64, uint64) (*DiscountActionResponse, error)
	UpdateDiscount(uint64, uint64, map[string]interface{}) (*DiscountActionResponse, error)
	UpdateDiscountItems(uint64, uint64, map[string]interface{}) (*DiscountResponse, error)
}

DiscountService: https://open.shopee.com/documents?module=1&type=1&id=361&version=1

type DiscountServiceOp

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

DiscountServiceOp handles communication with the product related methods of the Shopee API.

func (*DiscountServiceOp) AddDiscount

func (s *DiscountServiceOp) AddDiscount(sid uint64, req map[string]interface{}) (*DiscountResponse, error)

func (*DiscountServiceOp) AddDiscountItem

func (s *DiscountServiceOp) AddDiscountItem(sid, discountID uint64, req map[string]interface{}) (*DiscountResponse, error)

func (*DiscountServiceOp) DeleteDiscount

func (s *DiscountServiceOp) DeleteDiscount(sid, discountID uint64) (*DiscountActionResponse, error)

func (*DiscountServiceOp) DeleteDiscountItem

func (s *DiscountServiceOp) DeleteDiscountItem(sid, discountID, itemID, variationID uint64) (*DiscountActionResponse, error)

func (*DiscountServiceOp) UpdateDiscount

func (s *DiscountServiceOp) UpdateDiscount(sid, discountID uint64, req map[string]interface{}) (*DiscountActionResponse, error)

func (*DiscountServiceOp) UpdateDiscountItems

func (s *DiscountServiceOp) UpdateDiscountItems(sid, discountID uint64, req map[string]interface{}) (*DiscountResponse, error)

type DiscountVariation

type DiscountVariation struct {
	ID                     uint64  `json:"variation_id"`
	Name                   string  `json:"variation_name"`
	OriginalPrice          float64 `json:"variation_original_price"`
	PromotionPrice         float64 `json:"variation_promotion_price"`
	Stock                  uint32  `json:"variation_stock"`
	InflatedOriginalPrice  float64 `json:"variation_inflated_original_price"`
	InflatedPromotionPrice float64 `json:"variation_inflated_promotion_price"`
}

type Error

type Error struct {
	RequestID string `json:"request_id"`
	Error     string `json:"error"`
	Message   string `json:"msg"`
}

Error {"msg": "package_width should bigger than 1", "request_id": "2894fe4fc158a114ea4bfbbd391820c4", "error": "error_param"}

type GetLogisticInfoResponse

type GetLogisticInfoResponse struct {
	Pickup     GetLogisticInfoResponsePickup  `json:"pickup"`
	Dropoff    GetLogisticInfoResponseDropoff `json:"dropoff"`
	InfoNeeded map[string][]string            `json:"info_needed"`
	RequestID  string                         `json:"request_id"`
}

type GetLogisticInfoResponseDropoff

type GetLogisticInfoResponseDropoff struct {
	BranchList []Branch `json:"branch_list"`
}

type GetLogisticInfoResponsePickup

type GetLogisticInfoResponsePickup struct {
	AddressList []Address `json:"address_list"`
}

type Image

type Image struct {
	URL string `json:"url"`
}

type Item

type Item struct {
	ItemBase

	Images []string `json:"images"`
}

type ItemAttribute

type ItemAttribute struct {
	ID        uint64               `json:"attribute_id"`
	Name      string               `json:"attribute_name"`
	Mandatory bool                 `json:"is_mandatory"`
	Type      string               `json:"attribute_type"`
	InputType string               `json:"input_type"`
	Options   []string             `json:"options"`
	Values    []ItemAttributeValue `json:"values"`
}

type ItemAttributeService

type ItemAttributeService interface {
	List(cid uint64, options map[string]interface{}) ([]ItemAttribute, error)
}

type ItemAttributeServiceOp

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

ItemAttributeServiceOp handles communication with the product related methods of the Shopee API.

func (*ItemAttributeServiceOp) List

func (s *ItemAttributeServiceOp) List(cid uint64, options map[string]interface{}) ([]ItemAttribute, error)

List xxx

type ItemAttributeValue

type ItemAttributeValue struct {
	OriginalValue  string `json:"original_value"`
	TranslateValue string `json:"translate_value"`
}

type ItemAttributesResponse

type ItemAttributesResponse struct {
	Attributes []ItemAttribute `json:"attributes"`
	RequestID  string          `json:"request_id"`
}

type ItemBase

type ItemBase struct {
	ItemID                uint64      `json:"item_id"`
	ShopID                uint64      `json:"shopid"`
	ItemSKU               string      `json:"item_sku"`
	Status                string      `json:"status"`
	Name                  string      `json:"name"`
	Description           string      `json:"description"`
	Currency              string      `json:"currency"`
	HasVariation          bool        `json:"has_variation"`
	Price                 float64     `json:"price"`
	Stock                 uint32      `json:"stock"`
	CreateTime            uint32      `json:"create_time"`
	UpdateTime            uint32      `json:"update_time"`
	Weight                float64     `json:"weight"`
	CategoryID            uint64      `json:"category_id"`
	OriginalPrice         float64     `json:"original_price"`
	Variations            []Variation `json:"variations,omitempty"`
	Attributes            []Attribute `json:"attributes"`
	Logistics             []Logistic  `json:"logistics"`
	Wholesales            []Wholesale `json:"wholesales,omitempty"`
	RatingStar            float64     `json:"rating_star"`
	CMTCount              uint32      `json:"cmt_count"`
	Sales                 uint32      `json:"sales"`
	Views                 uint32      `json:"views"`
	Likes                 uint32      `json:"likes"`
	PackageLength         float64     `json:"package_length"`
	PackageWidth          float64     `json:"package_width"`
	PackageHeight         float64     `json:"package_height"`
	DaysToShip            uint32      `json:"days_to_ship"`
	SizeChart             string      `json:"size_chart"`
	Condition             string      `json:"condition"`
	DiscountID            uint64      `json:"discount_id"`
	Is2tierItem           bool        `json:"is_2tier_item"`
	Tenures               []uint32    `json:"tenures"`
	ReservedStock         uint32      `json:"reserved_stock"`
	IsPreOrder            bool        `json:"is_pre_order"`
	InflatedPrice         float64     `json:"inflated_price"`
	InflatedOriginalPrice float64     `json:"inflated_original_price"`
	SipItemPrice          float64     `json:"sip_item_price"`
	PriceSource           string      `json:"price_source"`
}

Item from https://open.shopee.com/documents?module=2&type=1&id=374

type ItemCategoriesResponse

type ItemCategoriesResponse struct {
	Categories []ItemCategory `json:"categories"`
	RequestID  string         `json:"request_id"`
}

type ItemCategory

type ItemCategory struct {
	ID               uint64            `json:"category_id"`
	ParentID         uint64            `json:"parent_id"`
	Name             string            `json:"category_name"`
	HasChildren      bool              `json:"has_children"`
	DaysToShipLimits *DaysToShipLimits `json:"days_to_ship_limits"`
}

type ItemCategoryService

type ItemCategoryService interface {
	List(sid uint64, options map[string]interface{}) ([]ItemCategory, error)
}

type ItemCategoryServiceOp

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

ItemCategoryServiceOp handles communication with the product related methods of the Shopee API.

func (*ItemCategoryServiceOp) List

func (s *ItemCategoryServiceOp) List(sid uint64, options map[string]interface{}) ([]ItemCategory, error)

List xxx

type ItemDeleteResponse

type ItemDeleteResponse struct {
	ItemID    uint64 `json:"item_id"`
	Msg       string `json:"msg"`
	RequestID string `json:"request_id"`
}

type ItemDetailResponse

type ItemDetailResponse struct {
	ItemID  uint64 `json:"item_id"`
	Item    *Item  `json:"item"`
	Warning string `json:"warning"`
}

type ItemOper

type ItemOper struct {
	ItemBase

	Images []Image `json:"images"`
}

ItemOper from https://open.shopee.com/documents?module=2&type=1&id=365

type ItemOperResponse

type ItemOperResponse struct {
	ItemID    uint64   `json:"item_id"`
	Item      *Item    `json:"item"`
	SizeChart string   `json:"size_chart,omitempty"`
	Warning   string   `json:"warning"`
	FailImage []string `json:"fail_image,omitempty"`
}

type ItemPriceOper

type ItemPriceOper struct {
	ID            uint64  `json:"item_id"`
	ModifiedTime  uint32  `json:"modified_time"`
	Price         float64 `json:"price"`
	InflatedPrice float64 `json:"inflated_price"`
}

type ItemPriceOperResponse

type ItemPriceOperResponse struct {
	Item      *ItemPriceOper `json:"item"`
	RequestID string         `json:"request_id"`
}

type ItemResponse

type ItemResponse struct {
	ItemID    uint64 `json:"item_id"`
	RequestID string `json:"request_id"`
}

type ItemService

type ItemService interface {
	List(interface{}) ([]Item, error)
	ListWithPagination(sid uint64, offset, limit uint32, options interface{}) ([]Item, *Pagination, error)
	Count(interface{}) (int, error)
	Get(uint64, uint64) (*Item, error)
	Create(newItem ItemOper) (*Item, error)
	Update(ItemBase) (*Item, error)
	UpdatePrice(sid, itemid uint64, price float64) (*ItemPriceOper, error)
	UpdateStock(sid, itemid uint64, stock uint32) (*ItemStockOper, error)
	Delete(sid, itemid uint64) error
	UnlistItem(sid, itemid uint64, unlist bool) ([]UnlistItemSuccess, []UnlistItemFailed, error)
	InitTierVariation(sid, itemid uint64, tierVariations []TierVariation, variations []TierVariationOperDef) ([]Variation, error)
	AddTierVariation(sid, itemid uint64, variations []TierVariationOperDef) ([]Variation, error)
	GetVariations(sid, itemid uint64) ([]TierVariation, []Variation, error)
	UpdateTierVariationList(sid, itemid uint64, tierVariations []TierVariation) error
	UpdateTierVariationIndex(sid, itemid uint64, variations []TierVariationIndexOperDef) error
}

type ItemServiceOp

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

ItemServiceOp handles communication with the product related methods of the Shopee API.

func (*ItemServiceOp) AddTierVariation

func (s *ItemServiceOp) AddTierVariation(sid, itemid uint64, variations []TierVariationOperDef) ([]Variation, error)

func (*ItemServiceOp) Count

func (s *ItemServiceOp) Count(interface{}) (int, error)

func (*ItemServiceOp) Create

func (s *ItemServiceOp) Create(newItem ItemOper) (*Item, error)

Create https://open.shopee.com/documents?module=2&type=1&id=365

func (*ItemServiceOp) Delete

func (s *ItemServiceOp) Delete(sid, itemid uint64) error

Delete https://open.shopee.com/documents?module=2&type=1&id=369

func (*ItemServiceOp) Get

func (s *ItemServiceOp) Get(sid, itemid uint64) (*Item, error)

func (*ItemServiceOp) GetVariations

func (s *ItemServiceOp) GetVariations(sid, itemid uint64) ([]TierVariation, []Variation, error)

func (*ItemServiceOp) InitTierVariation

func (s *ItemServiceOp) InitTierVariation(sid, itemid uint64, tierVariations []TierVariation, variations []TierVariationOperDef) ([]Variation, error)

func (*ItemServiceOp) List

func (s *ItemServiceOp) List(options interface{}) ([]Item, error)

func (*ItemServiceOp) ListWithPagination

func (s *ItemServiceOp) ListWithPagination(sid uint64, offset, limit uint32, options interface{}) ([]Item, *Pagination, error)

ListWithPagination https://open.shopee.com/documents?module=2&type=1&id=375

func (*ItemServiceOp) UnlistItem

func (s *ItemServiceOp) UnlistItem(sid, itemid uint64, unlist bool) ([]UnlistItemSuccess, []UnlistItemFailed, error)

UnlistItem https://open.shopee.com/documents?module=2&type=1&id=431

func (*ItemServiceOp) Update

func (s *ItemServiceOp) Update(updItem ItemBase) (*Item, error)

Update https://open.shopee.com/documents?module=2&type=1&id=376

func (*ItemServiceOp) UpdatePrice

func (s *ItemServiceOp) UpdatePrice(sid, itemid uint64, price float64) (*ItemPriceOper, error)

UpdatePrice https://open.shopee.com/documents?module=2&type=1&id=377

func (*ItemServiceOp) UpdateStock

func (s *ItemServiceOp) UpdateStock(sid, itemid uint64, stock uint32) (*ItemStockOper, error)

UpdateStock https://open.shopee.com/documents?module=2&type=1&id=378

func (*ItemServiceOp) UpdateTierVariationIndex

func (s *ItemServiceOp) UpdateTierVariationIndex(sid, itemid uint64, variations []TierVariationIndexOperDef) error

func (*ItemServiceOp) UpdateTierVariationList

func (s *ItemServiceOp) UpdateTierVariationList(sid, itemid uint64, tierVariations []TierVariation) error

type ItemStockOper

type ItemStockOper struct {
	ID           uint64 `json:"item_id"`
	ModifiedTime uint32 `json:"modified_time"`
	Stock        uint32 `json:"stock"`
}

type ItemStockOperResponse

type ItemStockOperResponse struct {
	Item      *ItemStockOper `json:"item"`
	RequestID string         `json:"request_id"`
}

type ItemsResponse

type ItemsResponse struct {
	Items     []Item `json:"items"`
	More      bool   `json:"more"`
	Total     uint32 `json:"total"`
	RequestID string `json:"request_id"`
}

ItemsResponse Represents the result from the GetItemsList endpoint https://open.shopee.com/documents?module=2&type=1&id=375

type LeveledLogger

type LeveledLogger struct {
	// Level is the minimum logging level that will be emitted by this logger.
	//
	// For example, a Level set to LevelWarn will emit warnings and errors, but
	// not informational or debug messages.
	//
	// Always set this with a constant like LevelWarn because the individual
	// values are not guaranteed to be stable.
	Level int
	// contains filtered or unexported fields
}

It prints warnings and errors to `os.Stderr` and other messages to `os.Stdout`.

func (*LeveledLogger) Debugf

func (l *LeveledLogger) Debugf(format string, v ...interface{})

Debugf logs a debug message using Printf conventions.

func (*LeveledLogger) Errorf

func (l *LeveledLogger) Errorf(format string, v ...interface{})

Errorf logs a warning message using Printf conventions.

func (*LeveledLogger) Infof

func (l *LeveledLogger) Infof(format string, v ...interface{})

Infof logs an informational message using Printf conventions.

func (*LeveledLogger) Warnf

func (l *LeveledLogger) Warnf(format string, v ...interface{})

Warnf logs a warning message using Printf conventions.

type LeveledLoggerInterface

type LeveledLoggerInterface interface {
	Debugf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
}

type ListReponse

type ListReponse struct {
	Logistics []Logistic `json:"logistics"`
	RequestID string     `json:"request_id"`
}

type Logistic

type Logistic struct {
	ID                   uint64  `json:"logistic_id"`
	Name                 string  `json:"logistic_name"`
	Enabled              bool    `json:"enabled"`
	ShippingFee          float64 `json:"shipping_fee"`
	SizeID               uint64  `json:"size_id"`
	IsFree               bool    `json:"is_free"`
	EstimatedShippingFee float64 `json:"estimated_shipping_fee"`
}

type LogisticInitResponse

type LogisticInitResponse struct {
	TrackingNumber string `json:"tracking_number"`
	RequestID      string `json:"request_id"`
}

type LogisticService

type LogisticService interface {
	Init(uint64, string, map[string]interface{}) (string, error)
	GetParameterForInit(sid uint64, ordersn string) (*map[string]interface{}, error)
	GetLogisticInfo(sid uint64, ordersn string) (*GetLogisticInfoResponse, error)
	List(uint64) ([]Logistic, error)
}

type LogisticServiceOp

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

LogisticServiceOp handles communication with the logistics related methods of the Shopee API.

func (*LogisticServiceOp) GetLogisticInfo

func (s *LogisticServiceOp) GetLogisticInfo(sid uint64, ordersn string) (*GetLogisticInfoResponse, error)

GetLogisticInfo https://open.shopee.com/documents?module=3&type=1&id=417

func (*LogisticServiceOp) GetParameterForInit

func (s *LogisticServiceOp) GetParameterForInit(sid uint64, ordersn string) (*map[string]interface{}, error)

GetParameterForInit https://open.shopee.com/documents?module=3&type=1&id=386

func (*LogisticServiceOp) Init

func (s *LogisticServiceOp) Init(sid uint64, ordersn string, params map[string]interface{}) (string, error)

Init https://open.shopee.com/documents?module=3&type=1&id=389

type Option

type Option func(c *Client)

Option is used to configure client with options

func WithLogger

func WithLogger(logger LeveledLoggerInterface) Option

func WithProxy

func WithProxy(proxyHost string) Option

func WithRetry

func WithRetry(retries int) Option

func WithVersion

func WithVersion(apiVersion string) Option

WithVersion optionally sets the api-version if the passed string is valid

type Order

type Order struct {
	OrderSN                      string            `json:"ordersn"`
	BuyerUsername                string            `json:"buyer_username"`
	RecipientAddress             *RecipientAddress `json:"recipient_address"`
	Status                       string            `json:"order_status"`
	Currency                     string            `json:"currency"`
	TrackingNo                   string            `json:"tracking_no"`
	EscrowAmount                 string            `json:"escrow_amount"`
	TotalAmount                  string            `json:"total_amount"`
	Country                      string            `json:"country"`
	ServiceCode                  string            `json:"service_code"`
	EstimatedShippingFee         string            `json:"estimated_shipping_fee"`
	PaymentMethod                string            `json:"payment_method"`
	ShippingCarrier              string            `json:"shipping_carrier"`
	COD                          bool              `json:"cod"`                  // This value indicates whether the order was a COD (cash on delivery) order.
	DaysToShip                   uint32            `json:"days_to_ship"`         // Shipping preparation time set by the seller when listing item on Shopee.
	ActualShippingCost           string            `json:"actual_shipping_cost"` // The actual shipping cost of the order if available from external logistics partners.
	GoodsToDeclare               bool              `json:"goods_to_declare"`
	MessageToSeller              string            `json:"message_to_seller"`
	Note                         string            `json:"note"`
	NoteUpdateTime               int64             `json:"note_update_time"`
	CreateTime                   int64             `json:"create_time"`
	UpdateTime                   int64             `json:"update_time"`
	Items                        []OrderItem       `json:"items"`
	PayTime                      *int64            `json:"pay_time"` // The time when the order status is updated from UNPAID to PAID. This value is NULL when order is not paid yet.
	DropShipper                  string            `json:"dropshipper"`
	CreditCardNumber             string            `json:"credit_card_number"`
	DropShipperPhone             string            `json:"dropshipper_phone"`
	ShipByDate                   int64             `json:"ship_by_date"`
	IsSplitUp                    bool              `json:"is_split_up"`
	BuyerCancelReason            interface{}       `json:"buyer_cancel_reason"` // Cancel order is number, eg. 0, other is string
	CancelBy                     string            `json:"cancel_by"`
	FmTN                         string            `json:"fm_tn"`         // The first-mile tracking number.
	CancelReason                 interface{}       `json:"cancel_reason"` // Cancel order is number, eg. 0, other is string
	EscrowTax                    string            `json:"escrow_tax"`
	IsActualShippingFeeConfirmed bool              `json:"is_actual_shipping_fee_confirmed"`
}

Order https://open.shopee.com/documents?module=4&type=1&id=397

type OrderCancelResponse

type OrderCancelResponse struct {
	ModifiedTime uint32 `json:"modified_time"`
	RequestID    string `json:"request_id"`
}

type OrderItem

type OrderItem struct {
	ItemID                   uint64  `json:"item_id"`
	ItemName                 string  `json:"item_name"`
	ItemSKU                  string  `json:"item_sku"`
	VariationID              uint64  `json:"variation_id"`
	VariationName            string  `json:"variation_name"`
	VariationSKU             string  `json:"variation_sku"`
	VariationQuantity        uint32  `json:"variation_quantity_purchased"`
	VariationDiscountedPrice string  `json:"variation_discounted_price"`
	VariationOriginalPrice   string  `json:"variation_original_price"`
	IsWholesale              bool    `json:"is_wholesale"`
	Weight                   float64 `json:"weight"`
	IsAddOnDeal              bool    `json:"is_add_on_deal"`
	IsMainItem               bool    `json:"is_main_item"`
	AddOnDealID              uint64  `json:"add_on_deal_id"`
	PromotionType            string  `json:"promotion_type"`
	PromotionID              uint32  `json:"promotion_id"`
}

type OrderService

type OrderService interface {
	List(uint64) ([]Order, error)
	ListWithPagination(sid uint64, offset, limit uint32, options map[string]interface{}) ([]Order, *Pagination, error)
	Count(interface{}) (int, error)
	Get(sid uint64, ordersn string) (*Order, error)
	GetMulti(sid uint64, orders []string) ([]Order, []string, error)
	Create(Order) (*Order, error)
	Update(Order) (*Order, error)
	Cancel(sid uint64, ordersn, reason string, options map[string]interface{}) error
	Delete(int64) error
}

type OrderServiceOp

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

OrderServiceOp handles communication with the product related methods of the Shopee API.

func (*OrderServiceOp) Cancel

func (s *OrderServiceOp) Cancel(sid uint64, ordersn, reason string, options map[string]interface{}) error

Cancel https://open.shopee.com/documents?module=4&type=1&id=395

func (*OrderServiceOp) Count

func (s *OrderServiceOp) Count(interface{}) (int, error)

func (*OrderServiceOp) Delete

func (s *OrderServiceOp) Delete(int64) error

func (*OrderServiceOp) Get

func (s *OrderServiceOp) Get(sid uint64, ordersn string) (*Order, error)

func (*OrderServiceOp) GetMulti

func (s *OrderServiceOp) GetMulti(sid uint64, orders []string) ([]Order, []string, error)

func (*OrderServiceOp) List

func (s *OrderServiceOp) List(sid uint64) ([]Order, error)

List xxx

func (*OrderServiceOp) ListWithPagination

func (s *OrderServiceOp) ListWithPagination(sid uint64, offset, limit uint32, options map[string]interface{}) ([]Order, *Pagination, error)

ListWithPagination https://open.shopee.com/documents?module=4&type=1&id=399

type OrdersDetailResponse

type OrdersDetailResponse struct {
	Orders    []Order  `json:"orders"`
	Errors    []string `json:"errors"`
	RequestID string   `json:"request_id"`
}

OrdersDetailResponse https://open.shopee.com/documents?module=4&type=1&id=397

type OrdersResponse

type OrdersResponse struct {
	Orders    []Order `json:"orders"`
	More      bool    `json:"more"`
	RequestID string  `json:"request_id"`
}

OrdersResponse Represents shopee.orders.GetOrdersList https://open.shopee.com/documents?module=4&type=1&id=399

type Pagination

type Pagination struct {
	Offset   uint32 `json:"offset"`
	PageSize uint32 `json:"page_size"`
	Total    uint32 `json:"total"`
	More     bool   `json:"more"`
}

Pagination of results

type RateLimitError

type RateLimitError struct {
	ResponseError
	RetryAfter int
}

An error specific to a rate-limiting response. Embeds the ResponseError to allow consumers to handle it the same was a normal ResponseError.

type RateLimitInfo

type RateLimitInfo struct {
	RequestCount      int
	BucketSize        int
	RetryAfterSeconds float64
}

type RecipientAddress

type RecipientAddress struct {
	Town        string `json:"town"`
	City        string `json:"city"`
	Name        string `json:"name"`
	District    string `json:"district"`
	Country     string `json:"country"`
	Zipcode     string `json:"zipcode"`
	FullAddress string `json:"full_address"`
	Phone       string `json:"phone"`
	State       string `json:"state"`
}

type ResponseDecodingError

type ResponseDecodingError struct {
	Body    []byte
	Message string
	Status  int
}

ResponseDecodingError occurs when the response body from Shopify could not be parsed.

func (ResponseDecodingError) Error

func (e ResponseDecodingError) Error() string

type ResponseError

type ResponseError struct {
	Status  int
	Message string
	Errors  []string
}

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

func (ResponseError) GetErrors

func (e ResponseError) GetErrors() []string

GetErrors returns response errors list

func (ResponseError) GetMessage

func (e ResponseError) GetMessage() string

GetMessage returns response error message

func (ResponseError) GetStatus

func (e ResponseError) GetStatus() int

GetStatus returns http response status

type SIPAffiliateShop

type SIPAffiliateShop struct {
	AffiliateShopID string `json:"a_shop_id"`
	Country         string `json:"country"`
}

type Shop

type Shop struct {
	ID                  uint64             `json:"shop_id"`
	Name                string             `json:"shop_name"`
	Country             string             `json:"country"`
	Description         string             `json:"shop_description"`
	Videos              []string           `json:"videos"`
	Images              []string           `json:"images"`
	DisableMakeOffer    uint32             `json:"disable_make_offer"`
	EnableDisplayUnitNo bool               `json:"enable_display_unitno"`
	ItemLimit           uint32             `json:"item_limit"`
	RequestID           string             `json:"request_id"`
	Status              string             `json:"status"`
	InstallmentStatus   uint32             `json:"installment_status"`
	SIPAffiliateShops   []SIPAffiliateShop `json:"sip_a_shops"`
	IsCB                bool               `json:"is_cb"`
	NonPreOrderDTS      int                `json:"non_pre_order_dts"`
	AuthTime            int64              `json:"auth_time"`
	ExpireTime          int64              `json:"expire_time"`
}

Shop https://open.shopee.com/documents?module=6&type=1&id=410

{
    "shop_id": 220006999,
    "shop_name": "roxieshopify.sg",
    "country": "SG",
    "shop_description": "",
    "videos": [],
    "images": [],
    "disable_make_offer": 0,
    "enable_display_unitno": false,
    "item_limit": 10000,
    "request_id": "541bb4a26f490b8244c9ea7b5a94cb5c",
    "status": "NORMAL",
    "installment_status": 0,
    "sip_a_shops": [],
    "is_cb": true,
    "non_pre_order_dts": 3,
    "auth_time": 1593507209,
    "expire_time": 1625043209
}

type ShopService

type ShopService interface {
	Get(sid uint64) (*Shop, error)
}

type ShopServiceOp

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

ShopServiceOp handles communication with the product related methods of the Shopee API.

func (*ShopServiceOp) Get

func (s *ShopServiceOp) Get(sid uint64) (*Shop, error)

type TierVariation

type TierVariation struct {
	Name    string   `json:"name"`
	Options []string `json:"options"`
}

TierVariation 2-tier variation https://open.shopee.com/documents?module=2&type=1&id=422

type TierVariationIndexOperDef

type TierVariationIndexOperDef struct {
	TierIndex []uint32 `json:"tier_index"`
	ID        uint64   `json:"variation_id"`
}

type TierVariationOperDef

type TierVariationOperDef struct {
	Stock     uint32   `json:"stock"`
	Price     float64  `json:"price"`
	TierIndex []uint32 `json:"tier_index"`
}

type TierVariationOperResponse

type TierVariationOperResponse struct {
	RequestID       string          `json:"request_id"`
	ItemID          uint64          `json:"item_id"` // help doc is uint32, in fact is uint64
	TierVariation   []TierVariation `json:"tier_variation,omitempty"`
	VariationIDList []Variation     `json:"variation_id_list"`
}

type UnlistItemFailed

type UnlistItemFailed struct {
	ItemID           uint64 `json:"item_id"`
	ErrorDescription string `json:"error_description"`
}

type UnlistItemSuccess

type UnlistItemSuccess struct {
	ItemID uint64 `json:"item_id"`
	Unlist bool   `json:"unlist"`
}

type UnlistResponse

type UnlistResponse struct {
	Failed    []UnlistItemFailed  `json:"failed"`
	Success   []UnlistItemSuccess `json:"success"`
	RequestID string              `json:"request_id"`
}

type UpdateVariationPriceRequest

type UpdateVariationPriceRequest struct {
	ItemID      uint64  `json:"item_id"`
	VariationID uint64  `json:"variation_id"`
	Price       float64 `json:"price"`
	ShopID      uint64  `json:"shopid"`
}

type UpdateVariationPriceResponse

type UpdateVariationPriceResponse struct {
	Variation Variation `json:"item"`
	RequestID string    `json:"request_id"`
}

type UpdateVariationStockRequest

type UpdateVariationStockRequest struct {
	ItemID      uint64 `json:"item_id"`
	VariationID uint64 `json:"variation_id"`
	Stock       uint32 `json:"stock"`
	ShopID      uint64 `json:"shopid"`
}

type UpdateVariationStockResponse

type UpdateVariationStockResponse struct {
	Variation Variation `json:"item"`
	RequestID string    `json:"request_id"`
}

type Variation

type Variation struct {
	ID                    uint64   `json:"variation_id"`
	Name                  string   `json:"name"`
	Stock                 uint32   `json:"stock"`
	ReservedStock         uint32   `json:"reserved_stock"`
	Price                 float64  `json:"price"`
	VariationSKU          string   `json:"variation_sku"`
	Status                string   `json:"status"`
	CreateTime            uint32   `json:"create_time"`
	UpdateTime            uint32   `json:"update_time"`
	OriginalPrice         float64  `json:"original_price"`
	InflatedOriginalPrice float64  `json:"inflated_original_price"`
	InflatedPrice         float64  `json:"inflated_price"`
	DiscountID            uint64   `json:"discount_id"`
	ModifiedTime          uint32   `json:"modified_time"`
	ItemID                uint64   `json:"item_id"`
	TierIndex             []uint32 `json:"tier_index,omitempty"`
}

type VariationPriceRequest

type VariationPriceRequest struct {
	ItemID      uint64  `json:"item_id"`
	VariationID uint64  `json:"variation_id"`
	Price       float64 `json:"price"`
	ItemPrice   float64 `json:"item_price"`
}

type VariationPriceResponse

type VariationPriceResponse struct {
	RequestID string                            `json:"request_id"`
	Result    VariationPriceResponseBatchResult `json:"batch_result"`
}

{"batch_result": {"failures": [{"item_id": 100926704, "error_description": "mst shop not found", "variation_id": 5249278}, {"item_id": 100926704, "error_description": "mst shop not found", "variation_id": 5249278}, {"item_id": 100926704, "error_description": "mst shop not found", "variation_id": 5249278}, {"item_id": 100926704, "error_description": "mst shop not found", "variation_id": 5249278}], "modifications": []}, "request_id": "6e0276c51cf3944d0ce518643c9ba149"}

type VariationPriceResponseBatchResult

type VariationPriceResponseBatchResult struct {
	Modifications []VariationPriceResponseBatchResultModification `json:"modifications"`
	Failures      []VariationPriceResponseBatchResultFailure      `json:"failures"`
}

type VariationPriceResponseBatchResultFailure

type VariationPriceResponseBatchResultFailure struct {
	ItemID           uint64 `json:"item_id"`
	VariationID      uint64 `json:"variation_id"`
	ErrorDiscription string `json:"error_description"`
}

type VariationPriceResponseBatchResultModification

type VariationPriceResponseBatchResultModification struct {
	ItemID      uint64  `json:"item_id"`
	VariationID uint64  `json:"variation_id"`
	ItemPrice   float64 `json:"item_price"`
}

type VariationService

type VariationService interface {
	Create(uint64, uint64, Variation) (*Variation, error)
	Delete(uint64, uint64, uint64) error
	UpdateVariationPrice(uint64, uint64, Variation) (*Variation, error)
	UpdateVariationStock(uint64, uint64, Variation) (*Variation, error)
	UpdateVariationPriceBatch(uint64, []VariationPriceRequest) (*VariationPriceResponse, error)
}

type VariationServiceOp

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

VariationServiceOp handles communication with the product related methods of the Shopee API.

func (*VariationServiceOp) Create

func (s *VariationServiceOp) Create(sid, itemID uint64, newItem Variation) (*Variation, error)

Create https://open.shopee.com/documents?module=2&type=1&id=368

func (*VariationServiceOp) Delete

func (s *VariationServiceOp) Delete(sid, itemID, variationID uint64) error

Delete https://open.shopee.com/documents?module=2&type=1&id=371

func (*VariationServiceOp) UpdateVariationPrice

func (s *VariationServiceOp) UpdateVariationPrice(sid, itemID uint64, updItem Variation) (*Variation, error)

UpdateVariationPrice https://open.shopee.com/documents?module=2&type=1&id=379

func (*VariationServiceOp) UpdateVariationPriceBatch

func (s *VariationServiceOp) UpdateVariationPriceBatch(sid uint64, params []VariationPriceRequest) (*VariationPriceResponse, error)

func (*VariationServiceOp) UpdateVariationStock

func (s *VariationServiceOp) UpdateVariationStock(sid, itemID uint64, updItem Variation) (*Variation, error)

UpdateVariationStock https://open.shopee.com/documents?module=2&type=1&id=380

type Wholesale

type Wholesale struct {
	Min       uint32  `json:"min"`
	Max       uint32  `json:"max"`
	UnitPrice float64 `json:"unit_price"`
}

Jump to

Keyboard shortcuts

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