Skip to content

Commit

Permalink
Merge conflicts fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ramahalingam committed Sep 3, 2020
2 parents 2a85d96 + 19cadc0 commit 7579dee
Show file tree
Hide file tree
Showing 9 changed files with 1,582 additions and 84 deletions.
249 changes: 232 additions & 17 deletions src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,215 @@ public HyperwalletList<HyperwalletStatusTransition> listPayPalAccountStatusTrans
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletStatusTransition>>() {
});
}
//--------------------------------------
// Venmo Accounts
//--------------------------------------

/**
* Create Venmo Account
*
* @param venmoAccount HyperwalletVenmoAccount object to create
* @return HyperwalletVenmoAccount created Venmo account for the specified user
*/
public HyperwalletVenmoAccount createVenmoAccount(HyperwalletVenmoAccount venmoAccount) {
if (venmoAccount == null) {
throw new HyperwalletException("Venmo Account is required");
}
if (StringUtils.isEmpty(venmoAccount.getUserToken())) {
throw new HyperwalletException("User token is required");
}
if (StringUtils.isEmpty(venmoAccount.getTransferMethodCountry())) {
throw new HyperwalletException("Transfer Method Country is required");
}
if (StringUtils.isEmpty(venmoAccount.getTransferMethodCurrency())) {
throw new HyperwalletException("Transfer Method Currency is required");
}
if (StringUtils.isEmpty(venmoAccount.getAccountId())) {
throw new HyperwalletException("Account is required");
}
if (StringUtils.isNotEmpty(venmoAccount.getToken())) {
throw new HyperwalletException("Venmo Account token may not be present");
}
if (venmoAccount.getType() == null) {
venmoAccount.setType(HyperwalletTransferMethod.Type.VENMO_ACCOUNT);
}
venmoAccount = copy(venmoAccount);
venmoAccount.setStatus(null);
venmoAccount.setCreatedOn(null);
return apiClient.post(url + "/users/" + venmoAccount.getUserToken() + "/venmo-accounts", venmoAccount, HyperwalletVenmoAccount.class);
}

/**
* Get Venmo Account
*
* @param userToken User token assigned
* @param venmoAccountToken Venmo Account token assigned
* @return HyperwalletVenmoAccount Venmo Account
*/
public HyperwalletVenmoAccount getVenmoAccount(String userToken, String venmoAccountToken) {
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is required");
}
if (StringUtils.isEmpty(venmoAccountToken)) {
throw new HyperwalletException("venmo Account token is required");
}
return apiClient.get(url + "/users/" + userToken + "/venmo-accounts/" + venmoAccountToken, HyperwalletVenmoAccount.class);
}

/**
* List Venmo Accounts
*
* @param userToken User token assigned
* @param options List filter option
* @return HyperwalletList of HyperwalletVenmoAccount
*/
public HyperwalletList<HyperwalletVenmoAccount> listVenmoAccounts(String userToken, HyperwalletPaginationOptions options) {
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is required");
}
String url = paginate(this.url + "/users/" + userToken + "/venmo-accounts", options);
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletVenmoAccount>>() {
});
}

/**
* List Venmo Accounts
*
* @param userToken User token assigned
* @return HyperwalletList of HyperwalletVenmoAccount
*/
public HyperwalletList<HyperwalletVenmoAccount> listVenmoAccounts(String userToken) {
return listVenmoAccounts(userToken, null);
}

/**
* Update Venmo Account
*
* @param venmoAccount Venmo Account to Update.
* @return HyperwalletVenmoAccount Updated Venmo Account
*/
public HyperwalletVenmoAccount updateVenmoAccount(HyperwalletVenmoAccount venmoAccount) {
if (venmoAccount == null) {
throw new HyperwalletException("Venmo Account is required");
}
if (StringUtils.isEmpty(venmoAccount.getUserToken())) {
throw new HyperwalletException("User token is required");
}
if (StringUtils.isEmpty(venmoAccount.getToken())) {
throw new HyperwalletException("Venmo Account token is required");
}
return apiClient.put(url + "/users/" + venmoAccount.getUserToken() + "/venmo-accounts/" + venmoAccount.getToken(), venmoAccount,
HyperwalletVenmoAccount.class);
}

