Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;

import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;

@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
Expand All @@ -33,6 +32,7 @@ public static enum Status {QUOTED, SCHEDULED, IN_PROGRESS, VERIFICATION_REQUIRED
private String notes;
private String memo;
private Date expiresOn;
private List<HyperwalletLink> links;

public String getToken() {
return token;
Expand Down Expand Up @@ -370,7 +370,29 @@ public HyperwalletTransfer clearForeignExchanges() {
return this;
}

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

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

public HyperwalletTransfer links(List<HyperwalletLink> links) {
addField("links", links);
this.links = links;
return this;
}

public HyperwalletTransfer clearLinks() {
clearField("links");
this.links = null;
return this;
}

public static class ForeignExchange {

private Double sourceAmount;
private String sourceCurrency;
private Double destinationAmount;
Expand Down
143 changes: 108 additions & 35 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.hyperwallet.clientsdk;

import com.hyperwallet.clientsdk.model.*;
import com.hyperwallet.clientsdk.model.HyperwalletBankAccount.Type;
import com.hyperwallet.clientsdk.model.HyperwalletPrepaidCard.Brand;
import com.hyperwallet.clientsdk.model.HyperwalletPrepaidCard.EReplacePrepaidCardReason;
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.CardType;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Status;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.VerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletTransferRefund.Status;
import com.hyperwallet.clientsdk.model.HyperwalletUser.Gender;
import com.hyperwallet.clientsdk.model.HyperwalletUser.ProfileType;
import org.mockserver.integration.ClientAndServer;
Expand Down Expand Up @@ -866,6 +866,15 @@ public void testCreateTransfer() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
Expand All @@ -881,11 +890,20 @@ public void testCreateTransfer() throws Exception {
assertThat(returnValue.getNotes(), is(equalTo("notes")));
assertThat(returnValue.getMemo(), is(equalTo("memo")));
assertThat(returnValue.getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getForeignExchanges().get(0).getSourceAmount(), is(equalTo(100.00)));
assertThat(returnValue.getForeignExchanges().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationAmount(), is(equalTo(63.49)));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getRate(), is(equalTo(0.79)));

ForeignExchange foreignExchange = returnValue.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(100.00)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(63.49)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getRate(), is(equalTo(0.79)));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

@Test
Expand All @@ -901,6 +919,15 @@ public void testGetTransfer() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
Expand All @@ -916,11 +943,20 @@ public void testGetTransfer() throws Exception {
assertThat(returnValue.getNotes(), is(equalTo("notes")));
assertThat(returnValue.getMemo(), is(equalTo("memo")));
assertThat(returnValue.getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getForeignExchanges().get(0).getSourceAmount(), is(equalTo(100.00)));
assertThat(returnValue.getForeignExchanges().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationAmount(), is(equalTo(63.49)));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getRate(), is(equalTo(0.79)));

ForeignExchange foreignExchange = returnValue.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(100.00)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(63.49)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getRate(), is(equalTo(0.79)));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

@Test
Expand All @@ -936,28 +972,48 @@ public void testListTransfer() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/transfers?offset=0&limit=10");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.hasNextPage(), is(equalTo(false)));
assertThat(returnValue.hasPreviousPage(), is(equalTo(false)));
assertThat(returnValue.getData().get(0).getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(returnValue.getData().get(0).getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(returnValue.getData().get(0).getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getData().get(0).getClientTransferId(), is(equalTo("clientTransferId")));
assertThat(returnValue.getData().get(0).getSourceToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(returnValue.getData().get(0).getSourceAmount(), is(equalTo(200.4)));
assertThat(returnValue.getData().get(0).getSourceFeeAmount(), is(equalTo(20.3)));
assertThat(returnValue.getData().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getDestinationToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(returnValue.getData().get(0).getDestinationAmount(), is(equalTo(100.2)));
assertThat(returnValue.getData().get(0).getDestinationFeeAmount(), is(equalTo(30.5)));
assertThat(returnValue.getData().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getNotes(), is(equalTo("notes")));
assertThat(returnValue.getData().get(0).getMemo(), is(equalTo("memo")));
assertThat(returnValue.getData().get(0).getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getSourceAmount(), is(equalTo(100.00)));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getDestinationAmount(), is(equalTo(63.49)));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getRate(), is(equalTo(0.79)));

HyperwalletTransfer hyperwalletTransfer = returnValue.getData().get(0);
assertThat(hyperwalletTransfer.getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(hyperwalletTransfer.getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(hyperwalletTransfer.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(hyperwalletTransfer.getClientTransferId(), is(equalTo("clientTransferId")));
assertThat(hyperwalletTransfer.getSourceToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(hyperwalletTransfer.getSourceAmount(), is(equalTo(200.4)));
assertThat(hyperwalletTransfer.getSourceFeeAmount(), is(equalTo(20.3)));
assertThat(hyperwalletTransfer.getSourceCurrency(), is(equalTo("USD")));
assertThat(hyperwalletTransfer.getDestinationToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(hyperwalletTransfer.getDestinationAmount(), is(equalTo(100.2)));
assertThat(hyperwalletTransfer.getDestinationFeeAmount(), is(equalTo(30.5)));
assertThat(hyperwalletTransfer.getDestinationCurrency(), is(equalTo("USD")));
assertThat(hyperwalletTransfer.getNotes(), is(equalTo("notes")));
assertThat(hyperwalletTransfer.getMemo(), is(equalTo("memo")));
assertThat(hyperwalletTransfer.getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));

ForeignExchange foreignExchange = hyperwalletTransfer.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(100.00)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(63.49)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getRate(), is(equalTo(0.79)));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

@Test
Expand All @@ -977,12 +1033,29 @@ public void testCreateTransferStatusTransition() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/transfers/trr-9e2e1a06-a33b-4c2f-9933-893ae21db442/status-transitions/sts-ed2207f0"
+ "-39cc-493f-9cd0-24998de0c0f7");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7")));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-30T19:50:49 UTC"))));
assertThat(returnValue.getTransition(), is(equalTo(SCHEDULED)));
assertThat(returnValue.getFromStatus(), is(equalTo(QUOTED)));
assertThat(returnValue.getToStatus(), is(equalTo(SCHEDULED)));
assertThat(returnValue.getNotes(), is(equalTo("Closing check.")));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

//
Expand Down Expand Up @@ -1018,7 +1091,7 @@ public void testCreateTransferRefund() throws Exception {

HyperwalletTransferRefund expectedValue = new HyperwalletTransferRefund()
.token("trd-a159dc18-eb29-4530-8733-060c7feaad0f")
.status(Status.COMPLETED)
.status(HyperwalletTransferRefund.Status.COMPLETED)
.clientRefundId("clientRefundId")
.sourceToken("act-ba4e8fdd-614b-11e5-af23-0faa28ca7c0f")
.sourceAmount(20.0)
Expand Down Expand Up @@ -1081,7 +1154,7 @@ public void testGetTransferRefund() throws Exception {

HyperwalletTransferRefund expectedValue = new HyperwalletTransferRefund()
.token("trd-19156720-01e8-4f1c-8ef3-7ced80672128")
.status(Status.COMPLETED)
.status(HyperwalletTransferRefund.Status.COMPLETED)
.clientRefundId("1573548663")
.sourceToken("act-ba4e8fdd-614b-11e5-af23-0faa28ca7c0f")
.sourceAmount(50.0)
Expand Down Expand Up @@ -1120,7 +1193,7 @@ public void testListTransferRefunds() throws Exception {
hyperwalletLinks.add(hyperwalletLink);
HyperwalletTransferRefund expectedValue = new HyperwalletTransferRefund()
.token("trd-e59d19d4-eccb-4160-b04c-4f11c83f99f0")
.status(Status.COMPLETED)
.status(HyperwalletTransferRefund.Status.COMPLETED)
.clientRefundId("1573566270")
.sourceToken("act-ba4e8fdd-614b-11e5-af23-0faa28ca7c0f")
.sourceAmount(50.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.hyperwallet.clientsdk.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class HyperwalletTransferTest extends BaseModelTest<HyperwalletTransfer> {
protected HyperwalletTransfer createBaseModel() {
Expand All @@ -12,6 +14,9 @@ protected HyperwalletTransfer createBaseModel() {
foreignExchange.setDestinationAmount(100.0);
foreignExchange.setDestinationCurrency("USD");
foreignExchange.setRate(2.3);
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
transfer
.token("test-token")
.status(HyperwalletTransfer.Status.QUOTED)
Expand All @@ -27,7 +32,8 @@ protected HyperwalletTransfer createBaseModel() {
.destinationCurrency("USD")
.notes("notes")
.memo("memo")
.expiresOn(new Date());
.expiresOn(new Date())
.links(hyperwalletLinkList);
transfer.setForeignExchanges(Collections.singletonList(foreignExchange));
return transfer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-1dea80c9-c73e-4490-91b7-097d4a07550f/paper-checks/trm-9e2e1a06-a33b-4c2f-9933-893ae21db442/status-transitions/sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trr-9e2e1a06-a33b-4c2f-9933-893ae21db442/status-transitions/sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7"
}
]
}
2 changes: 1 addition & 1 deletion src/test/resources/integration/getTransfer-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
}
]
}
4 changes: 2 additions & 2 deletions src/test/resources/integration/listTransfers-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
}
]
}
Expand All @@ -43,7 +43,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks?limit=10"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers?offset=0&limit=10"
}
]
}