diff --git a/GoCardless/GoCardless.csproj b/GoCardless/GoCardless.csproj index a9d697e..3943dd5 100644 --- a/GoCardless/GoCardless.csproj +++ b/GoCardless/GoCardless.csproj @@ -2,7 +2,7 @@ GoCardless - 5.11.0 + 5.12.0 GoCardless Ltd Client for the GoCardless API - a powerful, simple solution for the collection of recurring bank-to-bank payments false @@ -11,7 +11,7 @@ GoCardless Ltd gocardless payments rest api direct debit https://github.com/gocardless/gocardless-dotnet/blob/master/LICENSE.txt - https://github.com/gocardless/gocardless-dotnet/releases/tag/v5.11.0 + https://github.com/gocardless/gocardless-dotnet/releases/tag/v5.12.0 netstandard1.6;netstandard2.0;net46 True true diff --git a/GoCardless/GoCardlessClient.Generated.cs b/GoCardless/GoCardlessClient.Generated.cs index f9cd0c1..694a6a9 100644 --- a/GoCardless/GoCardlessClient.Generated.cs +++ b/GoCardless/GoCardlessClient.Generated.cs @@ -138,6 +138,11 @@ public partial class GoCardlessClient /// public ScenarioSimulatorService ScenarioSimulators => new ScenarioSimulatorService(this); + /// + ///A service for working with schemeentifier resources. + /// + public SchemeIdentifierService SchemeIdentifiers => new SchemeIdentifierService(this); + /// ///A service for working with subscription resources. /// @@ -148,6 +153,11 @@ public partial class GoCardlessClient /// public TaxRateService TaxRates => new TaxRateService(this); + /// + ///A service for working with verification detail resources. + /// + public VerificationDetailService VerificationDetails => new VerificationDetailService(this); + /// ///A service for working with webhook resources. /// diff --git a/GoCardless/GoCardlessClient.cs b/GoCardless/GoCardlessClient.cs index b78018d..33e344f 100644 --- a/GoCardless/GoCardlessClient.cs +++ b/GoCardless/GoCardlessClient.cs @@ -277,11 +277,11 @@ private HttpRequestMessage BuildHttpRequestMessage(string method, string path runtimeFrameworkInformation = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion(); #endif - var userAgentInformation = $" gocardless-dotnet/5.11.0 {runtimeFrameworkInformation} {Helpers.CleanupOSDescriptionString(OSRunningOn)}"; + var userAgentInformation = $" gocardless-dotnet/5.12.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", "5.11.0"); + requestMessage.Headers.Add("GoCardless-Client-Version", "5.12.0"); requestMessage.Headers.Add("GoCardless-Client-Library", "gocardless-dotnet"); requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _accessToken); diff --git a/GoCardless/Resources/BankAuthorisation.cs b/GoCardless/Resources/BankAuthorisation.cs index 89d964c..6f6a3c1 100644 --- a/GoCardless/Resources/BankAuthorisation.cs +++ b/GoCardless/Resources/BankAuthorisation.cs @@ -73,6 +73,20 @@ public class BankAuthorisation /// /// URL that the payer can be redirected to after authorising the /// payment. + /// + /// On completion of bank authorisation, the query parameter of either + /// `outcome=success` or `outcome=failure` will be + /// appended to the `redirect_uri` to indicate the result of the bank + /// authorisation. If the bank authorisation is + /// expired, the query parameter `outcome=timeout` will be appended to + /// the `redirect_uri`, in which case you should + /// prompt the user to try the bank authorisation step again. + /// + /// The `redirect_uri` you provide should handle the `outcome` query + /// parameter for displaying the result of the + /// bank authorisation as outlined above. + /// + /// Defaults to `https://pay.gocardless.com/billing/static/thankyou`. /// [JsonProperty("redirect_uri")] public string RedirectUri { get; set; } diff --git a/GoCardless/Resources/BillingRequest.cs b/GoCardless/Resources/BillingRequest.cs index b21b5b1..23c9e65 100644 --- a/GoCardless/Resources/BillingRequest.cs +++ b/GoCardless/Resources/BillingRequest.cs @@ -1077,6 +1077,10 @@ public class BillingRequestResourcesCustomerBillingDetail /// containing the IP address of the payer to whom the mandate belongs /// (i.e. as a result of their completion of a mandate setup flow in /// their browser). + /// + /// Not required for creating offline mandates where + /// `authorisation_source` is set to telephone or paper. + /// /// [JsonProperty("ip_address")] public string IpAddress { get; set; } diff --git a/GoCardless/Resources/Creditor.cs b/GoCardless/Resources/Creditor.cs index d2ae814..b4b164d 100644 --- a/GoCardless/Resources/Creditor.cs +++ b/GoCardless/Resources/Creditor.cs @@ -136,7 +136,7 @@ public class Creditor public bool? MerchantResponsibleForNotifications { get; set; } /// - /// The creditor's name. + /// The creditor's trading name. /// [JsonProperty("name")] public string Name { get; set; } @@ -329,19 +329,19 @@ public class CreditorLinks public class CreditorSchemeIdentifier { /// - /// The first line of the support address. + /// The first line of the scheme identifier's support address. /// [JsonProperty("address_line1")] public string AddressLine1 { get; set; } /// - /// The second line of the support address. + /// The second line of the scheme identifier's support address. /// [JsonProperty("address_line2")] public string AddressLine2 { get; set; } /// - /// The third line of the support address. + /// The third line of the scheme identifier's support address. /// [JsonProperty("address_line3")] public string AddressLine3 { get; set; } @@ -354,7 +354,7 @@ public class CreditorSchemeIdentifier public bool? CanSpecifyMandateReference { get; set; } /// - /// The city of the support address. + /// The city of the scheme identifier's support address. /// [JsonProperty("city")] public string City { get; set; } @@ -366,6 +366,13 @@ public class CreditorSchemeIdentifier [JsonProperty("country_code")] public string CountryCode { get; set; } + /// + /// Fixed [timestamp](#api-usage-time-zones--dates), recording when this + /// resource was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + /// /// The currency of the scheme identifier. /// @@ -373,11 +380,17 @@ public class CreditorSchemeIdentifier public CreditorSchemeIdentifierCurrency? Currency { get; set; } /// - /// The support email address. + /// Scheme identifier's support email address. /// [JsonProperty("email")] public string Email { get; set; } + /// + /// Unique identifier, usually beginning with "SU". + /// + [JsonProperty("id")] + public string Id { get; set; } + /// /// The minimum interval, in working days, between the sending of a /// pre-notification to the customer, and the charge date of a payment @@ -391,19 +404,20 @@ public class CreditorSchemeIdentifier public int? MinimumAdvanceNotice { get; set; } /// - /// The name which appears on customers' bank statements. + /// The name which appears on customers' bank statements. This should + /// usually be the merchant's trading name. /// [JsonProperty("name")] public string Name { get; set; } /// - /// The support phone number. + /// Scheme identifier's support phone number. /// [JsonProperty("phone_number")] public string PhoneNumber { get; set; } /// - /// The support postal code. + /// The scheme identifier's support postal code. /// [JsonProperty("postal_code")] public string PostalCode { get; set; } @@ -415,7 +429,8 @@ public class CreditorSchemeIdentifier public string Reference { get; set; } /// - /// The support address region, county or department. + /// The scheme identifier's support address region, county or + /// department. /// [JsonProperty("region")] public string Region { get; set; } @@ -425,6 +440,13 @@ public class CreditorSchemeIdentifier /// [JsonProperty("scheme")] public CreditorSchemeIdentifierScheme? Scheme { get; set; } + + /// + /// The status of the scheme identifier. Only `active` scheme + /// identifiers will be applied to a creditor and used against payments. + /// + [JsonProperty("status")] + public CreditorSchemeIdentifierStatus? Status { get; set; } } /// @@ -509,6 +531,24 @@ public enum CreditorSchemeIdentifierScheme { SepaInstantCreditTransfer, } + /// + /// The status of the scheme identifier. Only `active` scheme identifiers will be applied to a + /// creditor and used against payments. + /// + [JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)] + public enum CreditorSchemeIdentifierStatus { + /// Unknown status + [EnumMember(Value = "unknown")] + Unknown = 0, + + /// `status` with a value of "pending" + [EnumMember(Value = "pending")] + Pending, + /// `status` with a value of "active" + [EnumMember(Value = "active")] + Active, + } + /// /// The creditor's verification status, indicating whether they can yet receive payouts. For /// more details on handling verification as a partner, see our ["Helping your users get diff --git a/GoCardless/Resources/Mandate.cs b/GoCardless/Resources/Mandate.cs index aa07b68..9e33dbc 100644 --- a/GoCardless/Resources/Mandate.cs +++ b/GoCardless/Resources/Mandate.cs @@ -125,6 +125,13 @@ public class Mandate /// [JsonProperty("status")] public MandateStatus? Status { get; set; } + + /// + /// [Timestamp](#api-usage-time-zones--dates) recording when this + /// mandate was verified. + /// + [JsonProperty("verified_at")] + public string VerifiedAt { get; set; } } /// diff --git a/GoCardless/Resources/PayerAuthorisation.cs b/GoCardless/Resources/PayerAuthorisation.cs index 6980d95..258725f 100644 --- a/GoCardless/Resources/PayerAuthorisation.cs +++ b/GoCardless/Resources/PayerAuthorisation.cs @@ -444,6 +444,10 @@ public class PayerAuthorisationMandate /// containing the IP address of the payer to whom the mandate belongs /// (i.e. as a result of their completion of a mandate setup flow in /// their browser). + /// + /// Not required for creating offline mandates where + /// `authorisation_source` is set to telephone or paper. + /// /// [JsonProperty("payer_ip_address")] public string PayerIpAddress { get; set; } diff --git a/GoCardless/Resources/SchemeIdentifier.cs b/GoCardless/Resources/SchemeIdentifier.cs new file mode 100644 index 0000000..decd5cc --- /dev/null +++ b/GoCardless/Resources/SchemeIdentifier.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using GoCardless.Internals; + +namespace GoCardless.Resources +{ + + /// + /// Represents a schemeentifier resource. + /// + /// This represents a scheme identifier (e.g. a SUN in Bacs or a CID in + /// SEPA). Scheme identifiers are used to specify the beneficiary name that + /// appears on customers' bank statements. + /// + /// + public class SchemeIdentifier + { + /// + /// The first line of the scheme identifier's support address. + /// + [JsonProperty("address_line1")] + public string AddressLine1 { get; set; } + + /// + /// The second line of the scheme identifier's support address. + /// + [JsonProperty("address_line2")] + public string AddressLine2 { get; set; } + + /// + /// The third line of the scheme identifier's support address. + /// + [JsonProperty("address_line3")] + public string AddressLine3 { get; set; } + + /// + /// Whether a custom reference can be submitted for mandates using this + /// scheme identifier. + /// + [JsonProperty("can_specify_mandate_reference")] + public bool? CanSpecifyMandateReference { get; set; } + + /// + /// The city of the scheme identifier's support address. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// [ISO 3166-1 alpha-2 + /// code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// Fixed [timestamp](#api-usage-time-zones--dates), recording when this + /// resource was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The currency of the scheme identifier. + /// + [JsonProperty("currency")] + public SchemeIdentifierCurrency? Currency { get; set; } + + /// + /// Scheme identifier's support email address. + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// Unique identifier, usually beginning with "SU". + /// + [JsonProperty("id")] + public string Id { get; set; } + + /// + /// The minimum interval, in working days, between the sending of a + /// pre-notification to the customer, and the charge date of a payment + /// using this scheme identifier. + /// + /// By default, GoCardless sends these notifications automatically. + /// Please see our [compliance + /// requirements](#appendix-compliance-requirements) for more details. + /// + [JsonProperty("minimum_advance_notice")] + public int? MinimumAdvanceNotice { get; set; } + + /// + /// The name which appears on customers' bank statements. This should + /// usually be the merchant's trading name. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Scheme identifier's support phone number. + /// + [JsonProperty("phone_number")] + public string PhoneNumber { get; set; } + + /// + /// The scheme identifier's support postal code. + /// + [JsonProperty("postal_code")] + public string PostalCode { get; set; } + + /// + /// The scheme-unique identifier against which payments are submitted. + /// + [JsonProperty("reference")] + public string Reference { get; set; } + + /// + /// The scheme identifier's support address region, county or + /// department. + /// + [JsonProperty("region")] + public string Region { get; set; } + + /// + /// The scheme which this scheme identifier applies to. + /// + [JsonProperty("scheme")] + public SchemeIdentifierScheme? Scheme { get; set; } + + /// + /// The status of the scheme identifier. Only `active` scheme + /// identifiers will be applied to a creditor and used against payments. + /// + [JsonProperty("status")] + public SchemeIdentifierStatus? Status { get; set; } + } + + /// + /// The currency of the scheme identifier. + /// + [JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)] + public enum SchemeIdentifierCurrency { + /// Unknown status + [EnumMember(Value = "unknown")] + Unknown = 0, + + /// `currency` with a value of "AUD" + [EnumMember(Value = "AUD")] + AUD, + /// `currency` with a value of "CAD" + [EnumMember(Value = "CAD")] + CAD, + /// `currency` with a value of "DKK" + [EnumMember(Value = "DKK")] + DKK, + /// `currency` with a value of "EUR" + [EnumMember(Value = "EUR")] + EUR, + /// `currency` with a value of "GBP" + [EnumMember(Value = "GBP")] + GBP, + /// `currency` with a value of "NZD" + [EnumMember(Value = "NZD")] + NZD, + /// `currency` with a value of "SEK" + [EnumMember(Value = "SEK")] + SEK, + /// `currency` with a value of "USD" + [EnumMember(Value = "USD")] + USD, + } + + /// + /// The scheme which this scheme identifier applies to. + /// + [JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)] + public enum SchemeIdentifierScheme { + /// Unknown status + [EnumMember(Value = "unknown")] + Unknown = 0, + + /// `scheme` with a value of "ach" + [EnumMember(Value = "ach")] + Ach, + /// `scheme` with a value of "autogiro" + [EnumMember(Value = "autogiro")] + Autogiro, + /// `scheme` with a value of "bacs" + [EnumMember(Value = "bacs")] + Bacs, + /// `scheme` with a value of "becs" + [EnumMember(Value = "becs")] + Becs, + /// `scheme` with a value of "becs_nz" + [EnumMember(Value = "becs_nz")] + BecsNz, + /// `scheme` with a value of "betalingsservice" + [EnumMember(Value = "betalingsservice")] + Betalingsservice, + /// `scheme` with a value of "faster_payments" + [EnumMember(Value = "faster_payments")] + FasterPayments, + /// `scheme` with a value of "pad" + [EnumMember(Value = "pad")] + Pad, + /// `scheme` with a value of "pay_to" + [EnumMember(Value = "pay_to")] + PayTo, + /// `scheme` with a value of "sepa" + [EnumMember(Value = "sepa")] + Sepa, + /// `scheme` with a value of "sepa_credit_transfer" + [EnumMember(Value = "sepa_credit_transfer")] + SepaCreditTransfer, + /// `scheme` with a value of "sepa_instant_credit_transfer" + [EnumMember(Value = "sepa_instant_credit_transfer")] + SepaInstantCreditTransfer, + } + + /// + /// The status of the scheme identifier. Only `active` scheme identifiers will be applied to a + /// creditor and used against payments. + /// + [JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)] + public enum SchemeIdentifierStatus { + /// Unknown status + [EnumMember(Value = "unknown")] + Unknown = 0, + + /// `status` with a value of "pending" + [EnumMember(Value = "pending")] + Pending, + /// `status` with a value of "active" + [EnumMember(Value = "active")] + Active, + } + +} diff --git a/GoCardless/Resources/VerificationDetail.cs b/GoCardless/Resources/VerificationDetail.cs new file mode 100644 index 0000000..58e61dd --- /dev/null +++ b/GoCardless/Resources/VerificationDetail.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using GoCardless.Internals; + +namespace GoCardless.Resources +{ + + /// + /// Represents a verification detail resource. + /// + /// Details of a creditor that are required for verification + /// + public class VerificationDetail + { + /// + /// The first line of the company's address. + /// + [JsonProperty("address_line1")] + public string AddressLine1 { get; set; } + + /// + /// The second line of the company's address. + /// + [JsonProperty("address_line2")] + public string AddressLine2 { get; set; } + + /// + /// The third line of the company's address. + /// + [JsonProperty("address_line3")] + public string AddressLine3 { get; set; } + + /// + /// The city of the company's address. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The company's registration number. + /// + [JsonProperty("company_number")] + public string CompanyNumber { get; set; } + + /// + /// A summary describing what the company does. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The company's directors. + /// + [JsonProperty("directors")] + public List Directors { get; set; } + + /// + /// Resources linked to this VerificationDetail. + /// + [JsonProperty("links")] + public VerificationDetailLinks Links { get; set; } + + /// + /// The company's postal code. + /// + [JsonProperty("postal_code")] + public string PostalCode { get; set; } + } + + /// + /// Represents a verification detail director resource. + /// + /// A primary director of the company represented by the creditor. + /// + public class VerificationDetailDirector + { + /// + /// The city of the person's address. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// [ISO 3166-1 alpha-2 + /// code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The person's date of birth. + /// + [JsonProperty("date_of_birth")] + public string DateOfBirth { get; set; } + + /// + /// The person's family name. + /// + [JsonProperty("family_name")] + public string FamilyName { get; set; } + + /// + /// The person's given name. + /// + [JsonProperty("given_name")] + public string GivenName { get; set; } + + /// + /// The person's postal code. + /// + [JsonProperty("postal_code")] + public string PostalCode { get; set; } + + /// + /// The street of the person's address. + /// + [JsonProperty("street")] + public string Street { get; set; } + } + + /// + /// Resources linked to this VerificationDetail + /// + public class VerificationDetailLinks + { + /// + /// ID of the [creditor](#core-endpoints-creditors) + /// + [JsonProperty("creditor")] + public string Creditor { get; set; } + } + +} diff --git a/GoCardless/Services/BankAuthorisationService.cs b/GoCardless/Services/BankAuthorisationService.cs index 4dcdd4b..06286d5 100644 --- a/GoCardless/Services/BankAuthorisationService.cs +++ b/GoCardless/Services/BankAuthorisationService.cs @@ -144,6 +144,20 @@ public class BankAuthorisationLinks /// /// URL that the payer can be redirected to after authorising the /// payment. + /// + /// On completion of bank authorisation, the query parameter of either + /// `outcome=success` or `outcome=failure` will be + /// appended to the `redirect_uri` to indicate the result of the bank + /// authorisation. If the bank authorisation is + /// expired, the query parameter `outcome=timeout` will be appended to + /// the `redirect_uri`, in which case you should + /// prompt the user to try the bank authorisation step again. + /// + /// The `redirect_uri` you provide should handle the `outcome` query + /// parameter for displaying the result of the + /// bank authorisation as outlined above. + /// + /// Defaults to `https://pay.gocardless.com/billing/static/thankyou`. /// [JsonProperty("redirect_uri")] public string RedirectUri { get; set; } diff --git a/GoCardless/Services/BillingRequestService.cs b/GoCardless/Services/BillingRequestService.cs index d64730d..a502aaf 100644 --- a/GoCardless/Services/BillingRequestService.cs +++ b/GoCardless/Services/BillingRequestService.cs @@ -1052,6 +1052,10 @@ public class BillingRequestCustomerBillingDetail /// containing the IP address of the payer to whom the mandate /// belongs (i.e. as a result of their completion of a mandate setup /// flow in their browser). + /// + /// Not required for creating offline mandates where + /// `authorisation_source` is set to telephone or paper. + /// /// [JsonProperty("ip_address")] public string IpAddress { get; set; } diff --git a/GoCardless/Services/CreditorService.cs b/GoCardless/Services/CreditorService.cs index cb2b0ed..36f7a10 100644 --- a/GoCardless/Services/CreditorService.cs +++ b/GoCardless/Services/CreditorService.cs @@ -149,6 +149,33 @@ public Task UpdateAsync(string identity, CreditorUpdateRequest return _goCardlessClient.ExecuteAsync("PUT", "/creditors/:identity", urlParams, request, null, "creditors", customiseRequestMessage); } + + /// + /// Applies a [scheme identifier](#core-endpoints-scheme-identifiers) to + /// a creditor. + /// If the creditor already has a scheme identifier for the scheme, it + /// will be replaced, + /// and any mandates attached to it transferred asynchronously. + /// For some schemes, the application of the scheme identifier will be + /// performed asynchronously. + /// + /// + /// Unique identifier, beginning with "CR". + /// An optional `CreditorApplySchemeIdentifierRequest` representing the body for this apply_scheme_identifier request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single creditor resource + public Task ApplySchemeIdentifierAsync(string identity, CreditorApplySchemeIdentifierRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new CreditorApplySchemeIdentifierRequest(); + if (identity == null) throw new ArgumentException(nameof(identity)); + + var urlParams = new List> + { + new KeyValuePair("identity", identity), + }; + + return _goCardlessClient.ExecuteAsync("POST", "/creditors/:identity/actions/apply_scheme_identifier", urlParams, request, null, "data", customiseRequestMessage); + } } @@ -158,30 +185,6 @@ public Task UpdateAsync(string identity, CreditorUpdateRequest public class CreditorCreateRequest : IHasIdempotencyKey { - /// - /// The first line of the creditor's address. - /// - [JsonProperty("address_line1")] - public string AddressLine1 { get; set; } - - /// - /// The second line of the creditor's address. - /// - [JsonProperty("address_line2")] - public string AddressLine2 { get; set; } - - /// - /// The third line of the creditor's address. - /// - [JsonProperty("address_line3")] - public string AddressLine3 { get; set; } - - /// - /// The city of the creditor's address. - /// - [JsonProperty("city")] - public string City { get; set; } - /// /// [ISO 3166-1 alpha-2 /// code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) @@ -228,23 +231,11 @@ public enum CreditorCreditorType public IDictionary Links { get; set; } /// - /// The creditor's name. + /// The creditor's trading name. /// [JsonProperty("name")] public string Name { get; set; } - /// - /// The creditor's postal code. - /// - [JsonProperty("postal_code")] - public string PostalCode { get; set; } - - /// - /// The creditor's address region, county or department. - /// - [JsonProperty("region")] - public string Region { get; set; } - /// /// A unique key to ensure that this request only succeeds once, allowing you to safely retry request errors such as network failures. /// Any requests, where supported, to create a resource with a key that has previously been used will not succeed. @@ -433,7 +424,7 @@ public class CreditorLinks } /// - /// The creditor's name. + /// The creditor's trading name. /// [JsonProperty("name")] public string Name { get; set; } @@ -451,6 +442,39 @@ public class CreditorLinks public string Region { get; set; } } + + /// + /// Applies a [scheme identifier](#core-endpoints-scheme-identifiers) to a + /// creditor. + /// If the creditor already has a scheme identifier for the scheme, it will + /// be replaced, + /// and any mandates attached to it transferred asynchronously. + /// For some schemes, the application of the scheme identifier will be + /// performed asynchronously. + /// + /// + public class CreditorApplySchemeIdentifierRequest + { + + /// + /// The ID of the scheme identifier to apply + /// + [JsonProperty("links")] + public CreditorLinks Links { get; set; } + /// + /// Linked resources for a Creditor. + /// + public class CreditorLinks + { + + /// + /// Unique identifier, usually beginning with "SU". + /// + [JsonProperty("scheme_identifier")] + public string SchemeIdentifier { get; set; } + } + } + /// /// An API response for a request returning a single creditor. /// diff --git a/GoCardless/Services/MandateService.cs b/GoCardless/Services/MandateService.cs index f9a3c30..455cc05 100644 --- a/GoCardless/Services/MandateService.cs +++ b/GoCardless/Services/MandateService.cs @@ -298,6 +298,10 @@ public class MandateLinks /// containing the IP address of the payer to whom the mandate belongs /// (i.e. as a result of their completion of a mandate setup flow in /// their browser). + /// + /// Not required for creating offline mandates where + /// `authorisation_source` is set to telephone or paper. + /// /// [JsonProperty("payer_ip_address")] public string PayerIpAddress { get; set; } diff --git a/GoCardless/Services/PayerAuthorisationService.cs b/GoCardless/Services/PayerAuthorisationService.cs index d3eaa52..7774c70 100644 --- a/GoCardless/Services/PayerAuthorisationService.cs +++ b/GoCardless/Services/PayerAuthorisationService.cs @@ -509,6 +509,10 @@ public class PayerAuthorisationMandate /// containing the IP address of the payer to whom the mandate /// belongs (i.e. as a result of their completion of a mandate setup /// flow in their browser). + /// + /// Not required for creating offline mandates where + /// `authorisation_source` is set to telephone or paper. + /// /// [JsonProperty("payer_ip_address")] public string PayerIpAddress { get; set; } @@ -866,6 +870,10 @@ public class PayerAuthorisationMandate /// containing the IP address of the payer to whom the mandate /// belongs (i.e. as a result of their completion of a mandate setup /// flow in their browser). + /// + /// Not required for creating offline mandates where + /// `authorisation_source` is set to telephone or paper. + /// /// [JsonProperty("payer_ip_address")] public string PayerIpAddress { get; set; } diff --git a/GoCardless/Services/SchemeIdentifierService.cs b/GoCardless/Services/SchemeIdentifierService.cs new file mode 100644 index 0000000..c0b07ef --- /dev/null +++ b/GoCardless/Services/SchemeIdentifierService.cs @@ -0,0 +1,278 @@ + + +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 +{ + /// + /// Service class for working with scheme identifier resources. + /// + /// This represents a scheme identifier (e.g. a SUN in Bacs or a CID in + /// SEPA). Scheme identifiers are used to specify the beneficiary name that + /// appears on customers' bank statements. + /// + /// + + public class SchemeIdentifierService + { + private readonly GoCardlessClient _goCardlessClient; + + /// + /// Constructor. Users of this library should not call this. An instance of this + /// class can be accessed through an initialised GoCardlessClient. + /// + public SchemeIdentifierService(GoCardlessClient goCardlessClient) + { + _goCardlessClient = goCardlessClient; + } + + /// + /// Creates a new scheme identifier. The scheme identifier must be + /// [applied to a creditor](#creditors-apply-a-scheme-identifier) before + /// payments are taken using it. The scheme identifier must also have + /// the `status` of active before it can be used. For some schemes e.g. + /// faster_payments this will happen instantly. For other schemes e.g. + /// bacs this can take several days. + /// + /// + /// An optional `SchemeIdentifierCreateRequest` representing the body for this create request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single scheme identifier resource + public Task CreateAsync(SchemeIdentifierCreateRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SchemeIdentifierCreateRequest(); + + var urlParams = new List> + {}; + + return _goCardlessClient.ExecuteAsync("POST", "/scheme_identifiers", urlParams, request, id => GetAsync(id, null, customiseRequestMessage), "scheme_identifiers", customiseRequestMessage); + } + + /// + /// Returns a [cursor-paginated](#api-usage-cursor-pagination) list of + /// your scheme identifiers. + /// + /// An optional `SchemeIdentifierListRequest` representing the query parameters for this list request. + /// An optional `RequestSettings` allowing you to configure the request + /// A set of scheme identifier resources + public Task ListAsync(SchemeIdentifierListRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SchemeIdentifierListRequest(); + + var urlParams = new List> + {}; + + return _goCardlessClient.ExecuteAsync("GET", "/scheme_identifiers", urlParams, request, null, null, customiseRequestMessage); + } + + /// + /// Get a lazily enumerated list of scheme identifiers. + /// This acts like the #list method, but paginates for you automatically. + /// + public IEnumerable All(SchemeIdentifierListRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SchemeIdentifierListRequest(); + + string cursor = null; + do + { + request.After = cursor; + + var result = Task.Run(() => ListAsync(request, customiseRequestMessage)).Result; + foreach (var item in result.SchemeIdentifiers) + { + yield return item; + } + cursor = result.Meta?.Cursors?.After; + } while (cursor != null); + } + + /// + /// Get a lazily enumerated list of scheme identifiers. + /// This acts like the #list method, but paginates for you automatically. + /// + public IEnumerable>> AllAsync(SchemeIdentifierListRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SchemeIdentifierListRequest(); + + return new TaskEnumerable, string>(async after => + { + request.After = after; + var list = await this.ListAsync(request, customiseRequestMessage); + return Tuple.Create(list.SchemeIdentifiers, list.Meta?.Cursors?.After); + }); + } + + /// + /// Retrieves the details of an existing scheme identifier. + /// + /// Unique identifier, usually beginning with "SU". + /// An optional `SchemeIdentifierGetRequest` representing the query parameters for this get request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single scheme identifier resource + public Task GetAsync(string identity, SchemeIdentifierGetRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SchemeIdentifierGetRequest(); + if (identity == null) throw new ArgumentException(nameof(identity)); + + var urlParams = new List> + { + new KeyValuePair("identity", identity), + }; + + return _goCardlessClient.ExecuteAsync("GET", "/scheme_identifiers/:identity", urlParams, request, null, null, customiseRequestMessage); + } + } + + + /// + /// Creates a new scheme identifier. The scheme identifier must be [applied + /// to a creditor](#creditors-apply-a-scheme-identifier) before payments are + /// taken using it. The scheme identifier must also have the `status` of + /// active before it can be used. For some schemes e.g. faster_payments this + /// will happen instantly. For other schemes e.g. bacs this can take several + /// days. + /// + /// + public class SchemeIdentifierCreateRequest : IHasIdempotencyKey + { + + /// + /// The name which appears on customers' bank statements. This should + /// usually be the merchant's trading name. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The scheme which this scheme identifier applies to. + /// + [JsonProperty("scheme")] + public SchemeIdentifierScheme? Scheme { get; set; } + + /// + /// The scheme which this scheme identifier applies to. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemeIdentifierScheme + { + + /// `scheme` with a value of "ach" + [EnumMember(Value = "ach")] + Ach, + /// `scheme` with a value of "autogiro" + [EnumMember(Value = "autogiro")] + Autogiro, + /// `scheme` with a value of "bacs" + [EnumMember(Value = "bacs")] + Bacs, + /// `scheme` with a value of "becs" + [EnumMember(Value = "becs")] + Becs, + /// `scheme` with a value of "becs_nz" + [EnumMember(Value = "becs_nz")] + BecsNz, + /// `scheme` with a value of "betalingsservice" + [EnumMember(Value = "betalingsservice")] + Betalingsservice, + /// `scheme` with a value of "faster_payments" + [EnumMember(Value = "faster_payments")] + FasterPayments, + /// `scheme` with a value of "pad" + [EnumMember(Value = "pad")] + Pad, + /// `scheme` with a value of "pay_to" + [EnumMember(Value = "pay_to")] + PayTo, + /// `scheme` with a value of "sepa" + [EnumMember(Value = "sepa")] + Sepa, + /// `scheme` with a value of "sepa_credit_transfer" + [EnumMember(Value = "sepa_credit_transfer")] + SepaCreditTransfer, + /// `scheme` with a value of "sepa_instant_credit_transfer" + [EnumMember(Value = "sepa_instant_credit_transfer")] + SepaInstantCreditTransfer, + } + + /// + /// A unique key to ensure that this request only succeeds once, allowing you to safely retry request errors such as network failures. + /// Any requests, where supported, to create a resource with a key that has previously been used will not succeed. + /// See: https://developer.gocardless.com/api-reference/#making-requests-idempotency-keys + /// + [JsonIgnore] + public string IdempotencyKey { get; set; } + } + + + /// + /// Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your + /// scheme identifiers. + /// + public class SchemeIdentifierListRequest + { + + /// + /// Cursor pointing to the start of the desired set. + /// + [JsonProperty("after")] + public string After { get; set; } + + /// + /// Cursor pointing to the end of the desired set. + /// + [JsonProperty("before")] + public string Before { get; set; } + + /// + /// Number of records to return. + /// + [JsonProperty("limit")] + public int? Limit { get; set; } + } + + + /// + /// Retrieves the details of an existing scheme identifier. + /// + public class SchemeIdentifierGetRequest + { + } + + /// + /// An API response for a request returning a single scheme identifier. + /// + public class SchemeIdentifierResponse : ApiResponse + { + /// + /// The scheme identifier from the response. + /// + [JsonProperty("scheme_identifiers")] + public SchemeIdentifier SchemeIdentifier { get; private set; } + } + + /// + /// An API response for a request returning a list of scheme identifiers. + /// + public class SchemeIdentifierListResponse : ApiResponse + { + /// + /// The list of scheme identifiers from the response. + /// + [JsonProperty("scheme_identifiers")] + public IReadOnlyList SchemeIdentifiers { get; private set; } + /// + /// Response metadata (e.g. pagination cursors) + /// + public Meta Meta { get; private set; } + } +} diff --git a/GoCardless/Services/VerificationDetailService.cs b/GoCardless/Services/VerificationDetailService.cs new file mode 100644 index 0000000..3a5faeb --- /dev/null +++ b/GoCardless/Services/VerificationDetailService.cs @@ -0,0 +1,194 @@ + + +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 +{ + /// + /// Service class for working with verification detail resources. + /// + /// Details of a creditor that are required for verification + /// + + public class VerificationDetailService + { + private readonly GoCardlessClient _goCardlessClient; + + /// + /// Constructor. Users of this library should not call this. An instance of this + /// class can be accessed through an initialised GoCardlessClient. + /// + public VerificationDetailService(GoCardlessClient goCardlessClient) + { + _goCardlessClient = goCardlessClient; + } + + /// + /// Verification details represent any information needed by GoCardless + /// to verify a creditor. + /// Currently, only UK-based companies are supported. + /// In other words, to submit verification details for a creditor, their + /// creditor_type must be company and their country_code must be GB. + /// + /// An optional `VerificationDetailCreateRequest` representing the body for this create request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single verification detail resource + public Task CreateAsync(VerificationDetailCreateRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new VerificationDetailCreateRequest(); + + var urlParams = new List> + {}; + + return _goCardlessClient.ExecuteAsync("POST", "/verification_details", urlParams, request, null, "verification_details", customiseRequestMessage); + } + } + + + /// + /// Verification details represent any information needed by GoCardless to + /// verify a creditor. + /// Currently, only UK-based companies are supported. + /// In other words, to submit verification details for a creditor, their + /// creditor_type must be company and their country_code must be GB. + /// + public class VerificationDetailCreateRequest + { + + /// + /// The first line of the company's address. + /// + [JsonProperty("address_line1")] + public string AddressLine1 { get; set; } + + /// + /// The second line of the company's address. + /// + [JsonProperty("address_line2")] + public string AddressLine2 { get; set; } + + /// + /// The third line of the company's address. + /// + [JsonProperty("address_line3")] + public string AddressLine3 { get; set; } + + /// + /// The city of the company's address. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The company's registration number. + /// + [JsonProperty("company_number")] + public string CompanyNumber { get; set; } + + /// + /// A summary describing what the company does. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The company's directors. + /// + [JsonProperty("directors")] + public VerificationDetailDirectors[] Directors { get; set; } + /// + /// A primary director of the company represented by the creditor. + /// + public class VerificationDetailDirectors + { + + /// + /// The city of the person's address. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// [ISO 3166-1 alpha-2 + /// code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The person's date of birth. + /// + [JsonProperty("date_of_birth")] + public string DateOfBirth { get; set; } + + /// + /// The person's family name. + /// + [JsonProperty("family_name")] + public string FamilyName { get; set; } + + /// + /// The person's given name. + /// + [JsonProperty("given_name")] + public string GivenName { get; set; } + + /// + /// The person's postal code. + /// + [JsonProperty("postal_code")] + public string PostalCode { get; set; } + + /// + /// The street of the person's address. + /// + [JsonProperty("street")] + public string Street { get; set; } + } + + /// + /// Linked resources. + /// + [JsonProperty("links")] + public VerificationDetailLinks Links { get; set; } + /// + /// Linked resources for a VerificationDetail. + /// + public class VerificationDetailLinks + { + + /// + /// ID of the associated [creditor](#core-endpoints-creditors). + /// + [JsonProperty("creditor")] + public string Creditor { get; set; } + } + + /// + /// The company's postal code. + /// + [JsonProperty("postal_code")] + public string PostalCode { get; set; } + } + + /// + /// An API response for a request returning a single verification detail. + /// + public class VerificationDetailResponse : ApiResponse + { + /// + /// The verification detail from the response. + /// + [JsonProperty("verification_details")] + public VerificationDetail VerificationDetail { get; private set; } + } +} diff --git a/README.md b/README.md index d74b83a..b79a11c 100644 --- a/README.md +++ b/README.md @@ -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 5.11.0` +`Install-Package GoCardless -Version 5.12.0` ## Usage diff --git a/changes.patch b/changes.patch new file mode 100644 index 0000000..e69de29