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

Changes from gocardless/gocardless-dotnet-template #129

Merged
merged 3 commits into from
May 22, 2024
Merged
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
4 changes: 2 additions & 2 deletions GoCardless/GoCardless.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>GoCardless</PackageId>
<PackageVersion>6.0.2</PackageVersion>
<PackageVersion>6.1.0</PackageVersion>
<Authors>GoCardless Ltd</Authors>
<Description>Client for the GoCardless API - a powerful, simple solution for the collection of recurring bank-to-bank payments</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand All @@ -11,7 +11,7 @@
<Copyright>GoCardless Ltd</Copyright>
<PackageTags>gocardless payments rest api direct debit</PackageTags>
<PackageLicenseUrl>https://github.com/gocardless/gocardless-dotnet/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageReleaseNotes>https://github.com/gocardless/gocardless-dotnet/releases/tag/v6.0.2</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/gocardless/gocardless-dotnet/releases/tag/v6.1.0</PackageReleaseNotes>
<TargetFrameworks>netstandard1.6;netstandard2.0;netstandard2.1;net46;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
10 changes: 10 additions & 0 deletions GoCardless/GoCardlessClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public partial class GoCardlessClient
/// </summary>
public InstitutionService Institutions => new InstitutionService(this);

/// <summary>
///A service for working with logo resources.
/// </summary>
public LogoService Logos => new LogoService(this);

/// <summary>
///A service for working with mandate resources.
/// </summary>
Expand Down Expand Up @@ -113,6 +118,11 @@ public partial class GoCardlessClient
/// </summary>
public PayerAuthorisationService PayerAuthorisations => new PayerAuthorisationService(this);

/// <summary>
///A service for working with payer theme resources.
/// </summary>
public PayerThemeService PayerThemes => new PayerThemeService(this);

/// <summary>
///A service for working with payment resources.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions GoCardless/GoCardlessClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ private HttpRequestMessage BuildHttpRequestMessage<T>(string method, string path
runtimeFrameworkInformation = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion();
#endif

var userAgentInformation = $" gocardless-dotnet/6.0.2 {runtimeFrameworkInformation} {Helpers.CleanupOSDescriptionString(OSRunningOn)}";
var userAgentInformation = $" gocardless-dotnet/6.1.0 {runtimeFrameworkInformation} {Helpers.CleanupOSDescriptionString(OSRunningOn)}";

requestMessage.Headers.Add("User-Agent", userAgentInformation);
requestMessage.Headers.Add("GoCardless-Version", "2015-07-06");
requestMessage.Headers.Add("GoCardless-Client-Version", "6.0.2");
requestMessage.Headers.Add("GoCardless-Client-Version", "6.1.0");
requestMessage.Headers.Add("GoCardless-Client-Library", "gocardless-dotnet");
requestMessage.Headers.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _accessToken);
Expand Down
27 changes: 27 additions & 0 deletions GoCardless/Resources/Logo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using GoCardless.Internals;

namespace GoCardless.Resources
{

/// <summary>
/// Represents a logo resource.
///
/// Logos are image uploads that, when associated with a creditor, are shown
/// on the [billing request flow](#billing-requests-billing-request-flows)
/// payment pages.
/// </summary>
public class Logo
{
/// <summary>
/// Unique identifier, beginning with "LO".
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
}

}
25 changes: 25 additions & 0 deletions GoCardless/Resources/PayerTheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using GoCardless.Internals;

namespace GoCardless.Resources
{

/// <summary>
/// Represents a payer theme resource.
///
/// Custom colour themes for payment pages and customer notifications.
/// </summary>
public class PayerTheme
{
/// <summary>
/// Unique identifier, beginning with "PTH".
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
}

}
80 changes: 80 additions & 0 deletions GoCardless/Services/LogoService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using GoCardless.Internals;
using GoCardless.Resources;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace GoCardless.Services
{
/// <summary>
/// Service class for working with logo resources.
///
/// Logos are image uploads that, when associated with a creditor, are shown
/// on the [billing request flow](#billing-requests-billing-request-flows)
/// payment pages.
/// </summary>

public class LogoService
{
private readonly GoCardlessClient _goCardlessClient;

/// <summary>
/// Constructor. Users of this library should not call this. An instance of this
/// class can be accessed through an initialised GoCardlessClient.
/// </summary>
public LogoService(GoCardlessClient goCardlessClient)
{
_goCardlessClient = goCardlessClient;
}

/// <summary>
/// Creates a new logo associated with a creditor. If a creditor already
/// has a logo, this will update the existing logo linked to the
/// creditor.
/// </summary>
/// <param name="identity">Unique identifier, beginning with "CR".</param>
/// <param name="request">An optional `LogoCreateForCreditorRequest` representing the body for this create_for_creditor request.</param>
/// <param name="customiseRequestMessage">An optional `RequestSettings` allowing you to configure the request</param>
/// <returns>A single logo resource</returns>
public Task<LogoResponse> CreateForCreditorAsync(string identity, LogoCreateForCreditorRequest request = null, RequestSettings customiseRequestMessage = null)
{
request = request ?? new LogoCreateForCreditorRequest();
if (identity == null) throw new ArgumentException(nameof(identity));

var urlParams = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("identity", identity),
};

return _goCardlessClient.ExecuteAsync<LogoResponse>("POST", "/creditors/:identity/branding/logos", urlParams, request, null, "logos", customiseRequestMessage);
}
}


