Skip to content

Commit

Permalink
Merge pull request #33 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Changes from gocardless-dotnet-template
  • Loading branch information
StuartHadfield authored Jan 28, 2020
2 parents ab994a4 + 402bbb7 commit d2d3cf3
Show file tree
Hide file tree
Showing 25 changed files with 963 additions and 51 deletions.
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>3.0.1</PackageVersion>
<PackageVersion>3.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/v3.0.1</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/gocardless/gocardless-dotnet/releases/tag/v3.1.0</PackageReleaseNotes>
<TargetFrameworks>netstandard1.6;netstandard2.0;net46</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
5 changes: 5 additions & 0 deletions GoCardless/GoCardlessClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public partial class GoCardlessClient
/// </summary>
public EventService Events => new EventService(this);

/// <summary>
///A service for working with instalment schedule resources.
/// </summary>
public InstalmentScheduleService InstalmentSchedules => new InstalmentScheduleService(this);

/// <summary>
///A service for working with mandate 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 @@ -233,9 +233,9 @@ private HttpRequestMessage BuildHttpRequestMessage<T>(string method, string path
var httpMethod = new HttpMethod(method);

var requestMessage = new HttpRequestMessage(httpMethod, new Uri(_baseUrl, path));
requestMessage.Headers.Add("User-Agent", "gocardless-dotnet/3.0.1");
requestMessage.Headers.Add("User-Agent", "gocardless-dotnet/3.1.0");
requestMessage.Headers.Add("GoCardless-Version", "2015-07-06");
requestMessage.Headers.Add("GoCardless-Client-Version", "3.0.1");
requestMessage.Headers.Add("GoCardless-Client-Version", "3.1.0");
requestMessage.Headers.Add("GoCardless-Client-Library", "gocardless-dotnet");
requestMessage.Headers.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _accessToken);
Expand Down
7 changes: 7 additions & 0 deletions GoCardless/Resources/Creditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ public class CreditorLinks
/// </summary>
[JsonProperty("default_sek_payout_account")]
public string DefaultSekPayoutAccount { get; set; }

/// <summary>
/// ID of the [bank account](#core-endpoints-creditor-bank-accounts)
/// which is set up to receive payouts in USD.
/// </summary>
[JsonProperty("default_usd_payout_account")]
public string DefaultUsdPayoutAccount { get; set; }
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion GoCardless/Resources/CreditorBankAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class CreditorBankAccount
public string AccountHolderName { get; set; }

/// <summary>
/// Last two digits of account number.
/// The last few digits of the account number. Currently 4 digits for
/// NZD bank accounts and 2 digits for other currencies.
/// </summary>
[JsonProperty("account_number_ending")]
public string AccountNumberEnding { get; set; }
Expand Down
9 changes: 5 additions & 4 deletions GoCardless/Resources/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ public class Customer

/// <summary>
/// [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone
/// number, including country code. Required for New Zealand customers
/// only. Must be supplied if the customer's bank account is denominated
/// in New Zealand Dollars (NZD).
/// number, including country code.
/// </summary>
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }
Expand All @@ -134,7 +132,10 @@ public class Customer
public string PostalCode { get; set; }

/// <summary>
/// The customer's address region, county or department.
/// The customer's address region, county or department. For US
/// customers a 2 letter state code ([ISO
/// 3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) e.g CA) is
/// required.
/// </summary>
[JsonProperty("region")]
public string Region { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion GoCardless/Resources/CustomerBankAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class CustomerBankAccount
public string AccountHolderName { get; set; }

/// <summary>
/// Last two digits of account number.
/// The last few digits of the account number. Currently 4 digits for
/// NZD bank accounts and 2 digits for other currencies.
/// </summary>
[JsonProperty("account_number_ending")]
public string AccountNumberEnding { get; set; }
Expand Down
6 changes: 6 additions & 0 deletions GoCardless/Resources/CustomerNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public enum CustomerNotificationType {
/// <summary>`type` with a value of "subscription_created"</summary>
[EnumMember(Value = "subscription_created")]
SubscriptionCreated,
/// <summary>`type` with a value of "instalment_schedule_created"</summary>
[EnumMember(Value = "instalment_schedule_created")]
InstalmentScheduleCreated,
/// <summary>`type` with a value of "instalment_schedule_cancelled"</summary>
[EnumMember(Value = "instalment_schedule_cancelled")]
InstalmentScheduleCancelled,
}

}
19 changes: 19 additions & 0 deletions GoCardless/Resources/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class Event
/// <li>`payouts`</li>
/// <li>`refunds`</li>
/// <li>`subscriptions`</li>
/// <li>`instalment_schedules`</li>
/// </ul>
/// </summary>
[JsonProperty("resource_type")]
Expand Down Expand Up @@ -130,6 +131,12 @@ public enum EventCustomerNotificationType {
/// <summary>`type` with a value of "subscription_created"</summary>
[EnumMember(Value = "subscription_created")]
SubscriptionCreated,
/// <summary>`type` with a value of "instalment_schedule_created"</summary>
[EnumMember(Value = "instalment_schedule_created")]
InstalmentScheduleCreated,
/// <summary>`type` with a value of "instalment_schedule_cancelled"</summary>
[EnumMember(Value = "instalment_schedule_cancelled")]
InstalmentScheduleCancelled,
}

