Documentation
¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Body
- type CDATA
- type CatalogInventoryStockItemUpdateEntity
- type CatalogProductAdditionalAttributesEntity
- type CatalogProductCreateEntity
- type CatalogProductCreateRequest
- type CatalogProductCreateResponse
- type CatalogProductEntity
- type CatalogProductEntityArray
- type CatalogProductInfoRequest
- type CatalogProductInfoResponse
- type CatalogProductListRequest
- type CatalogProductListResponse
- type CatalogProductRequestAttributes
- type CatalogProductReturnEntity
- type CatalogProductService
- func (s *CatalogProductService) Create(requestBody *CatalogProductCreateRequest, ctx context.Context) (*CatalogProductCreateResponse, error)
- func (s *CatalogProductService) Info(requestBody *CatalogProductInfoRequest, ctx context.Context) (*CatalogProductInfoResponse, error)
- func (s *CatalogProductService) List(requestBody *CatalogProductListRequest, ctx context.Context) (*CatalogProductListResponse, error)
- func (s *CatalogProductService) Update(requestBody *CatalogProductUpdateRequest, ctx context.Context) (*CatalogProductUpdateResponse, error)
- type CatalogProductTierPriceEntity
- type CatalogProductUpdateRequest
- type CatalogProductUpdateResponse
- type Client
- func (c *Client) ApiKey() string
- func (c *Client) ApiUser() string
- func (c *Client) Do(req *http.Request, responseBody *Response) (*http.Response, error)
- func (c *Client) GetEndpoint() *url.URL
- func (c *Client) GetSession() *Session
- func (c *Client) Login() *Session
- func (c *Client) NewRequest(ctx context.Context, body *Request) (*http.Request, error)
- func (c *Client) SetApiKey(apiKey string)
- func (c *Client) SetApiUser(apiUser string)
- func (c *Client) SetDebug(debug bool)
- func (c *Client) SetEndpoint(baseURL *url.URL)
- func (c *Client) SetSandbox(sandbox bool)
- type Envelope
- type ErrorResponse
- type Filters
- type Header
- type IdentifierType
- type LoginRequest
- type LoginResponse
- type Request
- type RequestCompletionCallback
- type Response
- type Session
- type SessionService
- type TimeWithoutTimeZone
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a XML response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type Body ¶
type Body struct {
// If the XML element contains a sub-element that hasn't matched any
// of the above rules and the struct has a field with tag ",any",
// unmarshal maps the sub-element to that struct field.
Data interface{} `xml:",any"`
}
type CatalogInventoryStockItemUpdateEntity ¶
type CatalogInventoryStockItemUpdateEntity struct {
Qty int `xml:"qty"`
IsInstock bool `xml:"is_in_stock"`
ManageStock bool `xml:"manage_stock"`
UseConfigManageStock bool `xml:"use_config_manage_stock"`
MinQty int `xml:"min_qty"`
UseConfigMinQty bool `xml:"use_config_min_qty"`
MinSaleQty int `xml:"min_sale_qty"`
UseConfigMinSaleQty bool `xml:"use_config_min_sale_qty"`
MaxSaleQty int `xml:"max_sale_qty"`
UseConfigMaxSaleQty int `xml:"use_config_max_sale_qty"`
IsQtyDecimal bool `xml:"is_qty_decimal"`
Backorders bool `xml:"backorders"`
UseConfigBackorders bool `xml:"use_config_backorders"`
NotifyStockQty bool `xml:"notify_stock_qty"`
UseConfigNotifyStockQty bool `xml:"use_config_notify_stock_qty"`
}
type CatalogProductAdditionalAttributesEntity ¶
type CatalogProductAdditionalAttributesEntity struct {
MultiData []associativeMultiEntity `xml:"multi_data"`
SingleData []associativeEntity `xml:"single_date"`
}
type CatalogProductCreateEntity ¶
type CatalogProductCreateEntity struct {
Categories []string `xml:"categories"`
Websites []string `xml:"websites"`
Name string `xml:"name"`
Description string `xml:"description"`
ShortDescription string `xml:"short_description"`
Weight float64 `xml:"weight"`
URLKey string `xml:"url_key"`
URLPath string `xml:"url_path"`
Visibility string `xml:"visibility"`
CategoryIDs []string `xml:"category_ids"`
WebsiteIDs []string `xml:"website_ids"`
HasOptions bool `xml:"has_options"`
GiftMessageAvailable bool `xml:"gist_message_available"`
Price float64 `xml:"price"`
SpecialPrice float64 `xml:"special_price"`
SpecialFromDate date.Date `xml:"special_from_date"`
SpecialToDate date.Date `xml:"special_to_date"`
TaxClassID int `xml:"tax_class_id"`
TierPrice []CatalogProductTierPriceEntity `xml:"tier_price"`
MetaTitle string `xml:"meta_title"`
MetaKeyword string `xml:"meta_keyword"`
MetaDescription string `xml:"meta_description"`
CustomDesign string `xml:"custom_design"`
CustomLayoutUpdate string `xml:"custom_layout_update"`
OptionsContainer string `xml:"options_container"`
AdditionalAttributes []CatalogProductAdditionalAttributesEntity `xml:"additional_attributes"`
StockData []CatalogInventoryStockItemUpdateEntity `xml:"stock_data"`
}
The "websites" and "website_ids" or "categories" and "category_ids" parameters are interchangeable. In other words, you can specify an array of website IDs (int) and then you don't need to specify the array of website codes (string) and vice versa
type CatalogProductCreateRequest ¶
type CatalogProductCreateRequest struct {
XMLName xml.Name `xml:"catalogProductCreate"`
SessionID *Session
Type string `xml:"type"`
Set string `xml:"set"`
Sku string `xml:"sku"`
ProductData *CatalogProductCreateEntity `xml:"productData"`
StoreView string `xml:"storeView,omitempty"`
}
func NewCatalogProductCreateRequest ¶
func NewCatalogProductCreateRequest() *CatalogProductCreateRequest
type CatalogProductCreateResponse ¶
type CatalogProductCreateResponse struct {
Result int `xml:"result"`
}
func NewCatalogProductCreateResponse ¶
func NewCatalogProductCreateResponse() *CatalogProductCreateResponse
type CatalogProductEntity ¶
type CatalogProductEntityArray ¶
type CatalogProductEntityArray struct {
Items []CatalogProductEntity `xml:"item"`
}
type CatalogProductInfoRequest ¶
type CatalogProductInfoRequest struct {
XMLName xml.Name `xml:"catalogProductInfo"`
SessionID *Session
Product string `xml:"product"`
ProductID string `xml:"productId"`
StoreView string `xml:"storeView,omitempty"`
Attributes []CatalogProductRequestAttributes `xml:"attributes,omitempty"`
IdentifierType IdentifierType `xml:"identifierType"`
}
func NewCatalogProductInfoRequest ¶
func NewCatalogProductInfoRequest() *CatalogProductInfoRequest
type CatalogProductInfoResponse ¶
type CatalogProductInfoResponse struct {
XMLName xml.Name `xml:"catalogProductInfoResponse"`
Info CatalogProductReturnEntity `xml:"info"`
}
func NewCatalogProductInfoResponse ¶
func NewCatalogProductInfoResponse() *CatalogProductInfoResponse
type CatalogProductListRequest ¶
type CatalogProductListRequest struct {
XMLName xml.Name `xml:"catalogProductList"`
SessionID *Session
Filters *Filters `xml:filters,omitempty`
StoreView string `xml:"storeView,omitempty"`
}
func NewCatalogProductListRequest ¶
func NewCatalogProductListRequest() *CatalogProductListRequest
type CatalogProductListResponse ¶
type CatalogProductListResponse struct {
StoreView CatalogProductEntityArray `xml:"storeView"`
}
func NewCatalogProductListResponse ¶
func NewCatalogProductListResponse() *CatalogProductListResponse
type CatalogProductReturnEntity ¶
type CatalogProductReturnEntity struct {
CatalogProductCreateEntity
ProductID string `xml:"product_id"`
Set int `xml:"set"`
Type string `xml:"type"`
Sku string `xml:"sku"`
UpdatedAt TimeWithoutTimeZone `xml:"updated_at"`
CreatedAt time.Time `xml:"created_at"`
TypeID string `xml:"type_id"`
}
type CatalogProductService ¶
type CatalogProductService struct {
Client *Client
}
func NewCatalogProductService ¶
func NewCatalogProductService(client *Client) *CatalogProductService
func (*CatalogProductService) Create ¶
func (s *CatalogProductService) Create(requestBody *CatalogProductCreateRequest, ctx context.Context) (*CatalogProductCreateResponse, error)
func (*CatalogProductService) Info ¶
func (s *CatalogProductService) Info(requestBody *CatalogProductInfoRequest, ctx context.Context) (*CatalogProductInfoResponse, error)
func (*CatalogProductService) List ¶
func (s *CatalogProductService) List(requestBody *CatalogProductListRequest, ctx context.Context) (*CatalogProductListResponse, error)
func (*CatalogProductService) Update ¶
func (s *CatalogProductService) Update(requestBody *CatalogProductUpdateRequest, ctx context.Context) (*CatalogProductUpdateResponse, error)
type CatalogProductUpdateRequest ¶
type CatalogProductUpdateRequest struct {
XMLName xml.Name `xml:"catalogProductUpdate"`
SessionID *Session
Product string `xml:"product"`
ProductID string `xml:"productId"`
ProductData *CatalogProductCreateEntity `xml:"productData"`
StoreView string `xml:"storeView,omitempty"`
IdentifierType IdentifierType `xml:"identifierType"`
}
func NewCatalogProductUpdateRequest ¶
func NewCatalogProductUpdateRequest() *CatalogProductUpdateRequest
type CatalogProductUpdateResponse ¶
type CatalogProductUpdateResponse struct {
Result bool `xml:'result'`
}
func NewCatalogProductUpdateResponse ¶
func NewCatalogProductUpdateResponse() *CatalogProductUpdateResponse
type Client ¶
type Client struct {
// Url pointing to base Unit4 Multivers API
Endpoint *url.URL
// Debugging flag
Debug bool
// User agent for client
UserAgent string
// Services
CatalogProduct *CatalogProductService
Session *SessionService
// contains filtered or unexported fields
}
Client manages communication with Unit4 Multivers API
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is XML decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) GetEndpoint ¶
func (*Client) GetSession ¶
func (*Client) NewRequest ¶
func (*Client) SetApiUser ¶
func (*Client) SetEndpoint ¶
func (*Client) SetSandbox ¶
type Envelope ¶
type Envelope struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Header *Header `xml:"Header"`
Body *Body `xml:"Body"`
}
http://stackoverflow.com/questions/16202170/marshalling-xml-go-xmlname-xmlns
func NewEnvelope ¶
func NewEnvelope() *Envelope
type ErrorResponse ¶
type ErrorResponse struct {
// HTTP response that caused this error
Response *http.Response
// Fault code
Code string `xml:"Body>Fault>faultcode"`
// Fault message
Message string `xml:"Body>Fault>faultstring"`
// Reason
Reason string `xml:"Body>Fault>Reason>Text"`
}
An ErrorResponse reports the error caused by an API request <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>Sender</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>type ErrorResponse struct {
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type IdentifierType ¶
type IdentifierType string
const ( ID IdentifierType = "ID" SKU IdentifierType = "SKU" )
type LoginRequest ¶
type LoginRequest struct {
XMLName xml.Name `xml:"login"`
ApiUser CDATA `xml:"username"`
ApiKey CDATA `xml:"apiKey"`
}
func NewLoginRequest ¶
func NewLoginRequest() *LoginRequest
func (*LoginRequest) WithApiKey ¶
func (req *LoginRequest) WithApiKey(apiKey string) *LoginRequest
func (*LoginRequest) WithApiUser ¶
func (req *LoginRequest) WithApiUser(apiUser string) *LoginRequest
type LoginResponse ¶
type LoginResponse struct {
LoginReturn string `xml:"loginReturn"`
}
func NewLoginResponse ¶
func NewLoginResponse() *LoginResponse
type Request ¶
type Request struct {
Envelope *Envelope `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Action *url.URL `xml:""`
}
func NewRequest ¶
func NewRequest() *Request
type RequestCompletionCallback ¶
RequestCompletionCallback defines the type of the request callback function
type Response ¶
type Response struct {
Envelope *Envelope `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
}
func NewResponse ¶
func NewResponse() *Response
type Session ¶
type Session struct {
XMLName xml.Name `xml:"sessionId"`
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) MarshalXML ¶
type SessionService ¶
type SessionService struct {
Client *Client
}
func NewSessionService ¶
func NewSessionService(client *Client) *SessionService
func (*SessionService) Login ¶
func (s *SessionService) Login(requestBody *LoginRequest, ctx context.Context) (*LoginResponse, error)
type TimeWithoutTimeZone ¶
func (*TimeWithoutTimeZone) UnmarshalXML ¶
func (t *TimeWithoutTimeZone) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error