Skip to content

Commit

Permalink
Add Apm Crud Endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustafa Özcan committed Oct 8, 2024
1 parent b7525f4 commit 6d8728b
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 319 deletions.
113 changes: 40 additions & 73 deletions Craftgate/Adapter/MerchantApmAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,120 +8,87 @@

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

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

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

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

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

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

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

public void UpdateMerchantPosStatus(long id, PosStatus posStatus)
public void UpdateMerchantApmStatus(long id, UpdateMerchantApmStatusRequest updateMerchantApmStatusRequest)
{
var path = "/merchant/v1/merchant-poses/" + id + "/status/" + posStatus;
var path = "/merchant/v1/merchant-apms/" + id + "/status";

RestClient.Put<object>(RequestOptions.BaseUrl + path,
CreateHeaders(path, RequestOptions));
CreateHeaders(updateMerchantApmStatusRequest, path, RequestOptions),
updateMerchantApmStatusRequest);
}

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

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

public void DeleteMerchantPosAsync(long id)
public void DeleteMerchantApmAsync(long id)
{
var path = "/merchant/v1/merchant-poses/" + id;
var path = "/merchant/v1/merchant-apms/" + 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);
}
}
}
7 changes: 7 additions & 0 deletions Craftgate/CraftgateClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class CraftgateClient
private readonly MasterpassPaymentAdapter _masterpassPaymentAdapter;
private readonly BankAccountTrackingAdapter _bankAccountTrackingAdapter;
private readonly MerchantAdapter _merchantAdapter;
private readonly MerchantApmAdapter _merchantApmAdapter;
private readonly JuzdanPaymentAdapter _juzdanPaymentAdapter;
private readonly BkmExpressPaymentAdapter _bkmExpressPaymentAdapter;

Expand Down Expand Up @@ -57,6 +58,7 @@ public CraftgateClient(string apiKey, string secretKey, string baseUrl, string l
_masterpassPaymentAdapter = new MasterpassPaymentAdapter(requestOptions);
_bankAccountTrackingAdapter = new BankAccountTrackingAdapter(requestOptions);
_merchantAdapter = new MerchantAdapter(requestOptions);
_merchantApmAdapter = new MerchantApmAdapter(requestOptions);
_juzdanPaymentAdapter = new JuzdanPaymentAdapter(requestOptions);
_bkmExpressPaymentAdapter = new BkmExpressPaymentAdapter(requestOptions);
}
Expand Down Expand Up @@ -131,6 +133,11 @@ public MerchantAdapter Merchant()
return _merchantAdapter;
}

public MerchantApmAdapter MerchantApm()
{
return _merchantApmAdapter;
}