/// <summary>
/// Creates a new logo associated with a creditor. If a creditor already has
/// a logo, this will update the existing logo linked to the creditor.
/// </summary>
public class LogoCreateForCreditorRequest
{
}

/// <summary>
/// An API response for a request returning a single logo.
/// </summary>
public class LogoResponse : ApiResponse
{
/// <summary>
/// The logo from the response.
/// </summary>
[JsonProperty("logos")]
public Logo Logo { get; private set; }
}
}
103 changes: 103 additions & 0 deletions GoCardless/Services/PayerThemeService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using GoCardless.Internals;
using GoCardless.Resources;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace GoCardless.Services
{
/// <summary>
/// Service class for working with payer theme resources.
///
/// Custom colour themes for payment pages and customer notifications.
/// </summary>

public class PayerThemeService
{
private readonly GoCardlessClient _goCardlessClient;

/// <summary>
/// Constructor. Users of this library should not call this. An instance of this
/// class can be accessed through an initialised GoCardlessClient.
/// </summary>
public PayerThemeService(GoCardlessClient goCardlessClient)
{
_goCardlessClient = goCardlessClient;
}

/// <summary>
/// Creates a new payer theme associated with a creditor. If a creditor
/// already has payer themes, this will update the existing payer theme
/// linked to the creditor.
/// </summary>
/// <param name="identity">Unique identifier, beginning with "CR".</param>
/// <param name="request">An optional `PayerThemeCreateForCreditorRequest` representing the body for this create_for_creditor request.</param>
/// <param name="customiseRequestMessage">An optional `RequestSettings` allowing you to configure the request</param>
/// <returns>A single payer theme resource</returns>
public Task<PayerThemeResponse> CreateForCreditorAsync(string identity, PayerThemeCreateForCreditorRequest request = null, RequestSettings customiseRequestMessage = null)
{
request = request ?? new PayerThemeCreateForCreditorRequest();
if (identity == null) throw new ArgumentException(nameof(identity));

var urlParams = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("identity", identity),
};

return _goCardlessClient.ExecuteAsync<PayerThemeResponse>("POST", "/creditors/:identity/branding/payer_themes", urlParams, request, null, "payer_themes", customiseRequestMessage);
}
}


/// <summary>
/// Creates a new payer theme associated with a creditor. If a creditor
/// already has payer themes, this will update the existing payer theme
/// linked to the creditor.
/// </summary>
public class PayerThemeCreateForCreditorRequest
{

/// <summary>
/// Colour for buttons background (hexcode)
/// </summary>
[JsonProperty("button_background_colour")]
public string ButtonBackgroundColour { get; set; }

/// <summary>
/// Colour for content box border (hexcode)
/// </summary>
[JsonProperty("content_box_border_colour")]
public string ContentBoxBorderColour { get; set; }

/// <summary>
/// Colour for header background (hexcode)
/// </summary>
[JsonProperty("header_background_colour")]
public string HeaderBackgroundColour { get; set; }

/// <summary>
/// Colour for text links (hexcode)
/// </summary>
[JsonProperty("link_text_colour")]
public string LinkTextColour { get; set; }
}

/// <summary>
/// An API response for a request returning a single payer theme.
/// </summary>
public class PayerThemeResponse : ApiResponse
{
/// <summary>
/// The payer theme from the response.
/// </summary>
[JsonProperty("payer_themes")]
public PayerTheme PayerTheme { get; private set; }
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For full details of the GoCardless API, see the [API docs](https://developer.goc

To install `GoCardless`, run the following command in the [Package Manager Console](https://docs.microsoft.com/en-us/nuget/tools/package-manager-console)

`Install-Package GoCardless -Version 6.0.2`
`Install-Package GoCardless -Version 6.1.0`


## Usage
Expand Down
Loading