@@ -26,23 +26,35 @@ public class Account extends WePayResource {
26
26
public Account (Long accountId ) {
27
27
this .accountId = accountId ;
28
28
}
29
-
29
+
30
30
public static Account fetch (Long accountId , String accessToken ) throws JSONException , IOException , WePayException {
31
+ HeaderData headerData = new HeaderData ();
32
+ headerData .accessToken = accessToken ;
33
+ return Account .fetch (accountId , headerData );
34
+ }
35
+
36
+ public static Account fetch (Long accountId , HeaderData headerData ) throws JSONException , IOException , WePayException {
31
37
JSONObject params = new JSONObject ();
32
38
params .put ("account_id" , accountId );
33
- String response = request ("/account" , params , accessToken );
39
+ String response = request ("/account" , params , headerData );
34
40
Account a = gson .fromJson (response , Account .class );
35
41
AccountData ad = gson .fromJson (response , AccountData .class );
36
42
a .accountData = ad ;
37
43
return a ;
38
44
}
39
-
45
+
40
46
public static Account [] find (AccountFindData findData , String accessToken ) throws JSONException , IOException , WePayException {
47
+ HeaderData headerData = new HeaderData ();
48
+ headerData .accessToken = accessToken ;
49
+ return Account .find (findData , headerData );
50
+ }
51
+
52
+ public static Account [] find (AccountFindData findData , HeaderData headerData ) throws JSONException , IOException , WePayException {
41
53
JSONObject params = new JSONObject ();
42
54
if (findData .name != null ) params .put ("name" , findData .name );
43
55
if (findData .referenceId != null ) params .put ("reference_id" , findData .referenceId );
44
56
if (findData .sortOrder != null ) params .put ("sort_order" , findData .sortOrder );
45
- JSONArray results = new JSONArray (request ("/account/find" , params , accessToken ));
57
+ JSONArray results = new JSONArray (request ("/account/find" , params , headerData ));
46
58
Account [] found = new Account [results .length ()];
47
59
for (int i = 0 ; i < found .length ; i ++) {
48
60
Account a = gson .fromJson (results .get (i ).toString (), Account .class );
@@ -52,8 +64,14 @@ public static Account[] find(AccountFindData findData, String accessToken) throw
52
64
}
53
65
return found ;
54
66
}
55
-
67
+
56
68
public static Account create (AccountData data , String accessToken ) throws JSONException , IOException , WePayException {
69
+ HeaderData headerData = new HeaderData ();
70
+ headerData .accessToken = accessToken ;
71
+ return Account .create (data , headerData );
72
+ }
73
+
74
+ public static Account create (AccountData data , HeaderData headerData ) throws JSONException , IOException , WePayException {
57
75
JSONObject params = new JSONObject ();
58
76
params .put ("name" , data .name );
59
77
params .put ("description" , data .description );
@@ -73,13 +91,19 @@ public static Account create(AccountData data, String accessToken) throws JSONEx
73
91
String rbitsJson = gson .toJson (data .rbits );
74
92
params .put ("rbits" , new JSONArray (rbitsJson ));
75
93
}
76
- String response = request ("/account/create" , params , accessToken );
94
+ String response = request ("/account/create" , params , headerData );
77
95
Account a = gson .fromJson (response , Account .class );
78
96
a .accountData = data ;
79
97
return a ;
80
98
}
81
-
99
+
82
100
public void modify (AccountData data , String accessToken ) throws JSONException , IOException , WePayException {
101
+ HeaderData headerData = new HeaderData ();
102
+ headerData .accessToken = accessToken ;
103
+ this .modify (data , headerData );
104
+ }
105
+
106
+ public void modify (AccountData data , HeaderData headerData ) throws JSONException , IOException , WePayException {
83
107
JSONObject params = new JSONObject ();
84
108
params .put ("account_id" , this .accountId );
85
109
if (data .name != null ) params .put ("name" , data .name );
@@ -97,7 +121,7 @@ public void modify(AccountData data, String accessToken) throws JSONException, I
97
121
params .put ("rbits" , new JSONArray (rbitsJson ));
98
122
}
99
123
100
- String response = request ("/account/modify" , params , accessToken );
124
+ String response = request ("/account/modify" , params , headerData );
101
125
Account a = gson .fromJson (response , Account .class );
102
126
AccountData ad = gson .fromJson (response , AccountData .class );
103
127
ad .callbackUri = data .callbackUri ;
@@ -109,15 +133,27 @@ public void modify(AccountData data, String accessToken) throws JSONException, I
109
133
this .actionReasons = a .actionReasons ;
110
134
this .accountData = ad ;
111
135
}
112
-
136
+
113
137
public void delete (String reason , String accessToken ) throws JSONException , IOException , WePayException {
138
+ HeaderData headerData = new HeaderData ();
139
+ headerData .accessToken = accessToken ;
140
+ this .delete (reason , headerData );
141
+ }
142
+
143
+ public void delete (String reason , HeaderData headerData ) throws JSONException , IOException , WePayException {
114
144
JSONObject params = new JSONObject ();
115
145
params .put ("account_id" , this .accountId );
116
146
if (reason != null ) params .put ("reason" , reason );
117
- request ("/account/delete" , params , accessToken );
147
+ request ("/account/delete" , params , headerData );
118
148
}
119
-
149
+
120
150
public String getUpdateUri (AccountUpdateUriData data , String accessToken ) throws JSONException , IOException , WePayException {
151
+ HeaderData headerData = new HeaderData ();
152
+ headerData .accessToken = accessToken ;
153
+ return this .getUpdateUri (data , headerData );
154
+ }
155
+
156
+ public String getUpdateUri (AccountUpdateUriData data , HeaderData headerData ) throws JSONException , IOException , WePayException {
121
157
JSONObject params = new JSONObject ();
122
158
params .put ("account_id" , this .accountId );
123
159
if (data .mode != null ) {
@@ -132,15 +168,21 @@ public String getUpdateUri(AccountUpdateUriData data, String accessToken) throws
132
168
params .put ("prefill_info" , KYCPrefillInfoData .buildPrefillInfo (data .prefillInfo ));
133
169
}
134
170
135
- JSONObject object = new JSONObject (request ("/account/get_update_uri" , params , accessToken ));
171
+ JSONObject object = new JSONObject (request ("/account/get_update_uri" , params , headerData ));
136
172
return object .getString ("uri" );
137
173
}
138
174
139
175
public AccountReserveData getReserveDetails (String currency , String accessToken ) throws JSONException , IOException , WePayException {
176
+ HeaderData headerData = new HeaderData ();
177
+ headerData .accessToken = accessToken ;
178
+ return this .getReserveDetails (currency , headerData );
179
+ }
180
+
181
+ public AccountReserveData getReserveDetails (String currency , HeaderData headerData ) throws JSONException , IOException , WePayException {
140
182
JSONObject params = new JSONObject ();
141
183
params .put ("account_id" , this .accountId );
142
184
if (currency != null ) params .put ("currency" , currency );
143
- String response = request ("/account/get_reserve_details" , params , accessToken );
185
+ String response = request ("/account/get_reserve_details" , params , headerData );
144
186
AccountReserveData ar = gson .fromJson (response , AccountReserveData .class );
145
187
return ar ;
146
188
}
0 commit comments