magento

package module
v0.0.0-...-a8bc258 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

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"`
}

func NewBody

func NewBody() *Body

type CDATA

type CDATA string

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

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 CatalogProductEntity struct {
	XMLName xml.Name `xml:"item"`

	ProductID   int    `xml:"product_id"`
	Sku         string `xml:"sku"`
	Name        string `xml:"name"`
	Set         string `xml:"set"`
	Type        string `xml:"type"`
	CategoryIDs []int  `xml:"category_ids>item"`
	WebsiteIDs  []int  `xml:"website_ids>item"`
}

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 CatalogProductRequestAttributes

type CatalogProductRequestAttributes struct {
	Attributes           []string `xml:"attributes"`
	AdditionalAttributes []string `xml:"additional_attributes"`
}

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 (*CatalogProductService) Info

func (*CatalogProductService) List

func (*CatalogProductService) Update

type CatalogProductTierPriceEntity

type CatalogProductTierPriceEntity struct {
	CustomerGroupID string  `xml:"customer_group_id"`
	Website         string  `xml:"website"`
	Qty             int     `xml:"qty"`
	Price           float64 `xml:"price"`
}

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 NewClient

func NewClient(httpClient *http.Client, baseURL *url.URL, apiUser string, apiKey string) *Client

NewClient returns a new Unit4 Multivers API client

func (*Client) ApiKey

func (c *Client) ApiKey() string

func (*Client) ApiUser

func (c *Client) ApiUser() string

func (*Client) Do

func (c *Client) Do(req *http.Request, responseBody *Response) (*http.Response, error)

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 (c *Client) GetEndpoint() *url.URL

func (*Client) GetSession

func (c *Client) GetSession() *Session

func (*Client) Login

func (c *Client) Login() *Session

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, body *Request) (*http.Request, error)

func (*Client) SetApiKey

func (c *Client) SetApiKey(apiKey string)

func (*Client) SetApiUser

func (c *Client) SetApiUser(apiUser string)

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool)

func (*Client) SetEndpoint

func (c *Client) SetEndpoint(baseURL *url.URL)

func (*Client) SetSandbox

func (c *Client) SetSandbox(sandbox bool)

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 Filters

type Filters struct {
}
type Header struct {
	Data interface{}
}

func NewHeader

func NewHeader() *Header

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

func (*Request) WithData

func (r *Request) WithData(data interface{}) *Request

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

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

func (*Response) WithData

func (r *Response) WithData(data interface{}) *Response

type Session

type Session struct {
	XMLName xml.Name `xml:"sessionId"`
	// contains filtered or unexported fields
}

func NewSession

func NewSession(value string) *Session

func (*Session) Expiry

func (s *Session) Expiry() time.Time

func (*Session) IsExpired

func (s *Session) IsExpired() bool

func (*Session) MarshalXML

func (s *Session) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Session) Token

func (s *Session) Token() string

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

type TimeWithoutTimeZone struct {
	time.Time
}

func (*TimeWithoutTimeZone) UnmarshalXML

func (t *TimeWithoutTimeZone) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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