/**
* Deactivate Venmo Account
*
* @param userToken User token
* @param venmoAccountToken Venmo account token
* @return HyperwalletStatusTransition deactivated venmo account
*/
public HyperwalletStatusTransition deactivateVenmoAccount(String userToken, String venmoAccountToken) {
return deactivateVenmoAccount(userToken, venmoAccountToken, null);
}

/**
* Deactivate Venmo Account
*
* @param userToken User token
* @param venmoAccountToken Venmo account token
* @param notes Comments regarding the status change
* @return HyperwalletStatusTransition deactivated Venmo account
*/
public HyperwalletStatusTransition deactivateVenmoAccount(String userToken, String venmoAccountToken, String notes) {
return createVenmoAccountStatusTransition(userToken,
venmoAccountToken,
new HyperwalletStatusTransition(HyperwalletStatusTransition.Status.DE_ACTIVATED).notes(notes));
}

/**
* Create Venmo Account Status Transition
*
* @param userToken User token
* @param venmoAccountToken Venmo account token
* @param transition Status transition information
* @return HyperwalletStatusTransition new status for Venmo Account
*/
public HyperwalletStatusTransition createVenmoAccountStatusTransition(String userToken, String venmoAccountToken,
HyperwalletStatusTransition transition) {
if (transition == null) {
throw new HyperwalletException("Transition is required");
}
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is required");
}
if (StringUtils.isEmpty(venmoAccountToken)) {
throw new HyperwalletException("Venmo account token is required");
}
if (!StringUtils.isEmpty(transition.getToken())) {
throw new HyperwalletException("Status Transition token may not be present");
}
transition = copy(transition);
transition.setCreatedOn(null);
transition.setFromStatus(null);
transition.setToStatus(null);
return apiClient.post(url + "/users/" + userToken + "/venmo-accounts/" + venmoAccountToken + "/status-transitions", transition,
HyperwalletStatusTransition.class);
}

/**
* Get Venmo Account Status Transition
*
* @param userToken User token
* @param venmoAccountToken Venmo account token
* @param statusTransitionToken Status transition token
* @return HyperwalletStatusTransition
*/
public HyperwalletStatusTransition getVenmoAccountStatusTransition(String userToken, String venmoAccountToken, String statusTransitionToken) {
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is required");
}
if (StringUtils.isEmpty(venmoAccountToken)) {
throw new HyperwalletException("Venmo account token is required");
}
if (StringUtils.isEmpty(statusTransitionToken)) {
throw new HyperwalletException("Transition token is required");
}
return apiClient.get(url + "/users/" + userToken + "/venmo-accounts/" + venmoAccountToken + "/status-transitions/" + statusTransitionToken,
HyperwalletStatusTransition.class);
}

/**
* List All Venmo Account Status Transition information
*
* @param userToken User token
* @param venmoAccountToken Venmo account token
* @return HyperwalletList of HyperwalletStatusTransition
*/
public HyperwalletList<HyperwalletStatusTransition> listVenmoAccountStatusTransitions(String userToken, String venmoAccountToken) {
return listVenmoAccountStatusTransitions(userToken, venmoAccountToken, null);
}

/**
* List Venmo Account Status Transition information
*
* @param userToken User token
* @param venmoAccountToken Venmo account token
* @param options List filter option
* @return HyperwalletList of HyperwalletStatusTransition
*/
public HyperwalletList<HyperwalletStatusTransition> listVenmoAccountStatusTransitions(String userToken, String venmoAccountToken,
HyperwalletPaginationOptions options) {
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is required");
}
if (StringUtils.isEmpty(venmoAccountToken)) {
throw new HyperwalletException("Venmo account token is required");
}
String url = paginate(this.url + "/users/" + userToken + "/venmo-accounts/" + venmoAccountToken + "/status-transitions", options);
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletStatusTransition>>() {
});
}

