-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathproduct.go
More file actions
59 lines (51 loc) · 1.52 KB
/
product.go
File metadata and controls
59 lines (51 loc) · 1.52 KB
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
package sendcloud
import "encoding/json"
type Product struct {
Name string `json:"name"`
Code string `json:"code"`
Carrier string `json:"carrier"`
ServicePointsCarrier string `json:"service_points_carrier"`
WeightRange struct {
MinWeight int `json:"min_weight"`
MaxWeight int `json:"max_weight"`
} `json:"weight_range"`
Methods []struct {
Id int `json:"id"`
Name string `json:"name"`
ShippingProductCode string `json:"shipping_product_code"`
Properties struct {
MinWeight int `json:"min_weight"`
MaxWeight int `json:"max_weight"`
MaxDimensions struct {
Length int `json:"length"`
Width int `json:"width"`
Height int `json:"height"`
Unit string `json:"unit"`
} `json:"max_dimensions"`
} `json:"properties"`
LeadTimeHours struct {
NL struct {
NL int `json:"NL"`
} `json:"NL"`
} `json:"lead_time_hours"`
} `json:"methods"`
}
type ProductListResponseContainer struct {
Products []Product `json:"products"`
}
func (p *ProductListResponseContainer) SetResponse(body []byte) error {
return json.Unmarshal(body, &p.Products)
}
type ProductResponseContainer struct {
Product Product `json:"product"`
}
func (p *ProductResponseContainer) GetResponse() interface{} {
return p.Product
}
func (p *ProductListResponseContainer) GetResponse() interface{} {
var products []*Product
for i := range p.Products {
products = append(products, &p.Products[i])
}
return products
}