|
18 | 18 | */ |
19 | 19 | public class UsageRecord extends InstanceResource { |
20 | 20 |
|
21 | | - /** |
22 | | - * The Constant SID_PROPERTY. |
23 | | - */ |
24 | | - private static final String SID_PROPERTY = "sid"; |
25 | | - |
26 | | - /** |
27 | | - * Instantiates a new usageRecord. |
28 | | - * |
29 | | - * @param client the client |
30 | | - */ |
31 | | - public UsageRecord(TwilioRestClient client) { |
32 | | - super(client); |
33 | | - } |
34 | | - |
35 | | - /** |
36 | | - * {@inheritDoc} |
37 | | - */ |
38 | | - @Override |
39 | | - protected String getResourceLocation() { |
40 | | - return null; |
41 | | - } |
42 | | - |
43 | | - /** |
44 | | - * Instantiates a new usageRecord. |
45 | | - * |
46 | | - * @param client the client |
47 | | - * @param sid the sid |
48 | | - */ |
49 | | - public UsageRecord(TwilioRestClient client, String sid) { |
50 | | - super(client); |
51 | | - if (sid == null) { |
52 | | - throw new IllegalStateException( |
53 | | - "The Sid for a UsageRecord can not be null"); |
54 | | - } |
55 | | - this.setProperty(SID_PROPERTY, sid); |
56 | | - } |
57 | | - |
58 | | - /** |
59 | | - * Instantiates a new UsageRecord. |
60 | | - * |
61 | | - * @param client the client |
62 | | - * @param properties the properties |
63 | | - */ |
64 | | - public UsageRecord(TwilioRestClient client, Map<String, Object> properties) { |
65 | | - super(client, properties); |
66 | | - } |
67 | | - |
68 | | - |
69 | | - public UsageCategory getCategory() { |
70 | | - return UsageCategory.valueOf(getProperty("Category").replace('-', '_')); |
71 | | - } |
72 | | - |
73 | | - public String getDescription() { |
74 | | - return getProperty("Description"); |
75 | | - } |
76 | | - |
77 | | - public Date getStartDate() { |
78 | | - SimpleDateFormat format = new SimpleDateFormat( |
79 | | - "EEE, dd MMM yyyy HH:mm:ss Z"); |
80 | | - try { |
81 | | - return format.parse(this.getProperty("StartDate")); |
82 | | - } catch (ParseException e) { |
83 | | - return null; |
84 | | - } |
85 | | - } |
86 | | - |
87 | | - public Date getEndDate() { |
88 | | - SimpleDateFormat format = new SimpleDateFormat( |
89 | | - "EEE, dd MMM yyyy HH:mm:ss Z"); |
90 | | - try { |
91 | | - return format.parse(this.getProperty("EndDate")); |
92 | | - } catch (ParseException e) { |
93 | | - return null; |
94 | | - } |
95 | | - } |
96 | | - |
97 | | - public BigDecimal getUsage() { |
98 | | - return new BigDecimal(getProperty("Usage")); |
99 | | - } |
100 | | - |
101 | | - public String getUsageUnits() { |
102 | | - return getProperty("UsageUnits"); |
103 | | - } |
104 | | - |
105 | | - public Long getCount() { |
106 | | - String count = getProperty("Count"); |
107 | | - return count == null ? null : Long.parseLong(getProperty("Count")); |
108 | | - } |
109 | | - |
110 | | - public String getCountUnits() { |
111 | | - return getProperty("CountUnits"); |
112 | | - } |
113 | | - |
114 | | - public BigDecimal getPrice() { |
115 | | - return new BigDecimal(getProperty("Price")); |
116 | | - } |
117 | | - |
118 | | - public String getPriceUnit() { |
119 | | - return getProperty("PriceUnit"); |
120 | | - } |
121 | | - |
122 | | - public String getUri() { |
123 | | - return getProperty("Uri"); |
124 | | - } |
125 | | - |
126 | | - public String[] getSubresourceUris() { |
127 | | - return null; |
128 | | - } |
| 21 | + /** |
| 22 | + * The Constant SID_PROPERTY. |
| 23 | + */ |
| 24 | + private static final String SID_PROPERTY = "sid"; |
| 25 | + |
| 26 | + /** |
| 27 | + * Instantiates a new usageRecord. |
| 28 | + * |
| 29 | + * @param client the client |
| 30 | + */ |
| 31 | + public UsageRecord(TwilioRestClient client) { |
| 32 | + super(client); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * {@inheritDoc} |
| 37 | + */ |
| 38 | + @Override |
| 39 | + protected String getResourceLocation() { |
| 40 | + return null; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Instantiates a new usageRecord. |
| 45 | + * |
| 46 | + * @param client the client |
| 47 | + * @param sid the sid |
| 48 | + */ |
| 49 | + public UsageRecord(TwilioRestClient client, String sid) { |
| 50 | + super(client); |
| 51 | + if (sid == null) { |
| 52 | + throw new IllegalStateException( |
| 53 | + "The Sid for a UsageRecord can not be null"); |
| 54 | + } |
| 55 | + this.setProperty(SID_PROPERTY, sid); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Instantiates a new UsageRecord. |
| 60 | + * |
| 61 | + * @param client the client |
| 62 | + * @param properties the properties |
| 63 | + */ |
| 64 | + public UsageRecord(TwilioRestClient client, Map<String, Object> properties) { |
| 65 | + super(client, properties); |
| 66 | + } |
| 67 | + |
| 68 | + |
| 69 | + public UsageCategory getCategory() { |
| 70 | + return UsageCategory.valueOf(getProperty("Category").replace('-', '_')); |
| 71 | + } |
| 72 | + |
| 73 | + public String getDescription() { |
| 74 | + return getProperty("Description"); |
| 75 | + } |
| 76 | + |
| 77 | + public Date getStartDate() { |
| 78 | + SimpleDateFormat format = new SimpleDateFormat( |
| 79 | + "EEE, dd MMM yyyy HH:mm:ss Z"); |
| 80 | + try { |
| 81 | + return format.parse(this.getProperty("StartDate")); |
| 82 | + } catch (ParseException e) { |
| 83 | + return null; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + public Date getEndDate() { |
| 88 | + SimpleDateFormat format = new SimpleDateFormat( |
| 89 | + "EEE, dd MMM yyyy HH:mm:ss Z"); |
| 90 | + try { |
| 91 | + return format.parse(this.getProperty("EndDate")); |
| 92 | + } catch (ParseException e) { |
| 93 | + return null; |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + public BigDecimal getUsage() { |
| 98 | + return new BigDecimal(getProperty("Usage")); |
| 99 | + } |
| 100 | + |
| 101 | + public String getUsageUnits() { |
| 102 | + return getProperty("UsageUnits"); |
| 103 | + } |
| 104 | + |
| 105 | + public Long getCount() { |
| 106 | + String count = getProperty("Count"); |
| 107 | + return count == null ? null : Long.parseLong(getProperty("Count")); |
| 108 | + } |
| 109 | + |
| 110 | + public String getCountUnits() { |
| 111 | + return getProperty("CountUnits"); |
| 112 | + } |
| 113 | + |
| 114 | + public BigDecimal getPrice() { |
| 115 | + return new BigDecimal(getProperty("Price")); |
| 116 | + } |
| 117 | + |
| 118 | + public String getPriceUnit() { |
| 119 | + return getProperty("PriceUnit"); |
| 120 | + } |
| 121 | + |
| 122 | + public String getUri() { |
| 123 | + return getProperty("Uri"); |
| 124 | + } |
| 125 | + |
| 126 | + public String[] getSubresourceUris() { |
| 127 | + return null; |
| 128 | + } |
129 | 129 | } |
0 commit comments