From ded6bd8a4724048531f7b9eda2117af99b27d7dc Mon Sep 17 00:00:00 2001 From: Andrew Edwards Date: Sat, 31 Mar 2018 14:11:24 -0400 Subject: [PATCH 1/3] Made routes variable to be able to replace them with mocks for testing. Cleaned up config and provider. --- Sources/Stripe/Provider/Provider.swift | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Sources/Stripe/Provider/Provider.swift b/Sources/Stripe/Provider/Provider.swift index 8671583..aa112f9 100644 --- a/Sources/Stripe/Provider/Provider.swift +++ b/Sources/Stripe/Provider/Provider.swift @@ -29,34 +29,34 @@ public final class StripeProvider: Provider { services.register { (container) -> StripeClient in let httpClient = try container.make(Client.self) let config = try container.make(StripeConfig.self) - return StripeClient(config: config, client: httpClient) + return StripeClient(apiKey: config.apiKey, client: httpClient) } } } public struct StripeClient: Service { - public let balance: StripeBalanceRoutes - public let charge: StripeChargeRoutes - public let connectAccount: StripeConnectAccountRoutes - public let coupon: StripeCouponRoutes - public let customer: StripeCustomerRoutes - public let dispute: StripeDisputeRoutes - public let ephemeralKey: StripeEphemeralKeyRoutes - public let invoiceItem: StripeInvoiceItemRoutes - public let invoice: StripeInvoiceRoutes - public let orderReturn: StripeOrderReturnRoutes - public let order: StripeOrderRoutes - public let plan: StripePlanRoutes - public let product: StripeProductRoutes - public let refund: StripeRefundRoutes - public let sku: StripeSKURoutes - public let source: StripeSourceRoutes - public let subscriptionItem: StripeSubscriptionItemRoutes - public let subscription: StripeSubscriptionRoutes - public let token: StripeTokenRoutes + public var balance: StripeBalanceRoutes + public var charge: StripeChargeRoutes + public var connectAccount: StripeConnectAccountRoutes + public var coupon: StripeCouponRoutes + public var customer: StripeCustomerRoutes + public var dispute: StripeDisputeRoutes + public var ephemeralKey: StripeEphemeralKeyRoutes + public var invoiceItem: StripeInvoiceItemRoutes + public var invoice: StripeInvoiceRoutes + public var orderReturn: StripeOrderReturnRoutes + public var order: StripeOrderRoutes + public var plan: StripePlanRoutes + public var product: StripeProductRoutes + public var refund: StripeRefundRoutes + public var sku: StripeSKURoutes + public var source: StripeSourceRoutes + public var subscriptionItem: StripeSubscriptionItemRoutes + public var subscription: StripeSubscriptionRoutes + public var token: StripeTokenRoutes - internal init(config: StripeConfig, client: Client) { - let apiRequest = StripeAPIRequest(httpClient: client, apiKey: config.apiKey) + internal init(apiKey: String, client: Client) { + let apiRequest = StripeAPIRequest(httpClient: client, apiKey: apiKey) balance = StripeBalanceRoutes(request: apiRequest) charge = StripeChargeRoutes(request: apiRequest) From fa4308265fea2880166e37d33ed02821866da3c5 Mon Sep 17 00:00:00 2001 From: Andrew Edwards Date: Sun, 1 Apr 2018 11:11:09 -0400 Subject: [PATCH 2/3] Updates for keyDecodingStragety. Updated tests. --- README.md | 4 -- Sources/Stripe/API/StripeRequest.swift | 5 +- Sources/Stripe/Errors/StripeAPIError.swift | 9 ++++ Sources/Stripe/Helpers/CodeVerification.swift | 5 ++ Sources/Stripe/Models/Balance/Balance.swift | 8 +++ .../Models/Balance/BalanceHistoryList.swift | 8 +++ .../Balance/BalanceTransactionItem.swift | 17 ++++++ .../Models/Balance/BalanceTransfer.swift | 6 +++ Sources/Stripe/Models/Charges/Charge.swift | 39 ++++++++++++++ .../Stripe/Models/Charges/ChargeList.swift | 8 +++ .../Stripe/Models/Charges/FruadDetails.swift | 5 ++ Sources/Stripe/Models/Charges/Outcome.swift | 9 ++++ Sources/Stripe/Models/Connect/Account.swift | 32 +++++++++++ .../Stripe/Models/Connect/AccountList.swift | 8 +++ .../Models/Connect/AccountVerification.swift | 6 +++ .../Models/Connect/AdditionalOwner.swift | 10 ++++ .../Models/Connect/ExternalAccounts.swift | 12 ++++- .../Models/Connect/ExternalBankAccount.swift | 10 ++++ .../Models/Connect/ExternalCardAccount.swift | 17 ++++++ .../Stripe/Models/Connect/LegalEntity.swift | 20 +++++++ .../Connect/LegalEntityVerification.swift | 7 +++ .../Models/Connect/PayoutSchedule.swift | 7 +++ .../Stripe/Models/Connect/TOSAcceptance.swift | 6 +++ Sources/Stripe/Models/Coupons/Coupon.swift | 17 ++++++ .../Stripe/Models/Coupons/CouponList.swift | 8 +++ Sources/Stripe/Models/Customer/Customer.swift | 19 +++++++ .../Stripe/Models/Customer/CustomerList.swift | 8 +++ Sources/Stripe/Models/Dispute/Dispute.swift | 17 ++++++ .../Models/Dispute/DisputeEvidence.swift | 30 +++++++++++ .../Dispute/DisputeEvidenceDetails.swift | 7 +++ .../Stripe/Models/Dispute/DisputeList.swift | 8 +++ .../Models/EphemeralKey/EphemeralKey.swift | 10 ++++ Sources/Stripe/Models/Invoices/Invoice.swift | 38 +++++++++++++ .../Stripe/Models/Invoices/InvoiceItem.swift | 20 +++++++ .../Models/Invoices/InvoiceItemList.swift | 8 +++ .../Models/Invoices/InvoiceLineGroup.swift | 8 +++ .../Models/Invoices/InvoiceLineItem.swift | 18 +++++++ .../Stripe/Models/Invoices/InvoiceList.swift | 8 +++ Sources/Stripe/Models/Orders/Order.swift | 26 +++++++++ Sources/Stripe/Models/Orders/OrderList.swift | 8 +++ .../Models/Orders/OrderReturnList.swift | 8 +++ Sources/Stripe/Models/Plans/Plans.swift | 15 ++++++ Sources/Stripe/Models/Plans/PlansList.swift | 8 +++ Sources/Stripe/Models/Products/Products.swift | 22 ++++++++ .../Stripe/Models/Products/ProductsList.swift | 8 +++ Sources/Stripe/Models/Refunds/Refund.swift | 15 ++++++ .../Stripe/Models/Refunds/RefundList.swift | 8 +++ Sources/Stripe/Models/SKU/SKU.swift | 17 ++++++ Sources/Stripe/Models/SKU/SKUList.swift | 8 +++ .../Models/Shipping/ShippingLabel.swift | 8 +++ .../Models/Shipping/ShippingMethod.swift | 8 +++ .../Models/Shipping/StripeAddress.swift | 9 ++++ .../Stripe/Models/Sources/BankAccount.swift | 18 +++++++ Sources/Stripe/Models/Sources/Card.swift | 31 +++++++++++ Sources/Stripe/Models/Sources/Mandate.swift | 5 ++ .../Stripe/Models/Sources/OtherSources.swift | 54 +++++++++++++++++++ Sources/Stripe/Models/Sources/Owner.swift | 11 ++++ Sources/Stripe/Models/Sources/Receiver.swift | 9 ++++ Sources/Stripe/Models/Sources/Source.swift | 30 +++++++++++ .../Stripe/Models/Sources/SourceList.swift | 8 +++ .../Models/Sources/SourceRedirect.swift | 7 +++ .../Models/Subscriptions/Subscription.swift | 27 ++++++++++ .../Subscriptions/SubscriptionItem.swift | 10 ++++ .../Subscriptions/SubscriptionItemList.swift | 8 +++ .../Subscriptions/SubscriptionList.swift | 8 +++ Sources/Stripe/Models/Tokens/Token.swift | 12 +++++ Tests/StripeTests/AccountTests.swift | 23 ++++---- Tests/StripeTests/BalanceTests.swift | 10 ++-- Tests/StripeTests/ChargeTests.swift | 3 +- Tests/StripeTests/CustomerTests.swift | 3 +- Tests/StripeTests/DisputeTests.swift | 3 +- Tests/StripeTests/EphemeralKeyTests.swift | 3 +- Tests/StripeTests/ErrorTests.swift | 3 +- Tests/StripeTests/InvoiceTests.swift | 6 +-- Tests/StripeTests/OrderTests.swift | 15 +++--- Tests/StripeTests/ProductTests.swift | 3 +- Tests/StripeTests/RefundTests.swift | 3 +- Tests/StripeTests/SKUTests.swift | 3 +- Tests/StripeTests/SourceTests.swift | 21 ++++---- Tests/StripeTests/SubscriptionTests.swift | 3 +- Tests/StripeTests/TokenTests.swift | 6 +-- circle.yml | 17 ++++++ 82 files changed, 941 insertions(+), 72 deletions(-) create mode 100644 circle.yml diff --git a/README.md b/README.md index d86ced4..69a97d5 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,6 @@ futureCharge.do({ (charge) in And you can always check the documentation to see the required paramaters for specific API calls. -## Linux compatibility -Currently the project won't compile for linux. -You can track this issue [here](https://bugs.swift.org/browse/SR-7180) and [here](https://github.com/apple/swift-corelibs-foundation/pull/1347) - ## Whats Implemented ### Core Resources diff --git a/Sources/Stripe/API/StripeRequest.swift b/Sources/Stripe/API/StripeRequest.swift index 396b0d7..be65625 100644 --- a/Sources/Stripe/API/StripeRequest.swift +++ b/Sources/Stripe/API/StripeRequest.swift @@ -23,15 +23,14 @@ public extension StripeRequest { public func serializedResponse(response: HTTPResponse, worker: EventLoop) throws -> Future { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase guard response.status == .ok else { - return try decoder.decode(StripeAPIError.self, from: response.body, on: worker).map(to: SM.self) { error in + return try decoder.decode(StripeAPIError.self, from: response.body, maxSize: 65_536, on: worker).map(to: SM.self) { error in throw StripeError.apiError(error) } } - return try decoder.decode(SM.self, from: response.body, on: worker) + return try decoder.decode(SM.self, from: response.body, maxSize: 65_536, on: worker) } } diff --git a/Sources/Stripe/Errors/StripeAPIError.swift b/Sources/Stripe/Errors/StripeAPIError.swift index 8840dae..4c32b49 100644 --- a/Sources/Stripe/Errors/StripeAPIError.swift +++ b/Sources/Stripe/Errors/StripeAPIError.swift @@ -27,6 +27,15 @@ public struct StripeAPIErrorBody: APIError, StripeModel { public var code: StripeAPICardErrorType? public var declineCode: StripeAPIDeclineCode? public var param: String? + + public enum CodingKeys: CodingKey, String { + case type + case charge + case message + case code + case declineCode = "decline_code" + case param + } } public struct StripeAPIError: StripeModel { diff --git a/Sources/Stripe/Helpers/CodeVerification.swift b/Sources/Stripe/Helpers/CodeVerification.swift index 95638d0..b5b1ae7 100644 --- a/Sources/Stripe/Helpers/CodeVerification.swift +++ b/Sources/Stripe/Helpers/CodeVerification.swift @@ -8,4 +8,9 @@ public struct CodeVerification: StripeModel { public var attemptsRemaining: Int? public var status: StripeStatus? + + public enum CodingKeys: CodingKey, String { + case attemptsRemaining = "attempts_remaining" + case status + } } diff --git a/Sources/Stripe/Models/Balance/Balance.swift b/Sources/Stripe/Models/Balance/Balance.swift index a47b726..d307811 100644 --- a/Sources/Stripe/Models/Balance/Balance.swift +++ b/Sources/Stripe/Models/Balance/Balance.swift @@ -27,4 +27,12 @@ public struct StripeBalance: Balance, StripeModel { public var connectReserved: [StripeBalanceTransfer]? public var livemode: Bool? public var pending: [StripeBalanceTransfer]? + + public enum CodingKeys: CodingKey, String { + case object + case available + case connectReserved = "connect_reserved" + case livemode + case pending + } } diff --git a/Sources/Stripe/Models/Balance/BalanceHistoryList.swift b/Sources/Stripe/Models/Balance/BalanceHistoryList.swift index 2e0f7d9..2e020dd 100644 --- a/Sources/Stripe/Models/Balance/BalanceHistoryList.swift +++ b/Sources/Stripe/Models/Balance/BalanceHistoryList.swift @@ -17,4 +17,12 @@ public struct BalanceHistoryList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeBalance]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Balance/BalanceTransactionItem.swift b/Sources/Stripe/Models/Balance/BalanceTransactionItem.swift index cafece5..71adab1 100644 --- a/Sources/Stripe/Models/Balance/BalanceTransactionItem.swift +++ b/Sources/Stripe/Models/Balance/BalanceTransactionItem.swift @@ -47,4 +47,21 @@ public struct StripeBalanceTransactionItem: BalanceTransactionItem, StripeModel public var source: String? public var status: StripeStatus? public var type: BalanceTransactionType? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case availableOn = "available_on" + case created + case currency + case exchangeRate = "exchange_rate" + case description + case fee + case feeDetails = "fee_details" + case net + case source + case status + case type + } } diff --git a/Sources/Stripe/Models/Balance/BalanceTransfer.swift b/Sources/Stripe/Models/Balance/BalanceTransfer.swift index bf89384..f99c734 100644 --- a/Sources/Stripe/Models/Balance/BalanceTransfer.swift +++ b/Sources/Stripe/Models/Balance/BalanceTransfer.swift @@ -21,4 +21,10 @@ public struct StripeBalanceTransfer: BalanceTransfer, StripeModel { public var currency: StripeCurrency? public var amount: Int? public var sourceTypes: [String: Int]? + + public enum CodingKeys: CodingKey, String { + case currency + case amount + case sourceTypes = "source_types" + } } diff --git a/Sources/Stripe/Models/Charges/Charge.swift b/Sources/Stripe/Models/Charges/Charge.swift index d382248..0bc6b2a 100644 --- a/Sources/Stripe/Models/Charges/Charge.swift +++ b/Sources/Stripe/Models/Charges/Charge.swift @@ -94,4 +94,43 @@ public struct StripeCharge: Charge, StripeModel { public var status: StripeStatus? public var transfer: String? public var transferGroup: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case amountRefunded = "amount_refunded" + case application + case applicationFee = "application_fee" + case balanceTransaction = "balance_transaction" + case captured + case created + case currency + case customer + case description + case destination + case dispute + case failureCode = "failure_code" + case failureMessage = "failure_message" + case fraudDetails = "fraud_details" + case invoice + case livemode + case metadata + case onBehalfOf = "on_behalf_of" + case order + case outcome + case paid + case receiptEmail = "receipt_email" + case receiptNumber = "receipt_number" + case refunded + case refunds + case review + case shipping + case source + case sourceTransfer = "source_transfer" + case statementDescriptor = "statement_descriptor" + case status + case transfer + case transferGroup = "transfer_group" + } } diff --git a/Sources/Stripe/Models/Charges/ChargeList.swift b/Sources/Stripe/Models/Charges/ChargeList.swift index 4971c68..9e8596f 100644 --- a/Sources/Stripe/Models/Charges/ChargeList.swift +++ b/Sources/Stripe/Models/Charges/ChargeList.swift @@ -17,4 +17,12 @@ public struct ChargesList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeCharge]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Charges/FruadDetails.swift b/Sources/Stripe/Models/Charges/FruadDetails.swift index c7aaf40..46a3343 100644 --- a/Sources/Stripe/Models/Charges/FruadDetails.swift +++ b/Sources/Stripe/Models/Charges/FruadDetails.swift @@ -24,4 +24,9 @@ public protocol FraudDetails { public struct StripeFraudDetails: FraudDetails, StripeModel { public var userReport: FraudReport? public var stripeReport: FraudReport? + + public enum CodingKeys: CodingKey, String { + case userReport = "user_report" + case stripeReport = "stripe_report" + } } diff --git a/Sources/Stripe/Models/Charges/Outcome.swift b/Sources/Stripe/Models/Charges/Outcome.swift index 145d8ad..60b460c 100644 --- a/Sources/Stripe/Models/Charges/Outcome.swift +++ b/Sources/Stripe/Models/Charges/Outcome.swift @@ -50,4 +50,13 @@ public struct StripeOutcome: Outcome, StripeModel { public var rule: String? public var sellerMessage: String? public var type: OutcomeType? + + public enum CodingKeys: CodingKey, String { + case networkStatus = "network_status" + case reason + case riskLevel = "risk_level" + case rule + case sellerMessage = "seller_message" + case type + } } diff --git a/Sources/Stripe/Models/Connect/Account.swift b/Sources/Stripe/Models/Connect/Account.swift index 3f2fb44..90bf4ac 100644 --- a/Sources/Stripe/Models/Connect/Account.swift +++ b/Sources/Stripe/Models/Connect/Account.swift @@ -80,4 +80,36 @@ public struct StripeConnectAccount: ConnectAccount, StripeModel { public var type: ConnectedAccountType? public var verification: StripeAccountVerification? public var transfersEnabled: Bool? + + public enum CodingKeys: CodingKey, String { + case id + case object + case businessLogo = "business_logo" + case businessName = "business_name" + case businessUrl = "business_url" + case chargesEnabled = "charges_enabled" + case country + case created + case debitNegativeBalances = "debit_negative_balances" + case declineChargeOn = "decline_charge_on" + case defaultCurrency = "default_currency" + case detailsSubmitted = "details_submitted" + case displayName = "display_name" + case email + case externalAccounts = "external_accounts" + case legalEntity = "legal_entity" + case metadata + case payoutSchedule = "payout_schedule" + case payoutStatementDescriptor = "payout_statement_descriptor" + case payoutsEnabled = "payouts_enabled" + case productDescription = "product_description" + case statementDescriptor = "statement_descriptor" + case supportEmail = "support_email" + case supportPhone = "support_phone" + case timezone + case tosAcceptance = "tos_acceptance" + case type + case verification + case transfersEnabled = "transfers_enabled" + } } diff --git a/Sources/Stripe/Models/Connect/AccountList.swift b/Sources/Stripe/Models/Connect/AccountList.swift index b46380a..d549d98 100644 --- a/Sources/Stripe/Models/Connect/AccountList.swift +++ b/Sources/Stripe/Models/Connect/AccountList.swift @@ -17,4 +17,12 @@ public struct ConnectedAccountsList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeConnectAccount]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Connect/AccountVerification.swift b/Sources/Stripe/Models/Connect/AccountVerification.swift index 45799d0..495a8d4 100644 --- a/Sources/Stripe/Models/Connect/AccountVerification.swift +++ b/Sources/Stripe/Models/Connect/AccountVerification.swift @@ -22,4 +22,10 @@ public struct StripeAccountVerification: AccountVerification, StripeModel { public var disabledReason: String? public var dueBy: Date? public var fieldsNeeded: [String]? + + public enum CodingKeys: CodingKey, String { + case disabledReason = "disabled_reason" + case dueBy = "due_by" + case fieldsNeeded = "fields_needed" + } } diff --git a/Sources/Stripe/Models/Connect/AdditionalOwner.swift b/Sources/Stripe/Models/Connect/AdditionalOwner.swift index 73ccdfa..7fcbf84 100644 --- a/Sources/Stripe/Models/Connect/AdditionalOwner.swift +++ b/Sources/Stripe/Models/Connect/AdditionalOwner.swift @@ -32,4 +32,14 @@ public struct StripeLegalEntityAdditionalOwner: LegalEntityAdditionalOwner, Stri public var personalIdNumberProvided: Bool? public var address: StripeAddress? public var verification: StripeLegalEntityVerification? + + public enum CodingKeys: CodingKey, String { + case firstName = "first_name" + case lastName = "last_name" + case dob + case maidenName = "maiden_name" + case personalIdNumberProvided = "personal_id_number_provided" + case address + case verification + } } diff --git a/Sources/Stripe/Models/Connect/ExternalAccounts.swift b/Sources/Stripe/Models/Connect/ExternalAccounts.swift index a2a7bf7..dde254a 100644 --- a/Sources/Stripe/Models/Connect/ExternalAccounts.swift +++ b/Sources/Stripe/Models/Connect/ExternalAccounts.swift @@ -16,7 +16,7 @@ public struct ExternalAccountsList: StripeModel { public var hasMore: Bool? public var totalCount: Int? public var url: String? - private var data: String? + public var data: String? public var cardAccounts: [StripeCard]? public var bankAccounts: [StripeBankAccount]? @@ -29,6 +29,16 @@ public struct ExternalAccountsList: StripeModel { cardAccounts = try container.decodeIfPresent([StripeCard].self, forKey: .data)?.filter{ $0.object == "card" } bankAccounts = try container.decodeIfPresent([StripeBankAccount].self, forKey: .data)?.filter{ $0.object == "bank_account" } } + + public enum CodingKeys: String, CodingKey { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + case cardAccounts + case bankAccounts + } } public protocol ExternalAccount {} diff --git a/Sources/Stripe/Models/Connect/ExternalBankAccount.swift b/Sources/Stripe/Models/Connect/ExternalBankAccount.swift index 0901f25..c8b52ef 100644 --- a/Sources/Stripe/Models/Connect/ExternalBankAccount.swift +++ b/Sources/Stripe/Models/Connect/ExternalBankAccount.swift @@ -15,4 +15,14 @@ public struct StripeExternalBankAccount: ExternalAccount, StripeModel { public var accountHolderName: String? public var accountHolderType: String? public var routingNumber: String? + + public enum CodingKeys: CodingKey, String { + case object + case accountNumber = "account_number" + case country + case currency + case accountHolderName = "account_holder_name" + case accountHolderType = "account_holder_type" + case routingNumber = "routing_number" + } } diff --git a/Sources/Stripe/Models/Connect/ExternalCardAccount.swift b/Sources/Stripe/Models/Connect/ExternalCardAccount.swift index be81d47..77efe5a 100644 --- a/Sources/Stripe/Models/Connect/ExternalCardAccount.swift +++ b/Sources/Stripe/Models/Connect/ExternalCardAccount.swift @@ -23,4 +23,21 @@ public struct StripeExternalCardAccount: ExternalAccount, StripeModel { public var cvc: String? public var metadata: [String: String]? public var name: String? + + public enum CodingKeys: CodingKey, String { + case object + case defaultForCurrency = "default_for_currency" + case expMonth = "exp_month" + case expYear = "exp_year" + case number + case addressCity = "address_city" + case addressCountry = "address_country" + case addressLine1 = "address_line1" + case addressLine2 = "address_line2" + case addressState = "address_state" + case addressZip = "address_zip" + case cvc + case metadata + case name + } } diff --git a/Sources/Stripe/Models/Connect/LegalEntity.swift b/Sources/Stripe/Models/Connect/LegalEntity.swift index 27dbaba..d457abd 100644 --- a/Sources/Stripe/Models/Connect/LegalEntity.swift +++ b/Sources/Stripe/Models/Connect/LegalEntity.swift @@ -55,4 +55,24 @@ public struct StripeConnectAccountLegalEntity: LegalEntity, StripeModel { public var taxIdRegistrar: String? public var type: String? public var verification: StripeLegalEntityVerification? + + public enum CodingKeys: CodingKey, String { + case additionalOwners = "additional_owners" + case address + case businessName = "business_name" + case businessTaxIdProvided = "business_tax_id_provided" + case businessVATIdProvided = "business_vat_id_provided" + case dob + case firstName = "first_name" + case lastName = "last_name" + case gender + case maidenName = "maiden_name" + case personalIdNumberProvided = "personal_id_number_provided" + case personalAddress = "personal_address" + case phoneNumber = "phone_number" + case ssnLast4Provided = "ssn_last_4_provided" + case taxIdRegistrar = "tax_id_registrar" + case type + case verification + } } diff --git a/Sources/Stripe/Models/Connect/LegalEntityVerification.swift b/Sources/Stripe/Models/Connect/LegalEntityVerification.swift index ddf02fc..580b645 100644 --- a/Sources/Stripe/Models/Connect/LegalEntityVerification.swift +++ b/Sources/Stripe/Models/Connect/LegalEntityVerification.swift @@ -23,4 +23,11 @@ public struct StripeLegalEntityVerification: LegalEntityVerification, StripeMode public var detailsCode: LegalEntityVerificationState? public var document: String? public var status: LegalEntityVerificationStatus? + + public enum CodingKeys: CodingKey, String { + case details + case detailsCode = "details_code" + case document + case status + } } diff --git a/Sources/Stripe/Models/Connect/PayoutSchedule.swift b/Sources/Stripe/Models/Connect/PayoutSchedule.swift index 0faa50f..bef7a8c 100644 --- a/Sources/Stripe/Models/Connect/PayoutSchedule.swift +++ b/Sources/Stripe/Models/Connect/PayoutSchedule.swift @@ -23,4 +23,11 @@ public struct StripePayoutSchedule: PayoutSchedule, StripeModel { public var interval: StripePayoutInterval? public var monthlyAnchor: Int? public var weeklyAnchor: StripeWeeklyAnchor? + + public enum CodingKeys: CodingKey, String { + case delayDays = "delay_days" + case interval + case monthlyAnchor = "monthly_anchor" + case weeklyAnchor = "weekly_anchor" + } } diff --git a/Sources/Stripe/Models/Connect/TOSAcceptance.swift b/Sources/Stripe/Models/Connect/TOSAcceptance.swift index 63caf4f..406a82a 100644 --- a/Sources/Stripe/Models/Connect/TOSAcceptance.swift +++ b/Sources/Stripe/Models/Connect/TOSAcceptance.swift @@ -23,4 +23,10 @@ public struct StripeTOSAcceptance: TOSAcceptance, StripeModel { public var date: Date? public var ip: String? public var userAgent: String? + + public enum CodingKeys: CodingKey, String { + case date + case ip + case userAgent = "user_agent" + } } diff --git a/Sources/Stripe/Models/Coupons/Coupon.swift b/Sources/Stripe/Models/Coupons/Coupon.swift index 250455f..bee294e 100644 --- a/Sources/Stripe/Models/Coupons/Coupon.swift +++ b/Sources/Stripe/Models/Coupons/Coupon.swift @@ -45,4 +45,21 @@ public struct StripeCoupon: Coupon, StripeModel { public var redeemBy: Date? public var timesRedeemed: Int? public var valid: Bool? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amountOff = "amount_off" + case created + case currency + case duration + case durationInMonths = "duration_in_months" + case livemode + case maxRedemptions = "max_redemptions" + case metadata + case percentOff = "percent_off" + case redeemBy = "redeem_by" + case timesRedeemed = "times_redeemed" + case valid + } } diff --git a/Sources/Stripe/Models/Coupons/CouponList.swift b/Sources/Stripe/Models/Coupons/CouponList.swift index 54b60f3..f19624b 100644 --- a/Sources/Stripe/Models/Coupons/CouponList.swift +++ b/Sources/Stripe/Models/Coupons/CouponList.swift @@ -17,4 +17,12 @@ public struct CouponsList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeCoupon]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Customer/Customer.swift b/Sources/Stripe/Models/Customer/Customer.swift index 6f7696b..7c5e0bd 100644 --- a/Sources/Stripe/Models/Customer/Customer.swift +++ b/Sources/Stripe/Models/Customer/Customer.swift @@ -54,4 +54,23 @@ public struct StripeCustomer: Customer, StripeModel { public var shipping: ShippingLabel? public var sources: StripeSourcesList? public var subscriptions: SubscriptionList? + + public enum CodingKeys: CodingKey, String { + case id + case object + case accountBalance = "account_balance" + case bussinessVATId = "bussiness_vat_id" + case created + case currency + case defaultSource = "default_source" + case delinquent + case description + case discount + case email + case livemode + case metadata + case shipping + case sources + case subscriptions + } } diff --git a/Sources/Stripe/Models/Customer/CustomerList.swift b/Sources/Stripe/Models/Customer/CustomerList.swift index f2df4e6..430e9c0 100644 --- a/Sources/Stripe/Models/Customer/CustomerList.swift +++ b/Sources/Stripe/Models/Customer/CustomerList.swift @@ -17,4 +17,12 @@ public struct CustomersList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeCustomer]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Dispute/Dispute.swift b/Sources/Stripe/Models/Dispute/Dispute.swift index 013da30..056e2fd 100644 --- a/Sources/Stripe/Models/Dispute/Dispute.swift +++ b/Sources/Stripe/Models/Dispute/Dispute.swift @@ -49,4 +49,21 @@ public struct StripeDispute: Dispute, StripeModel { public var metadata: [String: String]? public var reason: DisputeReason? public var status: DisputeStatus? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case balanceTransactions = "balance_transactions" + case charge + case created + case currency + case evidence + case evidenceDetails = "evidence_details" + case isChargeRefundable = "is_charge_refundable" + case livemode + case metadata + case reason + case status + } } diff --git a/Sources/Stripe/Models/Dispute/DisputeEvidence.swift b/Sources/Stripe/Models/Dispute/DisputeEvidence.swift index 9ba272b..32556c4 100644 --- a/Sources/Stripe/Models/Dispute/DisputeEvidence.swift +++ b/Sources/Stripe/Models/Dispute/DisputeEvidence.swift @@ -68,4 +68,34 @@ public struct StripeDisputeEvidence: DisputeEvidence, StripeModel { public var shippingTrackingNumber: String? public var uncategorizedFile: String? public var uncategorizedText: String? + + public enum CodingKeys: CodingKey, String { + case accessActivityLog = "access_activity_log" + case billingAddress = "billing_address" + case cancellationPolicy = "cancellation_policy" + case cancellationPolicyDisclosure = "cancellation_policy_disclosure" + case cancellationRebuttal = "cancellation_rebuttal" + case customerCommunication = "customer_communication" + case customerEmailAddress = "customer_email_address" + case customerName = "customer_name" + case customerPurchaseIp = "customer_purchase_ip" + case customerSignature = "customer_signature" + case duplicateChargeDocumentation = "duplicate_charge_documentation" + case duplicateChargeExplanation = "duplicate_charge_explanation" + case duplicateChargeId = "duplicate_charge_id" + case productDescription = "product_description" + case receipt + case refundPolicy = "refund_policy" + case refundPolicyDisclosure = "refund_policy_disclosure" + case refundRefusalExplanation = "refund_refusal_explanation" + case serviceDate = "service_date" + case serviceDocumentation = "service_documentation" + case shippingAddress = "shipping_address" + case shippingCarrier = "shipping_carrier" + case shippingDate = "shipping_date" + case shippingDocumentation = "shipping_documentation" + case shippingTrackingNumber = "shipping_tracking_number" + case uncategorizedFile = "uncategorized_file" + case uncategorizedText = "uncategorized_text" + } } diff --git a/Sources/Stripe/Models/Dispute/DisputeEvidenceDetails.swift b/Sources/Stripe/Models/Dispute/DisputeEvidenceDetails.swift index b99b1f7..8594170 100644 --- a/Sources/Stripe/Models/Dispute/DisputeEvidenceDetails.swift +++ b/Sources/Stripe/Models/Dispute/DisputeEvidenceDetails.swift @@ -24,4 +24,11 @@ public struct StripeDisputeEvidenceDetails: DisputeEvidenceDetails, StripeModel public var hasEvidence: Bool? public var pastDue: Bool? public var submissionCount: Int? + + public enum CodingKeys: CodingKey, String { + case dueBy = "due_by" + case hasEvidence = "has_evidence" + case pastDue = "past_due" + case submissionCount = "submission_count" + } } diff --git a/Sources/Stripe/Models/Dispute/DisputeList.swift b/Sources/Stripe/Models/Dispute/DisputeList.swift index 526d0db..9fb806a 100644 --- a/Sources/Stripe/Models/Dispute/DisputeList.swift +++ b/Sources/Stripe/Models/Dispute/DisputeList.swift @@ -17,4 +17,12 @@ public struct DisputesList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeDispute]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/EphemeralKey/EphemeralKey.swift b/Sources/Stripe/Models/EphemeralKey/EphemeralKey.swift index 8944763..0d3ccd4 100644 --- a/Sources/Stripe/Models/EphemeralKey/EphemeralKey.swift +++ b/Sources/Stripe/Models/EphemeralKey/EphemeralKey.swift @@ -25,4 +25,14 @@ public struct StripeEphemeralKey: EphemeralKey, StripeModel { public var expires: Date? public var livemode: Bool? public var secret: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case associatedObjects = "associated_objects" + case created + case expires + case livemode + case secret + } } diff --git a/Sources/Stripe/Models/Invoices/Invoice.swift b/Sources/Stripe/Models/Invoices/Invoice.swift index 00c1df4..ef6c533 100644 --- a/Sources/Stripe/Models/Invoices/Invoice.swift +++ b/Sources/Stripe/Models/Invoices/Invoice.swift @@ -90,4 +90,42 @@ public struct StripeInvoice: Invoice, StripeModel { public var tax: Int? public var taxPercent: Decimal? public var webhooksDeliveredAt: Date? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amountDue = "amount_due" + case applicationFee = "application_fee" + case attemptCount = "attempt_count" + case attempted + case billing + case charge + case closed + case currency + case customer + case date + case description + case discount + case dueDate = "due_date" + case endingBalance = "ending_balance" + case forgiven + case lines + case livemode + case metadata + case nextPaymentAttempt = "next_payment_attempt" + case number + case paid + case periodEnd = "period_end" + case periodStart = "period_start" + case receiptNumber = "receipt_number" + case startingBalance = "starting_balance" + case statementDescriptor = "statement_descriptor" + case subscription + case subscriptionProrationDate = "subscription_proration_date" + case subtotal + case total + case tax + case taxPercent = "tax_percent" + case webhooksDeliveredAt = "webhooks_delivered_at" + } } diff --git a/Sources/Stripe/Models/Invoices/InvoiceItem.swift b/Sources/Stripe/Models/Invoices/InvoiceItem.swift index a231b0e..431c5eb 100644 --- a/Sources/Stripe/Models/Invoices/InvoiceItem.swift +++ b/Sources/Stripe/Models/Invoices/InvoiceItem.swift @@ -53,4 +53,24 @@ public struct StripeInvoiceItem: InvoiceItem, StripeModel { public var quantity: Int? public var subscription: String? public var subscriptionItem: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case currency + case customer + case date + case description + case discountable + case invoice + case livemode + case metadata + case period + case plan + case proration + case quantity + case subscription + case subscriptionItem = "subscription_item" + } } diff --git a/Sources/Stripe/Models/Invoices/InvoiceItemList.swift b/Sources/Stripe/Models/Invoices/InvoiceItemList.swift index 434fc38..e7ad927 100644 --- a/Sources/Stripe/Models/Invoices/InvoiceItemList.swift +++ b/Sources/Stripe/Models/Invoices/InvoiceItemList.swift @@ -16,5 +16,13 @@ public struct InvoiceItemsList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeInvoiceItem]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Invoices/InvoiceLineGroup.swift b/Sources/Stripe/Models/Invoices/InvoiceLineGroup.swift index 42652a6..b3c48f9 100644 --- a/Sources/Stripe/Models/Invoices/InvoiceLineGroup.swift +++ b/Sources/Stripe/Models/Invoices/InvoiceLineGroup.swift @@ -17,4 +17,12 @@ public struct InvoiceLineGroup: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeInvoiceLineItem]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Invoices/InvoiceLineItem.swift b/Sources/Stripe/Models/Invoices/InvoiceLineItem.swift index 6ad33b2..c624600 100644 --- a/Sources/Stripe/Models/Invoices/InvoiceLineItem.swift +++ b/Sources/Stripe/Models/Invoices/InvoiceLineItem.swift @@ -49,4 +49,22 @@ public struct StripeInvoiceLineItem: InvoiceLineItem, StripeModel { public var subscription: String? public var subscriptionItem: String? public var type: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case currency + case description + case discountable + case livemode + case metadata + case period + case plan + case proration + case quantity + case subscription + case subscriptionItem = "subscription_item" + case type + } } diff --git a/Sources/Stripe/Models/Invoices/InvoiceList.swift b/Sources/Stripe/Models/Invoices/InvoiceList.swift index 1a3d9ce..91d8f4e 100644 --- a/Sources/Stripe/Models/Invoices/InvoiceList.swift +++ b/Sources/Stripe/Models/Invoices/InvoiceList.swift @@ -16,4 +16,12 @@ public struct InvoicesList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeInvoice]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Orders/Order.swift b/Sources/Stripe/Models/Orders/Order.swift index 8b5f44e..8ffef7e 100644 --- a/Sources/Stripe/Models/Orders/Order.swift +++ b/Sources/Stripe/Models/Orders/Order.swift @@ -69,4 +69,30 @@ public struct StripeOrder: Order, StripeModel { public var statusTransitions: StripeOrderStatusTransitions? public var updated: Date? public var upstreamId: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case amountReturned = "amount_returned" + case application + case applicationFee = "application_fee" + case charge + case created + case currency + case customer + case email + case externalCouponCode = "external_coupon_code" + case items + case livemode + case metadata + case returns + case selectedShippingMethod = "selected_shipping_method" + case shipping + case shippingMethods = "shipping_methods" + case status + case statusTransitions = "status_transitions" + case updated + case upstreamId = "upstream_id" + } } diff --git a/Sources/Stripe/Models/Orders/OrderList.swift b/Sources/Stripe/Models/Orders/OrderList.swift index ac446a9..a9c89cd 100644 --- a/Sources/Stripe/Models/Orders/OrderList.swift +++ b/Sources/Stripe/Models/Orders/OrderList.swift @@ -17,4 +17,12 @@ public struct OrdersList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeOrder]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Orders/OrderReturnList.swift b/Sources/Stripe/Models/Orders/OrderReturnList.swift index bd163eb..e0cd34d 100644 --- a/Sources/Stripe/Models/Orders/OrderReturnList.swift +++ b/Sources/Stripe/Models/Orders/OrderReturnList.swift @@ -17,4 +17,12 @@ public struct OrderReturnList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeOrderReturn]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Plans/Plans.swift b/Sources/Stripe/Models/Plans/Plans.swift index e551c96..8b1d018 100644 --- a/Sources/Stripe/Models/Plans/Plans.swift +++ b/Sources/Stripe/Models/Plans/Plans.swift @@ -41,4 +41,19 @@ public struct StripePlan: Plan, StripeModel { public var nickname: String? public var product: String? public var trialPeriodDays: Int? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case created + case currency + case interval + case intervalCount = "interval_count" + case livemode + case metadata + case nickname + case product + case trialPeriodDays = "trial_period_days" + } } diff --git a/Sources/Stripe/Models/Plans/PlansList.swift b/Sources/Stripe/Models/Plans/PlansList.swift index fd3d8a7..4339acc 100644 --- a/Sources/Stripe/Models/Plans/PlansList.swift +++ b/Sources/Stripe/Models/Plans/PlansList.swift @@ -17,4 +17,12 @@ public struct PlansList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripePlan]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Products/Products.swift b/Sources/Stripe/Models/Products/Products.swift index 823f6b4..ce777e7 100644 --- a/Sources/Stripe/Models/Products/Products.swift +++ b/Sources/Stripe/Models/Products/Products.swift @@ -58,4 +58,26 @@ public struct StripeProduct: Product, StripeModel { public var type: String? public var updated: Date? public var url: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case active + case attributes + case caption + case created + case deactivateOn = "deactivate_on" + case description + case images + case livemode + case metadata + case name + case packageDimensions = "package_dimensions" + case shippable + case skus + case statementDescriptor = "statement_descriptor" + case type + case updated + case url + } } diff --git a/Sources/Stripe/Models/Products/ProductsList.swift b/Sources/Stripe/Models/Products/ProductsList.swift index 38ae4a5..22fcafd 100644 --- a/Sources/Stripe/Models/Products/ProductsList.swift +++ b/Sources/Stripe/Models/Products/ProductsList.swift @@ -17,4 +17,12 @@ public struct ProductsList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeProduct]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Refunds/Refund.swift b/Sources/Stripe/Models/Refunds/Refund.swift index a922707..ae49f47 100644 --- a/Sources/Stripe/Models/Refunds/Refund.swift +++ b/Sources/Stripe/Models/Refunds/Refund.swift @@ -41,4 +41,19 @@ public struct StripeRefund: Refund, StripeModel { public var reason: RefundReason? public var receiptNumber: String? public var status: StripeStatus? + + public enum CodingKeys: CodingKey, String { + case id + case object + case amount + case balanceTransaction = "balance_transaction" + case charge + case created + case currency + case description + case metadata + case reason + case receiptNumber = "receipt_number" + case status + } } diff --git a/Sources/Stripe/Models/Refunds/RefundList.swift b/Sources/Stripe/Models/Refunds/RefundList.swift index 09e5cc0..52422a6 100644 --- a/Sources/Stripe/Models/Refunds/RefundList.swift +++ b/Sources/Stripe/Models/Refunds/RefundList.swift @@ -17,4 +17,12 @@ public struct RefundsList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeRefund]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/SKU/SKU.swift b/Sources/Stripe/Models/SKU/SKU.swift index d82bfd6..812b7c2 100644 --- a/Sources/Stripe/Models/SKU/SKU.swift +++ b/Sources/Stripe/Models/SKU/SKU.swift @@ -48,4 +48,21 @@ public struct StripeSKU: SKU, StripeModel { public var price: Int? public var product: String? public var updated: Date? + + public enum CodingKeys: CodingKey, String { + case id + case object + case active + case attributes + case created + case currency + case image + case inventory + case livemode + case metadata + case packageDimensions = "package_dimensions" + case price + case product + case updated + } } diff --git a/Sources/Stripe/Models/SKU/SKUList.swift b/Sources/Stripe/Models/SKU/SKUList.swift index e0a217a..56aec61 100644 --- a/Sources/Stripe/Models/SKU/SKUList.swift +++ b/Sources/Stripe/Models/SKU/SKUList.swift @@ -17,4 +17,12 @@ public struct SKUList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeSKU]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Shipping/ShippingLabel.swift b/Sources/Stripe/Models/Shipping/ShippingLabel.swift index 43107f2..f304838 100644 --- a/Sources/Stripe/Models/Shipping/ShippingLabel.swift +++ b/Sources/Stripe/Models/Shipping/ShippingLabel.swift @@ -26,4 +26,12 @@ public struct ShippingLabel: Shipping, StripeModel { public var name: String? public var phone: String? public var trackingNumber: String? + + public enum CodingKeys: CodingKey, String { + case address + case carrier + case name + case phone + case trackingNumber = "tracking_number" + } } diff --git a/Sources/Stripe/Models/Shipping/ShippingMethod.swift b/Sources/Stripe/Models/Shipping/ShippingMethod.swift index 82f0b21..2ea1aaf 100644 --- a/Sources/Stripe/Models/Shipping/ShippingMethod.swift +++ b/Sources/Stripe/Models/Shipping/ShippingMethod.swift @@ -27,4 +27,12 @@ public struct StripeShippingMethod: ShippingMethod, StripeModel { public var currency: StripeCurrency? public var deliveryEstimate: StripeDeliveryEstimate? public var description: String? + + public enum CodingKeys: CodingKey, String { + case id + case amount + case currency + case deliveryEstimate = "delivery_estimate" + case description + } } diff --git a/Sources/Stripe/Models/Shipping/StripeAddress.swift b/Sources/Stripe/Models/Shipping/StripeAddress.swift index f41b91e..8a3e72c 100644 --- a/Sources/Stripe/Models/Shipping/StripeAddress.swift +++ b/Sources/Stripe/Models/Shipping/StripeAddress.swift @@ -27,4 +27,13 @@ public struct StripeAddress: Address, StripeModel { public var line2: String? public var postalCode: String? public var state: String? + + public enum CodingKeys: CodingKey, String { + case city + case country + case line1 + case line2 + case postalCode = "postal_code" + case state + } } diff --git a/Sources/Stripe/Models/Sources/BankAccount.swift b/Sources/Stripe/Models/Sources/BankAccount.swift index d1591cb..4c57f7b 100644 --- a/Sources/Stripe/Models/Sources/BankAccount.swift +++ b/Sources/Stripe/Models/Sources/BankAccount.swift @@ -45,4 +45,22 @@ public struct StripeBankAccount: BankAccount, StripeModel { public var metadata: [String : String]? public var routingNumber: String? public var status: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case account + case accountHolderName = "account_holder_name" + case accountHolderType = "account_holder_type" + case bankName = "bank_name" + case country + case currency + case customer + case defaultForCurrency = "default_for_currency" + case fingerprint + case last4 + case metadata + case routingNumber = "routing_number" + case status + } } diff --git a/Sources/Stripe/Models/Sources/Card.swift b/Sources/Stripe/Models/Sources/Card.swift index 03279c3..bee90f4 100644 --- a/Sources/Stripe/Models/Sources/Card.swift +++ b/Sources/Stripe/Models/Sources/Card.swift @@ -74,4 +74,35 @@ public struct StripeCard: Card, StripeModel { public var recipient: String? public var tokenizationMethod: TokenizedMethod? public var threeDSecure: String? + + public enum CodingKeys: CodingKey, String { + case id + case object + case account + case addressCity = "address_city" + case addressCountry = "address_country" + case addressLine1 = "address_line1" + case addressLine1Check = "address_line1_check" + case addressLine2 = "address_line2" + case addressState = "address_state" + case addressZip = "address_zip" + case addressZipCheck = "address_zip_check" + case availablePayoutMethods = "available_payout_methods" + case brand + case country + case customer + case cvcCheck = "cvc_check" + case defaultForCurrency = "default_for_currency" + case dynamicLast4 = "dynamic_last4" + case expMonth = "exp_month" + case expYear = "exp_year" + case fingerprint + case funding + case last4 + case metadata + case name + case recipient + case tokenizationMethod = "tokenization_method" + case threeDSecure = "three_d_secure" + } } diff --git a/Sources/Stripe/Models/Sources/Mandate.swift b/Sources/Stripe/Models/Sources/Mandate.swift index 8b32146..7a462e6 100644 --- a/Sources/Stripe/Models/Sources/Mandate.swift +++ b/Sources/Stripe/Models/Sources/Mandate.swift @@ -20,4 +20,9 @@ public protocol Mandate { public struct StripeMandate: Mandate, StripeModel { public var acceptance: StripeTOSAcceptance? public var notificationMethod: String? + + public enum CodingKeys: String, CodingKey { + case acceptance + case notificationMethod = "notification_method" + } } diff --git a/Sources/Stripe/Models/Sources/OtherSources.swift b/Sources/Stripe/Models/Sources/OtherSources.swift index a9d605a..d458205 100644 --- a/Sources/Stripe/Models/Sources/OtherSources.swift +++ b/Sources/Stripe/Models/Sources/OtherSources.swift @@ -23,6 +23,13 @@ public struct Giropay: StripeModel { public var bic: String? public var bankName: String? public var statementDescriptor: String? + + public enum CodingKeys: String, CodingKey { + case bankCode = "bank_code" + case bic + case bankName = "bank_name" + case statementDescriptor = "statement_descriptor" + } } // MARK: - SepaDebit @@ -33,6 +40,15 @@ public struct SepaDebit: StripeModel { public var last4: String? public var mandateReference: String? public var mandateUrl: String? + + public enum CodingKeys: String, CodingKey { + case bankCode = "bank_code" + case country + case fingerprint + case last4 + case mandateReference = "mandate_reference" + case mandateUrl = "mandate_url" + } } // MARK: - iDEAL @@ -41,6 +57,13 @@ public struct iDEAL: StripeModel { public var bic: String? public var ibanLast4: String? public var statementDescriptor: String? + + public enum CodingKeys: String, CodingKey { + case bank + case bic + case ibanLast4 = "iban_last4" + case statementDescriptor = "statement_descriptor" + } } // MARK: - SOFORT @@ -52,6 +75,16 @@ public struct SOFORT: StripeModel { public var ibanLast4: String? public var preferredLanguage: String? public var statementDescriptor: String? + + public enum CodingKeys: String, CodingKey { + case country + case bankCode = "bank_code" + case bic + case bankName = "bank_name" + case ibanLast4 = "iban_last4" + case preferredLanguage = "preferred_language" + case statementDescriptor = "statement_descriptor" + } } // MARK: - Bancontact @@ -61,12 +94,25 @@ public struct Bancontact: StripeModel { public var bankName: String? public var statementDescriptor: String? public var preferredLanguage: String? + + public enum CodingKeys: String, CodingKey { + case bankCode = "bank_code" + case bic + case bankName = "bank_name" + case statementDescriptor = "statement_descriptor" + case preferredLanguage = "preferred_language" + } } // MARK: - Alipay public struct Alipay: StripeModel { public var nativeUrl: String? public var statementDescriptor: String? + + public enum CodingKeys: String, CodingKey { + case nativeUrl = "native_url" + case statementDescriptor = "statement_descriptor" + } } // MARK: - P24 @@ -81,4 +127,12 @@ public struct ACHCreditTransfer: StripeModel { public var fingerprint: String? public var bankName: String? public var swiftCode: String? + + public enum CodingKeys: String, CodingKey { + case accountNumber = "account_number" + case routingNumber = "routing_number" + case fingerprint + case bankName = "bank_name" + case swiftCode = "swift_code" + } } diff --git a/Sources/Stripe/Models/Sources/Owner.swift b/Sources/Stripe/Models/Sources/Owner.swift index ede7ae6..6949460 100644 --- a/Sources/Stripe/Models/Sources/Owner.swift +++ b/Sources/Stripe/Models/Sources/Owner.swift @@ -32,4 +32,15 @@ public struct StripeOwner: Owner, StripeModel { public var verifiedEmail: String? public var verifiedName: String? public var verifiedPhone: String? + + public enum CodingKeys: String, CodingKey { + case address + case email + case name + case phone + case verifiedAddress = "verified_address" + case verifiedEmail = "verified_email" + case verifiedName = "verified_name" + case verifiedPhone = "verified_phone" + } } diff --git a/Sources/Stripe/Models/Sources/Receiver.swift b/Sources/Stripe/Models/Sources/Receiver.swift index 4c3a8b4..6cdc368 100644 --- a/Sources/Stripe/Models/Sources/Receiver.swift +++ b/Sources/Stripe/Models/Sources/Receiver.swift @@ -27,4 +27,13 @@ public struct StripeReceiver: Receiver, StripeModel { public var amountReturned: Int? public var refundAttributesMethod: String? public var refundAttributesStatus: String? + + public enum CodingKeys: String, CodingKey { + case address + case amountCharged = "amount_charged" + case amountReceived = "amount_received" + case amountReturned = "amount_returned" + case refundAttributesMethod = "refund_attributes_method" + case refundAttributesStatus = "refund_attributes_status" + } } diff --git a/Sources/Stripe/Models/Sources/Source.swift b/Sources/Stripe/Models/Sources/Source.swift index 89b1183..8c089d8 100644 --- a/Sources/Stripe/Models/Sources/Source.swift +++ b/Sources/Stripe/Models/Sources/Source.swift @@ -131,4 +131,34 @@ public struct StripeSource: Source, StripeModel { achCreditTransfer = try container.decodeIfPresent(ACHCreditTransfer.self, forKey: .achCreditTransfer) } } + + public enum CodingKeys: String, CodingKey { + case id + case object + case amount + case clientSecret = "client_secret" + case codeVerification = "code_verification" + case created + case currency + case flow + case livemode + case metadata + case owner + case receiver + case redirect + case statementDescriptor = "statement_descriptor" + case status + case usage + case type + case card + case threeDSecure = "three_d_secure" + case giropay + case sepaDebit = "sepa_debit" + case ideal + case sofort + case bancontact + case alipay + case p24 + case achCreditTransfer = "ach_credit_transfer" + } } diff --git a/Sources/Stripe/Models/Sources/SourceList.swift b/Sources/Stripe/Models/Sources/SourceList.swift index e94d0c6..764754a 100644 --- a/Sources/Stripe/Models/Sources/SourceList.swift +++ b/Sources/Stripe/Models/Sources/SourceList.swift @@ -17,4 +17,12 @@ public struct StripeSourcesList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeSource]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Sources/SourceRedirect.swift b/Sources/Stripe/Models/Sources/SourceRedirect.swift index e4e4c13..f205534 100644 --- a/Sources/Stripe/Models/Sources/SourceRedirect.swift +++ b/Sources/Stripe/Models/Sources/SourceRedirect.swift @@ -10,4 +10,11 @@ public struct SourceRedirect: StripeModel { public var returnUrl: String? public var status: String? public var url: String? + + public enum CodingKeys: String, CodingKey { + case failureReason = "failure_reason" + case returnUrl = "return_url" + case status + case url + } } diff --git a/Sources/Stripe/Models/Subscriptions/Subscription.swift b/Sources/Stripe/Models/Subscriptions/Subscription.swift index 4772bb4..2af3cf7 100644 --- a/Sources/Stripe/Models/Subscriptions/Subscription.swift +++ b/Sources/Stripe/Models/Subscriptions/Subscription.swift @@ -69,4 +69,31 @@ public struct StripeSubscription: Subscription, StripeModel { public var taxPercent: Decimal? public var trialEnd: Date? public var trialStart: Date? + + public enum CodingKeys: String, CodingKey { + case id + case object + case applicationFeePercent = "application_fee_percent" + case billing + case billingCycleAnchor = "billing_cycle_anchor" + case cancelAtPeriodEnd = "cancel_at_period_end" + case canceledAt = "canceled_at" + case created + case currentPeriodEnd = "current_period_end" + case currentPeriodStart = "current_period_start" + case customer + case daysUntilDue = "days_until_due" + case discount + case endedAt = "ended_at" + case items + case livemode + case metadata + case plan + case quantity + case start + case status + case taxPercent = "tax_percent" + case trialEnd = "trial_end" + case trialStart = "trial_start" + } } diff --git a/Sources/Stripe/Models/Subscriptions/SubscriptionItem.swift b/Sources/Stripe/Models/Subscriptions/SubscriptionItem.swift index 1c52808..4536c77 100644 --- a/Sources/Stripe/Models/Subscriptions/SubscriptionItem.swift +++ b/Sources/Stripe/Models/Subscriptions/SubscriptionItem.swift @@ -33,4 +33,14 @@ public struct StripeSubscriptionItem: SubscriptionItem, StripeModel { public var plan: StripePlan? public var quantity: Int? public var subscription: String? + + public enum CodingKeys: String, CodingKey { + case id + case object + case created + case metadata + case plan + case quantity + case subscription + } } diff --git a/Sources/Stripe/Models/Subscriptions/SubscriptionItemList.swift b/Sources/Stripe/Models/Subscriptions/SubscriptionItemList.swift index 99f67aa..3e8829d 100644 --- a/Sources/Stripe/Models/Subscriptions/SubscriptionItemList.swift +++ b/Sources/Stripe/Models/Subscriptions/SubscriptionItemList.swift @@ -17,4 +17,12 @@ public struct SubscriptionItemList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeSubscriptionItem]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Subscriptions/SubscriptionList.swift b/Sources/Stripe/Models/Subscriptions/SubscriptionList.swift index 4b53ec8..a21cd96 100644 --- a/Sources/Stripe/Models/Subscriptions/SubscriptionList.swift +++ b/Sources/Stripe/Models/Subscriptions/SubscriptionList.swift @@ -17,4 +17,12 @@ public struct SubscriptionList: List, StripeModel { public var totalCount: Int? public var url: String? public var data: [StripeSubscription]? + + public enum CodingKeys: CodingKey, String { + case object + case hasMore = "has_more" + case totalCount = "total_count" + case url + case data + } } diff --git a/Sources/Stripe/Models/Tokens/Token.swift b/Sources/Stripe/Models/Tokens/Token.swift index 7e48097..e2be7fa 100644 --- a/Sources/Stripe/Models/Tokens/Token.swift +++ b/Sources/Stripe/Models/Tokens/Token.swift @@ -38,4 +38,16 @@ public struct StripeToken: Token, StripeModel { public var used: Bool? public var card: StripeCard? public var bankAccount: StripeBankAccount? + + public enum CodingKeys: CodingKey, String { + case id + case object + case type + case clientIp = "client_ip" + case created + case livemode + case used + case card + case bankAccount = "bank_account" + } } diff --git a/Tests/StripeTests/AccountTests.swift b/Tests/StripeTests/AccountTests.swift index 73fce87..ae2f467 100644 --- a/Tests/StripeTests/AccountTests.swift +++ b/Tests/StripeTests/AccountTests.swift @@ -73,9 +73,9 @@ class AccountTests: XCTestCase { "maiden_name": "old", "personal_id_number_provided": true, "verification": { - "details": null, + "details": "Nothing to see here", "details_code": "failed_other", - "document": null, + "document": "thestuff.pdf", "status": "verified" }, "dob": { @@ -130,8 +130,8 @@ class AccountTests: XCTestCase { "payouts_enabled": false, "product_description": "Vapor", "statement_descriptor": "", - "support_email": null, - "support_phone": null, + "support_email": "a@b.com", + "support_phone": "1234567", "timezone": "US/Pacific", "tos_acceptance": { "date": 1385798567, @@ -168,10 +168,9 @@ class AccountTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: accountString) - let futureAccount = try decoder.decode(StripeConnectAccount.self, from: body, on: EmbeddedEventLoop()) + let futureAccount = try decoder.decode(StripeConnectAccount.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureAccount.do { (account) in XCTAssertEqual(account.id, "acct_1032D82eZvKYlo2C") @@ -183,8 +182,8 @@ class AccountTests: XCTestCase { XCTAssertEqual(account.country, "US") XCTAssertEqual(account.created, Date(timeIntervalSince1970: 1385798567)) XCTAssertEqual(account.debitNegativeBalances, true) - XCTAssertEqual(account.declineChargeOn?["avsFailure"], true) - XCTAssertEqual(account.declineChargeOn?["cvcFailure"], false) + XCTAssertEqual(account.declineChargeOn?["avs_failure"], true) + XCTAssertEqual(account.declineChargeOn?["cvc_failure"], false) XCTAssertEqual(account.defaultCurrency, .usd) XCTAssertEqual(account.detailsSubmitted, false) XCTAssertEqual(account.displayName, "Stripe.com") @@ -198,8 +197,8 @@ class AccountTests: XCTestCase { XCTAssertEqual(account.payoutsEnabled, false) XCTAssertEqual(account.productDescription, "Vapor") XCTAssertEqual(account.statementDescriptor, "") - XCTAssertEqual(account.supportEmail, nil) - XCTAssertEqual(account.supportPhone, nil) + XCTAssertEqual(account.supportEmail, "a@b.com") + XCTAssertEqual(account.supportPhone, "1234567") XCTAssertEqual(account.timezone, "US/Pacific") // TOS acceptance @@ -261,9 +260,9 @@ class AccountTests: XCTestCase { XCTAssertEqual(account.legalEntity?.additionalOwners?[0].lastName, "X") XCTAssertEqual(account.legalEntity?.additionalOwners?[0].maidenName, "old") XCTAssertEqual(account.legalEntity?.additionalOwners?[0].personalIdNumberProvided, true) - XCTAssertEqual(account.legalEntity?.additionalOwners?[0].verification?.details, nil) + XCTAssertEqual(account.legalEntity?.additionalOwners?[0].verification?.details, "Nothing to see here") XCTAssertEqual(account.legalEntity?.additionalOwners?[0].verification?.detailsCode, .failedOther) - XCTAssertEqual(account.legalEntity?.additionalOwners?[0].verification?.document, nil) + XCTAssertEqual(account.legalEntity?.additionalOwners?[0].verification?.document, "thestuff.pdf") XCTAssertEqual(account.legalEntity?.additionalOwners?[0].verification?.status, .verified) XCTAssertEqual(account.legalEntity?.additionalOwners?[0].dob?["day"], 10) XCTAssertEqual(account.legalEntity?.additionalOwners?[0].dob?["month"], 10) diff --git a/Tests/StripeTests/BalanceTests.swift b/Tests/StripeTests/BalanceTests.swift index 0b942e1..dfc7bd9 100644 --- a/Tests/StripeTests/BalanceTests.swift +++ b/Tests/StripeTests/BalanceTests.swift @@ -69,10 +69,9 @@ class BalanceTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: balanceString) - let futureBalance = try decoder.decode(StripeBalance.self, from: body, on: EmbeddedEventLoop()) + let futureBalance = try decoder.decode(StripeBalance.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureBalance.do { (balance) in XCTAssertEqual(balance.object, "balance") @@ -83,7 +82,7 @@ class BalanceTests: XCTestCase { XCTAssertEqual(balance.available?[0].amount, 32147287853) XCTAssertEqual(balance.available?[0].sourceTypes?["card"], 32026441972) // TODO: - Seeif this camel case is resolved in future versions of swift 4.1 snapshot - XCTAssertEqual(balance.available?[0].sourceTypes?["bankAccount"], 119300699) + XCTAssertEqual(balance.available?[0].sourceTypes?["bank_account"], 119300699) XCTAssertEqual(balance.connectReserved?[0].currency, .eur) XCTAssertEqual(balance.connectReserved?[0].amount, 0) @@ -140,10 +139,9 @@ class BalanceTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: balanceTransactionString) - let futureBalanceTransaction = try decoder.decode(StripeBalanceTransactionItem.self, from: body, on: EmbeddedEventLoop()) + let futureBalanceTransaction = try decoder.decode(StripeBalanceTransactionItem.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureBalanceTransaction.do { (balancetransaction) in XCTAssertEqual(balancetransaction.id, "txn_19XJJ02eZvKYlo2ClwuJ1rbA") @@ -165,8 +163,6 @@ class BalanceTests: XCTestCase { XCTAssertEqual(balancetransaction.feeDetails?[0].description, "Stripe processing fees") XCTAssertEqual(balancetransaction.feeDetails?[0].type, .stripeFee) - - }.catch { (error) in XCTFail("\(error.localizedDescription)") } diff --git a/Tests/StripeTests/ChargeTests.swift b/Tests/StripeTests/ChargeTests.swift index d85f4fa..73e4f03 100644 --- a/Tests/StripeTests/ChargeTests.swift +++ b/Tests/StripeTests/ChargeTests.swift @@ -63,10 +63,9 @@ class ChargeTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: chargeString) - let futureCharge = try decoder.decode(StripeCharge.self, from: body, on: EmbeddedEventLoop()) + let futureCharge = try decoder.decode(StripeCharge.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureCharge.do { (charge) in XCTAssertEqual(charge.id, "ch_1BrbM42eZvKYlo2CIu7qiNPF") diff --git a/Tests/StripeTests/CustomerTests.swift b/Tests/StripeTests/CustomerTests.swift index 018ab23..1c45ce7 100644 --- a/Tests/StripeTests/CustomerTests.swift +++ b/Tests/StripeTests/CustomerTests.swift @@ -36,10 +36,9 @@ class CustomerTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: customerString) - let futureCustomer = try decoder.decode(StripeCustomer.self, from: body, on: EmbeddedEventLoop()) + let futureCustomer = try decoder.decode(StripeCustomer.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureCustomer.do { (customer) in XCTAssertEqual(customer.id, "cus_CG7FIUH6U4JTkB") diff --git a/Tests/StripeTests/DisputeTests.swift b/Tests/StripeTests/DisputeTests.swift index 2312183..fc142cb 100644 --- a/Tests/StripeTests/DisputeTests.swift +++ b/Tests/StripeTests/DisputeTests.swift @@ -67,10 +67,9 @@ class DisputeTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: disputeString) - let futureDispute = try decoder.decode(StripeDispute.self, from: body, on: EmbeddedEventLoop()) + let futureDispute = try decoder.decode(StripeDispute.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureDispute.do { (dispute) in XCTAssertEqual(dispute.amount, 1000) diff --git a/Tests/StripeTests/EphemeralKeyTests.swift b/Tests/StripeTests/EphemeralKeyTests.swift index 317312d..670f595 100644 --- a/Tests/StripeTests/EphemeralKeyTests.swift +++ b/Tests/StripeTests/EphemeralKeyTests.swift @@ -28,10 +28,9 @@ class EphemeralKeyTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: emphkeyString) - let futureKey = try decoder.decode(StripeEphemeralKey.self, from: body, on: EmbeddedEventLoop()) + let futureKey = try decoder.decode(StripeEphemeralKey.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureKey.do { (key) in XCTAssertEqual(key.id, "eph_123456") diff --git a/Tests/StripeTests/ErrorTests.swift b/Tests/StripeTests/ErrorTests.swift index 3c686a2..fe2c213 100644 --- a/Tests/StripeTests/ErrorTests.swift +++ b/Tests/StripeTests/ErrorTests.swift @@ -27,10 +27,9 @@ class ErrorTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: errorString) - let futureError = try decoder.decode(StripeAPIError.self, from: body, on: EmbeddedEventLoop()) + let futureError = try decoder.decode(StripeAPIError.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureError.do { (stripeError) in XCTAssertEqual(stripeError.error.type, .cardError) diff --git a/Tests/StripeTests/InvoiceTests.swift b/Tests/StripeTests/InvoiceTests.swift index 34d3882..9bf0c8f 100644 --- a/Tests/StripeTests/InvoiceTests.swift +++ b/Tests/StripeTests/InvoiceTests.swift @@ -66,10 +66,9 @@ class InvoiceTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: invoiceString) - let futureInvoice = try decoder.decode(StripeInvoice.self, from: body, on: EmbeddedEventLoop()) + let futureInvoice = try decoder.decode(StripeInvoice.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureInvoice.do { (invoice) in XCTAssertEqual(invoice.id, "in_1BoJ2NKrZ43eBVAbQ8jb0Xfj") @@ -149,10 +148,9 @@ class InvoiceTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: invoiceItemString) - let futureInvoiceItem = try decoder.decode(StripeInvoiceItem.self, from: body, on: EmbeddedEventLoop()) + let futureInvoiceItem = try decoder.decode(StripeInvoiceItem.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureInvoiceItem.do { (invoiceItem) in XCTAssertEqual(invoiceItem.id, "ii_1BtydB2eZvKYlo2CzeKs27EC") diff --git a/Tests/StripeTests/OrderTests.swift b/Tests/StripeTests/OrderTests.swift index 320e0ac..88f3fca 100644 --- a/Tests/StripeTests/OrderTests.swift +++ b/Tests/StripeTests/OrderTests.swift @@ -66,11 +66,11 @@ class OrderTests: XCTestCase { "city": "Anytown", "country": "US", "line1": "1234 Main street", - "line2": null, + "line2": "suite 123", "postal_code": "123456", - "state": null + "state": "AL" }, - "carrier": null, + "carrier": "UPS", "name": "Jenny Rosen", "phone": null, "tracking_number": null @@ -90,10 +90,9 @@ class OrderTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: orderString) - let futureOrder = try decoder.decode(StripeOrder.self, from: body, on: EmbeddedEventLoop()) + let futureOrder = try decoder.decode(StripeOrder.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureOrder.do { (order) in XCTAssertEqual(order.id, "or_1BoJ2NKrZ43eBVAbFf4SZyvD") @@ -137,10 +136,10 @@ class OrderTests: XCTestCase { XCTAssertEqual(order.shipping?.address?.city, "Anytown") XCTAssertEqual(order.shipping?.address?.country, "US") XCTAssertEqual(order.shipping?.address?.line1, "1234 Main street") - XCTAssertEqual(order.shipping?.address?.line2, nil) + XCTAssertEqual(order.shipping?.address?.line2, "suite 123") XCTAssertEqual(order.shipping?.address?.postalCode, "123456") - XCTAssertEqual(order.shipping?.address?.state, nil) - XCTAssertEqual(order.shipping?.carrier, nil) + XCTAssertEqual(order.shipping?.address?.state, "AL") + XCTAssertEqual(order.shipping?.carrier, "UPS") XCTAssertEqual(order.shipping?.name, "Jenny Rosen") XCTAssertEqual(order.shipping?.phone, nil) XCTAssertEqual(order.shipping?.trackingNumber, nil) diff --git a/Tests/StripeTests/ProductTests.swift b/Tests/StripeTests/ProductTests.swift index 1849f25..df9f61e 100644 --- a/Tests/StripeTests/ProductTests.swift +++ b/Tests/StripeTests/ProductTests.swift @@ -82,10 +82,9 @@ class ProductTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: productString) - let futureProduct = try decoder.decode(StripeProduct.self, from: body, on: EmbeddedEventLoop()) + let futureProduct = try decoder.decode(StripeProduct.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureProduct.do { (product) in XCTAssertEqual(product.id, "prod_BosWT9EsdzgjPn") diff --git a/Tests/StripeTests/RefundTests.swift b/Tests/StripeTests/RefundTests.swift index 63e6be0..7dc9932 100644 --- a/Tests/StripeTests/RefundTests.swift +++ b/Tests/StripeTests/RefundTests.swift @@ -33,10 +33,9 @@ class RefundTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: refundString) - let futureRefund = try decoder.decode(StripeRefund.self, from: body, on: EmbeddedEventLoop()) + let futureRefund = try decoder.decode(StripeRefund.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureRefund.do { (refund) in XCTAssertEqual(refund.id, "re_1BrXqE2eZvKYlo2Cfa7NO6GF") diff --git a/Tests/StripeTests/SKUTests.swift b/Tests/StripeTests/SKUTests.swift index 0532361..ee897fb 100644 --- a/Tests/StripeTests/SKUTests.swift +++ b/Tests/StripeTests/SKUTests.swift @@ -47,10 +47,9 @@ class SKUTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: skuString) - let futureSku = try decoder.decode(StripeSKU.self, from: body, on: EmbeddedEventLoop()) + let futureSku = try decoder.decode(StripeSKU.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) futureSku.do { (sku) in XCTAssertEqual(sku.id, "sku_CG2zw7j7H8NEQq") diff --git a/Tests/StripeTests/SourceTests.swift b/Tests/StripeTests/SourceTests.swift index a1ab648..0eb1b2f 100644 --- a/Tests/StripeTests/SourceTests.swift +++ b/Tests/StripeTests/SourceTests.swift @@ -15,7 +15,6 @@ class SourceTests: XCTestCase { override func setUp() { decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase } let cardSourceString = """ @@ -85,7 +84,7 @@ class SourceTests: XCTestCase { func testCardSourceParsedProperly() throws { do { let body = HTTPBody(string: cardSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.threeDSecure) @@ -194,7 +193,7 @@ class SourceTests: XCTestCase { func testThreeDSecureSourceParsedProperly() throws { do { let body = HTTPBody(string: threeDSecureSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -258,7 +257,7 @@ class SourceTests: XCTestCase { func testSepaDebitSourceParsedProperly() throws { do { let body = HTTPBody(string: sepaDebitSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -327,7 +326,7 @@ class SourceTests: XCTestCase { func testAlipaySourceParsedProperly() throws { do { let body = HTTPBody(string: alipaySourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -395,7 +394,7 @@ class SourceTests: XCTestCase { func testGiropaySourceParsedProperly() throws { do { let body = HTTPBody(string: giroPaySourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -465,7 +464,7 @@ class SourceTests: XCTestCase { func testIdealSourceParsedProperly() throws { do { let body = HTTPBody(string: idealSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -532,7 +531,7 @@ class SourceTests: XCTestCase { func testP24SourceParsedProperly() throws { do { let body = HTTPBody(string: p24SourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -602,7 +601,7 @@ class SourceTests: XCTestCase { func testSofortSourceParsedProperly() throws { do { let body = HTTPBody(string: sofortSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -676,7 +675,7 @@ class SourceTests: XCTestCase { func testBancontactSourceParsedProperly() throws { do { let body = HTTPBody(string: bancontactSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) @@ -746,7 +745,7 @@ class SourceTests: XCTestCase { func testACHSourceParsedProperly() throws { do { let body = HTTPBody(string: achSourceString) - let source = try decoder.decode(StripeSource.self, from: body, on: EmbeddedEventLoop()) + let source = try decoder.decode(StripeSource.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) source.do { (source) in XCTAssertNil(source.card) diff --git a/Tests/StripeTests/SubscriptionTests.swift b/Tests/StripeTests/SubscriptionTests.swift index 2c19fed..5ca1d97 100644 --- a/Tests/StripeTests/SubscriptionTests.swift +++ b/Tests/StripeTests/SubscriptionTests.swift @@ -15,10 +15,9 @@ class SubscriptionTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: subscriptionString) - let subscription = try decoder.decode(StripeSubscription.self, from: body, on: EmbeddedEventLoop()) + let subscription = try decoder.decode(StripeSubscription.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) subscription.do({ (sub) in diff --git a/Tests/StripeTests/TokenTests.swift b/Tests/StripeTests/TokenTests.swift index e9b390a..1f5237b 100644 --- a/Tests/StripeTests/TokenTests.swift +++ b/Tests/StripeTests/TokenTests.swift @@ -15,10 +15,9 @@ class TokenTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: cardTokenString) - let cardToken = try decoder.decode(StripeToken.self, from: body, on: EmbeddedEventLoop()) + let cardToken = try decoder.decode(StripeToken.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) cardToken.do { (token) in XCTAssertNil(token.bankAccount) @@ -68,10 +67,9 @@ class TokenTests: XCTestCase { do { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .secondsSince1970 - decoder.keyDecodingStrategy = .convertFromSnakeCase let body = HTTPBody(string: bankAccountTokenString) - let bankToken = try decoder.decode(StripeToken.self, from: body, on: EmbeddedEventLoop()) + let bankToken = try decoder.decode(StripeToken.self, from: body, maxSize: 65_536, on: EmbeddedEventLoop()) bankToken.do { (token) in XCTAssertNil(token.card) diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..714dc84 --- /dev/null +++ b/circle.yml @@ -0,0 +1,17 @@ +version: 2 + +jobs: + linux: + docker: + - image: codevapor/swift:4.1 + steps: + - checkout + - run: swift build + - run: swift test + - run: swift build -c release + +workflows: + version: 2 + tests: + jobs: + - linux From ea8ce3acbbe7524b76b289f43d81fbb641fcaf35 Mon Sep 17 00:00:00 2001 From: Andrew Edwards Date: Sun, 1 Apr 2018 11:15:02 -0400 Subject: [PATCH 3/3] Updated readme and circle ci --- .circleci/config.yml | 25 ------------------------- README.md | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 035a42c..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: 2 - -jobs: - macos: - macos: - xcode: "9.2" - steps: - - checkout - - run: swift build - - run: swift test - linux: - docker: - - image: norionomura/swift:swift-4.1-branch - steps: - - checkout - - run: apt-get update - - run: apt-get install -yq libssl-dev - - run: swift build - - run: swift test -workflows: - version: 2 - tests: - jobs: - - linux - # - macos diff --git a/README.md b/README.md index 69a97d5..8f4fbf9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Swift](http://img.shields.io/badge/swift-4.1-brightgreen.svg) ![Vapor](http://img.shields.io/badge/vapor-3.0-brightgreen.svg) -[![CircleCI](https://circleci.com/gh/vapor-community/stripe-provider/tree/beta.svg?style=svg)](https://circleci.com/gh/vapor-community/stripe-provider/tree/beta) +[![CircleCI](https://circleci.com/gh/vapor-community/stripe-provider/tree/beta.svg?style=svg)](https://circleci.com/gh/vapor-community/stripe-provider) [Stripe][stripe_home] is a payment platform that handles credit cards, bitcoin and ACH transfers. They have become one of the best platforms for handling payments for projects, services or products.