Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds bank account tracking adapter to retrieve bank account tracking record #124

Merged
merged 4 commits into from
Nov 10, 2023
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
52 changes: 52 additions & 0 deletions Craftgate/Adapter/BankAccountTrackingAdapter.cs
Original file line number Diff line number Diff line change
@@ -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<BankAccountTrackingRecordListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public Task<BankAccountTrackingRecordListResponse> SearchRecordsAsync(SearchBankAccountTrackingRecordsRequest request)
{
var query = RequestQueryParamsBuilder.BuildQueryParam(request);
var path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records" + query;

return AsyncRestClient.Get<BankAccountTrackingRecordListResponse>(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<BankAccountTrackingRecordResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public Task<BankAccountTrackingRecordResponse> RetrieveRecordAsync(decimal Id)
{
var path = "/bank-account-tracking/v1/merchant-bank-account-trackings/records/" + Id;

return AsyncRestClient.Get<BankAccountTrackingRecordResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}
}
}
7 changes: 7 additions & 0 deletions Craftgate/CraftgateClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -112,5 +114,10 @@ public MasterpassPaymentAdapter Masterpass()
{
return _masterpassPaymentAdapter;
}

public BankAccountTrackingAdapter BankAccountTracking()
{
return _bankAccountTrackingAdapter;
}
}
}
9 changes: 9 additions & 0 deletions Craftgate/Model/BankAccountTrackingSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Runtime.Serialization;

namespace Craftgate.Model
{
public enum BankAccountTrackingSource
{
[EnumMember(Value = "YKB")] YKB
}
}
11 changes: 11 additions & 0 deletions Craftgate/Model/RecordType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.Serialization;

namespace Craftgate.Model
{
public enum RecordType
{
[EnumMember(Value = "SEND")] SEND,

[EnumMember(Value = "RECEIVE")] RECEIVE
}
}
17 changes: 17 additions & 0 deletions Craftgate/Request/SearchBankAccountTrackingRecordsRequest.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
9 changes: 9 additions & 0 deletions Craftgate/Response/BankAccountTrackingRecordListResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Craftgate.Response.Common;
using Craftgate.Response.Dto;

namespace Craftgate.Response
{
public class BankAccountTrackingRecordListResponse : ListResponse<BankAccountTrackingRecordResponse>
{
}
}
18 changes: 18 additions & 0 deletions Craftgate/Response/BankAccountTrackingRecordResponse.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
40 changes: 40 additions & 0 deletions Samples/BankAccountTrackingSample.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Loading