-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds bank account tracking adapter to retrieve bank account tracking …
…record (#130)
- Loading branch information
1 parent
fa82269
commit b328569
Showing
9 changed files
with
145 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/io/craftgate/adapter/BankAccountTrackingAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.craftgate.adapter; | ||
|
||
import io.craftgate.net.HttpClient; | ||
import io.craftgate.request.SearchBankAccountTrackingRecordsRequest; | ||
import io.craftgate.request.common.RequestOptions; | ||
import io.craftgate.request.common.RequestQueryParamsBuilder; | ||
import io.craftgate.response.BankAccountTrackingRecordListResponse; | ||
import io.craftgate.response.BankAccountTrackingRecordResponse; | ||
|
||
public class BankAccountTrackingAdapter extends BaseAdapter { | ||
|
||
public BankAccountTrackingAdapter(RequestOptions requestOptions) { | ||
super(requestOptions); | ||
} | ||
|
||
public BankAccountTrackingRecordListResponse searchRecords(SearchBankAccountTrackingRecordsRequest request) { | ||
String query = RequestQueryParamsBuilder.buildQueryParam(request); | ||
String path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records" + query; | ||
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), BankAccountTrackingRecordListResponse.class); | ||
} | ||
|
||
public BankAccountTrackingRecordResponse retrieveRecord(Long id) { | ||
String path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records/" + id; | ||
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), BankAccountTrackingRecordResponse.class); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/io/craftgate/model/BankAccountTrackingSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.craftgate.model; | ||
|
||
public enum BankAccountTrackingSource { | ||
YKB | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.craftgate.model; | ||
|
||
public enum RecordType { | ||
|
||
SEND, | ||
RECEIVE | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/io/craftgate/request/SearchBankAccountTrackingRecordsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.craftgate.request; | ||
|
||
import io.craftgate.model.CardAssociation; | ||
import io.craftgate.model.CardExpiryStatus; | ||
import io.craftgate.model.CardType; | ||
import io.craftgate.model.Currency; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@Builder | ||
public class SearchBankAccountTrackingRecordsRequest { | ||
|
||
private Currency currency; | ||
private String description; | ||
private String senderName; | ||
private String senderIban; | ||
private LocalDateTime minRecordDate; | ||
private LocalDateTime maxRecordDate; | ||
|
||
@Builder.Default | ||
private Integer page = 0; | ||
|
||
@Builder.Default | ||
private Integer size = 10; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/craftgate/response/BankAccountTrackingRecordListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.craftgate.response; | ||
|
||
import io.craftgate.response.common.ListResponse; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class BankAccountTrackingRecordListResponse extends ListResponse<BankAccountTrackingRecordResponse> { | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/io/craftgate/response/BankAccountTrackingRecordResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.craftgate.response; | ||
|
||
import io.craftgate.model.BankAccountTrackingSource; | ||
import io.craftgate.model.Currency; | ||
import io.craftgate.model.RecordType; | ||
import lombok.Data; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
public class BankAccountTrackingRecordResponse { | ||
|
||
private Long id; | ||
private String key; | ||
private Currency currency; | ||
private RecordType recordType; | ||
private String senderName; | ||
private String senderIban; | ||
private String description; | ||
private LocalDateTime recordDate; | ||
private BigDecimal amount; | ||
private BankAccountTrackingSource bankAccountTrackingSource; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/io/craftgate/sample/BankAccountTrackingSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.craftgate.sample; | ||
|
||
import io.craftgate.Craftgate; | ||
import io.craftgate.model.Currency; | ||
import io.craftgate.request.SearchBankAccountTrackingRecordsRequest; | ||
import io.craftgate.response.BankAccountTrackingRecordListResponse; | ||
import io.craftgate.response.BankAccountTrackingRecordResponse; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class BankAccountTrackingSample { | ||
|
||
private final Craftgate craftgate = new Craftgate("api-key", "secret-key", "https://sandbox-api.craftgate.io"); | ||
|
||
@Test | ||
void search_bank_account_tracking_records() { | ||
SearchBankAccountTrackingRecordsRequest request = SearchBankAccountTrackingRecordsRequest.builder() | ||
.page(0) | ||
.size(10) | ||
.currency(Currency.TRY) | ||
.build(); | ||
|
||
BankAccountTrackingRecordListResponse response = craftgate.bankAccountTracking().searchRecords(request); | ||
assertNotNull(response); | ||
assertFalse(response.getItems().isEmpty()); | ||
} | ||
|
||
@Test | ||
void retrieve_bank_account_tracking_record() { | ||
Long recordId = 326L; | ||
BankAccountTrackingRecordResponse response = craftgate.bankAccountTracking().retrieveRecord(recordId); | ||
assertNotNull(response); | ||
assertEquals(response.getId(), recordId); | ||
} | ||
} |