-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog.go
106 lines (90 loc) · 2.61 KB
/
catalog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package gofaapi
import (
"encoding/xml"
)
type Order struct {
XMLName xml.Name `xml:"sendFullOrder"`
Username string `xml:"username"`
Password string `xml:"password"`
QuantityID int `xml:"quantityId"`
ShippingTypeID int `xml:"shippingTypeId"`
Options Options
AddressList AddressList
ShippingID int `xml:"shippingId"`
AddressHandling int `xml:"isStandard"`
UpgradeID int `xml:"upgradeId,omitempty"`
PaymentID int `xml:"paymentId"`
UploadInfo UploadInfo
ResellerPrice string `xml:"resellerGross,omitempty"`
Width string `xml:"width,omitempty"`
Height string `xml:"height,omitempty"`
}
type Options map[int]int
type UploadInfo struct {
UploadType string
Time string
Text string
ReferenceText string
}
type AddressList struct {
DeliverAddress Address
SenderAddress Address
InvoiceAddress Address
}
type Address struct {
Customertype string
Vatnumber string
Taxnumber string
Company string
Gender string
FirstName string
LastName string
Address string
AddressAdd string
Postcode string
City string
County string
Locale string
Phone string
}
type requestGetPGroups struct {
XMLName xml.Name `xml:"getProductGroupIds"`
Space string `xml:"space"` // hack: we need a space between the opening and ending tag
}
type requestGetAttr struct {
XMLName xml.Name `xml:"getProductAttributesByGroupId"`
PGroupID int `xml:"PGroupID"`
}
type requestGetQuantityID struct {
XMLName xml.Name `xml:"findProductByQuantityId"`
QID int `xml:"QID"`
}
type requestAddProductToCart struct {
XMLName xml.Name `xml:"addProductToCart"`
QID int `xml:"QID"`
}
// GetProductGroups gets all available productgroups
func (c *Client) GetProductGroups() []byte {
r, _ := c.call("getProductGroupIds", &requestGetPGroups{Space: " "})
return r
}
// GetProductAttributes get all attributes of a productgroup
func (c *Client) GetProductAttributes(PGroupID int) []byte {
r, _ := c.call("getProductAttributesByGroupId", &requestGetAttr{})
return r
}
// GetProduct get a Product by QuantityID
func (c *Client) GetProduct(PGroupID int) []byte {
r, _ := c.call("findProductByQuantityId", &requestGetQuantityID{})
return r
}
// AddProductToCart adds a product to the cart
func (c *Client) AddProductToCart(PGroupID int) []byte {
r, _ := c.call("addProductToCart", &requestAddProductToCart{})
return r
}
// SendOrder sends a fully configured order
func (c *Client) SendOrder(order Order) []byte {
r, _ := c.call("sendFullOrder", &order)
return r
}