Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded to .NET 6 #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
ChargeOver C# API and Examples
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.


Expand Down
4 changes: 2 additions & 2 deletions src/ChargeOver.Wrapper.Examples/App.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ChargeOverAPIEndpoint" value="http://dev1.chargeover.test/api/v3"/>
Expand All @@ -7,6 +7,6 @@
<add key="ChargeOverAPIAuth" value="http-basic"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
73 changes: 10 additions & 63 deletions src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj
Original file line number Diff line number Diff line change
@@ -1,73 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0CE183C5-CA80-4696-AE28-785455DB47DE}</ProjectGuid>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChargeOver.Wrapper.Examples</RootNamespace>
<AssemblyName>ChargeOver.Wrapper.Examples</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ACHeCheckAccountsServiceExample.cs" />
<Compile Include="Services\CreditCardServiceExample.cs" />
<Compile Include="Services\CustomersServiceExample.cs" />
<Compile Include="Services\InvoiceServiceExample.cs" />
<Compile Include="Services\IServiceExample.cs" />
<Compile Include="Services\TransactionsServiceExample.cs" />
<Compile Include="Services\SubscriptionServiceExample.cs" />
<ProjectReference Include="..\ChargeOver.Wrapper\ChargeOver.Wrapper.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.355802">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ChargeOver.Wrapper\ChargeOver.Wrapper.csproj">
<Project>{03e09695-088d-4971-8888-eb16a8565eeb}</Project>
<Name>ChargeOver.Wrapper</Name>
</ProjectReference>
<Content Include="appsettings.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
13 changes: 8 additions & 5 deletions src/ChargeOver.Wrapper.Examples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using ChargeOver.Wrapper.Examples.Services;

namespace ChargeOver.Wrapper.Examples
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;

Expand All @@ -13,7 +14,7 @@ public ACHeCheckAccountsServiceExample()
_service = new ACHeCheckAccountsService();
}

public void Run()
public async void Run()
{
var request = new StoreACHAccount
{
Expand All @@ -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.");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;

Expand All @@ -13,7 +14,7 @@ public CreditCardServiceExample()
_service = new CreditCardsService();
}

public void Run()
public async void Run()
{
var request = new StoreCreditCard
{
Expand All @@ -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.");

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -15,7 +16,7 @@ public CustomersServiceExample()
_service = new CustomersService();
}

public void Run()
public async void Run()
{
var examples = new List<Action>
{
Expand All @@ -28,7 +29,7 @@ public void Run()
}
}

private void CreateCustomer()
private async void CreateCustomer()
{
var customer = new Customer
{
Expand All @@ -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()}");
}
Expand Down
9 changes: 6 additions & 3 deletions src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;

Expand All @@ -18,7 +19,7 @@ public InvoiceServiceExample()
_customersService = new CustomersService();
}

public void Run()
public async void Run()
{
var examples = new Action[] { CreateInvoice, QueryInvoiceByInvoiceId };

Expand All @@ -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<IIdentityResponse> CreateNewInvoice()
{
var id = TakeItemId();
var customer = TakeCustomerId();
Expand All @@ -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()}");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;

Expand All @@ -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<IIdentityResponse> 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
Expand Down Expand Up @@ -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()}");
}
Expand Down
Loading