Skip to content

Commit

Permalink
changes search wallet function to retrieve member wallet (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterSlave authored May 17, 2021
1 parent 5efcf8f commit 529d8e1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 38 deletions.
7 changes: 3 additions & 4 deletions src/main/java/io/craftgate/adapter/WalletAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ public WalletAdapter(RequestOptions requestOptions) {
super(requestOptions);
}

public WalletListResponse searchWallets(SearchWalletsRequest searchWalletsRequest) {
String query = RequestQueryParamsBuilder.buildQueryParam(searchWalletsRequest);
String path = "/wallet/v1/wallets" + query;
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), WalletListResponse.class);
public WalletResponse retrieveMemberWallet(Long memberId) {
String path = "/wallet/v1/members/" + memberId + "/wallet";
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), WalletResponse.class);
}

public WalletTransactionListResponse searchWalletTransactions(Long walletId, SearchWalletTransactionsRequest searchWalletTransactionsRequest) {
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/io/craftgate/request/SearchWalletsRequest.java

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/io/craftgate/response/WalletListResponse.java

This file was deleted.

1 change: 1 addition & 0 deletions src/main/java/io/craftgate/response/WalletResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class WalletResponse {
private LocalDateTime createdDate;
private LocalDateTime updatedDate;
private BigDecimal amount;
private BigDecimal withdrawalAmount;
private Currency currency;
private Long memberId;
}
16 changes: 10 additions & 6 deletions src/test/java/io/craftgate/sample/WalletSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ public class WalletSample {
private final Craftgate craftgate = new Craftgate("api-key", "secret-key", "https://sandbox-api.craftgate.io");

@Test
void search_wallets() {
SearchWalletsRequest request = SearchWalletsRequest.builder()
.memberId(1L)
.build();
void retrieveMemberWallet() {
Long memberId = 1L;

WalletListResponse response = craftgate.wallet().searchWallets(request);
assertTrue(response.getItems().size() > 0);
WalletResponse response = craftgate.wallet().retrieveMemberWallet(memberId);

assertNotNull(response.getId());
assertNotNull(response.getCreatedDate());
assertNotNull(response.getAmount());
assertNotNull(response.getWithdrawalAmount());
assertEquals(memberId, response.getMemberId());
assertEquals(Currency.TRY, response.getCurrency());
}

@Test
Expand Down

0 comments on commit 529d8e1

Please sign in to comment.