-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathCustomer.java
More file actions
228 lines (197 loc) · 8.49 KB
/
Customer.java
File metadata and controls
228 lines (197 loc) · 8.49 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package com.braintreegateway;
import com.braintreegateway.util.NodeWrapper;
import java.util.*;
public class Customer {
private Calendar createdAt;
private Calendar updatedAt;
private String company;
private String email;
private String fax;
private String firstName;
private String graphqlId;
private String id;
private String lastName;
private String phone;
private String website;
private List<Address> addresses;
private List<AmexExpressCheckoutCard> amexExpressCheckoutCards;
private List<AndroidPayCard> androidPayCards;
private List<ApplePayCard> applePayCards;
private List<CreditCard> creditCards;
private List<CustomActionsPaymentMethod> customActionsPaymentMethods;
private List<MasterpassCard> masterpassCards;
private List<PayPalAccount> paypalAccounts;
private List<SamsungPayCard> samsungPayCards;
private List<SepaDirectDebitAccount> sepaDirectDebitAccounts;
private List<UsBankAccount> usBankAccounts;
private List<VenmoAccount> venmoAccounts;
private List<VisaCheckoutCard> visaCheckoutCards;
private Map<String, String> customFields;
public Customer(NodeWrapper node) {
company = node.findString("company");
createdAt = node.findDateTime("created-at");
customFields = node.findMap("custom-fields/*");
email = node.findString("email");
fax = node.findString("fax");
firstName = node.findString("first-name");
graphqlId = node.findString("global-id");
id = node.findString("id");
lastName = node.findString("last-name");
phone = node.findString("phone");
updatedAt = node.findDateTime("updated-at");
website = node.findString("website");
creditCards = new ArrayList<CreditCard>();
for (NodeWrapper creditCardResponse : node.findAll("credit-cards/credit-card")) {
creditCards.add(new CreditCard(creditCardResponse));
}
paypalAccounts = new ArrayList<PayPalAccount>();
for (NodeWrapper paypalResponse : node.findAll("paypal-accounts/paypal-account")) {
paypalAccounts.add(new PayPalAccount(paypalResponse));
}
applePayCards = new ArrayList<ApplePayCard>();
for (NodeWrapper applePayCardResponse : node.findAll("apple-pay-cards/apple-pay-card")) {
applePayCards.add(new ApplePayCard(applePayCardResponse));
}
androidPayCards = new ArrayList<AndroidPayCard>();
for (NodeWrapper androidPayCardResponse : node.findAll("android-pay-cards/android-pay-card")) {
androidPayCards.add(new AndroidPayCard(androidPayCardResponse));
}
amexExpressCheckoutCards = new ArrayList<AmexExpressCheckoutCard>();
for (NodeWrapper amexExpressCheckoutCardResponse : node.findAll("amex-express-checkout-cards/amex-express-checkout-card")) {
amexExpressCheckoutCards.add(new AmexExpressCheckoutCard(amexExpressCheckoutCardResponse));
}
venmoAccounts = new ArrayList<VenmoAccount>();
for (NodeWrapper venmoAccountResponse : node.findAll("venmo-accounts/venmo-account")) {
venmoAccounts.add(new VenmoAccount(venmoAccountResponse));
}
visaCheckoutCards = new ArrayList<VisaCheckoutCard>();
for (NodeWrapper visaCheckoutCardResponse : node.findAll("visa-checkout-cards/visa-checkout-card")) {
visaCheckoutCards.add(new VisaCheckoutCard(visaCheckoutCardResponse));
}
masterpassCards = new ArrayList<MasterpassCard>();
for (NodeWrapper masterpassCardResponse : node.findAll("masterpass-cards/masterpass-card")) {
masterpassCards.add(new MasterpassCard(masterpassCardResponse));
}
usBankAccounts = new ArrayList<UsBankAccount>();
for (NodeWrapper usBankAccountResponse : node.findAll("us-bank-accounts/us-bank-account")) {
usBankAccounts.add(new UsBankAccount(usBankAccountResponse));
}
sepaDirectDebitAccounts = new ArrayList<SepaDirectDebitAccount>();
for (NodeWrapper sepaDirectDebitAccountResponse : node.findAll("sepa-debit-accounts/sepa-debit-account")) {
sepaDirectDebitAccounts.add(new SepaDirectDebitAccount(sepaDirectDebitAccountResponse));
}
samsungPayCards = new ArrayList<SamsungPayCard>();
for (NodeWrapper samsungPayCardResponse : node.findAll("samsung-pay-cards/samsung-pay-card")) {
samsungPayCards.add(new SamsungPayCard(samsungPayCardResponse));
}
customActionsPaymentMethods = new ArrayList<CustomActionsPaymentMethod>();
for (NodeWrapper customActionsPaymentMethodResponse : node.findAll("custom-actions-payment-methods/custom-actions-payment-method")) {
customActionsPaymentMethods.add(new CustomActionsPaymentMethod(customActionsPaymentMethodResponse));
}
addresses = new ArrayList<Address>();
for (NodeWrapper addressResponse : node.findAll("addresses/address")) {
addresses.add(new Address(addressResponse));
}
}
public Calendar getCreatedAt() {
return createdAt;
}
public Calendar getUpdatedAt() {
return updatedAt;
}
public String getId() {
return id;
}
public String getGraphQLId() {
return graphqlId;
}
public String getCompany() {
return company;
}
public Map<String, String> getCustomFields() {
return customFields;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getEmail() {
return email;
}
public String getFax() {
return fax;
}
public String getPhone() {
return phone;
}
public String getWebsite() {
return website;
}
public List<Address> getAddresses() {
return Collections.unmodifiableList(addresses);
}
public List<CreditCard> getCreditCards() {
return Collections.unmodifiableList(creditCards);
}
public List<PayPalAccount> getPayPalAccounts() {
return Collections.unmodifiableList(paypalAccounts);
}
public List<ApplePayCard> getApplePayCards() {
return Collections.unmodifiableList(applePayCards);
}
public List<AndroidPayCard> getAndroidPayCards() {
return Collections.unmodifiableList(androidPayCards);
}
@Deprecated
public List<AmexExpressCheckoutCard> getAmexExpressCheckoutCards() {
return Collections.unmodifiableList(amexExpressCheckoutCards);
}
public List<VenmoAccount> getVenmoAccounts() {
return Collections.unmodifiableList(venmoAccounts);
}
public List<VisaCheckoutCard> getVisaCheckoutCards() {
return Collections.unmodifiableList(visaCheckoutCards);
}
@Deprecated
public List<MasterpassCard> getMasterpassCards() {
return Collections.unmodifiableList(masterpassCards);
}
public List<UsBankAccount> getUsBankAccounts() {
return Collections.unmodifiableList(usBankAccounts);
}
public List<SepaDirectDebitAccount> getSepaDirectDebitAccounts() {
return Collections.unmodifiableList(sepaDirectDebitAccounts);
}
public List<SamsungPayCard> getSamsungPayCards() {
return Collections.unmodifiableList(samsungPayCards);
}
public List<CustomActionsPaymentMethod> getCustomActionsPaymentMethods() {
return Collections.unmodifiableList(customActionsPaymentMethods);
}
public List<? extends PaymentMethod> getPaymentMethods() {
List<PaymentMethod> paymentMethods = new ArrayList<PaymentMethod>();
paymentMethods.addAll(getCreditCards());
paymentMethods.addAll(getPayPalAccounts());
paymentMethods.addAll(getApplePayCards());
paymentMethods.addAll(getAndroidPayCards());
paymentMethods.addAll(getAmexExpressCheckoutCards());
paymentMethods.addAll(getVenmoAccounts());
paymentMethods.addAll(getVisaCheckoutCards());
paymentMethods.addAll(getMasterpassCards());
paymentMethods.addAll(getSamsungPayCards());
paymentMethods.addAll(getSepaDirectDebitAccounts());
paymentMethods.addAll(getCustomActionsPaymentMethods());
paymentMethods.addAll(getUsBankAccounts());
return Collections.unmodifiableList(paymentMethods);
}
public PaymentMethod getDefaultPaymentMethod() {
for (PaymentMethod paymentMethod : getPaymentMethods()) {
if (paymentMethod.isDefault()) {
return paymentMethod;
}
}
return null;
}
}