Skip to content

Commit

Permalink
Merge branch 'master' into apple-pay
Browse files Browse the repository at this point in the history
  • Loading branch information
onurpolattimur committed Mar 22, 2024
2 parents a5ae6fe + 382a8bb commit 2747874
Show file tree
Hide file tree
Showing 84 changed files with 1,794 additions and 80 deletions.
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));
}
}
}
2 changes: 1 addition & 1 deletion Craftgate/Adapter/BaseAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RequestOptions options
headers.Add(ApiKeyHeaderName, options.ApiKey);
headers.Add(RandomHeaderName, randomString);
headers.Add(AuthVersionHeaderName, ApiVersionHeaderValue);
headers.Add(ClientVersionHeaderName, ClientVersionHeaderValue + ":1.0.48");
headers.Add(ClientVersionHeaderName, ClientVersionHeaderValue + ":1.0.55");
headers.Add(SignatureHeaderName, PrepareAuthorizationString(request, path, randomString, options));
if (options.Language != null)
{
Expand Down
40 changes: 20 additions & 20 deletions Craftgate/Adapter/FraudAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,26 @@ public Task<FraudValueListResponse> RetrieveValueListAsync(string listName)
CreateHeaders(path, RequestOptions));
}

public void CreateValueList(string listName)
public void CreateValueList(string listName, FraudValueType type)
{
AddValueToValueList(listName, null, null);
AddValueToValueList(new FraudValueListRequest
{
ListName = listName,
Type = type,
Value = null,
DurationInSeconds = null
});
}

public Task CreateValueListAsync(string listName)
public Task CreateValueListAsync(string listName, FraudValueType type)
{
return AddValueToValueListAsync(listName, null, null);
return AddValueToValueListAsync(new FraudValueListRequest
{
ListName = listName,
Type = type,
Value = null,
DurationInSeconds = null
});
}

public void DeleteValueList(string listName)
Expand All @@ -97,28 +109,16 @@ public Task DeleteValueListAsync(string listName)
CreateHeaders(path, RequestOptions));
}

public void AddValueToValueList(string listName, string value, int? expireInSeconds)
public void AddValueToValueList(FraudValueListRequest request)
{
const string path = "/fraud/v1/value-lists";
var request = new FraudValueListRequest
{
ListName = listName,
Value = value,
DurationInSeconds = expireInSeconds
};
RestClient.Post<object>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions), request);
}

public Task AddValueToValueListAsync(string listName, string value, int? expireInSeconds)
public Task AddValueToValueListAsync(FraudValueListRequest request)
{
const string path = "/fraud/v1/value-lists";
var request = new FraudValueListRequest
{
ListName = listName,
Value = value,
DurationInSeconds = expireInSeconds
};
return AsyncRestClient.Post<object>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions), request);
}
Expand All @@ -130,9 +130,9 @@ public void RemoveValueFromValueList(string listName, string value)
CreateHeaders(path, RequestOptions));
}

public Task RemoveValueFromValueListAsync(string listName, string value)
public Task RemoveValueFromValueListAsync(string listName, string valueId)
{
var path = "/fraud/v1/value-lists/" + listName + "/values/" + value;
var path = "/fraud/v1/value-lists/" + listName + "/values/" + valueId;
return AsyncRestClient.Delete<object>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}
Expand Down
28 changes: 28 additions & 0 deletions Craftgate/Adapter/JuzdanPaymentAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Threading.Tasks;
using Craftgate.Net;
using Craftgate.Request;
using Craftgate.Request.Common;
using Craftgate.Response;

namespace Craftgate.Adapter
{
public class JuzdanPaymentAdapter : BaseAdapter
{
public JuzdanPaymentAdapter(RequestOptions requestOptions) : base(requestOptions)
{
}

public InitJuzdanPaymentResponse Init(InitJuzdanPaymentRequest initJuzdanPaymentRequest)
{
var path = "/payment/v1/juzdan-payments/init";
return RestClient.Post<InitJuzdanPaymentResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(initJuzdanPaymentRequest, path, RequestOptions), initJuzdanPaymentRequest);
}

public PaymentResponse Retrieve(string referenceId)
{
var path = "/payment/v1/juzdan-payments/" + referenceId;
return RestClient.Get<PaymentResponse>(RequestOptions.BaseUrl + path, CreateHeaders(path, RequestOptions));
}
}
}
127 changes: 127 additions & 0 deletions Craftgate/Adapter/MerchantAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System;
using System.Threading.Tasks;
using Craftgate.Model;
using Craftgate.Net;
using Craftgate.Request;
using Craftgate.Request.Common;
using Craftgate.Response;

