From 88ae8741c5ed851b04d78a6e6405f0715672c392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alican=20Akku=C5=9F?= Date: Fri, 10 Nov 2023 12:05:44 +0300 Subject: [PATCH] adds bank account tracking adapter to retrieve bank account tracking record (#124) --- .../Adapter/BankAccountTrackingAdapter.cs | 52 +++++++++++++++++++ Craftgate/CraftgateClient.cs | 7 +++ Craftgate/Model/BankAccountTrackingSource.cs | 9 ++++ Craftgate/Model/RecordType.cs | 11 ++++ ...SearchBankAccountTrackingRecordsRequest.cs | 17 ++++++ .../BankAccountTrackingRecordListResponse.cs | 9 ++++ .../BankAccountTrackingRecordResponse.cs | 18 +++++++ .../{StoredCard.cs => StoredCardResponse.cs} | 0 README.md | 16 ------ Samples/BankAccountTrackingSample.cs | 40 ++++++++++++++ 10 files changed, 163 insertions(+), 16 deletions(-) create mode 100644 Craftgate/Adapter/BankAccountTrackingAdapter.cs create mode 100644 Craftgate/Model/BankAccountTrackingSource.cs create mode 100644 Craftgate/Model/RecordType.cs create mode 100644 Craftgate/Request/SearchBankAccountTrackingRecordsRequest.cs create mode 100644 Craftgate/Response/BankAccountTrackingRecordListResponse.cs create mode 100644 Craftgate/Response/BankAccountTrackingRecordResponse.cs rename Craftgate/Response/{StoredCard.cs => StoredCardResponse.cs} (100%) create mode 100644 Samples/BankAccountTrackingSample.cs diff --git a/Craftgate/Adapter/BankAccountTrackingAdapter.cs b/Craftgate/Adapter/BankAccountTrackingAdapter.cs new file mode 100644 index 0000000..138e8af --- /dev/null +++ b/Craftgate/Adapter/BankAccountTrackingAdapter.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Craftgate.Net; +using Craftgate.Request; +using Craftgate.Request.Common; +using Craftgate.Response; +using Craftgate.Response.Dto; + +namespace Craftgate.Adapter +{ + public class BankAccountTrackingAdapter : BaseAdapter + { + public BankAccountTrackingAdapter(RequestOptions requestOptions) : base(requestOptions) + { + } + + public BankAccountTrackingRecordListResponse SearchRecords(SearchBankAccountTrackingRecordsRequest request) + { + var query = RequestQueryParamsBuilder.BuildQueryParam(request); + var path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records" + query; + + return RestClient.Get(RequestOptions.BaseUrl + path, + CreateHeaders(path, RequestOptions)); + } + + public Task SearchRecordsAsync(SearchBankAccountTrackingRecordsRequest request) + { + var query = RequestQueryParamsBuilder.BuildQueryParam(request); + var path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records" + query; + + return AsyncRestClient.Get(RequestOptions.BaseUrl + path, + CreateHeaders(path, RequestOptions)); + } + + public BankAccountTrackingRecordResponse RetrieveRecord(decimal Id) + { + var path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records/" + Id; + + return RestClient.Get(RequestOptions.BaseUrl + path, + CreateHeaders(path, RequestOptions)); + } + + public Task RetrieveRecordAsync(decimal Id) + { + var path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records/" + Id; + + return AsyncRestClient.Get(RequestOptions.BaseUrl + path, + CreateHeaders(path, RequestOptions)); + } + } +} \ No newline at end of file diff --git a/Craftgate/CraftgateClient.cs b/Craftgate/CraftgateClient.cs index 30b6108..412d8b7 100644 --- a/Craftgate/CraftgateClient.cs +++ b/Craftgate/CraftgateClient.cs @@ -18,6 +18,7 @@ public class CraftgateClient private readonly WalletAdapter _walletAdapter; private readonly HookAdapter _hookAdapter; private readonly MasterpassPaymentAdapter _masterpassPaymentAdapter; + private readonly BankAccountTrackingAdapter _bankAccountTrackingAdapter; public CraftgateClient(string apiKey, string secretKey) : this(apiKey, secretKey, BaseUrl, null) @@ -51,6 +52,7 @@ public CraftgateClient(string apiKey, string secretKey, string baseUrl, string l _fraudAdapter = new FraudAdapter(requestOptions); _hookAdapter = new HookAdapter(requestOptions); _masterpassPaymentAdapter = new MasterpassPaymentAdapter(requestOptions); + _bankAccountTrackingAdapter = new BankAccountTrackingAdapter(requestOptions); } public PaymentAdapter Payment() @@ -112,5 +114,10 @@ public MasterpassPaymentAdapter Masterpass() { return _masterpassPaymentAdapter; } + + public BankAccountTrackingAdapter BankAccountTracking() + { + return _bankAccountTrackingAdapter; + } } } \ No newline at end of file diff --git a/Craftgate/Model/BankAccountTrackingSource.cs b/Craftgate/Model/BankAccountTrackingSource.cs new file mode 100644 index 0000000..b841373 --- /dev/null +++ b/Craftgate/Model/BankAccountTrackingSource.cs @@ -0,0 +1,9 @@ +using System.Runtime.Serialization; + +namespace Craftgate.Model +{ + public enum BankAccountTrackingSource + { + [EnumMember(Value = "YKB")] YKB + } +} \ No newline at end of file diff --git a/Craftgate/Model/RecordType.cs b/Craftgate/Model/RecordType.cs new file mode 100644 index 0000000..5643431 --- /dev/null +++ b/Craftgate/Model/RecordType.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace Craftgate.Model +{ + public enum RecordType + { + [EnumMember(Value = "SEND")] SEND, + + [EnumMember(Value = "RECEIVE")] RECEIVE + } +} \ No newline at end of file diff --git a/Craftgate/Request/SearchBankAccountTrackingRecordsRequest.cs b/Craftgate/Request/SearchBankAccountTrackingRecordsRequest.cs new file mode 100644 index 0000000..2f0db5a --- /dev/null +++ b/Craftgate/Request/SearchBankAccountTrackingRecordsRequest.cs @@ -0,0 +1,17 @@ +using System; +using Craftgate.Model; + +namespace Craftgate.Request +{ + public class SearchBankAccountTrackingRecordsRequest + { + public string SenderName { get; set; } + public string SenderIban { get; set; } + public string Description { get; set; } + public Currency? Currency { get; set; } + public DateTime? MinRecordDate { get; set; } + public DateTime? MaxRecordDate { get; set; } + public int Page { get; set; } = 0; + public int Size { get; set; } = 10; + } +} \ No newline at end of file diff --git a/Craftgate/Response/BankAccountTrackingRecordListResponse.cs b/Craftgate/Response/BankAccountTrackingRecordListResponse.cs new file mode 100644 index 0000000..9eee40b --- /dev/null +++ b/Craftgate/Response/BankAccountTrackingRecordListResponse.cs @@ -0,0 +1,9 @@ +using Craftgate.Response.Common; +using Craftgate.Response.Dto; + +namespace Craftgate.Response +{ + public class BankAccountTrackingRecordListResponse : ListResponse + { + } +} \ No newline at end of file diff --git a/Craftgate/Response/BankAccountTrackingRecordResponse.cs b/Craftgate/Response/BankAccountTrackingRecordResponse.cs new file mode 100644 index 0000000..c9294cd --- /dev/null +++ b/Craftgate/Response/BankAccountTrackingRecordResponse.cs @@ -0,0 +1,18 @@ +using System; +using Craftgate.Model; + +namespace Craftgate.Response.Dto +{ + public class BankAccountTrackingRecordResponse + { + public long Id { get; set; } + public string SenderName { get; set; } + public string SenderIban { get; set; } + public string Description { get; set; } + public decimal Amount { get; set; } + public Currency Currency { get; set; } + public DateTime RecordDate { get; set; } + public RecordType RecordType { get; set; } + public BankAccountTrackingSource BankAccountTrackingSource { get; set; } + } +} \ No newline at end of file diff --git a/Craftgate/Response/StoredCard.cs b/Craftgate/Response/StoredCardResponse.cs similarity index 100% rename from Craftgate/Response/StoredCard.cs rename to Craftgate/Response/StoredCardResponse.cs diff --git a/README.md b/README.md index 01dac4c..5de951b 100644 --- a/README.md +++ b/README.md @@ -96,22 +96,6 @@ var response = _craftgate.Payment().CreatePayment(request); Assert.NotNull(response); ``` -### Advanced Usage: Adapters -In reality, the `Craftgate` class serves as a collection of adapters that integrates with different parts of the API. While the intended usage for most use-cases is to instantiate a `Craftgate` instance (as illustrated in the examples above) and use its adapter accessors (e.g. `payment()`), you can also manually import a certain adapter class and instantiate it. - -**Note:** When instantiating an adapter, you can use the same options as you would when instantiating a `Craftgate` - -For all adapters in the `Craftgate`, their purposes, accessors, as well as direct import paths, refer to the list below: - -| Adapter Name | Purpose | Accessor | -|--------------|---------|----------| -| `InstallmentAdapter` | Retrieving per-installment pricing information based on installment count or BIN number | `Installment()` | -| `OnboardingAdapter` | Conducting CRUD operations on members like buyers and submerchants | `Onboarding()` | -| `PaymentAdapter` | Conducting payments, retrieving payment information, managing stored cards | `Payment()` | -| `WalletAdapter` | Wallet operations like send, receive remittance and search wallets or wallet transactions of member's | `Wallet()` | -| `SettlementReportingAdapter` | Settlement operations like search payout completed transactions, search bounced payout transactions | `SettlementReporting()` | -| `SettlementAdapter` | Settlement operations like create instant wallet settlement | `Settlement()` | - ### Contributions For all contributions to this client please see the contribution guide [here](CONTRIBUTING.md). diff --git a/Samples/BankAccountTrackingSample.cs b/Samples/BankAccountTrackingSample.cs new file mode 100644 index 0000000..17651cd --- /dev/null +++ b/Samples/BankAccountTrackingSample.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Craftgate; +using Craftgate.Model; +using Craftgate.Request; +using Craftgate.Request.Dto; +using NUnit.Framework; + +namespace Samples +{ + public class BankAccountTrackingSample + { + private readonly CraftgateClient _craftgateClient = + new CraftgateClient("api-key", "secret-key", "http://localhost:8000"); + + [Test] + public void Search_Bank_Account_Tracking_Records() + { + var request = new SearchBankAccountTrackingRecordsRequest() + { + Currency = Currency.TRY, + Page = 0, + Size = 10 + }; + + var response = _craftgateClient.BankAccountTracking().SearchRecords(request); + Assert.NotNull(response); + Assert.True(response.Items.Count > 0); + } + + [Test] + public void Retrieve_Bank_Account_Tracking_Record() + { + var Id = 1; + var response = _craftgateClient.BankAccountTracking().RetrieveRecord(Id); + Assert.NotNull(response); + Assert.Equals(response.Id, Id); + } + } +} \ No newline at end of file