From 0ae9eaa7fa42f0d9bf8352c6504bd5ba1299fad8 Mon Sep 17 00:00:00 2001 From: "josue.garcia@blueoceantech.com.mx" Date: Tue, 27 Oct 2020 10:28:45 -0600 Subject: [PATCH 1/2] add Interfaces to services --- .gitignore | 3 ++ Openpay/BankAccountService.cs | 11 ++-- Openpay/CardService.cs | 28 +++++----- Openpay/ChargeService.cs | 58 ++++++++++---------- Openpay/CustomerService.cs | 6 +-- Openpay/FeeService.cs | 25 ++++----- Openpay/MerchantService.cs | 10 +--- Openpay/Openpay.csproj | 17 ++++++ Openpay/OpenpayAPI.cs | 50 ++++++++---------- Openpay/OpenpayFeesService.cs | 97 +++++++++++++++++----------------- Openpay/OpenpayHttpClient.cs | 27 +++++----- Openpay/PayoutReportService.cs | 49 +++++++++-------- Openpay/PayoutService.cs | 27 +++++----- Openpay/PlanService.cs | 6 +-- Openpay/SubscriptionService.cs | 6 +-- Openpay/TransferService.cs | 6 +-- Openpay/WebhookService.cs | 78 +++++++++++++-------------- 17 files changed, 238 insertions(+), 266 deletions(-) diff --git a/.gitignore b/.gitignore index 1bc915c..c1ac7dd 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,6 @@ $RECYCLE.BIN/ # Mac desktop service store files .DS_Store + +# Visual Studio 2015 cache/options directory +.vs/ \ No newline at end of file diff --git a/Openpay/BankAccountService.cs b/Openpay/BankAccountService.cs index 77acb71..6a8c4fb 100644 --- a/Openpay/BankAccountService.cs +++ b/Openpay/BankAccountService.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Openpay.Entities; +using Openpay.Entities; using Openpay.Entities.Request; +using System.Collections.Generic; namespace Openpay { - public class BankAccountService : OpenpayResourceService + public class BankAccountService : OpenpayResourceService, IBankAccountService { public BankAccountService(string api_key, string merchant_id, bool production = false) @@ -32,7 +29,7 @@ public BankAccount Create(BankAccount bankAccount) return base.Create(null, bankAccount); } - + public new void Delete(string customer_id, string bankAccount_id) { diff --git a/Openpay/CardService.cs b/Openpay/CardService.cs index 6ba9b19..e21b5e0 100644 --- a/Openpay/CardService.cs +++ b/Openpay/CardService.cs @@ -1,14 +1,10 @@ using Openpay.Entities; using Openpay.Entities.Request; -using Openpay.Utils; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class CardService : OpenpayResourceService + public class CardService : OpenpayResourceService, ICardService { public CardService(string api_key, string merchant_id, bool production = false) : base(api_key, merchant_id, production) @@ -62,17 +58,17 @@ public List List(SearchParams filters = null) return base.List(null, filters); } - public PointsBalance Points(string card_id) - { - string ep = GetEndPoint(null, card_id) + "/points"; - return this.httpClient.Get(ep); - } + public PointsBalance Points(string card_id) + { + string ep = GetEndPoint(null, card_id) + "/points"; + return this.httpClient.Get(ep); + } - public PointsBalance Points(string customer_id, string card_id) - { - string ep = GetEndPoint(customer_id, card_id) + "/points"; - return this.httpClient.Get(ep); - } + public PointsBalance Points(string customer_id, string card_id) + { + string ep = GetEndPoint(customer_id, card_id) + "/points"; + return this.httpClient.Get(ep); + } - } + } } diff --git a/Openpay/ChargeService.cs b/Openpay/ChargeService.cs index 3852265..bb70a06 100644 --- a/Openpay/ChargeService.cs +++ b/Openpay/ChargeService.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Openpay.Entities; +using Openpay.Entities; using Openpay.Entities.Request; +using System; +using System.Collections.Generic; namespace Openpay { - public class ChargeService : OpenpayResourceService + public class ChargeService : OpenpayResourceService, IChargeService { public ChargeService(string api_key, string merchant_id, bool production = false) @@ -27,36 +25,36 @@ public Charge Refund(string charge_id, string description) return this.Refund(null, charge_id, description); } - public Charge Refund(string charge_id, string description, Decimal? amount) - { - return this.Refund(null, charge_id, description, amount); - } + public Charge Refund(string charge_id, string description, Decimal? amount) + { + return this.Refund(null, charge_id, description, amount); + } - public Charge Refund(string customer_id, string charge_id, string description) + public Charge Refund(string customer_id, string charge_id, string description) { return this.Refund(customer_id, charge_id, description, null); - } - - public Charge Refund(string customer_id, string charge_id, string description, Decimal? amount) - { - if (charge_id == null) - throw new ArgumentNullException("charge_id cannot be null"); - string ep = GetEndPoint(customer_id, charge_id) + "/refund"; - RefundRequest request = new RefundRequest(); - request.Description = description; - - if (amount != null) - request.Amount = amount; - - return this.httpClient.Post(ep, request); - } + } + + public Charge Refund(string customer_id, string charge_id, string description, Decimal? amount) + { + if (charge_id == null) + throw new ArgumentNullException("charge_id cannot be null"); + string ep = GetEndPoint(customer_id, charge_id) + "/refund"; + RefundRequest request = new RefundRequest(); + request.Description = description; + + if (amount != null) + request.Amount = amount; + + return this.httpClient.Post(ep, request); + } public Charge Capture(string charge_id, Decimal? amount) { return this.Capture(null, charge_id, amount); } - public Charge Capture(string customer_id , string charge_id, Decimal? amount) + public Charge Capture(string customer_id, string charge_id, Decimal? amount) { if (charge_id == null) throw new ArgumentNullException("charge_id cannot be null"); @@ -72,13 +70,13 @@ public Charge Create(ChargeRequest charge_request) } public new Charge Create(string customer_id, ChargeRequest charge_request) - { + { return base.Create(customer_id, charge_request); } public Charge CancelByMerchant(string merchant_id, string charge_id, ChargeRequest charge_request) { - return base.CancelByMerchant(merchant_id, charge_id, charge_request); + return base.CancelByMerchant(merchant_id, charge_id, charge_request); } public new Charge Get(string customer_id, string charge_id) @@ -100,6 +98,6 @@ public List List(SearchParams filters = null) { return base.List(null, filters); } - + } } diff --git a/Openpay/CustomerService.cs b/Openpay/CustomerService.cs index fc10b65..29230b6 100644 --- a/Openpay/CustomerService.cs +++ b/Openpay/CustomerService.cs @@ -1,14 +1,10 @@ using Openpay.Entities; using Openpay.Entities.Request; -using Openpay.Utils; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class CustomerService : OpenpayResourceService + public class CustomerService : OpenpayResourceService, ICustomerService { public CustomerService(string api_key, string merchant_id, bool production = false) diff --git a/Openpay/FeeService.cs b/Openpay/FeeService.cs index 2f58944..86eeb82 100644 --- a/Openpay/FeeService.cs +++ b/Openpay/FeeService.cs @@ -1,14 +1,11 @@ using Openpay.Entities; using Openpay.Entities.Request; -using Openpay.Utils; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class FeeService : OpenpayResourceService + public class FeeService : OpenpayResourceService, IFeeService { public FeeService(string api_key, string merchant_id, bool production = false) @@ -33,17 +30,17 @@ public List List(SearchParams filters = null) return base.List(null, filters); } - public Fee Refund(string charge_id, string description) - { - if (charge_id == null) - throw new ArgumentNullException("charge_id cannot be null"); - string ep = GetEndPoint(null, charge_id) + "/refund"; + public Fee Refund(string charge_id, string description) + { + if (charge_id == null) + throw new ArgumentNullException("charge_id cannot be null"); + string ep = GetEndPoint(null, charge_id) + "/refund"; - RefundRequest request = new RefundRequest(); - request.Description = description; + RefundRequest request = new RefundRequest(); + request.Description = description; - return this.httpClient.Post(ep, request); - } + return this.httpClient.Post(ep, request); + } - } + } } diff --git a/Openpay/MerchantService.cs b/Openpay/MerchantService.cs index dd2c3b4..7a4864d 100644 --- a/Openpay/MerchantService.cs +++ b/Openpay/MerchantService.cs @@ -1,14 +1,8 @@ using Openpay.Entities; -using Openpay.Entities.Request; -using Openpay.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class MerchantService : OpenpayResourceService + public class MerchantService : OpenpayResourceService, IMerchantService { public MerchantService(string api_key, string merchant_id, bool production = false) @@ -27,6 +21,6 @@ public Merchant Get() { return base.Get(null, null); } - + } } diff --git a/Openpay/Openpay.csproj b/Openpay/Openpay.csproj index 8fb7891..554cdf2 100644 --- a/Openpay/Openpay.csproj +++ b/Openpay/Openpay.csproj @@ -50,6 +50,20 @@ + + + + + + + + + + + + + + @@ -107,6 +121,9 @@ Designer + + +