diff --git a/.github/workflows/Release_Package.yml b/.github/workflows/Release_Package.yml index 3e80fa9..f9ad5cd 100644 --- a/.github/workflows/Release_Package.yml +++ b/.github/workflows/Release_Package.yml @@ -1,8 +1,9 @@ name: Upload dotnet package on: - release: - types: [created] + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: deploy: @@ -19,12 +20,24 @@ jobs: env: NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} + - name: Build run: dotnet build --configuration Release - name: Create the package - run: dotnet pack --configuration Release + run: dotnet pack --configuration Release -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} - name: Publish the package to GPR working-directory: ./src/Pinch.SDK - run: dotnet nuget push ./bin/Release/*.nupkg \ No newline at end of file + run: dotnet nuget push ./bin/Release/*.nupkg + + - name: Publish Github Release + uses: marvinpinto/action-automatic-releases@v1.2.1 + with: + title: v${{ steps.get_version.outputs.VERSION }} + repo_token: ${{ secrets.GITHUB_TOKEN }} + prerelease: false + files: ./bin/Release/*.nupkg \ No newline at end of file diff --git a/readme.md b/readme.md index f027784..3ba79c1 100644 --- a/readme.md +++ b/readme.md @@ -1,27 +1,35 @@ ![Pinch .NET](https://user-images.githubusercontent.com/241857/124199780-118b3a80-db17-11eb-8fa4-5c0cb97f9de4.png) # Pinch SDK for .NET -The Pinch SDK for .NET helps developers build web, desktop, Silverlight, Windows Phone and Windows Store applications that integrate with Pinch. +The Pinch SDK for .NET helps developers build applications that integrate with Pinch across all supported .NET platforms. -## NuGet - Install-Package Pinch.SDK +## Installation +Using the .NET Core command-line interface (CLI) tools: + + dotnet add package Pinch.SDK -*The Pinch SDK for .NET binaries are only distributed via nuget. For those using older versions of Visual Studio that -does not support NuGet Package Manager, please download the [command line version of NuGet.exe](http://nuget.codeplex.com/releases/view/58939) and run the following -command.* +Using the NuGet Command Line Interface (CLI): nuget install Pinch.SDK - -If you would like to get an older version of the the binaries please use the following command. - nuget install Pinch.SDK -v 0.17.1 +Using the Package Manager Console: + + Install-Package Pinch.SDK + +From within Visual Studio: + +1. Open the Solution Explorer. +2. Right-click on a project within your solution. +3. Click on Manage NuGet Packages... +4. Click on the Browse tab and search for "Pinch.SDK". +5. Click on the Pinch.SDK package, select the appropriate version in the right-tab and click Install. See the [Pinch.SDK nuget page](https://www.nuget.org/packages/Pinch.SDK) for all previous versions. ## Documentation -You can find the documentation for this project [here](https://docs.getpinch.com.au/). +Check out the [Pinch API documentation here](https://docs.getpinch.com.au/) for the full API reference as well as example usages and guides on using the Pinch API. ## Features * Compatible with all Pinch REST API methods. @@ -29,7 +37,4 @@ You can find the documentation for this project [here](https://docs.getpinch.com * Sample applications and documentation are provided to get you started quickly. ## Supported Platforms -* .NET 3.5 (Client Profile and Full Profile) -* .NET 4.0 (Client Profile and Full Profile) -* .NET 4.5 * .NET Standard 2 diff --git a/src/Pinch.SDK/ApiResponse.cs b/src/Pinch.SDK/ApiResponse.cs index 8f9f41d..3270622 100644 --- a/src/Pinch.SDK/ApiResponse.cs +++ b/src/Pinch.SDK/ApiResponse.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Newtonsoft.Json; +using Pinch.SDK.Converters; using Pinch.SDK.Helpers; namespace Pinch.SDK @@ -9,7 +11,9 @@ namespace Pinch.SDK public class NonceApiResponse : ApiResponse { public bool IsNonceReplay { get; set; } - public string Nonce { get; set; } + + [JsonConverter(typeof(SingleOrArrayConverter))] + public List Nonce { get; set; } } public class ApiResponse diff --git a/src/Pinch.SDK/Converters/SingleOrArrayConverter.cs b/src/Pinch.SDK/Converters/SingleOrArrayConverter.cs new file mode 100644 index 0000000..8e32e51 --- /dev/null +++ b/src/Pinch.SDK/Converters/SingleOrArrayConverter.cs @@ -0,0 +1,43 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Pinch.SDK.Converters +{ + internal class SingleOrArrayConverter : JsonConverter + { + public override bool CanConvert(Type objectType) + { + return (objectType == typeof(List)); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + JToken token = JToken.Load(reader); + if (token.Type == JTokenType.Array) + { + return token.ToObject>(); + } + return new List { token.ToObject() }; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + List list = (List)value; + if (list.Count == 1) + { + value = list[0]; + } + serializer.Serialize(writer, value); + } + + public override bool CanWrite + { + get { return true; } + } + } +} diff --git a/src/Pinch.SDK/Helpers/HttpClientHelpers.cs b/src/Pinch.SDK/Helpers/HttpClientHelpers.cs index 98e4590..f18f7b0 100644 --- a/src/Pinch.SDK/Helpers/HttpClientHelpers.cs +++ b/src/Pinch.SDK/Helpers/HttpClientHelpers.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Pinch.SDK.Converters; namespace Pinch.SDK.Helpers { @@ -98,7 +99,9 @@ public class QuickResponse public List Errors { get; set; } public bool IsNonceReplay { get; set; } - public string Nonce { get; set; } + + [JsonConverter(typeof(SingleOrArrayConverter))] + public List Nonce { get; set; } public QuickResponse() { diff --git a/src/Pinch.SDK/Helpers/NonceResponseDto.cs b/src/Pinch.SDK/Helpers/NonceResponseDto.cs index 385d60a..22fe12b 100644 --- a/src/Pinch.SDK/Helpers/NonceResponseDto.cs +++ b/src/Pinch.SDK/Helpers/NonceResponseDto.cs @@ -1,9 +1,15 @@ -namespace Pinch.SDK.Helpers +using Newtonsoft.Json; +using Pinch.SDK.Converters; +using System.Collections.Generic; + +namespace Pinch.SDK.Helpers { public class NonceResponseDto { public bool IsNonceReplay { get; set; } - public string Nonce { get; set; } + + [JsonConverter(typeof(SingleOrArrayConverter))] + public List Nonce { get; set; } } public class NonceResponseDto : NonceResponseDto diff --git a/src/Pinch.SDK/Payments/PaymentDetailed.cs b/src/Pinch.SDK/Payments/PaymentDetailed.cs index be7cd8f..8b867f8 100644 --- a/src/Pinch.SDK/Payments/PaymentDetailed.cs +++ b/src/Pinch.SDK/Payments/PaymentDetailed.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Newtonsoft.Json; +using Pinch.SDK.Converters; using Pinch.SDK.Payers; using Pinch.SDK.Subscriptions; @@ -77,7 +79,8 @@ public class PaymentDetailed /// /// The Nonce that was sent with the initial request /// - public string Nonce { get; set; } + [JsonConverter(typeof(SingleOrArrayConverter))] + public List Nonce { get; set; } public PaymentDetailed() { diff --git a/src/Pinch.SDK/Pinch.SDK.csproj b/src/Pinch.SDK/Pinch.SDK.csproj index f69ef9b..d164b80 100644 --- a/src/Pinch.SDK/Pinch.SDK.csproj +++ b/src/Pinch.SDK/Pinch.SDK.csproj @@ -5,7 +5,7 @@ The easiest way to integrate your .net application with Pinch Payments. Create payers, add payments, receive webhooks, fetch payments, get paid. Really all the good stuff. It's for Australian businesses if you didn't already know. I'll assume you did if you got this far, if not, Welcome! but you should probably check out getpinch.com.au to get up to speed. Pinch Payments Pinch Payments - net45;netstandard2.0 + netstandard2.0 true Pinch.SDK Pinch.SDK @@ -13,7 +13,7 @@ https://raw.githubusercontent.com/PinchPayments/Pinch.SDK/master/assets/img/circle_logo_64x64.png https://github.com/PinchPayments/Pinch.SDK https://github.com/PinchPayments/Pinch.SDK - 0.21.0 + $(PackageVersion) @@ -21,11 +21,6 @@ - - - - -