-
Notifications
You must be signed in to change notification settings - Fork 32
Created transfer method endpoint #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bea9a8a
88dcbc7
579e5c3
0a4dfeb
0dcf236
0832584
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import java.text.DateFormat; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.Date; | ||
| import java.util.HashMap; | ||
| import java.util.Locale; | ||
| import java.util.TimeZone; | ||
|
|
||
|
|
@@ -927,6 +928,62 @@ public HyperwalletList<HyperwalletWebhookNotification> listWebhookEvents(Hyperwa | |
| return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletWebhookNotification>>() {}); | ||
| } | ||
|
|
||
| //-------------------------------------- | ||
| // Transfer Methods | ||
| //-------------------------------------- | ||
|
|
||
| /** | ||
| * Create a Transfer Method | ||
| * | ||
| * @param jsonCacheToken String JSON cache token | ||
| * @param transferMethod TransferMethod object to create | ||
| * @return HyperwalletTransferMethod Transfer Method object created | ||
| */ | ||
| public HyperwalletTransferMethod createTransferMethod(String jsonCacheToken, HyperwalletTransferMethod transferMethod) { | ||
|
|
||
| if (transferMethod == null || StringUtils.isEmpty(transferMethod.getUserToken())) { | ||
| throw new HyperwalletException("User token is required"); | ||
| } | ||
| if (StringUtils.isEmpty(jsonCacheToken)) { | ||
| throw new HyperwalletException("JSON token is required"); | ||
| } | ||
| transferMethod = copy(transferMethod); | ||
|
|
||
| transferMethod.setToken(null); | ||
| transferMethod.setStatus(null); | ||
| transferMethod.setCreatedOn(null); | ||
|
|
||
| HashMap<String, String> headers = new HashMap<String, String>(); | ||
| headers.put("Json-Cache-Token", jsonCacheToken); | ||
|
|
||
| return apiClient.post(url + "/users/" + transferMethod.getUserToken() + "/transfer-methods", transferMethod, HyperwalletTransferMethod.class, headers); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Create a Transfer Method | ||
| * | ||
| * @param jsonCacheToken String JSON cache token | ||
| * @param userToken String user token | ||
| * @return HyperwalletTransferMethod Transfer Method object created | ||
| */ | ||
| public HyperwalletTransferMethod createTransferMethod(String jsonCacheToken, String userToken) { | ||
|
|
||
| if (StringUtils.isEmpty(userToken)) { | ||
| throw new HyperwalletException("User token is required"); | ||
| } | ||
| if (StringUtils.isEmpty(jsonCacheToken)) { | ||
| throw new HyperwalletException("JSON token is required"); | ||
| } | ||
|
|
||
| HyperwalletTransferMethod transferMethod = new HyperwalletTransferMethod(); | ||
| transferMethod.setUserToken(userToken); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we cannot create TransferMethod without Type? i.e.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if that is the case we should either not provide this method, or have a default value.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep this method for me should be removed since even if we set a default but in this context we cannot know for sure what are the users available transfer methods or the concept of default transfer method to a specific user given only the |
||
|
|
||
| HashMap<String, String> headers = new HashMap<String, String>(); | ||
| headers.put("Json-Cache-Token", jsonCacheToken); | ||
|
|
||
| return apiClient.post(url + "/users/" + transferMethod.getUserToken() + "/transfer-methods", transferMethod, HyperwalletTransferMethod.class, headers); | ||
| } | ||
| //-------------------------------------- | ||
| // Internal utils | ||
| //-------------------------------------- | ||
|
|
@@ -998,4 +1055,9 @@ private HyperwalletStatusTransition copy(HyperwalletStatusTransition statusTrans | |
| return statusTransition; | ||
| } | ||
|
|
||
| private HyperwalletTransferMethod copy(HyperwalletTransferMethod transferMethod) { | ||
| transferMethod = HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(transferMethod), HyperwalletTransferMethod.class); | ||
| return transferMethod; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to check if transfer method type is set or we rely on service validators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the documentation i was following you are correct.
https://confluence.site1.hyperwallet.local/pages/viewpage.action?pageId=22299508
the other SDKs seem to handle it at the service level.