public class EventDetails
Expand Down Expand Up @@ -246,6 +253,14 @@ public enum EventDetailsScheme {
/// </summary>
public class EventLinks
{
/// <summary>
/// If `resource_type` is `instalment_schedule`, this is the ID of the
/// [instalment schedule](#core-endpoints-instalment-schedules) which
/// has been updated.
/// </summary>
[JsonProperty("instalment_schedule")]
public string InstalmentSchedule { get; set; }

/// <summary>
/// If `resource_type` is `mandates`, this is the ID of the
/// [mandate](#core-endpoints-mandates) which has been updated.
Expand Down Expand Up @@ -335,6 +350,7 @@ public class EventLinks
/// <li>`payouts`</li>
/// <li>`refunds`</li>
/// <li>`subscriptions`</li>
/// <li>`instalment_schedules`</li>
/// </ul>
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
Expand All @@ -355,6 +371,9 @@ public enum EventResourceType {
/// <summary>`resource_type` with a value of "subscriptions"</summary>
[EnumMember(Value = "subscriptions")]
Subscriptions,
/// <summary>`resource_type` with a value of "instalment_schedules"</summary>
[EnumMember(Value = "instalment_schedules")]
InstalmentSchedules,
}

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

namespace GoCardless.Resources
{

/// <summary>
/// Represents a instalment schedule resource.
///
/// Instalment schedules are objects which represent a collection of related
/// payments, with the
/// intention to collect the `total_amount` specified. The API supports both
/// schedule-based
/// creation (similar to subscriptions) as well as explicit selection of
/// differing payment
/// amounts and charge dates.
///
/// Unlike subscriptions, the payments are created immediately, so the
/// instalment schedule
/// cannot be modified once submitted and instead can only be cancelled
/// (which will cancel
/// any of the payments which have not yet been submitted).
///
/// Customers will receive a single notification about the complete schedule
/// of collection.
///
/// </summary>
public class InstalmentSchedule
{
/// <summary>
/// Fixed [timestamp](#api-usage-time-zones--dates), recording when this
/// resource was created.
/// </summary>
[JsonProperty("created_at")]
public DateTimeOffset? CreatedAt { get; set; }

/// <summary>
/// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes)
/// currency code. Currently "AUD", "CAD", "DKK", "EUR", "GBP", "NZD",
/// "SEK" and "USD" are supported.
/// </summary>
[JsonProperty("currency")]
public InstalmentScheduleCurrency? Currency { get; set; }

/// <summary>
/// Unique identifier, beginning with "IS".
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// Resources linked to this InstalmentSchedule.
/// </summary>
[JsonProperty("links")]
public InstalmentScheduleLinks Links { get; set; }

/// <summary>
/// Key-value store of custom data. Up to 3 keys are permitted, with key
/// names up to 50 characters and values up to 500 characters.
/// </summary>
[JsonProperty("metadata")]
public IDictionary<string, string> Metadata { get; set; }

/// <summary>
/// Name of the instalment schedule, up to 100 chars. This name will
/// also be
/// copied to the payments of the instalment schedule if you use
/// schedule-based creation.
///
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// If the status is `creation_failed`, this property will be populated
/// with validation
/// failures from the individual payments, arranged by the index of the
/// payment that
/// failed.
///
/// </summary>
[JsonProperty("payment_errors")]
public IDictionary<string, string> PaymentErrors { get; set; }

/// <summary>
/// One of:
/// <ul>
/// <li>`pending`: we're waiting for GC to create the payments</li>
/// <li>`active`: the payments have been created, and the schedule is
/// active</li>
/// <li>`creation_failed`: payment creation failed</li>
/// <li>`completed`: we have passed the date of the final payment and
/// all payments have been collected</li>
/// <li>`cancelled`: the schedule has been cancelled</li>
/// <li>`errored`: one or more payments have failed</li>
/// </ul>
/// </summary>
[JsonProperty("status")]
public InstalmentScheduleStatus? Status { get; set; }

/// <summary>
/// The total amount of the instalment schedule, defined as the sum of
/// all individual
/// payments. If the requested payment amounts do not sum up correctly,
/// a validation
/// error will be returned.
///
/// </summary>
[JsonProperty("total_amount")]
public int? TotalAmount { get; set; }
}

/// <summary>
/// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently
/// "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum InstalmentScheduleCurrency {

/// <summary>`currency` with a value of "AUD"</summary>
[EnumMember(Value = "AUD")]
AUD,
/// <summary>`currency` with a value of "CAD"</summary>
[EnumMember(Value = "CAD")]
CAD,
/// <summary>`currency` with a value of "DKK"</summary>
[EnumMember(Value = "DKK")]
DKK,
/// <summary>`currency` with a value of "EUR"</summary>
[EnumMember(Value = "EUR")]
EUR,
/// <summary>`currency` with a value of "GBP"</summary>
[EnumMember(Value = "GBP")]
GBP,
/// <summary>`currency` with a value of "NZD"</summary>
[EnumMember(Value = "NZD")]
NZD,
/// <summary>`currency` with a value of "SEK"</summary>
[EnumMember(Value = "SEK")]
SEK,
/// <summary>`currency` with a value of "USD"</summary>
[EnumMember(Value = "USD")]
USD,
}

/// <summary>
/// Represents a instalment schedule link resource.
///
/// Links to associated objects
/// </summary>
public class InstalmentScheduleLinks
{
/// <summary>
/// ID of the associated [customer](#core-endpoints-customers).
/// </summary>
[JsonProperty("customer")]
public string Customer { get; set; }

/// <summary>
/// ID of the associated [mandate](#core-endpoints-mandates) which the
/// instalment schedule will create payments against.
/// </summary>
[JsonProperty("mandate")]
public string Mandate { get; set; }

/// <summary>
/// Array of IDs of the associated [payments](#core-endpoints-payments)
/// </summary>
[JsonProperty("payments")]
public List<string> Payments { get; set; }
}

/// <summary>
/// One of:
/// <ul>
/// <li>`pending`: we're waiting for GC to create the payments</li>
/// <li>`active`: the payments have been created, and the schedule is active</li>
/// <li>`creation_failed`: payment creation failed</li>
/// <li>`completed`: we have passed the date of the final payment and all payments have been
/// collected</li>
/// <li>`cancelled`: the schedule has been cancelled</li>
/// <li>`errored`: one or more payments have failed</li>
/// </ul>
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum InstalmentScheduleStatus {

/// <summary>`status` with a value of "pending"</summary>
[EnumMember(Value = "pending")]
Pending,
/// <summary>`status` with a value of "active"</summary>
[EnumMember(Value = "active")]
Active,
/// <summary>`status` with a value of "creation_failed"</summary>
[EnumMember(Value = "creation_failed")]
CreationFailed,
/// <summary>`status` with a value of "completed"</summary>
[EnumMember(Value = "completed")]
Completed,
/// <summary>`status` with a value of "cancelled"</summary>
[EnumMember(Value = "cancelled")]
Cancelled,
/// <summary>`status` with a value of "errored"</summary>
[EnumMember(Value = "errored")]
Errored,
}

}
4 changes: 2 additions & 2 deletions GoCardless/Resources/Mandate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class Mandate
public IDictionary<string, string> Metadata { get; set; }

/// <summary>
/// The earliest date a newly created payment for this mandate could be
/// charged.
/// The earliest date that can be used as a `charge_date` on any newly
/// created payment for this mandate. This value will change over time.
/// </summary>
[JsonProperty("next_possible_charge_date")]
public string NextPossibleChargeDate { get; set; }
Expand Down
Loading

0 comments on commit d2d3cf3

Please sign in to comment.