-
Notifications
You must be signed in to change notification settings - Fork 4
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 (#124)
- Loading branch information
1 parent
63e2375
commit 88ae874
Showing
10 changed files
with
163 additions
and
16 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
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)); | ||
} | ||
} | ||
} |
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
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 | ||
} | ||
} |
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 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Craftgate.Model | ||
{ | ||
public enum RecordType | ||
{ | ||
[EnumMember(Value = "SEND")] SEND, | ||
|
||
[EnumMember(Value = "RECEIVE")] RECEIVE | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Craftgate/Request/SearchBankAccountTrackingRecordsRequest.cs
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,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; | ||
} | ||
} |
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,9 @@ | ||
using Craftgate.Response.Common; | ||
using Craftgate.Response.Dto; | ||
|
||
namespace Craftgate.Response | ||
{ | ||
public class BankAccountTrackingRecordListResponse : ListResponse<BankAccountTrackingRecordResponse> | ||
{ | ||
} | ||
} |
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,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; } | ||
} | ||
} |
File renamed without changes.
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
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); | ||
} | ||
} | ||
} |