-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSubscription.java
More file actions
98 lines (71 loc) · 2.45 KB
/
Subscription.java
File metadata and controls
98 lines (71 loc) · 2.45 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
package com.kwanzoo.recurly;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.UniformInterfaceException;
@XmlRootElement(name="subscription")
public class Subscription extends Base{
private static String resourceName = "subscription";
@XmlElement(name="plan_code")
public String planCode;
@XmlElement(name="quantity")
public Integer quantity;
@XmlElement(name="unit_amount")
public Integer unitAmount;
@XmlElement(name="timeframe")
public String timeframe;
@XmlElement(name="account")
public Account account;
@XmlElement(name="account_code")
public String accountCode;
@XmlElement(name="plan")
public Plan plan;
@XmlElementWrapper(name = "add_ons")
@XmlElement(name = "add_on")
public List<AddOn> addOns;
@XmlElement(name="state")
public String state;
@XmlElement(name="total_amount_in_cents")
public Integer totalAmountInCents;
@XmlElement(name="activated_at")
public Date activatedAt;
@XmlElement(name="canceled_at")
public Date canceledAt;
@XmlElement(name="expires_at")
public Date expiresAt;
@XmlElement(name="current_period_started_at")
public Date currentPeriodStartedAt;
@XmlElement(name="current_period_ends_at")
public Date currentPeriodEndsAt;
@XmlElement(name="trial_started_at")
public Date trialStartedAt;
@XmlElement(name="trial_ends_at")
public Date trialEndsAt;
private static String getResourcePath(String accountCode){
return Account.pluralResourceName + "/" + accountCode + "/" + resourceName;
}
public static Subscription get(final String accountCode) throws Exception{
try{
return getWebResourceBuilder(getResourcePath(accountCode)).get(new GenericType<Subscription>(){});
}
catch(final UniformInterfaceException uie){
throwStatusBasedException(uie.getResponse());
return null;
}
}
@Override
protected String getResourcePath() {
return getResourcePath(accountCode);
}
@Override
protected String getResourceCreationPath() {
return getResourcePath();
}
public Subscription(){}
public Subscription(final String accountCode){
this.accountCode = accountCode;
}
}