public JuzdanPaymentAdapter Juzdan()
{
return _juzdanPaymentAdapter;
Expand Down
6 changes: 2 additions & 4 deletions Craftgate/Model/ApmStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
namespace Craftgate.Model
{
[JsonConverter(typeof(StringEnumConverter))]
public enum PosStatus
public enum ApmStatus
{
[EnumMember(Value = "DELETED")] DELETED,
[EnumMember(Value = "PASSIVE")] PASSIVE,
[EnumMember(Value = "ACTIVE")] ACTIVE,
[EnumMember(Value = "REFUND_ONLY")] REFUND_ONLY,
[EnumMember(Value = "AUTOPILOT")] AUTOPILOT
[EnumMember(Value = "ACTIVE")] ACTIVE
}
}
23 changes: 6 additions & 17 deletions Craftgate/Request/CreateMerchantApmRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@

namespace Craftgate.Request
{
public class CreateMerchantPosRequest
public class CreateMerchantApmRequest
{
public PosStatus Status;
public ApmStatus Status = ApmStatus.ACTIVE;
public string Name;
public string ClientId;
public Currency Currency;
public string PosnetId;
public string TerminalId;
public string ThreedsPosnetId;
public string ThreedsTerminalId;
public string ThreedsKey;
public bool EnableForeignCard;
public bool EnableInstallment;
public bool EnablePaymentWithoutCvc;
public bool NewIntegration;
public int OrderNumber;
public PosIntegrator PosIntegrator;
public IList<PaymentAuthenticationType> EnabledPaymentAuthenticationTypes;
public IList<CreateMerchantPosUser> MerchantPosUsers;
public ApmType ApmType;
public string Hostname;
public List<Currency> SupportedCurrencies;
public Dictionary<string, object> Properties;
}
}
23 changes: 4 additions & 19 deletions Craftgate/Request/UpdateMerchantApmRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,12 @@

namespace Craftgate.Request
{
public class UpdateMerchantPosRequest
public class UpdateMerchantApmRequest
{
public string Name { get; set; }
public string Hostname { get; set; }
public string ClientId { get; set; }
public string Mode { get; set; }
public string Path { get; set; }
public int? Port { get; set; }
public string PosnetId { get; set; }
public string TerminalId { get; set; }
public string ThreedsPosnetId { get; set; }
public string ThreedsTerminalId { get; set; }
public string ThreedsKey { get; set; }
public string ThreedsPath { get; set; }
public bool EnableForeignCard { get; set; }
public bool EnableInstallment { get; set; }
public bool EnablePaymentWithoutCvc { get; set; }
public bool NewIntegration { get; set; }
public int OrderNumber { get; set; }
public IList<CardAssociation> SupportedCardAssociations { get; set; }
public IList<PaymentAuthenticationType> EnabledPaymentAuthenticationTypes { get; set; }
public IList<UpdateMerchantPosUser> MerchantPosUsers { get; set; }
public ApmStatus Status { get; set; }
public List<Currency> SupportedCurrencies { get; set; }
public Dictionary<string, object> Properties { get; set; }
}
}
10 changes: 10 additions & 0 deletions Craftgate/Request/UpdateMerchantApmStatusRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using Craftgate.Model;

namespace Craftgate.Request
{
public class UpdateMerchantApmStatusRequest
{
public ApmStatus Status { get; set; }
}
}
35 changes: 2 additions & 33 deletions Craftgate/Response/MerchantApmListResponse.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
using System.Collections.Generic;
using Craftgate.Model;
using Craftgate.Response.Common;

namespace Craftgate.Response
{
public class MerchantApmResponse
public class MerchantApmListResponse : ListResponse<MerchantApmResponse>
{
public long Id { get; set; }
public PosStatus Status { get; set; }
public string Name { get; set; }
public string Alias { get; set; }
public PosIntegrator PosIntegrator { get; set; }
public string Hostname { get; set; }
public string ClientId { get; set; }
public string PosCurrencyCode { get; set; }
public string Mode { get; set; }
public string Path { get; set; }
public int Port { get; set; }
public string PosnetId { get; set; }
public string TerminalId { get; set; }
public string ThreedsPosnetId { get; set; }
public string ThreedsTerminalId { get; set; }
public string ThreedsKey { get; set; }
public string ThreedsPath { get; set; }
public bool EnableForeignCard { get; set; }
public bool EnableInstallment { get; set; }
public bool EnablePaymentWithoutCvc { get; set; }
public bool NewIntegration { get; set; }
public int OrderNumber { get; set; }
public AutopilotState AutopilotState { get; set; }
public Currency Currency { get; set; }
public long BankId { get; set; }
public string BankName { get; set; }
public bool IsPf { get; set; }
public List<MerchantPosUser> MerchantPosUsers { get; set; }
public List<CardAssociation> SupportedCardAssociations { get; set; }
public List<PaymentAuthenticationType> EnabledPaymentAuthenticationTypes { get; set; }
}
}
34 changes: 6 additions & 28 deletions Craftgate/Response/MerchantApmResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,15 @@

namespace Craftgate.Response
{
public class MerchantPosResponse
public class MerchantApmResponse
{
public long Id { get; set; }
public PosStatus Status { get; set; }
public ApmStatus Status { get; set; }
public string Name { get; set; }
public string Alias { get; set; }
public PosIntegrator PosIntegrator { get; set; }
public ApmType ApmType { get; set; }
public string Hostname { get; set; }
public string ClientId { get; set; }
public string PosCurrencyCode { get; set; }
public string Mode { get; set; }
public string Path { get; set; }
public int Port { get; set; }
public string PosnetId { get; set; }
public string TerminalId { get; set; }
public string ThreedsPosnetId { get; set; }
public string ThreedsTerminalId { get; set; }
public string ThreedsKey { get; set; }
public string ThreedsPath { get; set; }
public bool EnableForeignCard { get; set; }
public bool EnableInstallment { get; set; }
public bool EnablePaymentWithoutCvc { get; set; }
public bool NewIntegration { get; set; }
public int OrderNumber { get; set; }
public AutopilotState AutopilotState { get; set; }
public Currency Currency { get; set; }
public long BankId { get; set; }
public string BankName { get; set; }
public bool IsPf { get; set; }
public List<MerchantPosUser> MerchantPosUsers { get; set; }
public List<CardAssociation> SupportedCardAssociations { get; set; }
public List<PaymentAuthenticationType> EnabledPaymentAuthenticationTypes { get; set; }
public long MerchantId { get; set; }
public List<Currency> SupportedCurrencies { get; set; }
public Dictionary<string, object> Properties { get; set; }
}
}
Loading

0 comments on commit 6d8728b

Please sign in to comment.