diff --git a/src/Plaid.OpenApiParser/Program.cs b/src/Plaid.OpenApiParser/Program.cs index e8e0a4c7..b242f3a9 100644 --- a/src/Plaid.OpenApiParser/Program.cs +++ b/src/Plaid.OpenApiParser/Program.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Text.RegularExpressions; using CaseExtensions; using Microsoft.OpenApi.Any; @@ -165,13 +165,14 @@ static string GetEnumName(string name) => BasePath = basePath, Name = name, Description = pd, - Properties = schema.Enum + Properties = GetEnumValues(schema) .OfType() .Select(e => new Property( e.Value, string.Empty, GetEnumName(e.Value), - ed.GetValueOrDefault(e.Value))) + ed.GetValueOrDefault(e.Value) + )) .ToList(), }; } @@ -292,20 +293,19 @@ private static (string enumDescription, Dictionary propertyDescr private static string GetPropertyDescription(OpenApiSchema type) { - var entityType = (type.Enum?.Any() ?? false) ? 2 : 1; - return - entityType == 2 - ? ParseEnumDescription(type.Description) - .enumDescription - : FixupDescription(type.Description); + var description = string.IsNullOrWhiteSpace(type.Description) + ? type.AllOf.LastOrDefault()?.Description ?? "" + : type.Description; + + return type.Enum is { Count: > 0 } + ? ParseEnumDescription(description).enumDescription + : FixupDescription(description); } private static string GetPropertyType(string className, string propertyName, OpenApiSchema schema, SchemaType type) { if (schema.Type == "array") - { return $"IReadOnlyList<{GetPropertyType(className, propertyName, schema.Items, type)}>"; - } if (schema.Type == "boolean") return "bool"; @@ -333,25 +333,22 @@ private static string GetPropertyType(string className, string propertyName, Ope } } - var entityType = (schema.Enum?.Any() ?? false) ? SchemaType.Enum : type; - if (schema.Type == "string" && entityType != SchemaType.Enum) + if (schema.AllOf.FirstOrDefault(s => s.Enum is { Count: > 0 }) is { } enumSchema) + return GetPropertyType(className, propertyName, enumSchema, type); + + var entityType = schema.Enum is { Count: > 0 } ? SchemaType.Enum : type; + if (schema.Type is "string" && entityType != SchemaType.Enum) return "string"; - if (schema.AllOf.Count == 1 - && schema.AllOf[0].Type == "string") - { + if (schema.AllOf is [{ Type: "string" }]) return "string"; - } if (schema.Reference != null) { if (schema.Reference.Id.EndsWith("Nullable", StringComparison.OrdinalIgnoreCase)) { - if (schema.AllOf.Count > 0) - { - var realType = schema.AllOf.First(); + if (schema.AllOf is [{ } realType, ..]) return GetPropertyType(className, propertyName, realType, entityType); - } } else if (schema.AdditionalProperties != null) return $"IReadOnlyDictionary"; @@ -701,6 +698,36 @@ private static string GetTemplate(string templateName) using var reader = new StreamReader(stream); return reader.ReadToEnd(); } + + private static bool IsEnum(OpenApiSchema schema) + { + if (schema.Enum is { Count: > 0 }) + return true; + + foreach (var s in schema.AllOf) + { + if (IsEnum(s)) + return true; + } + + return false; + } + + private static IList GetEnumValues(OpenApiSchema schema) + { + if (schema.Enum is not null) + { + return schema.Enum; + } + + foreach (var s in schema.AllOf) + { + if (GetEnumValues(s) is { Count: > 0 } values) + return values; + } + + return []; + } } internal enum SchemaType diff --git a/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerification.cs b/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerification.cs index fd59ec8b..a450aebf 100644 --- a/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerification.cs +++ b/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerification.cs @@ -6,13 +6,14 @@ namespace Going.Plaid.Entity; public class LinkTokenCreateRequestIdentityVerification { /// - /// + /// ID of the associated Identity Verification template. /// [JsonPropertyName("template_id")] public string TemplateId { get; set; } = default!; /// - /// + /// A flag specifying whether the end user has already agreed to a privacy policy specifying that their data will be shared with Plaid for verification purposes. + /// If gave_consent is set to true, the accept_tos step will be marked as skipped and the end user's session will start at the next step requirement. /// [JsonPropertyName("consent")] public Entity.LinkTokenCreateRequestIdentityVerificationConsentObject? Consent { get; set; } = default!; diff --git a/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerificationConsentObject.cs b/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerificationConsentObject.cs index 82c8f78b..3fdbd5a5 100644 --- a/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerificationConsentObject.cs +++ b/src/Plaid/Entity/LinkTokenCreateRequestIdentityVerificationConsentObject.cs @@ -1,7 +1,8 @@ namespace Going.Plaid.Entity; /// -/// +/// A flag specifying whether the end user has already agreed to a privacy policy specifying that their data will be shared with Plaid for verification purposes. +/// If gave_consent is set to true, the accept_tos step will be marked as skipped and the end user's session will start at the next step requirement. /// public class LinkTokenCreateRequestIdentityVerificationConsentObject { diff --git a/src/Plaid/Entity/LinkTokenCreateRequestUser.cs b/src/Plaid/Entity/LinkTokenCreateRequestUser.cs index 7319d677..8b8f39f9 100644 --- a/src/Plaid/Entity/LinkTokenCreateRequestUser.cs +++ b/src/Plaid/Entity/LinkTokenCreateRequestUser.cs @@ -18,7 +18,7 @@ public class LinkTokenCreateRequestUser public string? LegalName { get; set; } = default!; /// - /// + /// The user's full name. Optional if using the Identity Verification product; if not using Identity Verification, this field is not allowed. Users will not be asked for their name when this field is provided. /// [JsonPropertyName("name")] public Entity.LinkTokenCreateRequestUserNameObject? Name { get; set; } = default!; @@ -64,13 +64,13 @@ public class LinkTokenCreateRequestUser public DateOnly? DateOfBirth { get; set; } = default!; /// - /// + /// The user's address. Used only for Identity Verification. If provided, the user will not be shown fields to enter their address in the Identity Verification flow. May be omitted, but if not omitted, all fields marked as required must be provided. /// [JsonPropertyName("address")] public Entity.LinkTokenCreateRequestUserAddressObject? Address { get; set; } = default!; /// - /// + /// The user's ID number. Used only for Identity Verification. If provided, the user will not be shown fields to enter their ID number in the Identity Verification flow. May be omitted, but if not omitted, all fields marked as required must be provided. /// [JsonPropertyName("id_number")] public Entity.LinkTokenCreateRequestUserIdNumberObject? IdNumber { get; set; } = default!; diff --git a/src/Plaid/Entity/LinkTokenCreateRequestUserAddressObject.cs b/src/Plaid/Entity/LinkTokenCreateRequestUserAddressObject.cs index 9197930b..e4d3585b 100644 --- a/src/Plaid/Entity/LinkTokenCreateRequestUserAddressObject.cs +++ b/src/Plaid/Entity/LinkTokenCreateRequestUserAddressObject.cs @@ -1,7 +1,7 @@ namespace Going.Plaid.Entity; /// -/// +/// The user's address. Used only for Identity Verification. If provided, the user will not be shown fields to enter their address in the Identity Verification flow. May be omitted, but if not omitted, all fields marked as required must be provided. /// public class LinkTokenCreateRequestUserAddressObject { diff --git a/src/Plaid/Entity/LinkTokenCreateRequestUserIdNumberObject.cs b/src/Plaid/Entity/LinkTokenCreateRequestUserIdNumberObject.cs index 2d051c62..a5d4760f 100644 --- a/src/Plaid/Entity/LinkTokenCreateRequestUserIdNumberObject.cs +++ b/src/Plaid/Entity/LinkTokenCreateRequestUserIdNumberObject.cs @@ -1,7 +1,7 @@ namespace Going.Plaid.Entity; /// -/// +/// The user's ID number. Used only for Identity Verification. If provided, the user will not be shown fields to enter their ID number in the Identity Verification flow. May be omitted, but if not omitted, all fields marked as required must be provided. /// public class LinkTokenCreateRequestUserIdNumberObject { diff --git a/src/Plaid/Entity/LinkTokenCreateRequestUserNameObject.cs b/src/Plaid/Entity/LinkTokenCreateRequestUserNameObject.cs index f23cb1dc..1be07cae 100644 --- a/src/Plaid/Entity/LinkTokenCreateRequestUserNameObject.cs +++ b/src/Plaid/Entity/LinkTokenCreateRequestUserNameObject.cs @@ -1,7 +1,7 @@ namespace Going.Plaid.Entity; /// -/// +/// The user's full name. Optional if using the Identity Verification product; if not using Identity Verification, this field is not allowed. Users will not be asked for their name when this field is provided. /// public class LinkTokenCreateRequestUserNameObject { diff --git a/src/Plaid/Entity/Transfer.cs b/src/Plaid/Entity/Transfer.cs index efb04ec0..23548f7f 100644 --- a/src/Plaid/Entity/Transfer.cs +++ b/src/Plaid/Entity/Transfer.cs @@ -185,10 +185,14 @@ public record Transfer public IReadOnlyList? ExpectedSweepSettlementSchedule { get; init; } = default!; /// - /// + /// This field is now deprecated. You may ignore it for transfers created on and after 12/01/2023. + /// Specifies the source of funds for the transfer. Only valid for credit transfers, and defaults to sweep if not specified. This field is not specified for debit transfers. + /// sweep - Sweep funds from your funding account + /// prefunded_rtp_credits - Use your prefunded RTP credit balance with Plaid + /// prefunded_ach_credits - Use your prefunded ACH credit balance with Plaid /// [JsonPropertyName("credit_funds_source")] - public string CreditFundsSource { get; init; } = default!; + public Entity.TransferCreditFundsSource CreditFundsSource { get; init; } = default!; /// /// The amount to deduct from transfer.amount and distribute to the platform’s Ledger balance as a facilitator fee (decimal string with two digits of precision e.g. "10.00"). The remainder will go to the end-customer’s Ledger balance. This must be less than or equal to the transfer.amount. diff --git a/src/Plaid/Entity/TransferAuthorizationProposedTransfer.cs b/src/Plaid/Entity/TransferAuthorizationProposedTransfer.cs index 526f20e1..1b5f397a 100644 --- a/src/Plaid/Entity/TransferAuthorizationProposedTransfer.cs +++ b/src/Plaid/Entity/TransferAuthorizationProposedTransfer.cs @@ -78,9 +78,13 @@ public record TransferAuthorizationProposedTransfer public string? OriginatorClientId { get; init; } = default!; /// - /// + /// This field is now deprecated. You may ignore it for transfers created on and after 12/01/2023. + /// Specifies the source of funds for the transfer. Only valid for credit transfers, and defaults to sweep if not specified. This field is not specified for debit transfers. + /// sweep - Sweep funds from your funding account + /// prefunded_rtp_credits - Use your prefunded RTP credit balance with Plaid + /// prefunded_ach_credits - Use your prefunded ACH credit balance with Plaid /// [JsonPropertyName("credit_funds_source")] - public string CreditFundsSource { get; init; } = default!; + public Entity.TransferCreditFundsSource CreditFundsSource { get; init; } = default!; } diff --git a/src/Plaid/Entity/TransferCreditFundsSource.cs b/src/Plaid/Entity/TransferCreditFundsSource.cs new file mode 100644 index 00000000..af34a646 --- /dev/null +++ b/src/Plaid/Entity/TransferCreditFundsSource.cs @@ -0,0 +1,32 @@ +namespace Going.Plaid.Entity; + +/// +/// This field is now deprecated. You may ignore it for transfers created on and after 12/01/2023. +/// +public enum TransferCreditFundsSource +{ + /// + /// Sweep funds from your funding account + /// + [EnumMember(Value = "sweep")] + Sweep, + + /// + /// Use your prefunded RTP credit balance with Plaid + /// + [EnumMember(Value = "prefunded_rtp_credits")] + PrefundedRtpCredits, + + /// + /// Use your prefunded ACH credit balance with Plaid + /// + [EnumMember(Value = "prefunded_ach_credits")] + PrefundedAchCredits, + + /// + /// Catch-all for unknown values returned by Plaid. If you encounter this, please check if there is a later version of the Going.Plaid library. + /// + [EnumMember(Value = "undefined")] + Undefined, + +} diff --git a/src/Plaid/Income/IncomeVerificationPrecheckRequest.cs b/src/Plaid/Income/IncomeVerificationPrecheckRequest.cs index feee935d..770f789e 100644 --- a/src/Plaid/Income/IncomeVerificationPrecheckRequest.cs +++ b/src/Plaid/Income/IncomeVerificationPrecheckRequest.cs @@ -24,7 +24,7 @@ public partial class IncomeVerificationPrecheckRequest : RequestBase public Entity.IncomeVerificationPrecheckPayrollInstitution? PayrollInstitution { get; set; } = default!; /// - /// + /// The access token associated with the Item data is being requested for. /// [JsonPropertyName("transactions_access_token")] public string? TransactionsAccessToken { get; set; } = default!; diff --git a/src/Plaid/Link/LinkTokenCreateRequest.cs b/src/Plaid/Link/LinkTokenCreateRequest.cs index 3f3f084f..36496710 100644 --- a/src/Plaid/Link/LinkTokenCreateRequest.cs +++ b/src/Plaid/Link/LinkTokenCreateRequest.cs @@ -181,10 +181,18 @@ public partial class LinkTokenCreateRequest : RequestBase public Entity.LinkTokenCreateRequestCraOptions? CraOptions { get; set; } = default!; /// - /// + /// Describes the reason you are generating a Consumer Report for this user. This parameter is required if you want to generate a Consumer Report for the user automatically after the Link session. If you omit this parameter during Link token creation, you can later call the /cra/check_report/create endpoint to generate a report. + /// ACCOUNT_REVIEW_CREDIT: In connection with a consumer credit transaction for the review or collection of an account pursuant to FCRA Section 604(a)(3)(A). + /// ACCOUNT_REVIEW_NON_CREDIT: For a legitimate business need of the information to review a non-credit account provided primarily for personal, family, or household purposes to determine whether the consumer continues to meet the terms of the account pursuant to FCRA Section 604(a)(3)(F)(2). + /// EMPLOYMENT: For employment purposes pursuant to FCRA 604(a)(3)(B), including hiring, retention and promotion purposes. + /// EXTENSION_OF_CREDIT: In connection with a credit transaction initiated by and involving the consumer pursuant to FCRA Section 604(a)(3)(A). + /// LEGITIMATE_BUSINESS_NEED_TENANT_SCREENING: For a legitimate business need in connection with a business transaction initiated by the consumer primarily for personal, family, or household purposes in connection with a property rental assessment pursuant to FCRA Section 604(a)(3)(F)(i). + /// LEGITIMATE_BUSINESS_NEED_OTHER: For a legitimate business need in connection with a business transaction made primarily for personal, family, or household initiated by the consumer pursuant to FCRA Section 604(a)(3)(F)(i). + /// WRITTEN_INSTRUCTION_PREQUALIFICATION: In accordance with the written instructions of the consumer pursuant to FCRA Section 604(a)(2), to evaluate an application’s profile to make an offer to the consumer. + /// WRITTEN_INSTRUCTION_OTHER: In accordance with the written instructions of the consumer pursuant to FCRA Section 604(a)(2), such as when an individual agrees to act as a guarantor or assumes personal liability for a consumer, business, or commercial loan. /// [JsonPropertyName("consumer_report_permissible_purpose")] - public Entity.LinkTokenCreateRequestConsumerReportPermissiblePurposeObject? ConsumerReportPermissiblePurpose { get; set; } = default!; + public Entity.ConsumerReportPermissiblePurpose? ConsumerReportPermissiblePurpose { get; set; } = default!; /// /// Specifies options for initializing Link for use with the Auth product. This field can be used to enable or disable extended Auth flows for the resulting Link session. Omitting any field will result in a default that can be configured by your account manager. The default behavior described in the documentation is the default behavior that will apply if you have not requested your account manager to apply a different default. diff --git a/src/Plaid/PaymentInitiation/PaymentInitiationConsentPaymentExecuteRequest.cs b/src/Plaid/PaymentInitiation/PaymentInitiationConsentPaymentExecuteRequest.cs index f6d2ad7f..2fbc2820 100644 --- a/src/Plaid/PaymentInitiation/PaymentInitiationConsentPaymentExecuteRequest.cs +++ b/src/Plaid/PaymentInitiation/PaymentInitiationConsentPaymentExecuteRequest.cs @@ -34,10 +34,12 @@ public partial class PaymentInitiationConsentPaymentExecuteRequest : RequestBase public string? Reference { get; set; } = default!; /// - /// + /// Deprecated, payments will be executed within the type of the consent. + /// A scope of the payment. Must be one of the scopes mentioned in the consent. + /// Optional if the appropriate consent has only one scope defined, required otherwise. /// [JsonPropertyName("scope")] - public Entity.PaymentInitiationConsentPaymentExecuteRequestScopeObject? Scope { get; set; } = default!; + public Entity.PaymentInitiationConsentScope? Scope { get; set; } = default!; /// /// Decides the mode under which the payment processing should be performed, using IMMEDIATE as default. diff --git a/src/Plaid/Transfer/TransferAuthorizationCreateRequest.cs b/src/Plaid/Transfer/TransferAuthorizationCreateRequest.cs index 25b09277..dd10fcec 100644 --- a/src/Plaid/Transfer/TransferAuthorizationCreateRequest.cs +++ b/src/Plaid/Transfer/TransferAuthorizationCreateRequest.cs @@ -117,10 +117,14 @@ public partial class TransferAuthorizationCreateRequest : RequestBase public string? OriginatorClientId { get; set; } = default!; /// - /// + /// This field is now deprecated. You may ignore it for transfers created on and after 12/01/2023. + /// Specifies the source of funds for the transfer. Only valid for credit transfers, and defaults to sweep if not specified. This field is not specified for debit transfers. + /// sweep - Sweep funds from your funding account + /// prefunded_rtp_credits - Use your prefunded RTP credit balance with Plaid + /// prefunded_ach_credits - Use your prefunded ACH credit balance with Plaid /// [JsonPropertyName("credit_funds_source")] - public string? CreditFundsSource { get; set; } = default!; + public Entity.TransferCreditFundsSource? CreditFundsSource { get; set; } = default!; /// /// Plaid’s unique identifier for a test clock. This field may only be used when using sandbox environment. If provided, the authorization is created at the virtual_time on the provided test clock. diff --git a/src/Plaid/Transfer/TransferCreateRequest.cs b/src/Plaid/Transfer/TransferCreateRequest.cs index b8c30415..fac5b9e2 100644 --- a/src/Plaid/Transfer/TransferCreateRequest.cs +++ b/src/Plaid/Transfer/TransferCreateRequest.cs @@ -26,16 +26,20 @@ public partial class TransferCreateRequest : RequestBase public string AuthorizationId { get; set; } = default!; /// - /// + /// The type of transfer. This will be either debit or credit. A debit indicates a transfer of money into the origination account; a credit indicates a transfer of money out of the origination account. /// [JsonPropertyName("type")] - public string? Type { get; set; } = default!; + public Entity.TransferType? Type { get; set; } = default!; /// - /// + /// The network or rails used for the transfer. + /// For transfers submitted as ach, the next-day cutoff is 8:30 PM Eastern Time. + /// For transfers submitted as same-day-ach, the same-day cutoff is 3:30 PM Eastern Time. If the transfer is submitted after this cutoff but before the next-day cutoff, it will be sent over next-day rails and will not incur same-day charges; this will apply to both legs of the transfer if applicable. + /// For transfers submitted as rtp, Plaid will automatically route between Real Time Payment rail by TCH or FedNow rails as necessary. If a transfer is submitted as rtp and the counterparty account is not eligible for RTP, the /transfer/authorization/create request will fail with an INVALID_FIELD error code. To pre-check to determine whether a counterparty account can support RTP, call /transfer/capabilities/get before calling /transfer/authorization/create. + /// Wire transfers are currently in early availability. To request access to wire as a payment network, contact your Account Manager. For transfers submitted as wire, the type must be credit; wire debits are not supported. /// [JsonPropertyName("network")] - public string? Network { get; set; } = default!; + public Entity.TransferNetwork? Network { get; set; } = default!; /// /// The amount of the transfer (decimal string with two digits of precision e.g. "10.00"). When calling /transfer/authorization/create, specify the maximum amount to authorize. When calling /transfer/create, specify the exact amount of the transfer, up to a maximum of the amount authorized. If this field is left blank when calling /transfer/create, the maximum amount authorized in the authorization_id will be sent. @@ -50,10 +54,16 @@ public partial class TransferCreateRequest : RequestBase public string Description { get; set; } = default!; /// - /// + /// Specifies the use case of the transfer. Required for transfers on an ACH network. For more details, see ACH SEC codes. + /// Codes supported for credits: ccd, ppd + /// Codes supported for debits: ccd, tel, web + /// "ccd" - Corporate Credit or Debit - fund transfer between two corporate bank accounts + /// "ppd" - Prearranged Payment or Deposit - the transfer is part of a pre-existing relationship with a consumer, e.g. bill payment + /// "tel" - Telephone-Initiated Entry + /// "web" - Internet-Initiated Entry - debits from a consumer’s account where their authorization is obtained over the Internet /// [JsonPropertyName("ach_class")] - public string? AchClass { get; set; } = default!; + public Entity.AchClass? AchClass { get; set; } = default!; /// /// The legal name and other information for the account holder.