//--------------------------------------
// Bank Accounts
Expand Down Expand Up @@ -1896,8 +2105,28 @@ public HyperwalletTransferMethod createTransferMethod(String jsonCacheToken, Str
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);
return apiClient.post(url + "/users/" + transferMethod.getUserToken() + "/transfer-methods", transferMethod, HyperwalletTransferMethod.class,
headers);
}

//--------------------------------------
// Upload documents for user endpoint
//--------------------------------------

/**
* Upload documents
*
* @param userToken userToken for which documents to be uploaded
* @param multiPart multipart FormdataMultipart to get uploaded
* @return HyperwalletUser user object with document upload status
*/
public HyperwalletUser documentUpload(String userToken, FormDataMultiPart multiPart) {
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is not present");
}
return apiClient.put(url + "/users/" + userToken, multiPart, HyperwalletUser.class);
}

//--------------------------------------
// Internal utils
//--------------------------------------
Expand Down Expand Up @@ -1999,22 +2228,8 @@ private HyperwalletPayPalAccount copy(HyperwalletPayPalAccount payPalAccount) {
return payPalAccount;
}

//--------------------------------------
// Upload documents for user endpoint
//--------------------------------------

/**
* Upload documents
*
* @param userToken userToken for which documents to be uploaded
* @param multiPart multipart FormdataMultipart to get uploaded
* @return HyperwalletUser user object with document upload status
*/
public HyperwalletUser documentUpload(String userToken, FormDataMultiPart multiPart) {
if (StringUtils.isEmpty(userToken)) {
throw new HyperwalletException("User token is not present");
}
return apiClient.put(url + "/users/" + userToken, multiPart, HyperwalletUser.class);
private HyperwalletVenmoAccount copy(HyperwalletVenmoAccount venmoAccount) {
return HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(venmoAccount), HyperwalletVenmoAccount.class);
}

}
33 changes: 33 additions & 0 deletions src/main/java/com/hyperwallet/clientsdk/model/HyperwalletLink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.hyperwallet.clientsdk.model;

import java.util.Map;

/**
* @author amylavarapu HyperwalletLink represents HATEOAS links
*/

public class HyperwalletLink {

public Map<String, String> params;
public String href;

public HyperwalletLink() {
}

public Map<String, String> getParams() {
return params;
}

public void setParams(Map<String, String> params) {
this.params = params;
}

public String getHref() {
return href;
}

public void setHref(String href) {
this.href = href;
}
}

34 changes: 23 additions & 11 deletions src/main/java/com/hyperwallet/clientsdk/model/HyperwalletList.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@

public class HyperwalletList<T> {

private int count;
private int offset;
private boolean hasNextPage;
private boolean hasPreviousPage;
private int limit;
private List<T> data;
private List<HyperwalletLink> links = new ArrayList<HyperwalletLink>();

private List<T> data = new ArrayList<T>();
public HyperwalletList() {
}

public int getCount() {
return count;
public boolean hasNextPage() {
return hasNextPage;
}

public void setCount(int count) {
this.count = count;
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}

public int getOffset() {
return offset;
public boolean hasPreviousPage() {
return hasPreviousPage;
}

public void setOffset(int offset) {
this.offset = offset;
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}

public int getLimit() {
Expand All @@ -42,4 +45,13 @@ public List<T> getData() {
public void setData(List<T> data) {
this.data = data;
}

public List<HyperwalletLink> getLinks() {
return links;
}

public void setLinks(List<HyperwalletLink> links) {
this.links = links;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@XmlAccessorType(XmlAccessType.FIELD)
public class HyperwalletTransferMethod extends HyperwalletBaseMonitor {

public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT}
public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT, VENMO_ACCOUNT}

public enum Status {ACTIVATED, INVALID, DE_ACTIVATED, PRE_ACTIVATED, SUSPENDED, LOST_OR_STOLEN, QUEUED, DECLINED, LOCKED, COMPLIANCE_HOLE, KYC_HOLD, VERIFIED}

Expand Down
Loading

0 comments on commit 7579dee

Please sign in to comment.