-
Notifications
You must be signed in to change notification settings - Fork 21
/
type-item.go
98 lines (86 loc) · 1.93 KB
/
type-item.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
package ga
import "net/url"
//WARNING: This file was generated. Do not edit.
//Item Hit Type
type Item struct {
iD string
name string
price float64
priceSet bool
quantity int64
quantitySet bool
code string
codeSet bool
category string
categorySet bool
currencyCode string
currencyCodeSet bool
}
// NewItem creates a new Item Hit Type.
// A unique identifier for the transaction. This value should
// be the same for both the Transaction hit and Items hits
// associated to the particular transaction.
// Specifies the item name.
func NewItem(iD string, name string) *Item {
h := &Item{
iD: iD,
name: name,
}
return h
}
func (h *Item) addFields(v url.Values) error {
v.Add("ti", h.iD)
v.Add("in", h.name)
if h.priceSet {
v.Add("ip", float2str(h.price))
}
if h.quantitySet {
v.Add("iq", int2str(h.quantity))
}
if h.codeSet {
v.Add("ic", h.code)
}
if h.categorySet {
v.Add("iv", h.category)
}
if h.currencyCodeSet {
v.Add("cu", h.currencyCode)
}
return nil
}
// Specifies the price for a single item / unit.
func (h *Item) Price(price float64) *Item {
h.price = price
h.priceSet = true
return h
}
// Specifies the number of items purchased.
func (h *Item) Quantity(quantity int64) *Item {
h.quantity = quantity
h.quantitySet = true
return h
}
// Specifies the SKU or item code.
func (h *Item) Code(code string) *Item {
h.code = code
h.codeSet = true
return h
}
// Specifies the category that the item belongs to.
func (h *Item) Category(category string) *Item {
h.category = category
h.categorySet = true
return h
}
// When present indicates the local currency for all transaction
// currency values. Value should be a valid ISO 4217 currency
// code.
func (h *Item) CurrencyCode(currencyCode string) *Item {
h.currencyCode = currencyCode
h.currencyCodeSet = true
return h
}
func (h *Item) Copy() *Item {
c := *h
return &c
}