-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_attribute.go
45 lines (39 loc) · 1.33 KB
/
item_attribute.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
package goshopee
type ItemAttributeService interface {
List(cid uint64, options map[string]interface{}) ([]ItemAttribute, error)
}
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 ItemAttributeValue struct {
OriginalValue string `json:"original_value"`
TranslateValue string `json:"translate_value"`
}
// ItemAttributeServiceOp handles communication with the product related methods of
// the Shopee API.
type ItemAttributeServiceOp struct {
client *Client
}
type ItemAttributesResponse struct {
Attributes []ItemAttribute `json:"attributes"`
RequestID string `json:"request_id"`
}
// List xxx
func (s *ItemAttributeServiceOp) List(cid uint64, options map[string]interface{}) ([]ItemAttribute, error) {
path := "/item/attributes/get"
wrappedData := map[string]interface{}{
"category_id": cid,
}
for k, v := range options {
wrappedData[k] = v
}
resource := new(ItemAttributesResponse)
err := s.client.Post(path, wrappedData, resource)
return resource.Attributes, err
}