forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sku.go
69 lines (61 loc) · 1.75 KB
/
sku.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
package stripe
import "encoding/json"
type SKUParams struct {
Params
ID string
Active *bool
Desc string
Name string
Attrs map[string]string
Price int64
Currency string
Image string
Inventory Inventory
Product string
PackageDimensions *PackageDimensions
}
type Inventory struct {
Type string `json:"type"`
Quantity int64 `json:"quantity"`
Value string `json:"value"`
}
type SKU struct {
ID string `json:"id"`
Created int64 `json:"created"`
Updated int64 `json:"updated"`
Live bool `json:"livemode"`
Active bool `json:"active"`
Name string `json:"name"`
Desc string `json:"description"`
Attrs map[string]string `json:"attributes"`
Price int64 `json:"price"`
Currency string `json:"currency"`
PackageDimensions *PackageDimensions `json:"package_dimensions"`
Image string `json:"image"`
Inventory Inventory `json:"inventory"`
Product Product `json:"product"`
Meta map[string]string `json:"metadata"`
}
type SKUList struct {
ListMeta
Values []*SKU `json:"data"`
}
type SKUListParams struct {
ListParams
Active *bool
Product string
Attributes map[string]string
IDs []string
InStock *bool
}
func (s *SKU) UnmarshalJSON(data []byte) error {
type sku SKU
var sk sku
err := json.Unmarshal(data, &sk)
if err == nil {
*s = SKU(sk)
} else {
s.ID = string(data[1 : len(data)-1])
}
return nil
}