forked from matomo-org/matomo-java-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEcommerceItem.java
More file actions
146 lines (130 loc) · 3.23 KB
/
EcommerceItem.java
File metadata and controls
146 lines (130 loc) · 3.23 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Piwik Java Tracker
*
* @link https://github.com/piwik/piwik-java-tracker
* @license https://github.com/piwik/piwik-java-tracker/blob/master/LICENSE BSD-3 Clause
*/
package org.piwik.java.tracking;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonValue;
/**
* Represents an item in an ecommerce order.
*
* @author brettcsorba
*/
public class EcommerceItem implements JsonValue{
private String sku;
private String name;
private String category;
private Double price;
private Integer quantity;
/**
* Construct an EcommerceItem from its sku, name, category, price, and
* quantity of the order.
* @param sku the item's sku
* @param name the item's name
* @param category the item's category
* @param price the item's price
* @param quantity the quantity of this item in this order
*/
public EcommerceItem(String sku, String name, String category, Double price, Integer quantity){
this.sku = sku;
this.name = name;
this.category = category;
this.price = price;
this.quantity = quantity;
}
/**
* Get an item's sku.
* @return the item's sku
*/
public String getSku(){
return sku;
}
/**
* Set an item's sku.
* @param sku the sku to set
*/
public void setSku(String sku){
this.sku = sku;
}
/**
* Get an item's name.
* @return the item's name
*/
public String getName(){
return name;
}
/**
* Set an item's name.
* @param name the name to set
*/
public void setName(String name){
this.name = name;
}
/**
* Get an item's category.
* @return an item's category
*/
public String getCategory(){
return category;
}
/**
* Set an item's category.
* @param category the category to set
*/
public void setCategory(String category){
this.category = category;
}
/**
* Get an item's price.
* @return an item's price
*/
public Double getPrice(){
return price;
}
/**
* Set an item's price.
* @param price the price to set
*/
public void setPrice(Double price){
this.price = price;
}
/**
* Get the quantity of this item in this order.
* @return the quantity of this item in the order
*/
public Integer getQuantity(){
return quantity;
}
/**
* Set the quantity of this item in this order
* @param quantity the quantity of this item to set
*/
public void setQuantity(Integer quantity){
this.quantity = quantity;
}
/**
* Get the JSON value type of EcommerceItem.
* @return ValueType.ARRAY
*/
@Override
public ValueType getValueType(){
return ValueType.ARRAY;
}
/**
* Returns the value of this EcommerceItem as a JSON Object string.
* @return JSON object string
*/
@Override
public String toString(){
JsonArrayBuilder ab = Json.createArrayBuilder();
ab.add(sku);
ab.add(name);
ab.add(category);
ab.add(price);
ab.add(quantity);
return ab.build().toString();
}
}