Skip to content

Commit

Permalink
Added user receipt endpoint
Browse files Browse the repository at this point in the history
Modified Changelog
  • Loading branch information
fkrauthan-hyperwallet committed Jul 21, 2016
1 parent 2c8cfb8 commit 20ab438
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
0.2.0 (in progress)
-------------------

- Added list program account receipt endpoint
- Added list user receipt endpoint
- Added list prepaid card receipt endpoint

0.1.0 (2016-06-30)
------------------

Expand Down
90 changes: 90 additions & 0 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,96 @@ public void testListProgramAccountReceipts_withSomeParameters() throws Exception
Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v3/programs/test-program-token/accounts/test-account-token/receipts?createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by&offset=5"), Mockito.any(TypeReference.class));
}

@Test
public void testListUserReceipts_noParameters_noUserToken() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
try {
client.listUserReceipts(null, null);
fail("Expect HyperwalletException");
} catch (HyperwalletException e) {
assertThat(e.getErrorCode(), is(nullValue()));
assertThat(e.getResponse(), is(nullValue()));
assertThat(e.getErrorMessage(), is(equalTo("User token is required")));
assertThat(e.getMessage(), is(equalTo("User token is required")));
assertThat(e.getHyperwalletErrors(), is(nullValue()));
}
}

@Test
public void testListUserReceipts_noParameters() throws Exception {
HyperwalletList<HyperwalletReceipt> response = new HyperwalletList<HyperwalletReceipt>();

Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

Mockito.when(mockApiClient.get(Mockito.anyString(), Mockito.any(TypeReference.class))).thenReturn(response);

HyperwalletList<HyperwalletReceipt> resp = client.listUserReceipts("test-user-token");
assertThat(resp, is(equalTo(response)));

Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v3/users/test-user-token/receipts"), Mockito.any(TypeReference.class));
}

@Test
public void testListUserReceipts_withParameters_noUserToken() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
try {
client.listUserReceipts(null, new HyperwalletReceiptPaginationOptions());
fail("Expect HyperwalletException");
} catch (HyperwalletException e) {
assertThat(e.getErrorCode(), is(nullValue()));
assertThat(e.getResponse(), is(nullValue()));
assertThat(e.getErrorMessage(), is(equalTo("User token is required")));
assertThat(e.getMessage(), is(equalTo("User token is required")));
assertThat(e.getHyperwalletErrors(), is(nullValue()));
}
}

@Test
public void testListUserReceipts_withParameters() throws Exception {
HyperwalletList<HyperwalletReceipt> response = new HyperwalletList<HyperwalletReceipt>();

Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

HyperwalletReceiptPaginationOptions options = new HyperwalletReceiptPaginationOptions();
options
.type(HyperwalletReceipt.Type.ANNUAL_FEE)
.sortBy("test-sort-by")
.offset(5)
.limit(10)
.createdAfter(convertStringToDate("2016-06-29T17:58:26Z"))
.createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));

Mockito.when(mockApiClient.get(Mockito.anyString(), Mockito.any(TypeReference.class))).thenReturn(response);

HyperwalletList<HyperwalletReceipt> resp = client.listUserReceipts("test-user-token", options);
assertThat(resp, is(equalTo(response)));

Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v3/users/test-user-token/receipts?createdAfter=2016-06-29T17:58:26Z&createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by&offset=5&limit=10&type=ANNUAL_FEE"), Mockito.any(TypeReference.class));
}

@Test
public void testListUserReceipts_withSomeParameters() throws Exception {
HyperwalletList<HyperwalletReceipt> response = new HyperwalletList<HyperwalletReceipt>();

Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

HyperwalletReceiptPaginationOptions options = new HyperwalletReceiptPaginationOptions();
options
.sortBy("test-sort-by")
.offset(5)
.createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));

Mockito.when(mockApiClient.get(Mockito.anyString(), Mockito.any(TypeReference.class))).thenReturn(response);

HyperwalletList<HyperwalletReceipt> resp = client.listUserReceipts("test-user-token", options);
assertThat(resp, is(equalTo(response)));

Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v3/users/test-user-token/receipts?createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by&offset=5"), Mockito.any(TypeReference.class));
}

@Test
public void testListPrepaidCardReceipts_noParameters_noUserToken() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
Expand Down

0 comments on commit 20ab438

Please sign in to comment.