From 4e4495f5ddb590a0d0eff79c04a209e00a9bba96 Mon Sep 17 00:00:00 2001 From: Daniel Wermann Date: Tue, 13 Dec 2022 19:05:09 -0300 Subject: [PATCH 1/2] Upgraded to .NET 6 --- README.md | 2 +- src/ChargeOver.Wrapper.Examples/App.config | 4 +- .../ChargeOver.Wrapper.Examples.csproj | 73 +------ src/ChargeOver.Wrapper.Examples/Program.cs | 13 +- .../ACHeCheckAccountsServiceExample.cs | 5 +- .../Services/CreditCardServiceExample.cs | 5 +- .../Services/CustomersServiceExample.cs | 15 +- .../Services/IServiceExample.cs | 9 +- .../Services/InvoiceServiceExample.cs | 15 +- .../Services/SubscriptionServiceExample.cs | 14 +- .../Services/TransactionsServiceExample.cs | 15 +- .../appsettings.json | 6 + .../ChargeOver.Wrapper.csproj | 184 +----------------- src/ChargeOver.Wrapper/Models/Customer.cs | 10 +- .../Models/StoreCreditCard.cs | 12 +- .../Models/StoringUsageData.cs | 7 +- .../Models/SubscriptionLineItem.cs | 2 + .../Services/ACHeCheckAccountsService.cs | 9 +- .../Services/AdminWorkersService.cs | 13 +- .../Services/BaseService.cs | 102 +++++----- .../Services/BrandsService.cs | 5 +- .../Services/CampaignsService.cs | 5 +- .../Services/CategoriesService.cs | 5 +- .../Services/ChargeOverService.cs | 13 +- .../Services/CountriesService.cs | 5 +- .../Services/CreditCardsService.cs | 13 +- .../Services/CurrenciesService.cs | 5 +- .../Services/CustomersService.cs | 21 +- .../Services/IACHeCheckAccountsService.cs | 13 +- .../Services/IAdminWorkersService.cs | 23 +-- .../Services/IBrandsService.cs | 3 +- .../Services/ICampaignsService.cs | 3 +- .../Services/ICategoriesService.cs | 4 +- .../Services/IChargeOverService.cs | 7 +- .../Services/ICountriesService.cs | 3 +- .../Services/ICreditCardsService.cs | 23 +-- .../Services/ICurrenciesService.cs | 11 +- .../Services/ICustomersService.cs | 43 ++-- .../Services/IInvoicesService.cs | 37 ++-- .../Services/IItemsService.cs | 21 +- .../Services/ILanguagesService.cs | 11 +- .../Services/INotesService.cs | 21 +- .../Services/IRestHooksService.cs | 5 +- .../Services/ISubscriptionsService.cs | 49 ++--- .../Services/ISystemLogService.cs | 3 +- .../Services/ITermsService.cs | 3 +- .../Services/ITokenizedPayMethodsService.cs | 5 +- .../Services/ITransactionsService.cs | 35 ++-- .../Services/IUsageService.cs | 3 +- .../Services/IUsersContactsService.cs | 41 ++-- .../Services/InvoicesService.cs | 41 ++-- .../Services/ItemsService.cs | 9 +- .../Services/LanguagesService.cs | 5 +- .../Services/NotesService.cs | 9 +- .../Services/RESTHooksService.cs | 9 +- .../Services/SubscriptionsService.cs | 49 ++--- .../Services/SystemLogService.cs | 5 +- .../Services/TermsService.cs | 5 +- .../Services/TokenizedPayMethodsService.cs | 9 +- .../Services/TransactionsService.cs | 37 ++-- .../Services/UsageService.cs | 5 +- .../Services/UsersContactsService.cs | 37 ++-- .../Services/ACHeCheckAccountsServiceTests.cs | 8 +- .../Services/AdminWorkersServiceTests.cs | 14 +- .../Services/BrandsServiceTests.cs | 4 +- .../Services/CampaignsServiceTests.cs | 4 +- .../Services/CategoriesServiceTests.cs | 4 +- .../Services/ChargeOverServiceTests.cs | 12 +- .../Services/CountriesServiceTests.cs | 4 +- .../Services/CreditCardsServiceTests.cs | 12 +- .../Services/CurrenciesServiceTests.cs | 4 +- .../Services/CustomersServiceTests.cs | 33 ++-- .../Services/InvoicesServiceTests.cs | 40 ++-- .../Services/ItemsServiceTests.cs | 8 +- .../Services/LanguagesServiceTests.cs | 4 +- .../Services/NotesServiceTests.cs | 8 +- .../Services/RESTHooksServiceTests.cs | 8 +- .../Services/SubscriptionsServiceTests.cs | 61 +++--- .../Services/SystemLogServiceTests.cs | 4 +- .../Services/TermsServiceTests.cs | 4 +- .../TokenizedPayMethodsServiceTests.cs | 8 +- .../Services/TransactionsServiceTests.cs | 36 ++-- .../Services/UsageServiceTests.cs | 11 +- .../Services/UsersContactsServiceTests.cs | 32 +-- .../TestsChargeOver.Wrapper.csproj | 100 ++-------- 85 files changed, 697 insertions(+), 900 deletions(-) create mode 100644 src/ChargeOver.Wrapper.Examples/appsettings.json diff --git a/README.md b/README.md index 77c207b..b5b52e9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -ChargeOver C# API and Examples +ChargeOver C# API and Examples (.NET 6) ============================== This is a C# .NET library for the [ChargeOver recurring billing platform](http://www.chargeover.com/). ChargeOver is a billing platform geared towards easy, automated, recurring invoicing. diff --git a/src/ChargeOver.Wrapper.Examples/App.config b/src/ChargeOver.Wrapper.Examples/App.config index 3dfb5ea..f17d704 100644 --- a/src/ChargeOver.Wrapper.Examples/App.config +++ b/src/ChargeOver.Wrapper.Examples/App.config @@ -1,4 +1,4 @@ - + @@ -7,6 +7,6 @@ - + diff --git a/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj b/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj index d4c248c..8204e92 100644 --- a/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj +++ b/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj @@ -1,73 +1,20 @@ - - - + - Debug - AnyCPU - {0CE183C5-CA80-4696-AE28-785455DB47DE} + net7.0 Exe - Properties - ChargeOver.Wrapper.Examples - ChargeOver.Wrapper.Examples - v4.6.1 - 512 - true + false - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - + - + + + + all + - - {03e09695-088d-4971-8888-eb16a8565eeb} - ChargeOver.Wrapper - + - - \ No newline at end of file diff --git a/src/ChargeOver.Wrapper.Examples/Program.cs b/src/ChargeOver.Wrapper.Examples/Program.cs index a89b9c3..95fd0be 100644 --- a/src/ChargeOver.Wrapper.Examples/Program.cs +++ b/src/ChargeOver.Wrapper.Examples/Program.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using ChargeOver.Wrapper.Examples.Services; namespace ChargeOver.Wrapper.Examples @@ -9,15 +10,17 @@ static void Main() { var examples = new IServiceExample[] { - // CustomersServiceExample(), + new CustomersServiceExample(), new InvoiceServiceExample(), - //new SubscriptionServiceExample(), + new SubscriptionServiceExample(), new TransactionsServiceExample(), - //new CreditCardServiceExample(), - //new ACHeCheckAccountsServiceExample() + new CreditCardServiceExample(), + new ACHeCheckAccountsServiceExample() }.ToList(); examples.ForEach(e => e.Run()); + + Console.ReadLine(); } } } diff --git a/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs index 56ddfb5..9c4f61f 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; @@ -13,7 +14,7 @@ public ACHeCheckAccountsServiceExample() _service = new ACHeCheckAccountsService(); } - public void Run() + public async void Run() { var request = new StoreACHAccount { @@ -23,7 +24,7 @@ public void Run() Routing = "072403004", }; - var result = _service.StoreACHAccount(request); + var result = await _service.StoreACHAccount(request); if (!result.IsSuccess()) throw new Exception("Store ACH failed."); diff --git a/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs index 40c30da..3b95a59 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; @@ -13,7 +14,7 @@ public CreditCardServiceExample() _service = new CreditCardsService(); } - public void Run() + public async void Run() { var request = new StoreCreditCard { @@ -29,7 +30,7 @@ public void Run() Country = "United States", }; - var result = _service.StoreCreditCard(request); + var result = await _service.StoreCreditCard(request); if (!result.IsSuccess()) throw new Exception("Store credit card failed."); diff --git a/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs index 44b5604..cbfc3b7 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; @@ -15,7 +16,7 @@ public CustomersServiceExample() _service = new CustomersService(); } - public void Run() + public async void Run() { var examples = new List { @@ -28,7 +29,7 @@ public void Run() } } - private void CreateCustomer() + private async void CreateCustomer() { var customer = new Customer { @@ -40,23 +41,23 @@ private void CreateCustomer() SuperUserEmail = "mail@mail.com" }; - var result = _service.CreateCustomer(customer); + var result = await _service.CreateCustomer(customer); if (!result.IsSuccess()) throw new Exception("Create customer failed."); Console.WriteLine("Customer created with id: " + result.Id); } - private void QueryCustomerByName() + private async void QueryCustomerByName() { - var result = _service.QueryCustomers(new[] { "company:EQUALS:Name" }); + var result = await _service.QueryCustomers(new[] { "company:EQUALS:Name" }); Console.WriteLine($"Customers found 'by name': {result.Response.Count()}"); } - private void QueryCustomerByEmail() + private async void QueryCustomerByEmail() { - var result = _service.QueryCustomers(new[] { "superuser_email:EQUALS:mail@mail.com" }); + var result = await _service.QueryCustomers(new[] { "superuser_email:EQUALS:mail@mail.com" }); Console.WriteLine($"Customers found 'by email': {result.Response.Count()}"); } diff --git a/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs index aa095e6..f1e8e4d 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs @@ -1,7 +1,10 @@ -namespace ChargeOver.Wrapper.Examples.Services +using System.Threading.Tasks; + +namespace ChargeOver.Wrapper.Examples.Services { public interface IServiceExample { - void Run(); - } + + void Run(); + } } \ No newline at end of file diff --git a/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs index 364b6fa..4c2886a 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; @@ -18,7 +19,7 @@ public InvoiceServiceExample() _customersService = new CustomersService(); } - public void Run() + public async void Run() { var examples = new Action[] { CreateInvoice, QueryInvoiceByInvoiceId }; @@ -28,16 +29,16 @@ public void Run() } } - private void CreateInvoice() + private async void CreateInvoice() { - var result = CreateNewInvoice(); + var result = await CreateNewInvoice(); if (!result.IsSuccess()) throw new Exception("Create invoice failed."); Console.WriteLine("Invoice created with id: " + result.Id); } - private IIdentityResponse CreateNewInvoice() + private async Task CreateNewInvoice() { var id = TakeItemId(); var customer = TakeCustomerId(); @@ -60,13 +61,13 @@ private IIdentityResponse CreateNewInvoice() } } }; - var result = _service.CreateInvoice(request); + var result = await _service.CreateInvoice(request); return result; } - private void QueryInvoiceByInvoiceId() + private async void QueryInvoiceByInvoiceId() { - var result = _service.QueryInvoices(new[] { "invoice_id:EQUALS:" + CreateNewInvoice().Id }); + var result = await _service.QueryInvoices(new[] { "invoice_id:EQUALS:" + CreateNewInvoice().Id }); Console.WriteLine($"Invoices found by id: {result.Response.Count()}"); } diff --git a/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs index aa735a9..55e0faf 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; @@ -26,22 +27,21 @@ public void Run() } } - private void CreateSubscription() + private async void CreateSubscription() { - var result = CreateNewSubscription(); + var result = await CreateNewSubscription(); if (!result.IsSuccess()) throw new Exception("Create subscription failed."); Console.WriteLine("Subscription created with id: " + result.Id); } - private IIdentityResponse CreateNewSubscription() + private Task CreateNewSubscription() { var subscription = new Subscription { CustomerId = TakeCustomerId(), - HoldUntilDatetime = DateTime.Parse("2018-10-01"), - Coupon = 'The coupon code' + HoldUntilDatetime = DateTime.Parse("2018-10-01") }; var line1 = new SubscriptionLineItem @@ -81,10 +81,10 @@ private IIdentityResponse CreateNewSubscription() return result; } - private void GetSubscriptionByPackageId() + private async void GetSubscriptionByPackageId() { var subscription = CreateNewSubscription(); - var result = _service.QuerySubscriptions(new[] { "package_id:EQUALS:" + subscription.Id }); + var result = await _service.QuerySubscriptions(new[] { "package_id:EQUALS:" + subscription.Id }); Console.WriteLine($"Subscriptions found 'by id': {result.Response.Count()}"); } diff --git a/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs index bc2dbff..e2adbb1 100644 --- a/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs +++ b/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; @@ -24,7 +25,7 @@ public TransactionsServiceExample() _itemsService = new ItemsService(); } - public void Run() + public async void Run() { this._customerId = AddCustomer(); @@ -36,9 +37,9 @@ public void Run() } } - public void GetTransactionByTransactionId() + public async void GetTransactionByTransactionId() { - var result = _transactionsService.GetTransaction(this.AttemptPayment()); + var result = await _transactionsService.GetTransaction(await this.AttemptPayment()); Console.WriteLine("Transaction ID we just got is: " + result.Response.TransactionId + " and is applied to " + result.Response.AppliedTo.Length + " invoices"); @@ -50,9 +51,9 @@ public void GetTransactionByTransactionId() } - public void QueryTransactionByTransactionId() + public async void QueryTransactionByTransactionId() { - var result = _transactionsService.QueryTransactions(new[] { "transaction_id:EQUALS:" + AttemptPayment() }); + var result = await _transactionsService.QueryTransactions(new[] { "transaction_id:EQUALS:" + AttemptPayment() }); Console.WriteLine("Transactions found by id: " + result.Response.Count()); } @@ -64,7 +65,7 @@ public void AttemptPaymentExample() Console.WriteLine("Transaction ID for payment is: " + payment_id); } - public int AttemptPayment() + public async Task AttemptPayment() { var customerId = this._customerId; int creditcardId = StoreCreditCard(customerId); @@ -92,7 +93,7 @@ public int AttemptPayment() try { - var result = _transactionsService.AttemptPayment(request); + var result = await _transactionsService.AttemptPayment(request); if (!result.IsSuccess()) throw new Exception("Attempt payment failed."); diff --git a/src/ChargeOver.Wrapper.Examples/appsettings.json b/src/ChargeOver.Wrapper.Examples/appsettings.json new file mode 100644 index 0000000..b2bc73d --- /dev/null +++ b/src/ChargeOver.Wrapper.Examples/appsettings.json @@ -0,0 +1,6 @@ +{ + "ChargeOverAPIEndpoint": "", + "ChargeOverAPIUserName": "", + "ChargeOverAPIPassword": "", + "ChargeOverAPIAuth": "http-basic" +} \ No newline at end of file diff --git a/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj b/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj index 0aae5fe..b4ed4a1 100644 --- a/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj +++ b/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj @@ -1,182 +1,18 @@ - - - + - Debug - AnyCPU - {03E09695-088D-4971-8888-EB16A8565EEB} + net6.0 Library - Properties - ChargeOver.Wrapper - ChargeOver.Wrapper - v4.5.2 - 512 + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + all + - + - - \ No newline at end of file diff --git a/src/ChargeOver.Wrapper/Models/Customer.cs b/src/ChargeOver.Wrapper/Models/Customer.cs index 0406855..edffb17 100644 --- a/src/ChargeOver.Wrapper/Models/Customer.cs +++ b/src/ChargeOver.Wrapper/Models/Customer.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using System.Collections.Generic; namespace ChargeOver.Wrapper.Models { @@ -98,7 +99,7 @@ public sealed class Customer /// Main contact phone number /// [JsonProperty("superuser_phone")] - public string SuperuserPhone { get; set; } + public string SuperUserPhone { get; set; } /// /// Billing address line 1 /// @@ -214,5 +215,10 @@ public sealed class Customer /// [JsonProperty("dunning_delivery")] public string DunningDelivery { get; set; } - } + /// + /// A list of tags + /// + [JsonProperty("tags")] + public HashSet Tags { get; set; } + } } diff --git a/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs b/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs index f2ecfea..45f7398 100644 --- a/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs +++ b/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs @@ -65,5 +65,15 @@ public sealed class StoreCreditCard /// [JsonProperty("country")] public string Country { get; set; } - } + /// + /// Security Code + /// + [JsonProperty("cvv")] + public string SecurityCode { get; set; } + /// + /// The customer external key # + /// + [JsonProperty("customer_external_key")] + public int? CustomerExternalKey { get; set; } + } } diff --git a/src/ChargeOver.Wrapper/Models/StoringUsageData.cs b/src/ChargeOver.Wrapper/Models/StoringUsageData.cs index 47dd333..030af9f 100644 --- a/src/ChargeOver.Wrapper/Models/StoringUsageData.cs +++ b/src/ChargeOver.Wrapper/Models/StoringUsageData.cs @@ -30,5 +30,10 @@ public sealed class StoringUsageData /// [JsonProperty("external_key")] public string ExternalKey { get; set; } - } + /// + /// Line Item External key value + /// + [JsonProperty("line_item_external_key")] + public string LineItemExternalKey { get; set; } + } } diff --git a/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs b/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs index 2f07daa..aa9273a 100644 --- a/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs +++ b/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs @@ -47,5 +47,7 @@ public sealed class SubscriptionLineItem public Tierset Tierset { get; set; } [JsonProperty("line_quantity")] public int LineQuantity { get; set; } + [JsonProperty("item_is_usage")] + public bool ItemIsUsage { get; set; } } } \ No newline at end of file diff --git a/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs b/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs index 211bccf..1b5d9ea 100644 --- a/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs +++ b/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,18 +17,18 @@ public ACHeCheckAccountsService() /// Store an ACH account /// details: https://developer.chargeover.com/apidocs/rest/#create-ach /// - public IIdentityResponse StoreACHAccount(StoreACHAccount request) + public async Task StoreACHAccount(StoreACHAccount request) { - return Create("ach", request); + return await Create("ach", request); } /// /// Delete an ACH account /// details: https://developer.chargeover.com/apidocs/rest/#delete-an-ach /// - public IResponse DeleteACHAccount(int id) + public async Task DeleteACHAccount(int id) { - return Delete("ach", id); + return await Delete("ach", id); } } } diff --git a/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs b/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs index 6115ac6..90fbf18 100644 --- a/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs +++ b/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,27 +17,27 @@ public AdminWorkersService() /// Get a list of admin workers /// details: https://developer.chargeover.com/apidocs/rest/#list-admins /// - public IResponse ListAdminWorkers() + public async Task> ListAdminWorkers() { - return GetList("admin"); + return await GetList("admin"); } /// /// Query for admin workers /// details: https://developer.chargeover.com/apidocs/rest/#query-admins /// - public IResponse QueryAdminWorkers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryAdminWorkers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("admin", queries, orders, offset, limit); + return await Query("admin", queries, orders, offset, limit); } /// /// Get a specific admin worker /// details: https://developer.chargeover.com/apidocs/rest/#get-admin /// - public ICustomResponse GetAdminWorker(int id) + public async Task> GetAdminWorker(int id) { - return GetCustom("admin", id); + return await GetCustom("admin", id); } } } diff --git a/src/ChargeOver.Wrapper/Services/BaseService.cs b/src/ChargeOver.Wrapper/Services/BaseService.cs index 62cc8e7..f0781cc 100644 --- a/src/ChargeOver.Wrapper/Services/BaseService.cs +++ b/src/ChargeOver.Wrapper/Services/BaseService.cs @@ -2,7 +2,11 @@ using System.IO; using System.Linq; using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Net.Http.Json; using System.Text; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using Newtonsoft.Json; @@ -23,37 +27,37 @@ protected BaseService(IChargeOverAPIConfiguration config) protected BaseService() : this(new ConfigurationManagerChargeOverApiConfiguration()) { } - protected IIdentityResponse Create(string endpoint, T request) + protected async Task Create(string endpoint, T request) { - return new IdentityResponse(Request(MethodType.POST, $"/{endpoint}", request)); + return new IdentityResponse(await Request(MethodType.POST, $"/{endpoint}", request)); } - protected IResponse Delete(string endpoint, int id) + protected async Task Delete(string endpoint, int id) { - return new Response(Request(MethodType.DELETE, $"/{endpoint}/" + id, null)); + return new Response(await Request(MethodType.DELETE, $"/{endpoint}/" + id, null)); } - protected IResponse GetList(string endpoint) + protected async Task> GetList(string endpoint) { - return new Response(Request>(MethodType.GET, "/" + endpoint, null)); + return new Response(await Request>(MethodType.GET, "/" + endpoint, null)); } - protected ICustomResponse GetCustom(string endpoint, int id) + protected async Task> GetCustom(string endpoint, int id) { - return new CustomResponse(Request>(MethodType.GET, $"/{endpoint}/" + id, null)); + return new CustomResponse(await Request>(MethodType.GET, $"/{endpoint}/" + id, null)); } - protected ICustomResponse GetCustomBool(string endpoint, T requeset) + protected async Task> GetCustomBool(string endpoint, T requeset) { - return new CustomResponse(Request>(MethodType.POST, endpoint, requeset)); + return new CustomResponse(await Request>(MethodType.POST, endpoint, requeset)); } - protected IResponse Query(string endpoint, string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + protected async Task> Query(string endpoint, string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { var queriesData = Data(queries, "where"); var ordersData = Data(orders, "order"); - var result = Request>(MethodType.GET, $"/{endpoint}?_dummy=1&limit={limit}&offset={offset}{queriesData}{ordersData}", null); + var result = await Request>(MethodType.GET, $"/{endpoint}?_dummy=1&limit={limit}&offset={offset}{queriesData}{ordersData}", null); return new Response(result); } @@ -71,57 +75,49 @@ private string Data(string[] arguments, string name) return result; } - protected TResponse Request(MethodType method, string uri, T request) + protected async Task Request(MethodType method, string uri, T request) { - string httpMethod = method.ToString(), data = string.Empty; - - if (request != null) - data = JsonConvert.SerializeObject(request, new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore - }); - - var webRequest = (HttpWebRequest)WebRequest.Create(_config.Endpoint + uri); - - webRequest.KeepAlive = false; - webRequest.ProtocolVersion = HttpVersion.Version10; - webRequest.Method = httpMethod; - - byte[] postBytes = Encoding.ASCII.GetBytes(data); - - webRequest.ContentType = "application/json"; - webRequest.ContentLength = postBytes.Length; - //webRequest.Credentials = new NetworkCredential(_config.Username, _config.Password); + string httpMethod = method.ToString(), data = string.Empty; + + if (request != null) + data = JsonConvert.SerializeObject(request, new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }); + + var httpClient = new HttpClient(); + var requestMessage = new HttpRequestMessage + { + RequestUri = new Uri(_config.Endpoint + uri), + Method = new HttpMethod(httpMethod), + Content = new StringContent(data, Encoding.UTF8, "application/json") + }; string credentialsFormatted = string.Format("{0}:{1}", _config.Username, _config.Password); byte[] credentialBytes = Encoding.ASCII.GetBytes(credentialsFormatted); string basicCredentials = Convert.ToBase64String(credentialBytes); + requestMessage.Headers.Add("Authorization", "Basic " + basicCredentials); + var result = JsonConvert.DeserializeObject("{}"); - webRequest.Headers["Authorization"] = "Basic " + basicCredentials; + var response = await httpClient.SendAsync(requestMessage); - if (postBytes.Length > 0) - { - using (Stream requestStream = webRequest.GetRequestStream()) - { - requestStream.Write(postBytes, 0, postBytes.Length); - requestStream.Close(); - } - } + if (response.IsSuccessStatusCode) + { + var content = await response.Content.ReadAsStringAsync(); + result = JsonConvert.DeserializeObject(content); + } + else + { + string error = await response.Content.ReadAsStringAsync(); + throw new Exception(error); + } - HttpWebResponse response; - - response = (HttpWebResponse)webRequest.GetResponse(); - - string httpResponse = new StreamReader(response.GetResponseStream()).ReadToEnd(); - - var result = JsonConvert.DeserializeObject(httpResponse); - - return result; - } + return result; + } - #region sealed members + #region sealed members - public override sealed bool Equals(object obj) + public override sealed bool Equals(object obj) { return base.Equals(obj); } diff --git a/src/ChargeOver.Wrapper/Services/BrandsService.cs b/src/ChargeOver.Wrapper/Services/BrandsService.cs index 72cba32..ddf9d6e 100644 --- a/src/ChargeOver.Wrapper/Services/BrandsService.cs +++ b/src/ChargeOver.Wrapper/Services/BrandsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public BrandsService() /// Retrieve brand list /// details: https://developer.chargeover.com/apidocs/rest/#list-brand /// - public IResponse ListBrands() + public async Task> ListBrands() { - return GetList("brand"); + return await GetList("brand"); } } } diff --git a/src/ChargeOver.Wrapper/Services/CampaignsService.cs b/src/ChargeOver.Wrapper/Services/CampaignsService.cs index cb531ce..8a04540 100644 --- a/src/ChargeOver.Wrapper/Services/CampaignsService.cs +++ b/src/ChargeOver.Wrapper/Services/CampaignsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public CampaignsService() /// Retrieve campaign list /// details: https://developer.chargeover.com/apidocs/rest/#list-campaign /// - public IResponse ListCampaigns() + public async Task> ListCampaigns() { - return GetList("campaign"); + return await GetList("campaign"); } } } diff --git a/src/ChargeOver.Wrapper/Services/CategoriesService.cs b/src/ChargeOver.Wrapper/Services/CategoriesService.cs index 5996e80..58fc888 100644 --- a/src/ChargeOver.Wrapper/Services/CategoriesService.cs +++ b/src/ChargeOver.Wrapper/Services/CategoriesService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public CategoriesService() /// Query for categories /// details: https://developer.chargeover.com/apidocs/rest/#list-category /// - public IResponse QueryCategories(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async TaskQueryCategories(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("item_category", queries, orders, offset, limit); + return await Query("item_category", queries, orders, offset, limit); } } } diff --git a/src/ChargeOver.Wrapper/Services/ChargeOverService.cs b/src/ChargeOver.Wrapper/Services/ChargeOverService.cs index e342960..c2f7a38 100644 --- a/src/ChargeOver.Wrapper/Services/ChargeOverService.cs +++ b/src/ChargeOver.Wrapper/Services/ChargeOverService.cs @@ -1,5 +1,6 @@ using ChargeOver.Wrapper.Models; using Newtonsoft.Json; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -17,27 +18,27 @@ public ChargeOverService() /// Get a list of pending requests /// details: https://developer.chargeover.com/apidocs/rest/#list-chargeoverjs /// - public IResponse GetListPendingRequests() + public async Task> GetListPendingRequests() { - return GetList("_chargeoverjs"); + return await GetList("_chargeoverjs"); } /// /// Commit a ChargeOver.js request /// details: https://developer.chargeover.com/apidocs/rest/#commit-chargeoverjs /// - public IIdentityResponse CommitChargeOver(CommitChargeOver request) + public async Task CommitChargeOver(CommitChargeOver request) { - return Create("/_chargeoverjs ", request); + return await Create("/_chargeoverjs ", request); } /// /// Reject a ChargeOver.js request /// details: https://developer.chargeover.com/apidocs/rest/#reject-chargeoverjs /// - public IIdentityResponse RejectChargeOver(RejectChargeOver request) + public async Task RejectChargeOver(RejectChargeOver request) { - return Create("/_chargeoverjs ", request); + return await Create("/_chargeoverjs ", request); } } } diff --git a/src/ChargeOver.Wrapper/Services/CountriesService.cs b/src/ChargeOver.Wrapper/Services/CountriesService.cs index 69f7983..092fed2 100644 --- a/src/ChargeOver.Wrapper/Services/CountriesService.cs +++ b/src/ChargeOver.Wrapper/Services/CountriesService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public CountriesService() /// Retrieve country list /// details: https://developer.chargeover.com/apidocs/rest/#list-country /// - public IResponse ListCountries() + public async Task> ListCountries() { - return GetList("country"); + return await GetList("country"); } } } diff --git a/src/ChargeOver.Wrapper/Services/CreditCardsService.cs b/src/ChargeOver.Wrapper/Services/CreditCardsService.cs index 2ac1d34..74576be 100644 --- a/src/ChargeOver.Wrapper/Services/CreditCardsService.cs +++ b/src/ChargeOver.Wrapper/Services/CreditCardsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,27 +17,27 @@ public CreditCardsService() /// Store a credit card /// details: https://developer.chargeover.com/apidocs/rest/#create-card /// - public IIdentityResponse StoreCreditCard(StoreCreditCard request) + public async Task StoreCreditCard(StoreCreditCard request) { - return Create("creditcard", request); + return await Create("creditcard", request); } /// /// Querying for credit cards /// details: https://developer.chargeover.com/apidocs/rest/#query-card /// - public IResponse QueryCreditCards(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryCreditCards(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("creditcard", queries, orders, offset, limit); + return await Query("creditcard", queries, orders, offset, limit); } /// /// Delete a credit card /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-creditcard /// - public IResponse DeleteCreditCard(int id) + public async TaskDeleteCreditCard(int id) { - return Delete("creditcard", id); + return await Delete("creditcard", id); } } } diff --git a/src/ChargeOver.Wrapper/Services/CurrenciesService.cs b/src/ChargeOver.Wrapper/Services/CurrenciesService.cs index 524f203..991c2c7 100644 --- a/src/ChargeOver.Wrapper/Services/CurrenciesService.cs +++ b/src/ChargeOver.Wrapper/Services/CurrenciesService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public CurrenciesService() /// List currencies /// details: https://developer.chargeover.com/apidocs/rest/#list-currency /// - public IResponse ListCurrencies() + public async Task> ListCurrencies() { - return GetList("currency"); + return await GetList("currency"); } } } diff --git a/src/ChargeOver.Wrapper/Services/CustomersService.cs b/src/ChargeOver.Wrapper/Services/CustomersService.cs index 2dbab1c..567c15a 100644 --- a/src/ChargeOver.Wrapper/Services/CustomersService.cs +++ b/src/ChargeOver.Wrapper/Services/CustomersService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,45 +17,45 @@ public CustomersService() /// Create a Customer /// details: https://developer.chargeover.com/apidocs/rest/#create-a-customer /// - public IIdentityResponse CreateCustomer(Customer request) + public async Task CreateCustomer(Customer request) { - return Create("customer", request); + return await Create("customer", request); } /// /// Update a Customer /// details: https://developer.chargeover.com/apidocs/rest/#update-a-customer /// - public IIdentityResponse UpdateCustomer(int id, UpdateCustomer request) + public async Task UpdateCustomer(int id, UpdateCustomer request) { - return new IdentityResponse(Request(MethodType.PUT, "/customer/" + id, request)); + return new IdentityResponse(await Request(MethodType.PUT, "/customer/" + id, request)); } /// /// Get a list of Customers /// details: https://developer.chargeover.com/apidocs/rest/#list-customers /// - public IResponse ListCustomers() + public async Task> ListCustomers() { - return GetList("customer"); + return await GetList("customer"); } /// /// Query for Customers /// details: https://developer.chargeover.com/apidocs/rest/#query-for-customers /// - public IResponse QueryCustomers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryCustomers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("customer", queries, orders, offset, limit); + return await Query("customer", queries, orders, offset, limit); } /// /// Delete a Customer /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-customer /// - public IResponse DeleteCustomer(int id) + public async TaskDeleteCustomer(int id) { - return Delete("customer", id); + return await Delete("customer", id); } } } diff --git a/src/ChargeOver.Wrapper/Services/IACHeCheckAccountsService.cs b/src/ChargeOver.Wrapper/Services/IACHeCheckAccountsService.cs index ec0ba7e..7bfea84 100644 --- a/src/ChargeOver.Wrapper/Services/IACHeCheckAccountsService.cs +++ b/src/ChargeOver.Wrapper/Services/IACHeCheckAccountsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,12 +9,12 @@ public interface IACHeCheckAccountsService /// Store an ACH account /// details: https://developer.chargeover.com/apidocs/rest/#create-ach /// - IIdentityResponse StoreACHAccount(StoreACHAccount request); + Task StoreACHAccount(StoreACHAccount request); - /// - /// Delete an ACH account - /// details: https://developer.chargeover.com/apidocs/rest/#delete-an-ach - /// - IResponse DeleteACHAccount(int id); + /// + /// Delete an ACH account + /// details: https://developer.chargeover.com/apidocs/rest/#delete-an-ach + /// + Task DeleteACHAccount(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/IAdminWorkersService.cs b/src/ChargeOver.Wrapper/Services/IAdminWorkersService.cs index 603a123..c8c4b19 100644 --- a/src/ChargeOver.Wrapper/Services/IAdminWorkersService.cs +++ b/src/ChargeOver.Wrapper/Services/IAdminWorkersService.cs @@ -1,25 +1,26 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface IAdminWorkersService { - /// - /// Get a list of admin workers - /// details: https://developer.chargeover.com/apidocs/rest/#list-admins - /// - IResponse ListAdminWorkers(); + /// + /// Get a list of admin workers + /// details: https://developer.chargeover.com/apidocs/rest/#list-admins + /// + Task> ListAdminWorkers(); /// /// Query for admin workers /// details: https://developer.chargeover.com/apidocs/rest/#query-admins /// - IResponse QueryAdminWorkers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + Task> QueryAdminWorkers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); - /// - /// Get a specific admin worker - /// details: https://developer.chargeover.com/apidocs/rest/#get-admin - /// - ICustomResponse GetAdminWorker(int id); + /// + /// Get a specific admin worker + /// details: https://developer.chargeover.com/apidocs/rest/#get-admin + /// + Task> GetAdminWorker(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/IBrandsService.cs b/src/ChargeOver.Wrapper/Services/IBrandsService.cs index f599085..6ee7c72 100644 --- a/src/ChargeOver.Wrapper/Services/IBrandsService.cs +++ b/src/ChargeOver.Wrapper/Services/IBrandsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,6 +9,6 @@ public interface IBrandsService /// Retrieve brand list /// details: https://developer.chargeover.com/apidocs/rest/#list-brand /// - IResponse ListBrands(); + Task> ListBrands(); } } diff --git a/src/ChargeOver.Wrapper/Services/ICampaignsService.cs b/src/ChargeOver.Wrapper/Services/ICampaignsService.cs index 6f84c39..b422dd5 100644 --- a/src/ChargeOver.Wrapper/Services/ICampaignsService.cs +++ b/src/ChargeOver.Wrapper/Services/ICampaignsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,6 +9,6 @@ public interface ICampaignsService /// Retrieve campaign list /// details: https://developer.chargeover.com/apidocs/rest/#list-campaign /// - IResponse ListCampaigns(); + Task> ListCampaigns(); } } diff --git a/src/ChargeOver.Wrapper/Services/ICategoriesService.cs b/src/ChargeOver.Wrapper/Services/ICategoriesService.cs index e7b791d..f1cf078 100644 --- a/src/ChargeOver.Wrapper/Services/ICategoriesService.cs +++ b/src/ChargeOver.Wrapper/Services/ICategoriesService.cs @@ -1,3 +1,5 @@ +using System.Threading.Tasks; + namespace ChargeOver.Wrapper.Services { public interface ICategoriesService @@ -6,6 +8,6 @@ public interface ICategoriesService /// Query for categories /// details: https://developer.chargeover.com/apidocs/rest/#list-category /// - IResponse QueryCategories(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + Task QueryCategories(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); } } diff --git a/src/ChargeOver.Wrapper/Services/IChargeOverService.cs b/src/ChargeOver.Wrapper/Services/IChargeOverService.cs index 803dc82..df00aa1 100644 --- a/src/ChargeOver.Wrapper/Services/IChargeOverService.cs +++ b/src/ChargeOver.Wrapper/Services/IChargeOverService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,18 +9,18 @@ public interface IChargeOverService /// Get a list of pending requests /// details: https://developer.chargeover.com/apidocs/rest/#list-chargeoverjs /// - IResponse GetListPendingRequests(); + Task> GetListPendingRequests(); /// /// Commit a ChargeOver.js request /// details: https://developer.chargeover.com/apidocs/rest/#commit-chargeoverjs /// - IIdentityResponse CommitChargeOver(CommitChargeOver request); + Task CommitChargeOver(CommitChargeOver request); /// /// Reject a ChargeOver.js request /// details: https://developer.chargeover.com/apidocs/rest/#reject-chargeoverjs /// - IIdentityResponse RejectChargeOver(RejectChargeOver request); + Task RejectChargeOver(RejectChargeOver request); } } diff --git a/src/ChargeOver.Wrapper/Services/ICountriesService.cs b/src/ChargeOver.Wrapper/Services/ICountriesService.cs index 6183d02..0fd8ea4 100644 --- a/src/ChargeOver.Wrapper/Services/ICountriesService.cs +++ b/src/ChargeOver.Wrapper/Services/ICountriesService.cs @@ -1,5 +1,6 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface ICountriesService @@ -8,6 +9,6 @@ public interface ICountriesService /// Retrieve country list /// details: https://developer.chargeover.com/apidocs/rest/#list-country /// - IResponse ListCountries(); + Task> ListCountries(); } } diff --git a/src/ChargeOver.Wrapper/Services/ICreditCardsService.cs b/src/ChargeOver.Wrapper/Services/ICreditCardsService.cs index b6c789e..539070f 100644 --- a/src/ChargeOver.Wrapper/Services/ICreditCardsService.cs +++ b/src/ChargeOver.Wrapper/Services/ICreditCardsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,18 +9,18 @@ public interface ICreditCardsService /// Store a credit card /// details: https://developer.chargeover.com/apidocs/rest/#create-card /// - IIdentityResponse StoreCreditCard(StoreCreditCard request); + Task StoreCreditCard(StoreCreditCard request); - /// - /// Querying for credit cards - /// details: https://developer.chargeover.com/apidocs/rest/#query-card - /// - IResponse QueryCreditCards(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + /// + /// Querying for credit cards + /// details: https://developer.chargeover.com/apidocs/rest/#query-card + /// + Task> QueryCreditCards(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); - /// - /// Delete a credit card - /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-creditcard - /// - IResponse DeleteCreditCard(int id); + /// + /// Delete a credit card + /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-creditcard + /// + Task DeleteCreditCard(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/ICurrenciesService.cs b/src/ChargeOver.Wrapper/Services/ICurrenciesService.cs index 63278ca..3b55939 100644 --- a/src/ChargeOver.Wrapper/Services/ICurrenciesService.cs +++ b/src/ChargeOver.Wrapper/Services/ICurrenciesService.cs @@ -1,13 +1,14 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface ICurrenciesService { - /// - /// List currencies - /// details: https://developer.chargeover.com/apidocs/rest/#list-currency - /// - IResponse ListCurrencies(); + /// + /// List currencies + /// details: https://developer.chargeover.com/apidocs/rest/#list-currency + /// + Task> ListCurrencies(); } } diff --git a/src/ChargeOver.Wrapper/Services/ICustomersService.cs b/src/ChargeOver.Wrapper/Services/ICustomersService.cs index 98b3328..0041e6c 100644 --- a/src/ChargeOver.Wrapper/Services/ICustomersService.cs +++ b/src/ChargeOver.Wrapper/Services/ICustomersService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,30 +9,30 @@ public interface ICustomersService /// Create a Customer /// details: https://developer.chargeover.com/apidocs/rest/#create-a-customer /// - IIdentityResponse CreateCustomer(Models.Customer request); + Task CreateCustomer(Models.Customer request); - /// - /// Update a Customer - /// details: https://developer.chargeover.com/apidocs/rest/#update-a-customer - /// - IIdentityResponse UpdateCustomer(int id, UpdateCustomer request); + /// + /// Update a Customer + /// details: https://developer.chargeover.com/apidocs/rest/#update-a-customer + /// + Task UpdateCustomer(int id, UpdateCustomer request); - /// - /// Get a list of Customers - /// details: https://developer.chargeover.com/apidocs/rest/#list-customers - /// - IResponse ListCustomers(); + /// + /// Get a list of Customers + /// details: https://developer.chargeover.com/apidocs/rest/#list-customers + /// + Task> ListCustomers(); - /// - /// Query for Customers - /// details: https://developer.chargeover.com/apidocs/rest/#query-for-customers - /// - IResponse QueryCustomers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + /// + /// Query for Customers + /// details: https://developer.chargeover.com/apidocs/rest/#query-for-customers + /// + Task> QueryCustomers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); - /// - /// Delete a Customer - /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-customer - /// - IResponse DeleteCustomer(int id); + /// + /// Delete a Customer + /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-customer + /// + Task DeleteCustomer(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/IInvoicesService.cs b/src/ChargeOver.Wrapper/Services/IInvoicesService.cs index 0f8bad8..1a6cdec 100644 --- a/src/ChargeOver.Wrapper/Services/IInvoicesService.cs +++ b/src/ChargeOver.Wrapper/Services/IInvoicesService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,60 +9,60 @@ public interface IInvoicesService /// Create an invoice /// details: https://developer.chargeover.com/apidocs/rest/#create-an-invoice /// - IIdentityResponse CreateInvoice(Models.Invoice request); + Task CreateInvoice(Models.Invoice request); /// /// Update an invoice /// details: https://developer.chargeover.com/apidocs/rest/#update-an-invoice /// - IIdentityResponse UpdateInvoice(int invoiceId, UpdateInvoice request); + Task UpdateInvoice(int invoiceId, UpdateInvoice request); /// /// Get a specific invoice /// details: https://developer.chargeover.com/apidocs/rest/#get-for-invoices /// - ICustomResponse GetInvoice(int id); + Task> GetInvoice(int id); /// /// Query for invoices /// details: https://developer.chargeover.com/apidocs/rest/#query-for-invoices /// - IResponse QueryInvoices(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + Task> QueryInvoices(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); - /// - /// Credit card payment (specify card details) - /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-cc - /// - ICustomResponse CreditCardPayment(int invoiceId, CreditCardPayment request); + /// + /// Credit card payment (specify card details) + /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-cc + /// + Task> CreditCardPayment(int invoiceId, CreditCardPayment request); /// /// ACH/eCheck payment (specify ACH details) /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-ach-new /// - ICustomResponse ACHCheckpayment(int invoiceId, ACHCheckPayment request); + Task> ACHCheckpayment(int invoiceId, ACHCheckPayment request); /// /// Apply an open customer balance /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-balance /// - ICustomResponse ApplyOpenCustomerBalance(int invoiceId, ApplyOpenCustomerBalance request); + Task> ApplyOpenCustomerBalance(int invoiceId, ApplyOpenCustomerBalance request); - /// - /// Void an invoice - /// details: https://developer.chargeover.com/apidocs/rest/#void-an-invoice - /// - IResponse VoidInvoice(int invoiceId); + /// + /// Void an invoice + /// details: https://developer.chargeover.com/apidocs/rest/#void-an-invoice + /// + Task VoidInvoice(int invoiceId); /// /// Email an invoice /// details: https://developer.chargeover.com/apidocs/rest/#email-an-invoice /// - ICustomResponse EmailInvoice(int invoiceId, EmailInvoice request); + Task> EmailInvoice(int invoiceId, EmailInvoice request); /// /// Print & mail an invoice /// details: https://developer.chargeover.com/apidocs/rest/#print-an-invoice /// - ICustomResponse PrintInvoice(int invoiceId, PrintInvoice request); + Task> PrintInvoice(int invoiceId, PrintInvoice request); } } diff --git a/src/ChargeOver.Wrapper/Services/IItemsService.cs b/src/ChargeOver.Wrapper/Services/IItemsService.cs index ae85721..c107bc4 100644 --- a/src/ChargeOver.Wrapper/Services/IItemsService.cs +++ b/src/ChargeOver.Wrapper/Services/IItemsService.cs @@ -1,19 +1,20 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface IItemsService { - /// - /// Create an item - /// details: https://developer.chargeover.com/apidocs/rest/#create-item - /// - IIdentityResponse CreateItem(Models.Item request); + /// + /// Create an item + /// details: https://developer.chargeover.com/apidocs/rest/#create-item + /// + Task CreateItem(Models.Item request); - /// - /// Querying for items - /// details: https://developer.chargeover.com/apidocs/rest/#query-item - /// - IResponse QueryItems(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + /// + /// Querying for items + /// details: https://developer.chargeover.com/apidocs/rest/#query-item + /// + Task> QueryItems(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); } } diff --git a/src/ChargeOver.Wrapper/Services/ILanguagesService.cs b/src/ChargeOver.Wrapper/Services/ILanguagesService.cs index c34c91a..024ff39 100644 --- a/src/ChargeOver.Wrapper/Services/ILanguagesService.cs +++ b/src/ChargeOver.Wrapper/Services/ILanguagesService.cs @@ -1,13 +1,14 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface ILanguagesService { - /// - /// List languages - /// details: https://developer.chargeover.com/apidocs/rest/#list-language - /// - IResponse ListLanguages(); + /// + /// List languages + /// details: https://developer.chargeover.com/apidocs/rest/#list-language + /// + Task> ListLanguages(); } } diff --git a/src/ChargeOver.Wrapper/Services/INotesService.cs b/src/ChargeOver.Wrapper/Services/INotesService.cs index e40d3ad..300e3dc 100644 --- a/src/ChargeOver.Wrapper/Services/INotesService.cs +++ b/src/ChargeOver.Wrapper/Services/INotesService.cs @@ -1,19 +1,20 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface INotesService { - /// - /// Create a note - /// details: https://developer.chargeover.com/apidocs/rest/#create_note - /// - IIdentityResponse CreateNote(Note request); + /// + /// Create a note + /// details: https://developer.chargeover.com/apidocs/rest/#create_note + /// + TaskCreateNote(Note request); - /// - /// Query notes for an object - /// details: https://developer.chargeover.com/apidocs/rest/#query_note - /// - IResponse QueryNotesForObject(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + /// + /// Query notes for an object + /// details: https://developer.chargeover.com/apidocs/rest/#query_note + /// + Task> QueryNotesForObject(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); } } diff --git a/src/ChargeOver.Wrapper/Services/IRestHooksService.cs b/src/ChargeOver.Wrapper/Services/IRestHooksService.cs index fc72be6..c5406b5 100644 --- a/src/ChargeOver.Wrapper/Services/IRestHooksService.cs +++ b/src/ChargeOver.Wrapper/Services/IRestHooksService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,12 +9,12 @@ public interface IRESTHooksService /// Subscribing /// details: https://developer.chargeover.com/apidocs/rest/#subscribe-resthook /// - IIdentityResponse Subscribe(Subscribing request); + Task Subscribe(Subscribing request); /// /// Unsubscribing /// details: https://developer.chargeover.com/apidocs/rest/#unsubscribe-resthook /// - IResponse Unsubscribe(int id); + Task Unsubscribe(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/ISubscriptionsService.cs b/src/ChargeOver.Wrapper/Services/ISubscriptionsService.cs index 4817a3e..d6f8374 100644 --- a/src/ChargeOver.Wrapper/Services/ISubscriptionsService.cs +++ b/src/ChargeOver.Wrapper/Services/ISubscriptionsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,72 +9,72 @@ public interface ISubscriptionsService /// Create a subscription /// details: https://developer.chargeover.com/apidocs/rest/#create-recurring-package /// - IIdentityResponse CreateSubscription(Subscription request); + Task CreateSubscription(Subscription request); /// /// Update a subscription /// details: https://developer.chargeover.com/apidocs/rest/#update-recurring-package /// - IIdentityResponse UpdateSubscription(int id, UpdateSubscription request); + Task UpdateSubscription(int id, UpdateSubscription request); - /// - /// Get a specific subscription - /// details: https://developer.chargeover.com/apidocs/rest/#get-subscription - /// - ICustomResponse GetSubscription(int id); + /// + /// Get a specific subscription + /// details: https://developer.chargeover.com/apidocs/rest/#get-subscription + /// + Task> GetSubscription(int id); /// /// Querying for subscriptions /// details: https://developer.chargeover.com/apidocs/rest/#query-subscription /// - IResponse QuerySubscriptions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + Task> QuerySubscriptions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); - /// - /// Upgrade/downgrade a subscription - /// details: https://developer.chargeover.com/apidocs/rest/#subscription-upgrade-downgrade - /// - ICustomResponse UpgradeDowngradeSubscription(int id, UpgradeDowngradesubscription request); + /// + /// Upgrade/downgrade a subscription + /// details: https://developer.chargeover.com/apidocs/rest/#subscription-upgrade-downgrade + /// + Task> UpgradeDowngradeSubscription(int id, UpgradeDowngradesubscription request); /// /// Change pricing on a subscription /// details: https://developer.chargeover.com/apidocs/rest/#subscription-change-pricing /// - ICustomResponse ChangePricingOnSubscription(int subscriptionId, ChangePricingOnSubscription request); + Task> ChangePricingOnSubscription(int subscriptionId, ChangePricingOnSubscription request); /// /// Invoice a subscription now /// details: https://developer.chargeover.com/apidocs/rest/#example-package-invoice /// - IIdentityResponse InvoiceSubscriptionNow(int id); + Task InvoiceSubscriptionNow(int id); - /// - /// Suspend a subscription (indefinitely) - /// details: https://developer.chargeover.com/apidocs/rest/#suspend-recurring-package-indefinitely - /// - ICustomResponse SuspendSubscription(int id); + /// + /// Suspend a subscription (indefinitely) + /// details: https://developer.chargeover.com/apidocs/rest/#suspend-recurring-package-indefinitely + /// + Task> SuspendSubscription(int id); /// /// Unsuspend a subscription /// details: https://developer.chargeover.com/apidocs/rest/#contract-unsuspend /// - ICustomResponse UnsuspendSubscription(int id); + Task> UnsuspendSubscription(int id); /// /// Cancel a subscription /// details: https://developer.chargeover.com/apidocs/rest/#cancel-package /// - ICustomResponse CancelSubscription(int id); + Task> CancelSubscription(int id); /// /// Set the payment method /// details: https://developer.chargeover.com/apidocs/rest/#example-package-set-paymethod /// - ICustomResponse SetPaymentMethod(int id, SetThePaymentMethod request); + Task> SetPaymentMethod(int id, SetThePaymentMethod request); /// /// Send a welcome e-mail /// details: https://developer.chargeover.com/apidocs/rest/#example-package-send-welcome /// - ICustomResponse SendWelcomeEmail(int id); + Task> SendWelcomeEmail(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/ISystemLogService.cs b/src/ChargeOver.Wrapper/Services/ISystemLogService.cs index e57a51a..54d7fd8 100644 --- a/src/ChargeOver.Wrapper/Services/ISystemLogService.cs +++ b/src/ChargeOver.Wrapper/Services/ISystemLogService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,6 +9,6 @@ public interface ISystemLogService /// Retrieve the system log /// details: https://developer.chargeover.com/apidocs/rest/#list-syslog /// - IResponse ListSystemLogs(); + Task> ListSystemLogs(); } } diff --git a/src/ChargeOver.Wrapper/Services/ITermsService.cs b/src/ChargeOver.Wrapper/Services/ITermsService.cs index 8418b0a..c2fbc53 100644 --- a/src/ChargeOver.Wrapper/Services/ITermsService.cs +++ b/src/ChargeOver.Wrapper/Services/ITermsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,6 +9,6 @@ public interface ITermsService /// List terms /// details: https://developer.chargeover.com/apidocs/rest/#list-terms /// - IResponse ListTerms(); + Task> ListTerms(); } } diff --git a/src/ChargeOver.Wrapper/Services/ITokenizedPayMethodsService.cs b/src/ChargeOver.Wrapper/Services/ITokenizedPayMethodsService.cs index 9501758..50cddbb 100644 --- a/src/ChargeOver.Wrapper/Services/ITokenizedPayMethodsService.cs +++ b/src/ChargeOver.Wrapper/Services/ITokenizedPayMethodsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,12 +9,12 @@ public interface ITokenizedPayMethodsService /// Store a pay method token /// details: https://developer.chargeover.com/apidocs/rest/#create-tokenized /// - IIdentityResponse StorePayMethodToken(StorePayMethodToken request); + Task StorePayMethodToken(StorePayMethodToken request); /// /// Delete tokenized pay method /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-tokenized /// - IResponse DeleteTokenizedPayMethod(int id); + Task DeleteTokenizedPayMethod(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/ITransactionsService.cs b/src/ChargeOver.Wrapper/Services/ITransactionsService.cs index e174cf6..a5de619 100644 --- a/src/ChargeOver.Wrapper/Services/ITransactionsService.cs +++ b/src/ChargeOver.Wrapper/Services/ITransactionsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,54 +9,54 @@ public interface ITransactionsService /// Create a payment /// details: https://developer.chargeover.com/apidocs/rest/#create-transaction /// - IIdentityResponse CreatePayment(Payment request); + Task CreatePayment(Payment request); - /// - /// Get a specific transaction - /// details: https://developer.chargeover.com/apidocs/rest/#get-transaction - /// - ICustomResponse GetTransaction(int id); + /// + /// Get a specific transaction + /// details: https://developer.chargeover.com/apidocs/rest/#get-transaction + /// + Task> GetTransaction(int id); /// /// List transactions /// details: https://developer.chargeover.com/apidocs/rest/#list-all-transactions /// - IResponse ListTransactions(); + Task> ListTransactions(); /// /// Query for transactions /// details: https://developer.chargeover.com/apidocs/rest/#query-for-transactions /// - IResponse QueryTransactions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + Task> QueryTransactions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); /// /// Attempt a payment /// details: https://developer.chargeover.com/apidocs/rest/#pay-transaction /// - IIdentityResponse AttemptPayment(AttemptPayment request); + Task AttemptPayment(AttemptPayment request); /// /// Create a refund /// details: https://developer.chargeover.com/apidocs/rest/#create-transaction-refund /// - IIdentityResponse CreateRefund(Refund request); + Task CreateRefund(Refund request); /// /// Refund a payment /// details: https://developer.chargeover.com/apidocs/rest/#refund-transaction /// - IIdentityResponse RefundPayment(int id, RefundPayment request); + Task RefundPayment(int id, RefundPayment request); - /// - /// Void a transaction - /// details: https://developer.chargeover.com/apidocs/rest/#void-a-transaction - /// - ICustomResponse VoidTransaction(int id); + /// + /// Void a transaction + /// details: https://developer.chargeover.com/apidocs/rest/#void-a-transaction + /// + Task> VoidTransaction(int id); /// /// Email a receipt /// details: https://developer.chargeover.com/apidocs/rest/#email-a-transaction /// - ICustomResponse EmailReceipt(int id, EmailInvoice request); + Task> EmailReceipt(int id, EmailInvoice request); } } diff --git a/src/ChargeOver.Wrapper/Services/IUsageService.cs b/src/ChargeOver.Wrapper/Services/IUsageService.cs index d2af023..1513c13 100644 --- a/src/ChargeOver.Wrapper/Services/IUsageService.cs +++ b/src/ChargeOver.Wrapper/Services/IUsageService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -8,6 +9,6 @@ public interface IUsageService /// Storing Usage Data /// details: https://developer.chargeover.com/apidocs/rest/#create-usage /// - IIdentityResponse StoreUsageData(StoringUsageData request); + Task StoreUsageData(StoringUsageData request); } } diff --git a/src/ChargeOver.Wrapper/Services/IUsersContactsService.cs b/src/ChargeOver.Wrapper/Services/IUsersContactsService.cs index a5cc9fe..3dfa660 100644 --- a/src/ChargeOver.Wrapper/Services/IUsersContactsService.cs +++ b/src/ChargeOver.Wrapper/Services/IUsersContactsService.cs @@ -1,55 +1,56 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { public interface IUsersContactsService { - /// - /// Add a contact - /// details: https://developer.chargeover.com/apidocs/rest/#create-a-user - /// - IIdentityResponse AddContact(AddContact request); + /// + /// Add a contact + /// details: https://developer.chargeover.com/apidocs/rest/#create-a-user + /// + Task AddContact(AddContact request); - /// - /// Get a specific contact - /// details: https://developer.chargeover.com/apidocs/rest/#get-users - /// - ICustomResponse GetContact(int id); + /// + /// Get a specific contact + /// details: https://developer.chargeover.com/apidocs/rest/#get-users + /// + Task> GetContact(int id); /// /// Get a list of contacts /// details: https://developer.chargeover.com/apidocs/rest/#list-users /// - IResponse ListContacts(); + Task> ListContacts(); /// /// Query for contacts /// details: https://developer.chargeover.com/apidocs/rest/#query-users /// - IResponse QueryForContacts(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); + Task> QueryForContacts(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10); - /// - /// Send a password reset - /// details: https://developer.chargeover.com/apidocs/rest/#reset-a-password - /// - ICustomResponse SendPasswordReset(int userId); + /// + /// Send a password reset + /// details: https://developer.chargeover.com/apidocs/rest/#reset-a-password + /// + Task> SendPasswordReset(int userId); /// /// Set a password /// details: https://developer.chargeover.com/apidocs/rest/#set-a-password /// - ICustomResponse SetPassword(int userId, SetPassword request); + Task> SetPassword(int userId, SetPassword request); /// /// Log in a user /// details: https://developer.chargeover.com/apidocs/rest/#login-a-user /// - ICustomResponse LogIn(int id); + Task> LogIn(int id); /// /// Delete a contact /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-user /// - IResponse DeleteContact(int id); + Task DeleteContact(int id); } } diff --git a/src/ChargeOver.Wrapper/Services/InvoicesService.cs b/src/ChargeOver.Wrapper/Services/InvoicesService.cs index cbd0358..bfe7f02 100644 --- a/src/ChargeOver.Wrapper/Services/InvoicesService.cs +++ b/src/ChargeOver.Wrapper/Services/InvoicesService.cs @@ -1,5 +1,6 @@ using ChargeOver.Wrapper.Models; using Newtonsoft.Json; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -17,90 +18,90 @@ public InvoicesService() /// Create an invoice /// details: https://developer.chargeover.com/apidocs/rest/#create-an-invoice /// - public IIdentityResponse CreateInvoice(Models.Invoice request) + public async Task CreateInvoice(Models.Invoice request) { - return Create("/invoice ", request); + return await Create("/invoice ", request); } /// /// Update an invoice /// details: https://developer.chargeover.com/apidocs/rest/#update-an-invoice /// - public IIdentityResponse UpdateInvoice(int invoiceId, UpdateInvoice request) + public async Task UpdateInvoice(int invoiceId, UpdateInvoice request) { - return new IdentityResponse(Request(MethodType.PUT, $"/invoice/{invoiceId}", request)); + return new IdentityResponse(await Request(MethodType.PUT, $"/invoice/{invoiceId}", request)); } /// /// Get a specific invoice /// details: https://developer.chargeover.com/apidocs/rest/#get-for-invoices /// - public ICustomResponse GetInvoice(int id) + public async Task> GetInvoice(int id) { - return GetCustom("invoice", id); + return await GetCustom("invoice", id); } /// /// Query for invoices /// details: https://developer.chargeover.com/apidocs/rest/#query-for-invoices /// - public IResponse QueryInvoices(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryInvoices(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("invoice", queries, orders, offset, limit); + return await Query("invoice", queries, orders, offset, limit); } /// /// Credit card payment (specify card details) /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-cc /// - public ICustomResponse CreditCardPayment(int invoiceId, CreditCardPayment request) + public async Task> CreditCardPayment(int invoiceId, CreditCardPayment request) { - return new CustomResponse(Request>(MethodType.POST, $"/invoice/{invoiceId}?action=pay", request)); + return new CustomResponse(await Request>(MethodType.POST, $"/invoice/{invoiceId}?action=pay", request)); } /// /// ACH/eCheck payment (specify ACH details) /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-ach-new /// - public ICustomResponse ACHCheckpayment(int invoiceId, ACHCheckPayment request) + public async Task> ACHCheckpayment(int invoiceId, ACHCheckPayment request) { - return GetCustomBool($"/invoice/{invoiceId}?action=pay", request); + return await GetCustomBool($"/invoice/{invoiceId}?action=pay", request); } /// /// Apply an open customer balance /// details: https://developer.chargeover.com/apidocs/rest/#payment-for-invoice-balance /// - public ICustomResponse ApplyOpenCustomerBalance(int invoiceId, ApplyOpenCustomerBalance request) + public async Task> ApplyOpenCustomerBalance(int invoiceId, ApplyOpenCustomerBalance request) { - return GetCustomBool($"/invoice/{invoiceId}?action=pay", request); + return await GetCustomBool($"/invoice/{invoiceId}?action=pay", request); } /// /// Void an invoice /// details: https://developer.chargeover.com/apidocs/rest/#void-an-invoice /// - public IResponse VoidInvoice(int invoiceId) + public async TaskVoidInvoice(int invoiceId) { - return GetCustomBool($"/invoice/{invoiceId}?action=void", new { }); + return await GetCustomBool($"/invoice/{invoiceId}?action=void", new { }); } /// /// Email an invoice /// details: https://developer.chargeover.com/apidocs/rest/#email-an-invoice /// - public ICustomResponse EmailInvoice(int invoiceId, EmailInvoice request) + public async Task> EmailInvoice(int invoiceId, EmailInvoice request) { - return new CustomResponse(Request>(MethodType.POST, $"/invoice/{invoiceId}?action=email", request)); + return new CustomResponse(await Request>(MethodType.POST, $"/invoice/{invoiceId}?action=email", request)); } /// /// Print & mail an invoice /// details: https://developer.chargeover.com/apidocs/rest/#print-an-invoice /// - public ICustomResponse PrintInvoice(int invoiceId, PrintInvoice request) + public async Task> PrintInvoice(int invoiceId, PrintInvoice request) { - return GetCustomBool($"/invoice/{invoiceId}?action=print", request); + return await GetCustomBool($"/invoice/{invoiceId}?action=print", request); } } } diff --git a/src/ChargeOver.Wrapper/Services/ItemsService.cs b/src/ChargeOver.Wrapper/Services/ItemsService.cs index 5de75e6..7208fd6 100644 --- a/src/ChargeOver.Wrapper/Services/ItemsService.cs +++ b/src/ChargeOver.Wrapper/Services/ItemsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,18 +17,18 @@ public ItemsService() /// Create an item /// details: https://developer.chargeover.com/apidocs/rest/#create-item /// - public IIdentityResponse CreateItem(Models.Item request) + public async Task CreateItem(Models.Item request) { - return Create("item", request); + return await Create("item", request); } /// /// Querying for items /// details: https://developer.chargeover.com/apidocs/rest/#query-item /// - public IResponse QueryItems(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryItems(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("item"); + return await Query("item"); } } } diff --git a/src/ChargeOver.Wrapper/Services/LanguagesService.cs b/src/ChargeOver.Wrapper/Services/LanguagesService.cs index ec6fa43..5a0bfff 100644 --- a/src/ChargeOver.Wrapper/Services/LanguagesService.cs +++ b/src/ChargeOver.Wrapper/Services/LanguagesService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public LanguagesService() /// List languages /// details: https://developer.chargeover.com/apidocs/rest/#list-language /// - public IResponse ListLanguages() + public async Task> ListLanguages() { - return GetList("/language"); + return await GetList("/language"); } } } diff --git a/src/ChargeOver.Wrapper/Services/NotesService.cs b/src/ChargeOver.Wrapper/Services/NotesService.cs index c4d741e..edada0d 100644 --- a/src/ChargeOver.Wrapper/Services/NotesService.cs +++ b/src/ChargeOver.Wrapper/Services/NotesService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,18 +17,18 @@ public NotesService() /// Create a note /// details: https://developer.chargeover.com/apidocs/rest/#create_note /// - public IIdentityResponse CreateNote(Note request) + public async Task CreateNote(Note request) { - return Create("note", request); + return await Create("note", request); } /// /// Query notes for an object /// details: https://developer.chargeover.com/apidocs/rest/#query_note /// - public IResponse QueryNotesForObject(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryNotesForObject(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("note", queries, orders, offset, limit); + return await Query("note", queries, orders, offset, limit); } } } diff --git a/src/ChargeOver.Wrapper/Services/RESTHooksService.cs b/src/ChargeOver.Wrapper/Services/RESTHooksService.cs index 6b80a00..4a2ce63 100644 --- a/src/ChargeOver.Wrapper/Services/RESTHooksService.cs +++ b/src/ChargeOver.Wrapper/Services/RESTHooksService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,18 +17,18 @@ public RESTHooksService() /// Subscribing /// details: https://developer.chargeover.com/apidocs/rest/#subscribe-resthook /// - public IIdentityResponse Subscribe(Subscribing request) + public async Task Subscribe(Subscribing request) { - return Create("/_resthook", request); + return await Create("/_resthook", request); } /// /// Unsubscribing /// details: https://developer.chargeover.com/apidocs/rest/#unsubscribe-resthook /// - public IResponse Unsubscribe(int id) + public async TaskUnsubscribe(int id) { - return Delete("_resthook", id); + return await Delete("_resthook", id); } } } diff --git a/src/ChargeOver.Wrapper/Services/SubscriptionsService.cs b/src/ChargeOver.Wrapper/Services/SubscriptionsService.cs index 0239c92..405ceac 100644 --- a/src/ChargeOver.Wrapper/Services/SubscriptionsService.cs +++ b/src/ChargeOver.Wrapper/Services/SubscriptionsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,108 +17,108 @@ public SubscriptionsService() /// Create a subscription /// details: https://developer.chargeover.com/apidocs/rest/#create-recurring-package /// - public IIdentityResponse CreateSubscription(Subscription request) + public async Task CreateSubscription(Subscription request) { - return Create("package", request); + return await Create("package", request); } /// /// Update a subscription /// details: https://developer.chargeover.com/apidocs/rest/#update-recurring-package /// - public IIdentityResponse UpdateSubscription(int id, UpdateSubscription request) + public async Task UpdateSubscription(int id, UpdateSubscription request) { - return new IdentityResponse(Request(MethodType.PUT, "/package/" + id, request)); + return new IdentityResponse(await Request(MethodType.PUT, "/package/" + id, request)); } /// /// Get a specific subscription /// details: https://developer.chargeover.com/apidocs/rest/#get-subscription /// - public ICustomResponse GetSubscription(int id) + public async Task> GetSubscription(int id) { - return GetCustom("package", id); + return await GetCustom("package", id); } /// /// Querying for subscriptions /// details: https://developer.chargeover.com/apidocs/rest/#query-subscription /// - public IResponse QuerySubscriptions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QuerySubscriptions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("package", queries, orders, offset, limit); + return await Query("package", queries, orders, offset, limit); } /// /// Upgrade/downgrade a subscription /// details: https://developer.chargeover.com/apidocs/rest/#subscription-upgrade-downgrade /// - public ICustomResponse UpgradeDowngradeSubscription(int id, UpgradeDowngradesubscription request) + public async Task> UpgradeDowngradeSubscription(int id, UpgradeDowngradesubscription request) { - return GetCustomBool($"/package/{id}?action=upgrade", request); + return await GetCustomBool($"/package/{id}?action=upgrade", request); } /// /// Change pricing on a subscription /// details: https://developer.chargeover.com/apidocs/rest/#subscription-change-pricing /// - public ICustomResponse ChangePricingOnSubscription(int subscription, ChangePricingOnSubscription request) + public async Task> ChangePricingOnSubscription(int subscription, ChangePricingOnSubscription request) { - return GetCustomBool($"/package/{subscription}?action=upgrade", request); + return await GetCustomBool($"/package/{subscription}?action=upgrade", request); } /// /// Invoice a subscription now /// details: https://developer.chargeover.com/apidocs/rest/#example-package-invoice /// - public IIdentityResponse InvoiceSubscriptionNow(int id) + public async Task InvoiceSubscriptionNow(int id) { - return Create($"/package/{id}?action=invoice", string.Empty); + return await Create($"/package/{id}?action=invoice", string.Empty); } /// /// Suspend a subscription (indefinitely) /// details: https://developer.chargeover.com/apidocs/rest/#suspend-recurring-package-indefinitely /// - public ICustomResponse SuspendSubscription(int id) + public async Task> SuspendSubscription(int id) { - return GetCustomBool($"/package/{id}?action=suspend", string.Empty); + return await GetCustomBool($"/package/{id}?action=suspend", string.Empty); } /// /// Unsuspend a subscription /// details: https://developer.chargeover.com/apidocs/rest/#contract-unsuspend /// - public ICustomResponse UnsuspendSubscription(int id) + public async Task> UnsuspendSubscription(int id) { - return GetCustomBool($"/package/{id}?action=unsuspend", string.Empty); + return await GetCustomBool($"/package/{id}?action=unsuspend", string.Empty); } /// /// Cancel a subscription /// details: https://developer.chargeover.com/apidocs/rest/#cancel-package /// - public ICustomResponse CancelSubscription(int id) + public async Task> CancelSubscription(int id) { - return GetCustomBool($"/package/{id}?action=cancel", string.Empty); + return await GetCustomBool($"/package/{id}?action=cancel", string.Empty); } /// /// Set the payment method /// details: https://developer.chargeover.com/apidocs/rest/#example-package-set-paymethod /// - public ICustomResponse SetPaymentMethod(int id, SetThePaymentMethod request) + public async Task> SetPaymentMethod(int id, SetThePaymentMethod request) { - return GetCustomBool($"/package/{id}?action=paymethod", request); + return await GetCustomBool($"/package/{id}?action=paymethod", request); } /// /// Send a welcome e-mail /// details: https://developer.chargeover.com/apidocs/rest/#example-package-send-welcome /// - public ICustomResponse SendWelcomeEmail(int id) + public async Task> SendWelcomeEmail(int id) { - return GetCustomBool($"/package/{id}?action=welcome", new { }); + return await GetCustomBool($"/package/{id}?action=welcome", new { }); } } } diff --git a/src/ChargeOver.Wrapper/Services/SystemLogService.cs b/src/ChargeOver.Wrapper/Services/SystemLogService.cs index 65bdf84..ffe6df0 100644 --- a/src/ChargeOver.Wrapper/Services/SystemLogService.cs +++ b/src/ChargeOver.Wrapper/Services/SystemLogService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public SystemLogService() /// Retrieve the system log /// details: https://developer.chargeover.com/apidocs/rest/#list-syslog /// - public IResponse ListSystemLogs() + public async Task> ListSystemLogs() { - return GetList("_log_system"); + return await GetList("_log_system"); } } } diff --git a/src/ChargeOver.Wrapper/Services/TermsService.cs b/src/ChargeOver.Wrapper/Services/TermsService.cs index 156088a..9c60d01 100644 --- a/src/ChargeOver.Wrapper/Services/TermsService.cs +++ b/src/ChargeOver.Wrapper/Services/TermsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public TermsService() /// List terms /// details: https://developer.chargeover.com/apidocs/rest/#list-terms /// - public IResponse ListTerms() + public async Task> ListTerms() { - return GetList("terms"); + return await GetList("terms"); } } } diff --git a/src/ChargeOver.Wrapper/Services/TokenizedPayMethodsService.cs b/src/ChargeOver.Wrapper/Services/TokenizedPayMethodsService.cs index dd2c0e6..3d6d30c 100644 --- a/src/ChargeOver.Wrapper/Services/TokenizedPayMethodsService.cs +++ b/src/ChargeOver.Wrapper/Services/TokenizedPayMethodsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,18 +17,18 @@ public TokenizedPayMethodsService() /// Store a pay method token /// details: https://developer.chargeover.com/apidocs/rest/#create-tokenized /// - public IIdentityResponse StorePayMethodToken(StorePayMethodToken request) + public async Task StorePayMethodToken(StorePayMethodToken request) { - return Create("tokenized", request); + return await Create("tokenized", request); } /// /// Delete tokenized pay method /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-tokenized /// - public IResponse DeleteTokenizedPayMethod(int id) + public async TaskDeleteTokenizedPayMethod(int id) { - return Delete("tokenized", id); + return await Delete("tokenized", id); } } } diff --git a/src/ChargeOver.Wrapper/Services/TransactionsService.cs b/src/ChargeOver.Wrapper/Services/TransactionsService.cs index db1e5d9..3c51e31 100644 --- a/src/ChargeOver.Wrapper/Services/TransactionsService.cs +++ b/src/ChargeOver.Wrapper/Services/TransactionsService.cs @@ -1,5 +1,6 @@ using ChargeOver.Wrapper.Models; using Newtonsoft.Json; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -17,81 +18,81 @@ public TransactionsService() /// Create a payment /// details: https://developer.chargeover.com/apidocs/rest/#create-transaction /// - public IIdentityResponse CreatePayment(Payment request) + public async Task CreatePayment(Payment request) { - return Create("transaction", request); + return await Create("transaction", request); } /// /// Get a specific transaction /// details: https://developer.chargeover.com/apidocs/rest/#get-transaction /// - public ICustomResponse GetTransaction(int id) + public async Task> GetTransaction(int id) { - return GetCustom("transaction", id); + return await GetCustom("transaction", id); } /// /// List transactions /// details: https://developer.chargeover.com/apidocs/rest/#list-all-transactions /// - public IResponse ListTransactions() + public async Task> ListTransactions() { - return GetList("transaction"); + return await GetList("transaction"); } /// /// Query for transactions /// details: https://developer.chargeover.com/apidocs/rest/#query-for-transactions /// - public IResponse QueryTransactions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryTransactions(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("transaction", queries, orders, offset, limit); + return await Query("transaction", queries, orders, offset, limit); } /// /// Attempt a payment /// details: https://developer.chargeover.com/apidocs/rest/#pay-transaction /// - public IIdentityResponse AttemptPayment(AttemptPayment request) + public async Task AttemptPayment(AttemptPayment request) { - return Create("transaction?action=pay", request); + return await Create("transaction?action=pay", request); } /// /// Create a refund /// details: https://developer.chargeover.com/apidocs/rest/#create-transaction-refund /// - public IIdentityResponse CreateRefund(Refund request) + public async Task CreateRefund(Refund request) { - return Create("transaction", request); + return await Create("transaction", request); } /// /// Refund a payment /// details: https://developer.chargeover.com/apidocs/rest/#refund-transaction /// - public IIdentityResponse RefundPayment(int id, RefundPayment request) + public async Task RefundPayment(int id, RefundPayment request) { - return Create($"transaction/{id}?action=refund", request); + return await Create($"transaction/{id}?action=refund", request); } /// /// Void a transaction /// details: https://developer.chargeover.com/apidocs/rest/#void-a-transaction /// - public ICustomResponse VoidTransaction(int id) + public async Task> VoidTransaction(int id) { - return new CustomResponse(Request>(MethodType.POST, $"/transaction/{id}/?action=void", null)); + return new CustomResponse(await Request>(MethodType.POST, $"/transaction/{id}/?action=void", null)); } /// /// Email a receipt /// details: https://developer.chargeover.com/apidocs/rest/#email-a-transaction /// - public ICustomResponse EmailReceipt(int id, EmailInvoice request) + public async Task> EmailReceipt(int id, EmailInvoice request) { - return new CustomResponse(Request>(MethodType.POST, $"/transaction/{id}?action=email", request)); + return new CustomResponse(await Request>(MethodType.POST, $"/transaction/{id}?action=email", request)); } } } diff --git a/src/ChargeOver.Wrapper/Services/UsageService.cs b/src/ChargeOver.Wrapper/Services/UsageService.cs index e8f8748..58e5276 100644 --- a/src/ChargeOver.Wrapper/Services/UsageService.cs +++ b/src/ChargeOver.Wrapper/Services/UsageService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,9 +17,9 @@ public UsageService() /// Storing Usage Data /// details: https://developer.chargeover.com/apidocs/rest/#create-usage /// - public IIdentityResponse StoreUsageData(StoringUsageData request) + public async Task StoreUsageData(StoringUsageData request) { - return Create("usage", request); + return await Create("usage", request); } } } diff --git a/src/ChargeOver.Wrapper/Services/UsersContactsService.cs b/src/ChargeOver.Wrapper/Services/UsersContactsService.cs index 66b6856..d33223c 100644 --- a/src/ChargeOver.Wrapper/Services/UsersContactsService.cs +++ b/src/ChargeOver.Wrapper/Services/UsersContactsService.cs @@ -1,4 +1,5 @@ using ChargeOver.Wrapper.Models; +using System.Threading.Tasks; namespace ChargeOver.Wrapper.Services { @@ -16,18 +17,18 @@ public UsersContactsService() /// Add a contact /// details: https://developer.chargeover.com/apidocs/rest/#create-a-user /// - public IIdentityResponse AddContact(AddContact request) + public async Task AddContact(AddContact request) { - return Create("user", request); + return await Create("user", request); } /// /// Get a specific contact /// details: https://developer.chargeover.com/apidocs/rest/#get-users /// - public ICustomResponse GetContact(int id) + public async Task> GetContact(int id) { - return GetCustom("user", id); + return await GetCustom("user", id); } /// @@ -37,63 +38,63 @@ public ICustomResponse GetContact(int id) /// The contact. /// Identifier. /// Request. - public IIdentityResponse UpdateContact(int id, Contact request) + public async Task UpdateContact(int id, Contact request) { - return new IdentityResponse(Request(MethodType.PUT, "/user/" + id, request)); + return new IdentityResponse(await Request(MethodType.PUT, "/user/" + id, request)); } /// /// Get a list of contacts /// details: https://developer.chargeover.com/apidocs/rest/#list-users /// - public IResponse ListContacts() + public async Task> ListContacts() { - return GetList("user"); + return await GetList("user"); } /// /// Query for contacts /// details: https://developer.chargeover.com/apidocs/rest/#query-users /// - public IResponse QueryForContacts(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) + public async Task> QueryForContacts(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10) { - return Query("user", queries, orders, offset, limit); + return await Query("user", queries, orders, offset, limit); } /// /// Send a password reset /// details: https://developer.chargeover.com/apidocs/rest/#reset-a-password /// - public ICustomResponse SendPasswordReset(int userId) + public async Task> SendPasswordReset(int userId) { - return GetCustomBool($"/user/{userId}?action=password", null); + return await GetCustomBool($"/user/{userId}?action=password", null); } /// /// Set a password /// details: https://developer.chargeover.com/apidocs/rest/#set-a-password /// - public ICustomResponse SetPassword(int userId, SetPassword request) + public async Task> SetPassword(int userId, SetPassword request) { - return GetCustomBool($"/user/{userId}?action=password", request); + return await GetCustomBool($"/user/{userId}?action=password", request); } /// /// Log in a user /// details: https://developer.chargeover.com/apidocs/rest/#login-a-user /// - public ICustomResponse LogIn(int id) + public async Task> LogIn(int id) { - return new CustomResponse(Request>(MethodType.POST, $"/user/{id}?action=login", null)); + return new CustomResponse(await Request>(MethodType.POST, $"/user/{id}?action=login", null)); } /// /// Delete a contact /// details: https://developer.chargeover.com/apidocs/rest/#delete-a-user /// - public IResponse DeleteContact(int id) + public async TaskDeleteContact(int id) { - return Delete("user", id); + return await Delete("user", id); } } } diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/ACHeCheckAccountsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/ACHeCheckAccountsServiceTests.cs index 3a03013..8b9f8f6 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/ACHeCheckAccountsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/ACHeCheckAccountsServiceTests.cs @@ -13,7 +13,7 @@ protected override ACHeCheckAccountsService Initialize(IChargeOverAPIConfigurati } [Test] - public void should_call_StoreACHAccount() + public async void should_call_StoreACHAccount() { //arrange var request = new StoreACHAccount @@ -24,7 +24,7 @@ public void should_call_StoreACHAccount() Routing = "072403004", }; //act - var actual = Sut.StoreACHAccount(request); + var actual = await Sut.StoreACHAccount(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -32,11 +32,11 @@ public void should_call_StoreACHAccount() } [Test] - public void should_call_DeleteACHAccount() + public async void should_call_DeleteACHAccount() { //arrange //act - var actual = Sut.DeleteACHAccount(AddACHAccount()); + var actual = await Sut.DeleteACHAccount(AddACHAccount()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/AdminWorkersServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/AdminWorkersServiceTests.cs index d7ab855..9b6fdfe 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/AdminWorkersServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/AdminWorkersServiceTests.cs @@ -14,11 +14,11 @@ protected override AdminWorkersService Initialize(IChargeOverAPIConfiguration co } [Test] - public void should_call_GetListAdminWorkers() + public async void should_call_GetListAdminWorkers() { //arrange //act - var actual = Sut.ListAdminWorkers(); + var actual = await Sut.ListAdminWorkers(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -26,11 +26,11 @@ public void should_call_GetListAdminWorkers() } [Test] - public void should_call_QueryForAdminWorkers() + public async void should_call_QueryForAdminWorkers() { //arrange //act - var actual = Sut.QueryAdminWorkers(); + var actual = await Sut.QueryAdminWorkers(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -38,12 +38,12 @@ public void should_call_QueryForAdminWorkers() } [Test] - public void should_call_GetSpecificAdminWorker() + public async void should_call_GetSpecificAdminWorker() { //arrange - var adminWorkers = Sut.ListAdminWorkers().Response.First(); + var adminWorkers = (await Sut.ListAdminWorkers()).Response.First(); //act - var actual = Sut.GetAdminWorker(adminWorkers.AdminId); + var actual = await Sut.GetAdminWorker(adminWorkers.AdminId); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/BrandsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/BrandsServiceTests.cs index d3b4a19..7afe2f0 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/BrandsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/BrandsServiceTests.cs @@ -12,11 +12,11 @@ protected override BrandsService Initialize(IChargeOverAPIConfiguration config) } [Test] - public void should_call_RetrieveBrandList() + public async void should_call_RetrieveBrandList() { //arrange //act - var actual = Sut.ListBrands(); + var actual = await Sut.ListBrands(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/CampaignsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/CampaignsServiceTests.cs index f10f421..9c84c8a 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/CampaignsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/CampaignsServiceTests.cs @@ -12,11 +12,11 @@ protected override CampaignsService Initialize(IChargeOverAPIConfiguration confi } [Test] - public void should_call_RetrieveCampaignList() + public async void should_call_RetrieveCampaignList() { //arrange //act - var actual = Sut.ListCampaigns(); + var actual = await Sut.ListCampaigns(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/CategoriesServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/CategoriesServiceTests.cs index 5d4fc2e..0dab428 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/CategoriesServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/CategoriesServiceTests.cs @@ -12,11 +12,11 @@ protected override CategoriesService Initialize(IChargeOverAPIConfiguration conf } [Test] - public void should_call_QueryForCategories() + public async void should_call_QueryForCategories() { //arrange //act - var actual = Sut.QueryCategories(); + var actual = await Sut.QueryCategories(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/ChargeOverServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/ChargeOverServiceTests.cs index 4a637d4..ccf74dc 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/ChargeOverServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/ChargeOverServiceTests.cs @@ -13,11 +13,11 @@ protected override ChargeOverService Initialize(IChargeOverAPIConfiguration conf } [Test] - public void should_call_GetListPendingRequests() + public async void should_call_GetListPendingRequests() { //arrange //act - var actual = Sut.GetListPendingRequests(); + var actual = await Sut.GetListPendingRequests(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -26,7 +26,7 @@ public void should_call_GetListPendingRequests() [Test] [Ignore("we NOT be able to automate unit tests for that")] - public void should_call_CommitChargeOver() + public async void should_call_CommitChargeOver() { //arrange var request = new CommitChargeOver @@ -34,7 +34,7 @@ public void should_call_CommitChargeOver() Commit = "6KHW4JiguocfQEO2yhmq58ZsVNGlIPb0", }; //act - var actual = Sut.CommitChargeOver(request); + var actual = await Sut.CommitChargeOver(request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -43,7 +43,7 @@ public void should_call_CommitChargeOver() [Test] [Ignore("we NOT be able to automate unit tests for that")] - public void should_call_RejectChargeOver() + public async void should_call_RejectChargeOver() { //arrange var request = new RejectChargeOver @@ -51,7 +51,7 @@ public void should_call_RejectChargeOver() Reject = "6m4npbichesodlur", }; //act - var actual = Sut.RejectChargeOver(request); + var actual = await Sut.RejectChargeOver(request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/CountriesServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/CountriesServiceTests.cs index 9e22ed5..cb65fed 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/CountriesServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/CountriesServiceTests.cs @@ -12,11 +12,11 @@ protected override CountriesService Initialize(IChargeOverAPIConfiguration confi } [Test] - public void should_call_RetrieveCountryList() + public async void should_call_RetrieveCountryList() { //arrange //act - var actual = Sut.ListCountries(); + var actual = await Sut.ListCountries(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/CreditCardsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/CreditCardsServiceTests.cs index 8387f3f..86f9e2a 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/CreditCardsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/CreditCardsServiceTests.cs @@ -14,7 +14,7 @@ protected override CreditCardsService Initialize(IChargeOverAPIConfiguration con } [Test] - public void should_call_StoreCreditCard() + public async void should_call_StoreCreditCard() { //arrange var request = new StoreCreditCard @@ -31,7 +31,7 @@ public void should_call_StoreCreditCard() Country = "United States", }; //act - var actual = Sut.StoreCreditCard(request); + var actual = await Sut.StoreCreditCard(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -39,11 +39,11 @@ public void should_call_StoreCreditCard() } [Test] - public void should_call_QueryingForCreditCards() + public async void should_call_QueryingForCreditCards() { //arrange //act - var actual = Sut.QueryCreditCards(); + var actual = await Sut.QueryCreditCards(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -51,11 +51,11 @@ public void should_call_QueryingForCreditCards() } [Test] - public void should_call_DeleteCreditCard() + public async void should_call_DeleteCreditCard() { //arrange //act - var actual = Sut.DeleteCreditCard(AddCard()); + var actual = await Sut.DeleteCreditCard(AddCard()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/CurrenciesServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/CurrenciesServiceTests.cs index dc6b131..5a3dbf0 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/CurrenciesServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/CurrenciesServiceTests.cs @@ -12,11 +12,11 @@ protected override CurrenciesService Initialize(IChargeOverAPIConfiguration conf } [Test] - public void should_call_ListCurrencies() + public async void should_call_ListCurrencies() { //arrange //act - var actual = Sut.ListCurrencies(); + var actual = await Sut.ListCurrencies(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/CustomersServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/CustomersServiceTests.cs index 007ec72..6ff2c96 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/CustomersServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/CustomersServiceTests.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; using NUnit.Framework; @@ -14,7 +15,7 @@ protected override CustomersService Initialize(IChargeOverAPIConfiguration confi } [Test] - public void should_call_CreateCustomer() + public async void should_call_CreateCustomer() { //arrange var request = new Customer @@ -26,7 +27,7 @@ public void should_call_CreateCustomer() BillState = "CT" }; //act - var actual = Sut.CreateCustomer(request); + var actual = await Sut.CreateCustomer(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -34,10 +35,10 @@ public void should_call_CreateCustomer() } [Test] - public void should_call_UpdateCustomer() + public async void should_call_UpdateCustomer() { //arrange - var customerId = CreateCustomer(); + var customerId = await CreateCustomer(); var request = new UpdateCustomer { @@ -50,21 +51,21 @@ public void should_call_UpdateCustomer() BillCountry = "USA" }; //act - var actual = Sut.UpdateCustomer(customerId, request); + var actual = await Sut.UpdateCustomer(customerId, request); //assert Assert.AreEqual(202, actual.Code); Assert.IsEmpty(actual.Message); Assert.AreEqual("OK", actual.Status); - var customer = Sut.QueryCustomers(new[] { "customer_id:EQUALS:" + customerId }).Response.First(); + var customer = (await Sut.QueryCustomers(new[] { "customer_id:EQUALS:" + customerId })).Response.First(); Assert.AreEqual(request.BillAddr1, customer.BillAddr1); } [Test] - public void should_call_GetListCustomers() + public async void should_call_GetListCustomers() { //arrange //act - var actual = Sut.ListCustomers(); + var actual = await Sut.ListCustomers(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -72,11 +73,11 @@ public void should_call_GetListCustomers() } [Test] - public void should_call_QueryForCustomers() + public async void should_call_QueryForCustomers() { //arrange //act - var actual = Sut.QueryCustomers(orders: new[] { "company:DESC" }, limit: 5); + var actual = await Sut.QueryCustomers(orders: new[] { "company:DESC" }, limit: 5); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -85,28 +86,28 @@ public void should_call_QueryForCustomers() } [Test] - public void should_call_DeleteCustomer() + public async void should_call_DeleteCustomer() { //arrange - var customerId = CreateCustomer(); + var customerId = await CreateCustomer(); //act - var actual = Sut.DeleteCustomer(customerId); + var actual = await Sut.DeleteCustomer(customerId); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); Assert.AreEqual("OK", actual.Status); } - private int CreateCustomer() + private async Task CreateCustomer() { - var customerId = Sut.CreateCustomer(new Customer + var customerId = (await Sut.CreateCustomer(new Customer { Company = "Test Company Name", BillAddr1 = "16 Dog Lane", BillAddr2 = "Suite D", BillCity = "Storrs", BillState = "CT" - }).Id; + })).Id; return customerId; } } diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/InvoicesServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/InvoicesServiceTests.cs index a54eb8c..1558293 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/InvoicesServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/InvoicesServiceTests.cs @@ -14,7 +14,7 @@ protected override InvoicesService Initialize(IChargeOverAPIConfiguration config } [Test] - public void should_call_CreateInvoice() + public async void should_call_CreateInvoice() { //arrange var id = TakeItemId(); @@ -39,7 +39,7 @@ public void should_call_CreateInvoice() } }; //act - var actual = Sut.CreateInvoice(request); + var actual = await Sut.CreateInvoice(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -47,7 +47,7 @@ public void should_call_CreateInvoice() } [Test] - public void should_call_UpdateInvoice() + public async void should_call_UpdateInvoice() { //arrange var request = new UpdateInvoice @@ -65,7 +65,7 @@ public void should_call_UpdateInvoice() } }; //act - var actual = Sut.UpdateInvoice(TakeInvoice(), request); + var actual = await Sut.UpdateInvoice(TakeInvoice(), request); //assert Assert.AreEqual(202, actual.Code); Assert.IsEmpty(actual.Message); @@ -73,11 +73,11 @@ public void should_call_UpdateInvoice() } [Test] - public void should_call_GetSpecificInvoice() + public async void should_call_GetSpecificInvoice() { //arrange //act - var actual = Sut.GetInvoice(TakeInvoice()); + var actual = await Sut.GetInvoice(TakeInvoice()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -85,11 +85,11 @@ public void should_call_GetSpecificInvoice() } [Test] - public void should_call_QueryForInvoices() + public async void should_call_QueryForInvoices() { //arrange //act - var actual = Sut.QueryInvoices(); + var actual = await Sut.QueryInvoices(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -97,7 +97,7 @@ public void should_call_QueryForInvoices() } [Test] - public void should_call_CreditCardPayment() + public async void should_call_CreditCardPayment() { //arrange var request = new CreditCardPayment @@ -113,7 +113,7 @@ public void should_call_CreditCardPayment() Country = "United States", }; //act - var actual = Sut.CreditCardPayment(TakeInvoice(), request); + var actual = await Sut.CreditCardPayment(TakeInvoice(), request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -121,7 +121,7 @@ public void should_call_CreditCardPayment() } [Test] - public void should_call_ACHCheckpayment() + public async void should_call_ACHCheckpayment() { //arrange var request = new ACHCheckPayment @@ -132,7 +132,7 @@ public void should_call_ACHCheckpayment() Type = "chec", }; //act - var actual = Sut.ACHCheckpayment(TakeInvoice(), request); + var actual = await Sut.ACHCheckpayment(TakeInvoice(), request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -140,7 +140,7 @@ public void should_call_ACHCheckpayment() } [Test] - public void should_call_ApplyOpenCustomerBalance() + public async void should_call_ApplyOpenCustomerBalance() { //arrange var customerId = TakeCustomerId(); @@ -153,7 +153,7 @@ public void should_call_ApplyOpenCustomerBalance() UseCustomerBalance = true, }; //act - var actual = Sut.ApplyOpenCustomerBalance(invoiceId, request); + var actual = await Sut.ApplyOpenCustomerBalance(invoiceId, request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -161,11 +161,11 @@ public void should_call_ApplyOpenCustomerBalance() } [Test] - public void should_call_VoidInvoice() + public async void should_call_VoidInvoice() { //arrange //act - var actual = Sut.VoidInvoice(TakeInvoice()); + var actual = await Sut.VoidInvoice(TakeInvoice()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -173,7 +173,7 @@ public void should_call_VoidInvoice() } [Test] - public void should_call_EmailInvoice() + public async void should_call_EmailInvoice() { //arrange var request = new EmailInvoice @@ -181,7 +181,7 @@ public void should_call_EmailInvoice() Email = "mail@mail.com" }; //act - var actual = Sut.EmailInvoice(TakeInvoice(), request); + var actual = await Sut.EmailInvoice(TakeInvoice(), request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -189,12 +189,12 @@ public void should_call_EmailInvoice() } [Test] - public void should_call_PrintInvoice() + public async void should_call_PrintInvoice() { //arrange var request = new PrintInvoice(); //act - var actual = Sut.PrintInvoice(TakeInvoice(), request); + var actual = await Sut.PrintInvoice(TakeInvoice(), request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/ItemsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/ItemsServiceTests.cs index e54f213..9b517d4 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/ItemsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/ItemsServiceTests.cs @@ -14,7 +14,7 @@ protected override ItemsService Initialize(IChargeOverAPIConfiguration config) } [Test] - public void should_call_CreateItem() + public async void should_call_CreateItem() { //arrange var request = new Item @@ -29,7 +29,7 @@ public void should_call_CreateItem() } }; //act - var actual = Sut.CreateItem(request); + var actual = await Sut.CreateItem(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -37,11 +37,11 @@ public void should_call_CreateItem() } [Test] - public void should_call_QueryingForItems() + public async void should_call_QueryingForItems() { //arrange //act - var actual = Sut.QueryItems(); + var actual = await Sut.QueryItems(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/LanguagesServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/LanguagesServiceTests.cs index 03c5874..cff61ca 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/LanguagesServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/LanguagesServiceTests.cs @@ -12,11 +12,11 @@ protected override LanguagesService Initialize(IChargeOverAPIConfiguration confi } [Test] - public void should_call_ListLanguages() + public async void should_call_ListLanguages() { //arrange //act - var actual = Sut.ListLanguages(); + var actual = await Sut.ListLanguages(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/NotesServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/NotesServiceTests.cs index f2e4b70..d31d0d3 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/NotesServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/NotesServiceTests.cs @@ -13,7 +13,7 @@ protected override NotesService Initialize(IChargeOverAPIConfiguration config) } [Test] - public void should_call_CreateNote() + public async void should_call_CreateNote() { //arrange var result = new CustomersService(Config).CreateCustomer(new Customer @@ -32,7 +32,7 @@ public void should_call_CreateNote() ObjId = result.Id }; //act - var actual = Sut.CreateNote(request); + var actual = await Sut.CreateNote(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -40,11 +40,11 @@ public void should_call_CreateNote() } [Test] - public void should_call_QueryNotesForObject() + public async void should_call_QueryNotesForObject() { //arrange //act - var actual = Sut.QueryNotesForObject(new[] { "obj_type:EQUALS:customer,obj_id:EQUALS:" + TakeCustomerId() }); + var actual = await Sut.QueryNotesForObject(new[] { "obj_type:EQUALS:customer,obj_id:EQUALS:" + TakeCustomerId() }); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/RESTHooksServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/RESTHooksServiceTests.cs index ebdb1d7..5eb5502 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/RESTHooksServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/RESTHooksServiceTests.cs @@ -13,7 +13,7 @@ protected override RESTHooksService Initialize(IChargeOverAPIConfiguration confi } [Test] - public void should_call_Subscribing() + public async void should_call_Subscribing() { //arrange var request = new Subscribing @@ -22,7 +22,7 @@ public void should_call_Subscribing() Event = "customer.insert", }; //act - var actual = Sut.Subscribe(request); + var actual = await Sut.Subscribe(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -30,11 +30,11 @@ public void should_call_Subscribing() } [Test] - public void should_call_Unsubscribing() + public async void should_call_Unsubscribing() { //arrange //act - var actual = Sut.Unsubscribe(AddSubscription()); + var actual = await Sut.Unsubscribe(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/SubscriptionsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/SubscriptionsServiceTests.cs index 07f0a8f..7e02f82 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/SubscriptionsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/SubscriptionsServiceTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; using NUnit.Framework; @@ -14,7 +15,7 @@ protected override SubscriptionsService Initialize(IChargeOverAPIConfiguration c } [Test] - public void should_call_CreateSubscription() + public async void should_call_CreateSubscription() { //arrange var request = new Subscription @@ -23,7 +24,7 @@ public void should_call_CreateSubscription() HoldUntilDatetime = DateTime.Parse("2013-10-01") }; //act - var actual = Sut.CreateSubscription(request); + var actual = await Sut.CreateSubscription(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -31,7 +32,7 @@ public void should_call_CreateSubscription() } [Test] - public void should_call_UpdateSubscription() + public async void should_call_UpdateSubscription() { //arrange var request = new UpdateSubscription @@ -39,7 +40,7 @@ public void should_call_UpdateSubscription() Nickname = "My new nickname", }; //act - var actual = Sut.UpdateSubscription(AddSubscription(), request); + var actual = await Sut.UpdateSubscription(AddSubscription(), request); //assert Assert.AreEqual(202, actual.Code); Assert.IsEmpty(actual.Message); @@ -47,11 +48,11 @@ public void should_call_UpdateSubscription() } [Test] - public void should_call_GetSpecificSubscription() + public async void should_call_GetSpecificSubscription() { //arrange //act - var actual = Sut.GetSubscription(AddSubscription()); + var actual = await Sut.GetSubscription(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -59,11 +60,11 @@ public void should_call_GetSpecificSubscription() } [Test] - public void should_call_QueryingForSubscriptions() + public async void should_call_QueryingForSubscriptions() { //arrange //act - var actual = Sut.QuerySubscriptions(); + var actual = await Sut.QuerySubscriptions(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -71,12 +72,12 @@ public void should_call_QueryingForSubscriptions() } [Test] - public void should_call_UpgradeDowngradesubscription() + public async void should_call_UpgradeDowngradesubscription() { //arrange var customer = TakeCustomer(); var lineId = TakeLineItem(); - var subscription = CreateLineItemFromSubscription(customer, lineId); + var subscription = await CreateLineItemFromSubscription(customer, lineId); var request = new UpgradeDowngradesubscription { @@ -92,7 +93,7 @@ public void should_call_UpgradeDowngradesubscription() } }; //act - var actual = Sut.UpgradeDowngradeSubscription(subscription.Item1, request); + var actual = await Sut.UpgradeDowngradeSubscription(subscription.Item1, request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -100,11 +101,11 @@ public void should_call_UpgradeDowngradesubscription() } [Test] - public void should_call_ChangePricingOnSubscription() + public async void should_call_ChangePricingOnSubscription() { //arrange var itemId = TakeLineItem(); - var data = CreateLineItemFromSubscription(TakeCustomer(), itemId); + var data = await CreateLineItemFromSubscription(TakeCustomer(), itemId); var request = new ChangePricingOnSubscription { @@ -135,7 +136,7 @@ public void should_call_ChangePricingOnSubscription() } }; //act - var actual = Sut.ChangePricingOnSubscription(data.Item1, request); + var actual = await Sut.ChangePricingOnSubscription(data.Item1, request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -143,11 +144,11 @@ public void should_call_ChangePricingOnSubscription() } [Test] - public void should_call_InvoiceSubscriptionNow() + public async void should_call_InvoiceSubscriptionNow() { //arrange //act - var actual = Sut.InvoiceSubscriptionNow(AddSubscription()); + var actual = await Sut.InvoiceSubscriptionNow(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -155,11 +156,11 @@ public void should_call_InvoiceSubscriptionNow() } [Test] - public void should_call_SuspendSubscription() + public async void should_call_SuspendSubscription() { //arrange //act - var actual = Sut.SuspendSubscription(AddSubscription()); + var actual = await Sut.SuspendSubscription(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -167,11 +168,11 @@ public void should_call_SuspendSubscription() } [Test] - public void should_call_UnsuspendSubscription() + public async void should_call_UnsuspendSubscription() { //arrange //act - var actual = Sut.UnsuspendSubscription(AddSubscription()); + var actual = await Sut.UnsuspendSubscription(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -179,11 +180,11 @@ public void should_call_UnsuspendSubscription() } [Test] - public void should_call_CancelSubscription() + public async void should_call_CancelSubscription() { //arrange //act - var actual = Sut.CancelSubscription(AddSubscription()); + var actual = await Sut.CancelSubscription(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -191,7 +192,7 @@ public void should_call_CancelSubscription() } [Test] - public void should_call_SetThePaymentMethod() + public async void should_call_SetThePaymentMethod() { //arrange var customerId = TakeCustomer(); @@ -202,7 +203,7 @@ public void should_call_SetThePaymentMethod() }; //act var addSubscription = AddSubscription(customerId: customerId); - var actual = Sut.SetPaymentMethod(addSubscription, request); + var actual = await Sut.SetPaymentMethod(addSubscription, request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -210,11 +211,11 @@ public void should_call_SetThePaymentMethod() } [Test] - public void should_call_SendWelcomeEmail() + public async void should_call_SendWelcomeEmail() { //arrange //act - var actual = Sut.SendWelcomeEmail(AddSubscription()); + var actual = await Sut.SendWelcomeEmail(AddSubscription()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -297,9 +298,9 @@ private int TakeCreditCard(int? customerId = null) }).Id; } - private Tuple CreateLineItemFromSubscription(int customerId, int itemId) + private async Task> CreateLineItemFromSubscription(int customerId, int itemId) { - var subscriptionId = Sut.CreateSubscription(new Subscription + var subscriptionId = (await Sut.CreateSubscription(new Subscription { CustomerId = customerId, HoldUntilDatetime = DateTime.Parse("2013-10-01"), @@ -311,9 +312,9 @@ private Tuple CreateLineItemFromSubscription(int customerId, int itemI ItemId = itemId } } - }).Id; + })).Id; - var subscriptionDetails = Sut.GetSubscription(subscriptionId).Response; + var subscriptionDetails = (await Sut.GetSubscription(subscriptionId)).Response; return new Tuple(subscriptionDetails.PackageId.Value, subscriptionDetails.LineItems[0].LineItemId); } diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/SystemLogServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/SystemLogServiceTests.cs index e3ad3d5..57c2091 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/SystemLogServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/SystemLogServiceTests.cs @@ -12,11 +12,11 @@ protected override SystemLogService Initialize(IChargeOverAPIConfiguration confi } [Test] - public void should_call_RetrieveTheSystemLog() + public async void should_call_RetrieveTheSystemLog() { //arrange //act - var actual = Sut.ListSystemLogs(); + var actual = await Sut.ListSystemLogs(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/TermsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/TermsServiceTests.cs index 4f8a756..3ac6647 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/TermsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/TermsServiceTests.cs @@ -12,11 +12,11 @@ protected override TermsService Initialize(IChargeOverAPIConfiguration config) } [Test] - public void should_call_ListTerms() + public async void should_call_ListTerms() { //arrange //act - var actual = Sut.ListTerms(); + var actual = await Sut.ListTerms(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/TokenizedPayMethodsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/TokenizedPayMethodsServiceTests.cs index 8dfce9a..cea49d0 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/TokenizedPayMethodsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/TokenizedPayMethodsServiceTests.cs @@ -13,7 +13,7 @@ protected override TokenizedPayMethodsService Initialize(IChargeOverAPIConfigura } [Test] - public void should_call_StorePayMethodToken() + public async void should_call_StorePayMethodToken() { //arrange var request = new StorePayMethodToken @@ -23,7 +23,7 @@ public void should_call_StorePayMethodToken() Type = "customer", }; //act - var actual = Sut.StorePayMethodToken(request); + var actual = await Sut.StorePayMethodToken(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -31,11 +31,11 @@ public void should_call_StorePayMethodToken() } [Test] - public void should_call_DeleteTokenizedPayMethod() + public async void should_call_DeleteTokenizedPayMethod() { //arrange //act - var actual = Sut.DeleteTokenizedPayMethod(AddPayMethod()); + var actual = await Sut.DeleteTokenizedPayMethod(AddPayMethod()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/TransactionsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/TransactionsServiceTests.cs index 5d44341..9e6fa21 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/TransactionsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/TransactionsServiceTests.cs @@ -14,7 +14,7 @@ protected override TransactionsService Initialize(IChargeOverAPIConfiguration co } [Test] - public void should_call_CreatePayment() + public async void should_call_CreatePayment() { //arrange var request = new Payment @@ -34,7 +34,7 @@ public void should_call_CreatePayment() AutoApply = "best_fit" }; //act - var actual = Sut.CreatePayment(request); + var actual = await Sut.CreatePayment(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -42,11 +42,11 @@ public void should_call_CreatePayment() } [Test] - public void should_call_GetSpecificTransaction() + public async void should_call_GetSpecificTransaction() { //arrange //act - var actual = Sut.GetTransaction(AddTransaction()); + var actual = await Sut.GetTransaction(AddTransaction()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -54,11 +54,11 @@ public void should_call_GetSpecificTransaction() } [Test] - public void should_call_ListTransactions() + public async void should_call_ListTransactions() { //arrange //act - var actual = Sut.ListTransactions(); + var actual = await Sut.ListTransactions(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -66,11 +66,11 @@ public void should_call_ListTransactions() } [Test] - public void should_call_QueryForTransactions() + public async void should_call_QueryForTransactions() { //arrange //act - var actual = Sut.QueryTransactions(limit: 5); + var actual = await Sut.QueryTransactions(limit: 5); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -78,7 +78,7 @@ public void should_call_QueryForTransactions() } [Test] - public void should_call_AttemptPayment() + public async void should_call_AttemptPayment() { //arrange var customerId = AddCustomer(); @@ -96,7 +96,7 @@ public void should_call_AttemptPayment() } }; //act - var actual = Sut.AttemptPayment(request); + var actual = await Sut.AttemptPayment(request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -104,7 +104,7 @@ public void should_call_AttemptPayment() } [Test] - public void should_call_CreateRefund() + public async void should_call_CreateRefund() { //arrange var request = new Refund @@ -121,7 +121,7 @@ public void should_call_CreateRefund() TransactionDate = DateTime.Parse("2016-08-16") }; //act - var actual = Sut.CreateRefund(request); + var actual = await Sut.CreateRefund(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -129,7 +129,7 @@ public void should_call_CreateRefund() } [Test] - public void should_call_RefundPayment() + public async void should_call_RefundPayment() { //arrange var request = new RefundPayment @@ -140,7 +140,7 @@ public void should_call_RefundPayment() var cardId = StoreCreditCard(customer); var payment = AttemptPayment(customer, cardId); //act - var actual = Sut.RefundPayment(payment, request); + var actual = await Sut.RefundPayment(payment, request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -148,11 +148,11 @@ public void should_call_RefundPayment() } [Test] - public void should_call_VoidTransaction() + public async void should_call_VoidTransaction() { //arrange //act - var actual = Sut.VoidTransaction(AddTransaction()); + var actual = await Sut.VoidTransaction(AddTransaction()); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -160,7 +160,7 @@ public void should_call_VoidTransaction() } [Test] - public void should_call_EmailReceipt() + public async void should_call_EmailReceipt() { //arrange var request = new EmailInvoice @@ -169,7 +169,7 @@ public void should_call_EmailReceipt() }; var customer = AddCustomer(); //act - var actual = Sut.EmailReceipt(AddTransaction(customer), request); + var actual = await Sut.EmailReceipt(AddTransaction(customer), request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/UsageServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/UsageServiceTests.cs index d8458db..c048072 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/UsageServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/UsageServiceTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using ChargeOver.Wrapper.Models; using ChargeOver.Wrapper.Services; using NUnit.Framework; @@ -14,12 +15,12 @@ protected override UsageService Initialize(IChargeOverAPIConfiguration config) } [Test] - public void should_call_StoringUsageData() + public async void should_call_StoringUsageData() { //arrange var customerId = CreateCustomer(); var itemId = TakeItemId(); - var lineItemId = CreateLineItemFromSubscription(customerId, itemId); + var lineItemId = await CreateLineItemFromSubscription(customerId, itemId); var request = new StoringUsageData { @@ -29,7 +30,7 @@ public void should_call_StoringUsageData() To = DateTime.Parse("2013-10-16") }; //act - var actual = Sut.StoreUsageData(request); + var actual = await Sut.StoreUsageData(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -48,7 +49,7 @@ private int CreateCustomer() }).Id; } - private int CreateLineItemFromSubscription(int customerId, int itemId) + private async Task CreateLineItemFromSubscription(int customerId, int itemId) { var subscriptionsService = new SubscriptionsService(Config); var subscriptionId = subscriptionsService.CreateSubscription(new Subscription @@ -65,7 +66,7 @@ private int CreateLineItemFromSubscription(int customerId, int itemId) } }).Id; - return subscriptionsService.GetSubscription(subscriptionId).Response.LineItems[0].LineItemId; + return (await subscriptionsService.GetSubscription(subscriptionId)).Response.LineItems[0].LineItemId; } private int TakeItemId() diff --git a/src/Tests/TestsChargeOver.Wrapper/Services/UsersContactsServiceTests.cs b/src/Tests/TestsChargeOver.Wrapper/Services/UsersContactsServiceTests.cs index e2d2c78..4c1c15e 100644 --- a/src/Tests/TestsChargeOver.Wrapper/Services/UsersContactsServiceTests.cs +++ b/src/Tests/TestsChargeOver.Wrapper/Services/UsersContactsServiceTests.cs @@ -14,7 +14,7 @@ protected override UsersContactsService Initialize(IChargeOverAPIConfiguration c } [Test] - public void should_call_AddContact() + public async void should_call_AddContact() { //arrange var request = new AddContact @@ -27,7 +27,7 @@ public void should_call_AddContact() Phone = "888-555-1212", }; //act - var actual = Sut.AddContact(request); + var actual = await Sut.AddContact(request); //assert Assert.AreEqual(201, actual.Code); Assert.IsEmpty(actual.Message); @@ -35,12 +35,12 @@ public void should_call_AddContact() } [Test] - public void should_call_GetSpecificContact() + public async void should_call_GetSpecificContact() { //arrange var id = AddContact(); //act - var actual = Sut.GetContact(id); + var actual = await Sut.GetContact(id); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -48,11 +48,11 @@ public void should_call_GetSpecificContact() } [Test] - public void should_call_GetListContacts() + public async void should_call_GetListContacts() { //arrange //act - var actual = Sut.ListContacts(); + var actual = await Sut.ListContacts(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -60,11 +60,11 @@ public void should_call_GetListContacts() } [Test] - public void should_call_QueryForContacts() + public async void should_call_QueryForContacts() { //arrange //act - var actual = Sut.QueryForContacts(); + var actual = await Sut.QueryForContacts(); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -72,12 +72,12 @@ public void should_call_QueryForContacts() } [Test] - public void should_call_SendPasswordReset() + public async void should_call_SendPasswordReset() { //arrange var userId = AddContact(); //act - var actual = Sut.SendPasswordReset(userId); + var actual = await Sut.SendPasswordReset(userId); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -85,7 +85,7 @@ public void should_call_SendPasswordReset() } [Test] - public void should_call_SetPassword() + public async void should_call_SetPassword() { //arrange var userId = AddContact(); @@ -94,7 +94,7 @@ public void should_call_SetPassword() Password = "here is the new password", }; //act - var actual = Sut.SetPassword(userId, request); + var actual = await Sut.SetPassword(userId, request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -102,12 +102,12 @@ public void should_call_SetPassword() } [Test] - public void should_call_LogInUser() + public async void should_call_LogInUser() { //arrange var id = AddContact(); //act - var actual = Sut.LogIn(id); + var actual = await Sut.LogIn(id); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); @@ -115,12 +115,12 @@ public void should_call_LogInUser() } [Test] - public void should_call_DeleteContact() + public async void should_call_DeleteContact() { //arrange var request = AddContact(); //act - var actual = Sut.DeleteContact(request); + var actual = await Sut.DeleteContact(request); //assert Assert.AreEqual(200, actual.Code); Assert.IsEmpty(actual.Message); diff --git a/src/Tests/TestsChargeOver.Wrapper/TestsChargeOver.Wrapper.csproj b/src/Tests/TestsChargeOver.Wrapper/TestsChargeOver.Wrapper.csproj index 3581a3d..5d6edb4 100644 --- a/src/Tests/TestsChargeOver.Wrapper/TestsChargeOver.Wrapper.csproj +++ b/src/Tests/TestsChargeOver.Wrapper/TestsChargeOver.Wrapper.csproj @@ -1,95 +1,25 @@ - - - + - Debug - AnyCPU - {691BED37-679C-45C0-B675-FE2CF4D3CB19} + net6.0 Library - Properties - TestsChargeOver.Wrapper - TestsChargeOver.Wrapper - v4.5.2 - 512 + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll - True - - - ..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - {03e09695-088d-4971-8888-eb16a8565eeb} - ChargeOver.Wrapper - + + App.config + - + + + + + + + all + - - \ No newline at end of file From 6f07d2a7da864343c0ec22f6d91a0cacba16e765 Mon Sep 17 00:00:00 2001 From: Daniel Wermann Date: Mon, 19 Dec 2022 11:33:33 -0300 Subject: [PATCH 2/2] Updated README.md Added information about the upgrade to .NET 6. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index b5b52e9..47f9b2a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ ChargeOver C# API and Examples (.NET 6) ============================== +----- + +* Upgraded from .NET Framework to .NET 6. +* Used .NET Upgrade Assistant to facilitate the process. +* Replaced HttpWebRequest by HttpClient to comply with the new .NET 6 standards. + +----- + This is a C# .NET library for the [ChargeOver recurring billing platform](http://www.chargeover.com/). ChargeOver is a billing platform geared towards easy, automated, recurring invoicing.