namespace Craftgate.Adapter
{
public class MerchantAdapter : BaseAdapter
{
public MerchantAdapter(RequestOptions requestOptions) : base(requestOptions)
{
}

public MerchantPosResponse CreateMerchantPos(CreateMerchantPosRequest createMemberRequest)
{
var path = "/merchant/v1/merchant-poses";
return RestClient.Post<MerchantPosResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(createMemberRequest, path, RequestOptions),
createMemberRequest);
}

public Task<MerchantPosResponse> CreateMerchantPosAsync(CreateMerchantPosRequest createMemberRequest)
{
var path = "/merchant/v1/merchant-poses";
return AsyncRestClient.Post<MerchantPosResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(createMemberRequest, path, RequestOptions),
createMemberRequest);
}

public MerchantPosResponse RetrieveMerchantPos(long id)
{
var path = "/merchant/v1/merchant-poses/" + id;
return RestClient.Get<MerchantPosResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public Task<MerchantPosResponse> RetrieveMerchantPosAsync(long id)
{
var path = "/merchant/v1/merchant-poses/" + id;
return AsyncRestClient.Get<MerchantPosResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public MerchantPosResponse UpdateMerchantPos(long id, UpdateMerchantPosRequest updateMerchantPosRequest)
{
var path = "/merchant/v1/merchant-poses/" + id;
return RestClient.Put<MerchantPosResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(updateMerchantPosRequest, path, RequestOptions),
updateMerchantPosRequest);
}

public Task<MerchantPosResponse> UpdateMerchantPosAsync(long id,
UpdateMerchantPosRequest updateMerchantPosRequest)
{
var path = "/merchant/v1/merchant-poses/" + id;
return AsyncRestClient.Put<MerchantPosResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(updateMerchantPosRequest, path, RequestOptions),
updateMerchantPosRequest);
}

public void UpdateMerchantPosStatus(long id, PosStatus posStatus)
{
var path = "/merchant/v1/merchant-poses/" + id + "/status/" + posStatus;
RestClient.Put<object>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public void UpdateMerchantPosStatusAsync(long id, PosStatus posStatus)
{
var path = "/merchant/v1/merchant-poses/" + id + "/status/" + posStatus;
AsyncRestClient.Put<object>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public void DeleteMerchantPos(long id)
{
var path = "/merchant/v1/merchant-poses/" + id;
RestClient.Delete<object>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public void DeleteMerchantPosAsync(long id)
{
var path = "/merchant/v1/merchant-poses/" + id;
AsyncRestClient.Delete<object>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public MerchantPosListResponse SearchMerchantPos(SearchMerchantPosRequest searchMerchantPosRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(searchMerchantPosRequest);
var path = "/merchant/v1/merchant-poses" + queryParam;
return RestClient.Get<MerchantPosListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public Task<MerchantPosListResponse> SearchMerchantPosAsync(SearchMerchantPosRequest searchMerchantPosRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(searchMerchantPosRequest);
var path = "/merchant/v1/merchant-poses" + queryParam;
return AsyncRestClient.Get<MerchantPosListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public MerchantPosCommissionListResponse RetrieveMerchantPosCommissions(long id)
{
var path = "/merchant/v1/merchant-poses/" + id + "/commissions";
return RestClient.Get<MerchantPosCommissionListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

/*
* This endpoint using for creating and updating merchant pos commissions. The HTTP method is POST due to this requirement.
* */
public MerchantPosCommissionListResponse UpdateMerchantPosCommissions(long id,
UpdateMerchantPosCommissionsRequest request)
{
var path = "/merchant/v1/merchant-poses/" + id + "/commissions";
return RestClient.Post<MerchantPosCommissionListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions),
request);
}
}
}
16 changes: 16 additions & 0 deletions Craftgate/Adapter/OnboardingAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,21 @@ public Task<MemberListResponse> SearchMembersAsync(SearchMembersRequest searchMe
return AsyncRestClient.Get<MemberListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public CreateMerchantResponse CreateMerchant(CreateMerchantRequest createMerchantRequest)
{
var path = "/onboarding/v1/merchants";
return RestClient.Post<CreateMerchantResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(createMerchantRequest, path, RequestOptions),
createMerchantRequest);
}

public Task<CreateMerchantResponse> CreateMerchantAsync(CreateMerchantRequest createMerchantRequest)
{
var path = "/onboarding/v1/merchants";
return AsyncRestClient.Post<CreateMerchantResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(createMerchantRequest, path, RequestOptions),
createMerchantRequest);
}
}
}
57 changes: 57 additions & 0 deletions Craftgate/Adapter/PaymentAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,63 @@ public Task<PaymentTransactionResponse> UpdatePaymentTransactionAsync(
return AsyncRestClient.Put<PaymentTransactionResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(updatePaymentTransactionRequest, path, RequestOptions), updatePaymentTransactionRequest);
}

