Skip to content

Commit

Permalink
changes to bankcard list query parameters for v4
Browse files Browse the repository at this point in the history
  • Loading branch information
saikgupta committed Jun 8, 2021
1 parent 475d21f commit 2cf2ced
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 34 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.model.*;
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;
import com.hyperwallet.clientsdk.util.*;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -774,7 +775,7 @@ public HyperwalletBankCard createBankCard(HyperwalletBankCard bankCard) {
throw new HyperwalletException("Bank Card token may not be present");
}
if (bankCard.getType() == null) {
bankCard.setType(HyperwalletTransferMethod.Type.BANK_CARD);
bankCard.setType(Type.BANK_CARD);
}
bankCard = copy(bankCard);
bankCard.setStatus(null);
Expand Down Expand Up @@ -837,7 +838,7 @@ public HyperwalletList<HyperwalletBankCard> listBankCards(String userToken) {
* @param options List filter option
* @return HyperwalletList of HyperwalletBankCard
*/
public HyperwalletList<HyperwalletBankCard> listBankCards(String userToken, HyperwalletListPaginationOptions options) {
public HyperwalletList<HyperwalletBankCard> listBankCards(String userToken, HyperwalletBankCardListPaginationOptions options) {


if (StringUtils.isEmpty(userToken)) {
Expand All @@ -846,6 +847,7 @@ public HyperwalletList<HyperwalletBankCard> listBankCards(String userToken, Hype
String url = paginate(this.url + "/users/" + userToken + "/bank-cards", options);
if (options != null) {
url = addParameter(url, "status", options.getStatus());
url = addParameter(url, "type", options.getType());
}
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletBankCard>>() {
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public enum Brand {VISA, MASTERCARD}

public enum CardType {DEBIT}

private HyperwalletTransferMethod.Type type;
public enum Type {BANK_CARD}

public enum Status {ACTIVATED, INVALID, VERIFIED,DE_ACTIVATED}
private Type type;
private String token;
private HyperwalletTransferMethod.Status status;
private Status status;
private Date createdOn;

private String transferMethodCountry;
Expand All @@ -36,16 +39,16 @@ public enum CardType {DEBIT}
private String processingTime;
private List<HyperwalletLink> links;

public HyperwalletTransferMethod.Type getType() {
public Type getType() {
return type;
}

public void setType(HyperwalletTransferMethod.Type type) {
public void setType(Type type) {
addField("type", type);
this.type = type;
}

public HyperwalletBankCard type(HyperwalletTransferMethod.Type type) {
public HyperwalletBankCard type(Type type) {
addField("type", type);
this.type = type;
return this;
Expand Down Expand Up @@ -78,16 +81,16 @@ public HyperwalletBankCard clearToken() {
return this;
}

public HyperwalletTransferMethod.Status getStatus() {
public Status getStatus() {
return status;
}

public void setStatus(HyperwalletTransferMethod.Status status) {
public void setStatus(Status status) {
addField("status", status);
this.status = status;
}

public HyperwalletBankCard status(HyperwalletTransferMethod.Status status) {
public HyperwalletBankCard status(Status status) {
addField("status", status);
this.status = status;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
package com.hyperwallet.clientsdk.model;public class HyperwalletBankCardListPaginationOptions {
}
package com.hyperwallet.clientsdk.model;

public class HyperwalletBankCardListPaginationOptions extends HyperwalletPaginationOptions{
private HyperwalletBankCard.Type type;
private HyperwalletBankCard.Status status;

public HyperwalletBankCard.Status getStatus() {
return status;
}

public void setStatus(HyperwalletBankCard.Status status) {
this.status = status;
}

public HyperwalletBankCardListPaginationOptions status(HyperwalletBankCard.Status status) {
this.status = status;
return this;
}

public void setType(HyperwalletBankCard.Type type) {
this.type = type;
}

public HyperwalletBankCard.Type getType() {
return type;
}

public HyperwalletBankCardListPaginationOptions type(HyperwalletBankCard.Type type) {
this.type = type;
return this;
}
}
23 changes: 13 additions & 10 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.hyperwallet.clientsdk.model.*;
import com.hyperwallet.clientsdk.model.HyperwalletPrepaidCard.Brand;
import com.hyperwallet.clientsdk.model.HyperwalletPrepaidCard.EReplacePrepaidCardReason;
import com.hyperwallet.clientsdk.model.HyperwalletStatusTransition.Status;
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.CardType;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Type;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.VerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletUser.Gender;
import com.hyperwallet.clientsdk.model.HyperwalletUser.GovernmentIdType;
Expand Down Expand Up @@ -471,8 +473,8 @@ public void testCreateBankCard() throws Exception {
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransferMethod.Status.ACTIVATED)));
assertThat(returnValue.getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletBankCard.Status.ACTIVATED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-11-09T22:50:14 UTC"))));
assertThat(returnValue.getTransferMethodCountry(), is(equalTo("US")));
assertThat(returnValue.getTransferMethodCurrency(), is(equalTo("USD")));
Expand Down Expand Up @@ -518,8 +520,8 @@ public void testUpdateBankCard() throws Exception {
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransferMethod.Status.ACTIVATED)));
assertThat(returnValue.getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletBankCard.Status.ACTIVATED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-11-09T22:50:14 UTC"))));
assertThat(returnValue.getTransferMethodCountry(), is(equalTo("US")));
assertThat(returnValue.getTransferMethodCurrency(), is(equalTo("USD")));
Expand Down Expand Up @@ -560,8 +562,8 @@ public void testGetBankCard() throws Exception {
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransferMethod.Status.ACTIVATED)));
assertThat(returnValue.getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletBankCard.Status.ACTIVATED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-11-09T22:50:14 UTC"))));
assertThat(returnValue.getTransferMethodCountry(), is(equalTo("US")));
assertThat(returnValue.getTransferMethodCurrency(), is(equalTo("USD")));
Expand All @@ -585,8 +587,9 @@ public void testListBankCard() throws Exception {

HyperwalletList<HyperwalletBankCard> returnValue;

HyperwalletListPaginationOptions options = new HyperwalletListPaginationOptions();
options.status(HyperwalletTransferMethod.Status.ACTIVATED)
HyperwalletBankCardListPaginationOptions options = new HyperwalletBankCardListPaginationOptions();
options.status(HyperwalletBankCard.Status.ACTIVATED)
.type(HyperwalletBankCard.Type.BANK_CARD)
.sortBy("test-sort-by")
.limit(10)
.createdAfter(convertStringToDate("2016-06-29T17:58:26Z"))
Expand All @@ -611,8 +614,8 @@ public void testListBankCard() throws Exception {
assertThat(returnValue.hasNextPage(), is(equalTo(true)));
assertThat(returnValue.hasPreviousPage(), is(equalTo(true)));
assertThat(returnValue.getData().get(0).getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getData().get(0).getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
assertThat(returnValue.getData().get(0).getStatus(), is(equalTo(HyperwalletTransferMethod.Status.ACTIVATED)));
assertThat(returnValue.getData().get(0).getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
assertThat(returnValue.getData().get(0).getStatus(), is(equalTo(HyperwalletBankCard.Status.ACTIVATED)));
assertThat(returnValue.getData().get(0).getCreatedOn(), is(equalTo(dateFormat.parse("2017-11-09T22:50:14 UTC"))));
assertThat(returnValue.getData().get(0).getTransferMethodCountry(), is(equalTo("US")));
assertThat(returnValue.getData().get(0).getTransferMethodCurrency(), is(equalTo("USD")));
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ public void testCreateBankCard_prepaidCardTokenSpecified() {
public void testCreateBankCard_noType() throws Exception {
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard.setUserToken("test-user-token");
bankCard.setStatus(HyperwalletTransferMethod.Status.ACTIVATED);
bankCard.setStatus(HyperwalletBankCard.Status.ACTIVATED);
bankCard.setCreatedOn(new Date());
bankCard.setCardType(HyperwalletBankCard.CardType.DEBIT);
bankCard.setTransferMethodCountry("test-transfer-method-country");
Expand All @@ -1681,7 +1681,7 @@ public void testCreateBankCard_noType() throws Exception {

HyperwalletBankCard apiClientBankCard = argument.getValue();
assertThat(apiClientBankCard, is(notNullValue()));
assertThat(apiClientBankCard.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
assertThat(apiClientBankCard.getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
assertThat(apiClientBankCard.getStatus(), is(nullValue()));
assertThat(apiClientBankCard.getCreatedOn(), is(nullValue()));
assertThat(apiClientBankCard.getCardType(), is(nullValue()));
Expand All @@ -1692,8 +1692,8 @@ public void testCreateBankCard_noType() throws Exception {
public void testCreateBankCard_withType() throws Exception {
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard.setUserToken("test-user-token");
bankCard.setType(HyperwalletTransferMethod.Type.BANK_ACCOUNT);
bankCard.setStatus(HyperwalletTransferMethod.Status.ACTIVATED);
bankCard.setType(HyperwalletBankCard.Type.BANK_CARD);
bankCard.setStatus(HyperwalletBankCard.Status.ACTIVATED);
bankCard.setCreatedOn(new Date());
bankCard.setCardType(HyperwalletBankCard.CardType.DEBIT);
bankCard.setTransferMethodCountry("test-transfer-method-country");
Expand All @@ -1720,7 +1720,7 @@ public void testCreateBankCard_withType() throws Exception {

HyperwalletBankCard apiClienBankCard = argument.getValue();
assertThat(apiClienBankCard, is(notNullValue()));
assertThat(apiClienBankCard.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_ACCOUNT)));
assertThat(apiClienBankCard.getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
assertThat(apiClienBankCard.getStatus(), is(nullValue()));
assertThat(apiClienBankCard.getCreatedOn(), is(nullValue()));
assertThat(apiClienBankCard.getCardType(), is(nullValue()));
Expand Down Expand Up @@ -1893,7 +1893,7 @@ public void testListBankCards_noParameters() throws Exception {
public void testListBankCards_withParameters_noUserToken() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
try {
client.listBankCards(null, new HyperwalletListPaginationOptions());
client.listBankCards(null, new HyperwalletBankCardListPaginationOptions());
fail("Expect HyperwalletException");
} catch (HyperwalletException e) {
assertThat(e.getErrorCode(), is(nullValue()));
Expand All @@ -1912,9 +1912,9 @@ public void testListBankCards_withParameters() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

HyperwalletListPaginationOptions options = new HyperwalletListPaginationOptions();
HyperwalletBankCardListPaginationOptions options = new HyperwalletBankCardListPaginationOptions();
options
.status(HyperwalletTransferMethod.Status.ACTIVATED)
.status(HyperwalletBankCard.Status.ACTIVATED)
.sortBy("test-sort-by")
.limit(10)
.createdAfter(convertStringToDate("2016-06-29T17:58:26Z"))
Expand All @@ -1937,7 +1937,7 @@ public void testListBankCards_withSomeParameters() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

HyperwalletListPaginationOptions options = new HyperwalletListPaginationOptions();
HyperwalletBankCardListPaginationOptions options = new HyperwalletBankCardListPaginationOptions();
options
.sortBy("test-sort-by")
.createdBefore(convertStringToDate("2019-06-29T17:58:26Z"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
package com.hyperwallet.clientsdk.model;public class HyperwalletBankCardListPaginationOptionsTest {
package com.hyperwallet.clientsdk.model;

import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;

public class HyperwalletBankCardListPaginationOptionsTest extends BaseModelTest<HyperwalletBankCardListPaginationOptions> {
protected HyperwalletBankCardListPaginationOptions createBaseModel() {
HyperwalletBankCardListPaginationOptions options = new HyperwalletBankCardListPaginationOptions();
options
.type(Type.BANK_CARD)
.status(HyperwalletBankCard.Status.ACTIVATED);
return options;
}

protected Class<HyperwalletBankCardListPaginationOptions> createModelClass() {
return HyperwalletBankCardListPaginationOptions.class;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.hyperwallet.clientsdk.model;

import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Status;
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand All @@ -12,9 +15,9 @@ protected HyperwalletBankCard createBaseModel() {
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard
.token("test-token")
.type(HyperwalletTransferMethod.Type.PREPAID_CARD)
.type(Type.BANK_CARD)

.status(HyperwalletTransferMethod.Status.ACTIVATED)
.status(Status.ACTIVATED)
.createdOn(new Date())
.transferMethodCountry("test-transfer-method-country")
.transferMethodCurrency("test-transfer-method-currency")
Expand Down

0 comments on commit 2cf2ced

Please sign in to comment.