public BnplPaymentOfferResponse RetrieveBnplOffers(BnplPaymentOfferRequest request)
{
var path = "/payment/v1/bnpl-payments/offers";
return RestClient.Post<BnplPaymentOfferResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions), request);
}

public Task<BnplPaymentOfferResponse> RetrieveBnplOffersAsync(BnplPaymentOfferRequest request)
{
var path = "/payment/v1/bnpl-payments/offers";
return AsyncRestClient.Post<BnplPaymentOfferResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions), request);
}

public InitBnplPaymentResponse InitBnplPayment(InitBnplPaymentRequest request)
{
var path = "/payment/v1/bnpl-payments/init";
return RestClient.Post<InitBnplPaymentResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions), request);
}

public Task<InitBnplPaymentResponse> InitBnplPaymentAsync(InitBnplPaymentRequest request)
{
var path = "/payment/v1/bnpl-payments/init";
return AsyncRestClient.Post<InitBnplPaymentResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(request, path, RequestOptions), request);
}

public void ApproveBnplPayment(long PaymentId)
{
var path = "/payment/v1/bnpl-payments/" + PaymentId + "/approve";
RestClient.Post<object>(RequestOptions.BaseUrl + path,
CreateHeaders(null, path, RequestOptions), null);
}

public Task ApproveBnplPaymentAsync(long PaymentId)
{
var path = "/payment/v1/bnpl-payments/" + PaymentId + "/approve";
return AsyncRestClient.Post<object>(RequestOptions.BaseUrl + path,
CreateHeaders(null, path, RequestOptions), null);
}

public InstantTransferBanksResponse RetrieveActiveBanks()
{
var path = "/payment/v1/instant-transfer-banks";
return RestClient.Get<InstantTransferBanksResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}

public Task<InstantTransferBanksResponse> RetrieveActiveBanksAsync()
{
var path = "/payment/v1/instant-transfer-banks";
return AsyncRestClient.Get<InstantTransferBanksResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}


public object CreateApplePayMerchantSession(
ApplePayMerchantSessionCreateRequest applePayMerchantSessionCreateRequest)
Expand Down
4 changes: 2 additions & 2 deletions Craftgate/Adapter/SettlementReportingAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public PayoutCompletedTransactionListResponse SearchPayoutCompletedTransactions(
SearchPayoutCompletedTransactionsRequest searchPayoutCompletedTransactionsRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(searchPayoutCompletedTransactionsRequest);
var path = "/settlement-reporting/v1/settlement-file/payout-completed-transactions" + queryParam;
var path = "/settlement-reporting/v2/settlement-file/payout-completed-transactions" + queryParam;
return RestClient.Get<PayoutCompletedTransactionListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}
Expand All @@ -25,7 +25,7 @@ public Task<PayoutCompletedTransactionListResponse> SearchPayoutCompletedTransac
SearchPayoutCompletedTransactionsRequest searchPayoutCompletedTransactionsRequest)
{
var queryParam = RequestQueryParamsBuilder.BuildQueryParam(searchPayoutCompletedTransactionsRequest);
var path = "/settlement-reporting/v1/settlement-file/payout-completed-transactions" + queryParam;
var path = "/settlement-reporting/v2/settlement-file/payout-completed-transactions" + queryParam;
return AsyncRestClient.Get<PayoutCompletedTransactionListResponse>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
}
Expand Down
Loading

0 comments on commit 2747874

Please sign in to comment.