From ce8c7c60578c217b95a75b5b7dcce8631fd84a3a Mon Sep 17 00:00:00 2001 From: Debojit Dhar <32851891+ddhar-hw@users.noreply.github.com> Date: Wed, 27 Jan 2021 15:25:11 -0800 Subject: [PATCH] Release 1.0.0-beta11 (#111) - Support Paper Check as a transfer method - Support update transfer method - Enhancements --- CHANGELOG.md | 7 + HyperwalletSDK.podspec | 2 +- HyperwalletSDK.xcodeproj/project.pbxproj | 74 +- README.md | 99 +- Sources/Hyperwallet.swift | 169 ++- Sources/Info.plist | 2 +- ...erwalletTransferMethodConfiguration.swift} | 20 +- ...lletTransferMethodConfigurationField.swift | 6 +- ...ansferMethodUpdateConfigurationField.swift | 45 + ...etTransferMethodConfigurationQueries.swift | 6 +- ...sferMethodUpdateConfigurationQueries.swift | 96 ++ .../Model/Receipt/HyperwalletReceipt.swift | 9 +- .../HyperwalletBankAccount.swift | 96 +- .../HyperwalletPaperCheck.swift | 469 +++++++ .../HyperwalletPaperCheckQueryParam.swift | 31 + .../HyperwalletTransferMethod.swift | 6 + .../HyperwalletTransferMethodQueryParam.swift | 2 + Sources/TransactionType.swift | 2 +- Tests/AnyCodableTests.swift | 2 +- ...ansferMethodUpdateConfigurationTests.swift | 281 ++++ ...erMethodConfigurationFieldQueryTests.swift | 7 + ...rMethodConfigurationFieldResultTests.swift | 2 +- Tests/HTTPTransactionTests.swift | 14 +- Tests/Receipt/HyperwalletReceiptTests.swift | 15 +- Tests/Responses/ListBankAccountResponse.json | 2 +- Tests/Responses/ListUserReceiptResponse.json | 105 +- .../PaperCheck/ListPaperCheckResponse.json | 103 ++ .../PaperCheckBusinessResponse.json | 46 + ...ErrorResponseWithMissingStateProvince.json | 9 + .../PaperCheckIndividualResponse.json | 38 + ...sferMethodConfigurationFieldsResponse.json | 2 +- ...teConfigurationFieldsBankCardResponse.json | 90 ++ ...dateConfigurationFieldsPaypalResponse.json | 47 + ...thodUpdateConfigurationFieldsResponse.json | 1194 +++++++++++++++++ ...pdateConfigurationFieldsVenmoResponse.json | 46 + .../HyperwalletBankAccountTests.swift | 91 +- .../HyperwalletPaperCheckTests.swift | 423 ++++++ .../HyperwalletTransferMethodTests.swift | 4 +- 38 files changed, 3467 insertions(+), 195 deletions(-) rename Sources/Model/GraphQL/{TransferMethodConfiguration.swift => HyperwalletTransferMethodConfiguration.swift} (91%) create mode 100644 Sources/Model/GraphQL/HyperwalletTransferMethodUpdateConfigurationField.swift create mode 100644 Sources/Model/GraphQL/Query/HyperwalletTransferMethodUpdateConfigurationQueries.swift create mode 100644 Sources/Model/TransferMethod/HyperwalletPaperCheck.swift create mode 100644 Sources/Model/TransferMethod/HyperwalletPaperCheckQueryParam.swift create mode 100644 Tests/GraphQL/HyperwalletTransferMethodUpdateConfigurationTests.swift create mode 100644 Tests/Responses/PaperCheck/ListPaperCheckResponse.json create mode 100644 Tests/Responses/PaperCheck/PaperCheckBusinessResponse.json create mode 100644 Tests/Responses/PaperCheck/PaperCheckErrorResponseWithMissingStateProvince.json create mode 100644 Tests/Responses/PaperCheck/PaperCheckIndividualResponse.json create mode 100644 Tests/Responses/TransferMethodUpdateConfigurationFieldsBankCardResponse.json create mode 100644 Tests/Responses/TransferMethodUpdateConfigurationFieldsPaypalResponse.json create mode 100644 Tests/Responses/TransferMethodUpdateConfigurationFieldsResponse.json create mode 100644 Tests/Responses/TransferMethodUpdateConfigurationFieldsVenmoResponse.json create mode 100644 Tests/TransferMethod/HyperwalletPaperCheckTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index fedf0577..5289746d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +[1.0.0-beta11](https://github.com/hyperwallet/hyperwallet-ios-sdk/releases/tag/1.0.0-beta11) +------------------- +- Support Paper Check as a transfer method +- Support update transfer method +- Enhancements + + [1.0.0-beta10](https://github.com/hyperwallet/hyperwallet-ios-sdk/releases/tag/1.0.0-beta10) ------------------- - Added Venmo as a Transfer method diff --git a/HyperwalletSDK.podspec b/HyperwalletSDK.podspec index e3f2c203..aa5bcdb9 100644 --- a/HyperwalletSDK.podspec +++ b/HyperwalletSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'HyperwalletSDK' - spec.version = '1.0.0-beta10' + spec.version = '1.0.0-beta11' spec.summary = 'Hyperwallet Core SDK for iOS to integrate with Hyperwallet Platform' spec.homepage = 'https://github.com/hyperwallet/hyperwallet-ios-sdk' spec.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/HyperwalletSDK.xcodeproj/project.pbxproj b/HyperwalletSDK.xcodeproj/project.pbxproj index d280634a..651824ca 100644 --- a/HyperwalletSDK.xcodeproj/project.pbxproj +++ b/HyperwalletSDK.xcodeproj/project.pbxproj @@ -22,6 +22,8 @@ 2B5433FB229EDF0900F900D2 /* HyperwalletReceiptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B5433FA229EDF0900F900D2 /* HyperwalletReceiptTests.swift */; }; 2B5433FD229EF11A00F900D2 /* ListPayPalAccountResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 07C00B542278EFB200E0930C /* ListPayPalAccountResponse.json */; }; 2B5433FE229EF11F00F900D2 /* ListUserReceiptResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 2B5433F8229EDDED00F900D2 /* ListUserReceiptResponse.json */; }; + 2E6A04142575C06700244BE6 /* HyperwalletPaperCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E6A04132575C06700244BE6 /* HyperwalletPaperCheck.swift */; }; + 2E6A04162575E69C00244BE6 /* HyperwalletPaperCheckQueryParam.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E6A04152575E69C00244BE6 /* HyperwalletPaperCheckQueryParam.swift */; }; 2EF6F260235F8D30007700EB /* HyperwalletTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EF6F25F235F8D30007700EB /* HyperwalletTests.swift */; }; 2EFBE4CD24FEB89800F5228A /* HyperwalletPrepaidCardBalanceQueryParam.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EFBE4CC24FEB89800F5228A /* HyperwalletPrepaidCardBalanceQueryParam.swift */; }; 4A41069C22B11E7F00A930AC /* ListPrepaidCardReceiptResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A41069B22B10FAF00A930AC /* ListPrepaidCardReceiptResponse.json */; }; @@ -46,8 +48,13 @@ 980C15DB2273BF91004C60D6 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 980C15DA2273BF91004C60D6 /* CHANGELOG.md */; }; 980C15F12273D1FA004C60D6 /* ListBankCardResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = DBCA37A6225D6D1700CD4137 /* ListBankCardResponse.json */; }; 98101DC42238A2F000BA04CA /* HyperwalletSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 98101DBA2238A2F000BA04CA /* HyperwalletSDK.framework */; }; + B062E353E292414C07C70355 /* HyperwalletPaperCheckTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B062EB9A428EB097C6B5B4FC /* HyperwalletPaperCheckTests.swift */; }; + B062E601D8A9A6E7FCC498F7 /* PaperCheckErrorResponseWithMissingStateProvince.json in Resources */ = {isa = PBXBuildFile; fileRef = B062EC1CDD525FA26E0A7ED3 /* PaperCheckErrorResponseWithMissingStateProvince.json */; }; + B062EA1444CB4994B8D9AA73 /* ListPaperCheckResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = B062EB32004F6CDC55028D37 /* ListPaperCheckResponse.json */; }; B062EAC060764557C3C10497 /* ListPrepaidCardBalancesResponseSuccess.json in Resources */ = {isa = PBXBuildFile; fileRef = B062E2EA3710B0D9432C055C /* ListPrepaidCardBalancesResponseSuccess.json */; }; + B062ECDDC58F6B4924B88B94 /* PaperCheckIndividualResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = B062E470A67F25DDA9FAA711 /* PaperCheckIndividualResponse.json */; }; B062EDD6B61D1A2D118183F7 /* HyperwalletPrepaidCardBalanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B062ED9C3E0C8A8D1F1146DE /* HyperwalletPrepaidCardBalanceTests.swift */; }; + B062EFE8EFA8BD39172CD276 /* PaperCheckBusinessResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = B062EC5C4AC51AD8307C13F9 /* PaperCheckBusinessResponse.json */; }; B327ED7F23C66B6B0007EF58 /* HyperwalletBalance.swift in Sources */ = {isa = PBXBuildFile; fileRef = B327ED7E23C66B6B0007EF58 /* HyperwalletBalance.swift */; }; B327ED8123C66D350007EF58 /* HyperwalletBalanceQueryParam.swift in Sources */ = {isa = PBXBuildFile; fileRef = B327ED8023C66D350007EF58 /* HyperwalletBalanceQueryParam.swift */; }; B327ED8723C689570007EF58 /* HyperwalletBalanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B327ED8523C688A00007EF58 /* HyperwalletBalanceTests.swift */; }; @@ -67,7 +74,7 @@ DB1A03E2225D3DD80080C8D6 /* HyperwalletError.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03D5225D3DD80080C8D6 /* HyperwalletError.swift */; }; DB1A03E3225D3DD80080C8D6 /* Hyperwallet.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03D6225D3DD80080C8D6 /* Hyperwallet.swift */; }; DB1A03FC225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationField.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03E6225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationField.swift */; }; - DB1A03FE225D3DE40080C8D6 /* TransferMethodConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03E8225D3DE40080C8D6 /* TransferMethodConfiguration.swift */; }; + DB1A03FE225D3DE40080C8D6 /* HyperwalletTransferMethodConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03E8225D3DE40080C8D6 /* HyperwalletTransferMethodConfiguration.swift */; }; DB1A03FF225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03E9225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationKey.swift */; }; DB1A0401225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationQueries.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03EC225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationQueries.swift */; }; DB1A0402225D3DE40080C8D6 /* GraphQlQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1A03ED225D3DE40080C8D6 /* GraphQlQuery.swift */; }; @@ -132,6 +139,14 @@ E8438C4BD714EB191BF7A98B /* HyperwalletVenmoAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8438FACD77368B4A83CCA41 /* HyperwalletVenmoAccount.swift */; }; E8438CA7F43C3CB6FD545187 /* VenmoAccountResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = E843856BD0D7E5295973780D /* VenmoAccountResponse.json */; }; E8438DB98656EB3F69DE0776 /* VenmoAccountWrongFormatAccountId.json in Resources */ = {isa = PBXBuildFile; fileRef = E84381CE41DDB491C2F2B63D /* VenmoAccountWrongFormatAccountId.json */; }; + FD1208CC2581FE3200A8D8B2 /* TransferMethodUpdateConfigurationFieldsVenmoResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = FD1208CB2581FE3200A8D8B2 /* TransferMethodUpdateConfigurationFieldsVenmoResponse.json */; }; + FD536D072579F98B0056DC2D /* HyperwalletTransferMethodUpdateConfigurationQueries.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD536D062579F98B0056DC2D /* HyperwalletTransferMethodUpdateConfigurationQueries.swift */; }; + FD536D09257A3C610056DC2D /* HyperwalletTransferMethodUpdateConfigurationField.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD536D08257A3C610056DC2D /* HyperwalletTransferMethodUpdateConfigurationField.swift */; }; + FD536D0C257A60CE0056DC2D /* HyperwalletTransferMethodUpdateConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD536D0A257A60920056DC2D /* HyperwalletTransferMethodUpdateConfigurationTests.swift */; }; + FDD2F4CF2580AFB0008E4CFC /* TransferMethodUpdateConfigurationFieldsPaypalResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = FDD2F4CE2580AFB0008E4CFC /* TransferMethodUpdateConfigurationFieldsPaypalResponse.json */; }; + FDD2F4D12580B1D0008E4CFC /* TransferMethodUpdateConfigurationFieldsBankCardResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = FDD2F4D02580B1D0008E4CFC /* TransferMethodUpdateConfigurationFieldsBankCardResponse.json */; }; + FDF2E7A6257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = FDF2E7A5257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json */; }; + FDF2E7A7257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = FDF2E7A5257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -160,6 +175,8 @@ 07E5FCB6228C9ECA008C5B15 /* TransferMethodConfigurationKeyResultTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferMethodConfigurationKeyResultTests.swift; sourceTree = ""; }; 2B5433F8229EDDED00F900D2 /* ListUserReceiptResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ListUserReceiptResponse.json; sourceTree = ""; }; 2B5433FA229EDF0900F900D2 /* HyperwalletReceiptTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletReceiptTests.swift; sourceTree = ""; }; + 2E6A04132575C06700244BE6 /* HyperwalletPaperCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletPaperCheck.swift; sourceTree = ""; }; + 2E6A04152575E69C00244BE6 /* HyperwalletPaperCheckQueryParam.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletPaperCheckQueryParam.swift; sourceTree = ""; }; 2EF6F25F235F8D30007700EB /* HyperwalletTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletTests.swift; sourceTree = ""; }; 2EFBE4CC24FEB89800F5228A /* HyperwalletPrepaidCardBalanceQueryParam.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletPrepaidCardBalanceQueryParam.swift; sourceTree = ""; }; 4A41069B22B10FAF00A930AC /* ListPrepaidCardReceiptResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ListPrepaidCardReceiptResponse.json; sourceTree = ""; }; @@ -187,6 +204,11 @@ 98101DC32238A2F000BA04CA /* HyperwalletSDKTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HyperwalletSDKTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 98101DCA2238A2F000BA04CA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B062E2EA3710B0D9432C055C /* ListPrepaidCardBalancesResponseSuccess.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ListPrepaidCardBalancesResponseSuccess.json; sourceTree = ""; }; + B062E470A67F25DDA9FAA711 /* PaperCheckIndividualResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PaperCheckIndividualResponse.json; sourceTree = ""; }; + B062EB32004F6CDC55028D37 /* ListPaperCheckResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ListPaperCheckResponse.json; sourceTree = ""; }; + B062EB9A428EB097C6B5B4FC /* HyperwalletPaperCheckTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletPaperCheckTests.swift; sourceTree = ""; }; + B062EC1CDD525FA26E0A7ED3 /* PaperCheckErrorResponseWithMissingStateProvince.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PaperCheckErrorResponseWithMissingStateProvince.json; sourceTree = ""; }; + B062EC5C4AC51AD8307C13F9 /* PaperCheckBusinessResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PaperCheckBusinessResponse.json; sourceTree = ""; }; B062ED9C3E0C8A8D1F1146DE /* HyperwalletPrepaidCardBalanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletPrepaidCardBalanceTests.swift; sourceTree = ""; }; B327ED7E23C66B6B0007EF58 /* HyperwalletBalance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletBalance.swift; sourceTree = ""; }; B327ED8023C66D350007EF58 /* HyperwalletBalanceQueryParam.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletBalanceQueryParam.swift; sourceTree = ""; }; @@ -207,7 +229,7 @@ DB1A03D5225D3DD80080C8D6 /* HyperwalletError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletError.swift; sourceTree = ""; }; DB1A03D6225D3DD80080C8D6 /* Hyperwallet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Hyperwallet.swift; sourceTree = ""; }; DB1A03E6225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodConfigurationField.swift; sourceTree = ""; }; - DB1A03E8225D3DE40080C8D6 /* TransferMethodConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransferMethodConfiguration.swift; sourceTree = ""; }; + DB1A03E8225D3DE40080C8D6 /* HyperwalletTransferMethodConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodConfiguration.swift; sourceTree = ""; }; DB1A03E9225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodConfigurationKey.swift; sourceTree = ""; }; DB1A03EC225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationQueries.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodConfigurationQueries.swift; sourceTree = ""; }; DB1A03ED225D3DE40080C8D6 /* GraphQlQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphQlQuery.swift; sourceTree = ""; }; @@ -269,6 +291,13 @@ E8438B2F7AA2659EA914914B /* VenmoAccountList.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = VenmoAccountList.json; sourceTree = ""; }; E8438F714A2ED30BE185DE8C /* HyperwalletVenmoQueryParam.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletVenmoQueryParam.swift; sourceTree = ""; }; E8438FACD77368B4A83CCA41 /* HyperwalletVenmoAccount.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletVenmoAccount.swift; sourceTree = ""; }; + FD1208CB2581FE3200A8D8B2 /* TransferMethodUpdateConfigurationFieldsVenmoResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = TransferMethodUpdateConfigurationFieldsVenmoResponse.json; sourceTree = ""; }; + FD536D062579F98B0056DC2D /* HyperwalletTransferMethodUpdateConfigurationQueries.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodUpdateConfigurationQueries.swift; sourceTree = ""; }; + FD536D08257A3C610056DC2D /* HyperwalletTransferMethodUpdateConfigurationField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodUpdateConfigurationField.swift; sourceTree = ""; }; + FD536D0A257A60920056DC2D /* HyperwalletTransferMethodUpdateConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferMethodUpdateConfigurationTests.swift; sourceTree = ""; }; + FDD2F4CE2580AFB0008E4CFC /* TransferMethodUpdateConfigurationFieldsPaypalResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = TransferMethodUpdateConfigurationFieldsPaypalResponse.json; sourceTree = ""; }; + FDD2F4D02580B1D0008E4CFC /* TransferMethodUpdateConfigurationFieldsBankCardResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = TransferMethodUpdateConfigurationFieldsBankCardResponse.json; sourceTree = ""; }; + FDF2E7A5257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = TransferMethodUpdateConfigurationFieldsResponse.json; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -291,6 +320,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2E6A04172577162E00244BE6 /* PaperCheck */ = { + isa = PBXGroup; + children = ( + B062E470A67F25DDA9FAA711 /* PaperCheckIndividualResponse.json */, + B062EC5C4AC51AD8307C13F9 /* PaperCheckBusinessResponse.json */, + B062EC1CDD525FA26E0A7ED3 /* PaperCheckErrorResponseWithMissingStateProvince.json */, + B062EB32004F6CDC55028D37 /* ListPaperCheckResponse.json */, + ); + path = PaperCheck; + sourceTree = ""; + }; 641324DE22954E2500512816 /* BankAccount */ = { isa = PBXGroup; children = ( @@ -427,6 +467,8 @@ 07B1FE6122C2A11F00F461D0 /* HyperwalletPrepaidCardQueryParam.swift */, E8438FACD77368B4A83CCA41 /* HyperwalletVenmoAccount.swift */, E8438F714A2ED30BE185DE8C /* HyperwalletVenmoQueryParam.swift */, + 2E6A04132575C06700244BE6 /* HyperwalletPaperCheck.swift */, + 2E6A04152575E69C00244BE6 /* HyperwalletPaperCheckQueryParam.swift */, ); path = TransferMethod; sourceTree = ""; @@ -465,6 +507,7 @@ 07B1FE6622C2C67500F461D0 /* HyperwalletPrepaidCardTests.swift */, DBCA3773225D6A8D00CD4137 /* HyperwalletTransferMethodTests.swift */, E84387C963FD99B5F8D69E49 /* HyperwalletVenmoAccountTests.swift */, + B062EB9A428EB097C6B5B4FC /* HyperwalletPaperCheckTests.swift */, ); path = TransferMethod; sourceTree = ""; @@ -490,6 +533,7 @@ children = ( DB45190D22DD00890022BD1F /* Query */, DBCA376E225D6A8D00CD4137 /* HyperwalletTransferMethodConfigurationTests.swift */, + FD536D0A257A60920056DC2D /* HyperwalletTransferMethodUpdateConfigurationTests.swift */, DBCA376F225D6A8D00CD4137 /* TransferMethodConfigurationFieldResultTests.swift */, 07E5FCB6228C9ECA008C5B15 /* TransferMethodConfigurationKeyResultTests.swift */, ); @@ -542,8 +586,9 @@ DB1A03F0225D3DE40080C8D6 /* GraphQlError.swift */, DB1A03EE225D3DE40080C8D6 /* GraphQlResult.swift */, DB1A03E6225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationField.swift */, + FD536D08257A3C610056DC2D /* HyperwalletTransferMethodUpdateConfigurationField.swift */, DB1A03E9225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationKey.swift */, - DB1A03E8225D3DE40080C8D6 /* TransferMethodConfiguration.swift */, + DB1A03E8225D3DE40080C8D6 /* HyperwalletTransferMethodConfiguration.swift */, ); path = GraphQL; sourceTree = ""; @@ -552,6 +597,7 @@ isa = PBXGroup; children = ( DB1A03EC225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationQueries.swift */, + FD536D062579F98B0056DC2D /* HyperwalletTransferMethodUpdateConfigurationQueries.swift */, DB1A03ED225D3DE40080C8D6 /* GraphQlQuery.swift */, ); path = Query; @@ -601,6 +647,7 @@ DB99FF2E225D600000F86181 /* Responses */ = { isa = PBXGroup; children = ( + 2E6A04172577162E00244BE6 /* PaperCheck */, 641324DE22954E2500512816 /* BankAccount */, 641EBE992292DA3300D718F4 /* AuthenticationTokens */, 64D2493D22BD023600561C14 /* Transfer */, @@ -627,6 +674,10 @@ DBCA37A9225D6D1700CD4137 /* TransferMethodConfigurationFieldsResponse.json */, DBCA37A4225D6D1600CD4137 /* TransferMethodConfigurationGraphQlResponse.json */, DBCA37AD225D6D1700CD4137 /* TransferMethodConfigurationKeysResponse.json */, + FDF2E7A5257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json */, + FDD2F4D02580B1D0008E4CFC /* TransferMethodUpdateConfigurationFieldsBankCardResponse.json */, + FDD2F4CE2580AFB0008E4CFC /* TransferMethodUpdateConfigurationFieldsPaypalResponse.json */, + FD1208CB2581FE3200A8D8B2 /* TransferMethodUpdateConfigurationFieldsVenmoResponse.json */, DBCA37AB225D6D1700CD4137 /* TransferMethodConfigurationKeysWithoutFeeResponse.json */, DBCA37BF225D6E3A00CD4137 /* TransferMethodMockedSuccessResponse.json */, E843856BD0D7E5295973780D /* VenmoAccountResponse.json */, @@ -741,6 +792,7 @@ buildActionMask = 2147483647; files = ( DB866F272261EE28003C41F6 /* HyperwalletSDK.podspec in Resources */, + FDF2E7A6257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json in Resources */, 980C15DB2273BF91004C60D6 /* CHANGELOG.md in Resources */, DB866F282261EE28003C41F6 /* Cartfile.private in Resources */, DB866F2A2261EE28003C41F6 /* README.md in Resources */, @@ -776,13 +828,16 @@ 641EBE9C2292DA3300D718F4 /* AuthenticationTokenIndividualResponse.json in Resources */, DBCA37BA225D6D1700CD4137 /* TransferMethodConfigurationKeysResponse.json in Resources */, 2B5433FD229EF11A00F900D2 /* ListPayPalAccountResponse.json in Resources */, + FDF2E7A7257E06D600589076 /* TransferMethodUpdateConfigurationFieldsResponse.json in Resources */, 641EBE9D2292DA3300D718F4 /* AuthenticationTokenBusinessResponse.json in Resources */, 07C00B522278EE4D00E0930C /* PayPalAccountResponseWithInvalidEmail.json in Resources */, DBCA37AF225D6D1700CD4137 /* ListBankAccountResponse.json in Resources */, 2B5433FE229EF11F00F900D2 /* ListUserReceiptResponse.json in Resources */, DBCA37B6225D6D1700CD4137 /* TransferMethodConfigurationFieldsResponse.json in Resources */, + FDD2F4CF2580AFB0008E4CFC /* TransferMethodUpdateConfigurationFieldsPaypalResponse.json in Resources */, 644A69C322B0FB830058E77E /* WireAccountIndividualResponse.json in Resources */, DB3151CF22780AA300FC9F8E /* UserIndividualResponse.json in Resources */, + FDD2F4D12580B1D0008E4CFC /* TransferMethodUpdateConfigurationFieldsBankCardResponse.json in Resources */, 64278CAF22C0CE0D00B8736B /* CreateTransferResponseInvalidDestinationToken.json in Resources */, DBCA37B8225D6D1700CD4137 /* TransferMethodConfigurationKeysWithoutFeeResponse.json in Resources */, DBCA37B7225D6D1700CD4137 /* BankAccountErrorResponseWithMissingBankId.json in Resources */, @@ -795,11 +850,16 @@ DBCA37B4225D6D1700CD4137 /* StatusTransitionMockedResponseInvalidTransition.json in Resources */, 980B9AE7251C0A2400653D1C /* PrepaidCardResponse.json in Resources */, B327ED8D23C6B43E0007EF58 /* ListUserBalancesResponseSortCurrencyDesc.json in Resources */, + FD1208CC2581FE3200A8D8B2 /* TransferMethodUpdateConfigurationFieldsVenmoResponse.json in Resources */, E84386A084517B13701D478D /* VenmoAccountResponse.json in Resources */, E8438B2A7A266EEF5106635D /* VenmoAccountMissingAccountId.json in Resources */, E84382CC1BE536B23E3F8EEA /* VenmoAccountWrongFormatAccountId.json in Resources */, E84384B6EEE1B33A35A8A5E4 /* VenmoAccountList.json in Resources */, B062EAC060764557C3C10497 /* ListPrepaidCardBalancesResponseSuccess.json in Resources */, + B062ECDDC58F6B4924B88B94 /* PaperCheckIndividualResponse.json in Resources */, + B062EFE8EFA8BD39172CD276 /* PaperCheckBusinessResponse.json in Resources */, + B062E601D8A9A6E7FCC498F7 /* PaperCheckErrorResponseWithMissingStateProvince.json in Resources */, + B062EA1444CB4994B8D9AA73 /* ListPaperCheckResponse.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -836,6 +896,7 @@ 64D2493522BCB4A000561C14 /* HyperwalletTransfer.swift in Sources */, DB1A03DF225D3DD80080C8D6 /* AuthenticationTokenDecoder.swift in Sources */, DB1A0406225D3DE40080C8D6 /* HyperwalletBankAccount.swift in Sources */, + 2E6A04142575C06700244BE6 /* HyperwalletPaperCheck.swift in Sources */, DB1A0401225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationQueries.swift in Sources */, DB1A0402225D3DE40080C8D6 /* GraphQlQuery.swift in Sources */, DB1A0403225D3DE40080C8D6 /* GraphQlResult.swift in Sources */, @@ -850,11 +911,13 @@ 07C00B032277D25700E0930C /* HyperwalletPayPalAccountQueryParam.swift in Sources */, DB1A03DA225D3DD80080C8D6 /* HyperwalletAuthenticationTokenProvider.swift in Sources */, DB1A040C225D3DE40080C8D6 /* HyperwalletBankAccountQueryParam.swift in Sources */, + 2E6A04162575E69C00244BE6 /* HyperwalletPaperCheckQueryParam.swift in Sources */, DB1A0407225D3DE40080C8D6 /* HyperwalletTransferMethod.swift in Sources */, DB1A03D8225D3DD80080C8D6 /* TransactionType.swift in Sources */, DB1A03D7225D3DD80080C8D6 /* AnyCodable.swift in Sources */, DB1A03FF225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationKey.swift in Sources */, DB1A03DB225D3DD80080C8D6 /* HTTPMethod.swift in Sources */, + FD536D072579F98B0056DC2D /* HyperwalletTransferMethodUpdateConfigurationQueries.swift in Sources */, B327ED8123C66D350007EF58 /* HyperwalletBalanceQueryParam.swift in Sources */, DB1A03FC225D3DE40080C8D6 /* HyperwalletTransferMethodConfigurationField.swift in Sources */, 9807B74522642BEA0028A280 /* OSLog.swift in Sources */, @@ -868,10 +931,11 @@ DB1A040E225D3DE40080C8D6 /* HyperwalletBankCard.swift in Sources */, DB1A0409225D3DE40080C8D6 /* QueryParam.swift in Sources */, DB1A0408225D3DE40080C8D6 /* HyperwalletTransferMethodQueryParam.swift in Sources */, - DB1A03FE225D3DE40080C8D6 /* TransferMethodConfiguration.swift in Sources */, + DB1A03FE225D3DE40080C8D6 /* HyperwalletTransferMethodConfiguration.swift in Sources */, 07B1FE6022C29BCD00F461D0 /* HyperwalletPrepaidCard.swift in Sources */, 0733FE092277C191000FB92A /* HyperwalletPayPalAccount.swift in Sources */, DB1A03D9225D3DD80080C8D6 /* HTTPClient.swift in Sources */, + FD536D09257A3C610056DC2D /* HyperwalletTransferMethodUpdateConfigurationField.swift in Sources */, E8438C4BD714EB191BF7A98B /* HyperwalletVenmoAccount.swift in Sources */, E84381C0BBE7F7A6D9AD04E8 /* HyperwalletVenmoQueryParam.swift in Sources */, ); @@ -886,6 +950,7 @@ B327ED8723C689570007EF58 /* HyperwalletBalanceTests.swift in Sources */, DB45190F22DD00A00022BD1F /* HyperwalletTransferMethodConfigurationFieldQueryTests.swift in Sources */, 64D2493C22BD011600561C14 /* HyperwalletTransferTests.swift in Sources */, + FD536D0C257A60CE0056DC2D /* HyperwalletTransferMethodUpdateConfigurationTests.swift in Sources */, DBCA3779225D6A8D00CD4137 /* HyperwalletErrorTests.swift in Sources */, 07E5FCB7228C9ECA008C5B15 /* TransferMethodConfigurationKeyResultTests.swift in Sources */, DB1A0417225D4D8B0080C8D6 /* AnyCodableTests.swift in Sources */, @@ -907,6 +972,7 @@ 2B5433FB229EDF0900F900D2 /* HyperwalletReceiptTests.swift in Sources */, E84382D7D9B88D30117E833F /* HyperwalletVenmoAccountTests.swift in Sources */, B062EDD6B61D1A2D118183F7 /* HyperwalletPrepaidCardBalanceTests.swift in Sources */, + B062E353E292414C07C70355 /* HyperwalletPaperCheckTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/README.md b/README.md index 5fa90567..d0c90f60 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Hyperwallet iOS Core SDK [![Platforms](https://img.shields.io/cocoapods/p/HyperwalletSDK.svg?)](https://cocoapods.org/pods/HyperwalletSDK) -[![Build Status](https://travis-ci.org/hyperwallet/hyperwallet-ios-sdk.svg?branch=master)](https://travis-ci.org/hyperwallet/hyperwallet-ios-sdk) +[![Build Status](https://travis-ci.com/hyperwallet/hyperwallet-ios-sdk.svg?branch=master)](https://travis-ci.com/hyperwallet/hyperwallet-ios-sdk) [![Coverage Status](https://coveralls.io/repos/github/hyperwallet/hyperwallet-ios-sdk/badge.svg?branch=master)](https://coveralls.io/github/hyperwallet/hyperwallet-ios-sdk?branch=master) [![CocoaPods](https://img.shields.io/cocoapods/v/HyperwalletSDK.svg?color=lightgray)](https://cocoapods.org/pods/HyperwalletSDK) @@ -27,13 +27,13 @@ Use [Carthage](https://github.com/Carthage/Carthage) or [CocoaPods](https://coco ### Carthage Specify it in your Cartfile: ```ogdl -github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta10" +github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta11" ``` ### CocoaPods Specify it in your Podfile: ```ruby -pod 'HyperwalletSDK', '~> 1.0.0-beta10' +pod 'HyperwalletSDK', '~> 1.0.0-beta11' ``` ## Initialization @@ -318,6 +318,81 @@ Hyperwallet.shared.listBankAccounts(queryParam: bankAccountQueryParam) { (result } ``` +### Create Paper Check + +```swift +let paperCheck = HyperwalletPaperCheck.Builder(transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "INDIVIDUAL") +.shippingMethod("STANDARD") +.build() + +Hyperwallet.shared.createPaperCheck(account: paperCheck, completion: { (result, error) in + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account creation + guard error == nil else { + print(error?.getHyperwalletErrors()?.errorList?) + return + } + + // On successful creation, response (HyperwalletPaperCheck in this case) payload will contain information about the paper check created + print(result) +}) +``` +### Get Paper Check +```swift +Hyperwallet.shared.getPaperCheck(transferMethodToken: "123123", completion: { (result, error) in + // On success, response (HyperwalletPaperCheck? in this case) will contain information about the user’s paper check or nil if not exist. + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure +}) +``` + +### Update Paper Check + +```swift +let paperCheck = HyperwalletPaperCheck +.Builder(token: "12345") +.shippingMethod("STANDARD") +.build() + +Hyperwallet.shared.updatePaperCheck(account: paperCheck, completion: { (response, error) in + // Code to handle successful response or error + // On successful update, response (HyperwalletPaperCheck in this case) payload will contain information about the paper check updated + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure while updating +}) +``` + +### Deactivate Paper Check + +```swift +Hyperwallet.shared.deactivatePaperCheck(transferMethodToken: "trm-12345", notes: "deactivate paper check", completion: { (result, error) in + // Code to handle successful response or error + // On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure +}) +``` + +### List Paper Check +```swift +let paperCheckQueryParam = HyperwalletPaperCheckQueryParam() +paperCheckQueryParam.status = HyperwalletPaperCheckQueryParam.QueryStatus.activated.rawValue +paperCheckQueryParam.sortBy = HyperwalletPaperCheckQueryParam.QuerySortable.ascendantCreatedOn.rawValue + +Hyperwallet.shared.listPaperChecks(queryParam: paperCheckQueryParam) { (result, error) in + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure + guard error == nil else { + print(error?.getHyperwalletErrors()?.errorList?) + return + } + + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + if let paperChecks = result?.data { + for paperCheck in paperChecks { + print(paperCheck.token ?? "") + } + } +} +``` + ### Create Bank Card ```swift let bankCard = HyperwalletBankCard.Builder(transferMethodCountry: "US", @@ -638,5 +713,23 @@ Hyperwallet.shared.retrieveTransferMethodConfigurationFields(request: fieldQuery } ``` +### Get fields for updating transfer method +```swift +let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000001") + +Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in + guard error == nil else { + print(error?.getHyperwalletErrors()?.errorList) + return + } + + guard let result = result else { return } + + print(result.transferMethodUpdateConfiguration()?.fieldGroups?.nodes) + print(result.transferMethodUpdateConfiguration()?.transferMethodType) +} +``` + + ## License The Hyperwallet iOS SDK is open source and available under the [MIT](https://github.com/hyperwallet/hyperwallet-ios-sdk/blob/master/LICENSE) license diff --git a/Sources/Hyperwallet.swift b/Sources/Hyperwallet.swift index 0ad8cdd8..33a49929 100644 --- a/Sources/Hyperwallet.swift +++ b/Sources/Hyperwallet.swift @@ -118,6 +118,28 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Creates a `HyperwalletPaperCheck` for the User associated with the authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. + /// + /// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void` + /// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck) + /// or error(HyperwalletErrorType) from processing the request. + /// + /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider` + /// if the current one is expired or is about to expire. + /// + /// - Parameters: + /// - account: the `HyperwalletPaperCheck` to be created + /// - completion: the callback handler of responses from the Hyperwallet platform + public func createPaperCheck( + account: HyperwalletPaperCheck, + completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .post, + urlPath: "users/%@/paper-checks", + payload: account, + completionHandler: completion) + } + /// Creates a `HyperwalletBankCard` for the User associated with the authentication token returned from /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. /// @@ -233,6 +255,34 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Deactivates the `HyperwalletPaperCheck` linked to the transfer method token specified. The + /// `HyperwalletPaperCheck` being deactivated must belong to the User that is associated with the + /// authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. + /// + /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to + /// this method invocation will receive the successful response(HyperwalletStatusTransition) or + /// error(HyperwalletErrorType) from processing the request. + /// + /// This function will request a new authentication token via HyperwalletAuthenticationTokenProvider` + /// if the current one is expired or is about to expire. + /// + /// - Parameters: + /// - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPaperCheck` + /// being deactivated + /// - notes: a note regarding the status change + /// - completion: the callback handler of responses from the Hyperwallet platform + public func deactivatePaperCheck(transferMethodToken: String, + notes: String? = nil, + completion: @escaping (HyperwalletStatusTransition?, + HyperwalletErrorType?) -> Void) { + let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build() + httpTransaction.performRest(httpMethod: .post, + urlPath: "users/%@/paper-checks/\(transferMethodToken)/status-transitions", + payload: statusTransition, + completionHandler: completion) + } + /// Deactivates the `HyperwalletBankCard` linked to the transfer method token specified. The /// `HyperwalletBankCard` being deactivated must belong to the User that is associated with the /// authentication token returned from @@ -359,6 +409,25 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Returns the `HyperwalletPaperCheck` linked to the transfer method token specified, or nil if none exists. + /// + /// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void` + /// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck) + /// or error(HyperwalletErrorType) from processing the request. + /// + /// - Parameters: + /// - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPaperCheck` + /// being requested + /// - completion: the callback handler of responses from the Hyperwallet platform + public func getPaperCheck( + transferMethodToken: String, + completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .get, + urlPath: "users/%@/paper-checks/\(transferMethodToken)", + payload: "", + completionHandler: completion) + } + /// Returns the `HyperwalletBankCard` linked to the transfer method token specified, or nil if none exists. /// /// The `completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void` that is passed in to @@ -493,6 +562,44 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Returns the list of `HyperwalletPaperCheck`s for the User associated with the authentication token + /// returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`, + /// or nil if non exist. + /// + /// The ordering and filtering of `HyperwalletPaperCheck`s will be based on the criteria specified within + /// the `HyperwalletPaperCheckQueryParam` object, if it is not nil. Otherwise the default ordering and + /// filtering will be applied: + /// + /// * Offset: 0 + /// * Limit: 10 + /// * Created Before: N/A + /// * Created After: N/A + /// * Type: Paper Check + /// * Status: All + /// * Sort By: Created On + /// + /// The `completion: @escaping (HyperwalletPageList?, HyperwalletErrorType?) -> Void` + /// that is passed in to this method invocation will receive the successful + /// response(HyperwalletPageList?) or error(HyperwalletErrorType) from processing the + /// request. + /// + /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider` + /// if the current one is expired or is about to expire. + /// + /// - Parameters: + /// - queryParam: the ordering and filtering criteria + /// - completion: the callback handler of responses from the Hyperwallet platform + public func listPaperChecks(queryParam: HyperwalletPaperCheckQueryParam? = nil, + completion: @escaping (HyperwalletPageList?, + HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .get, + urlPath: "users/%@/paper-checks", + payload: "", + queryParam: queryParam, + completionHandler: completion) + } + /// Returns the `HyperwalletBankCard` for the User associated with the authentication token returned from /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`, /// or nil if non exist. @@ -800,6 +907,28 @@ public final class Hyperwallet: NSObject { completionHandler: transferMethodConfigurationFieldResponseHandler(completion)) } + /// Returns the transfer method update configuration fields set for the User that is associated with + /// the authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. + /// + /// The `completion: @escaping (HyperwalletTransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void` + /// that is passed in to this method invocation will receive the successful + /// response(HyperwalletTransferMethodUpdateConfigurationField) or error(HyperwalletErrorType) from processing the + /// request. + /// + /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider` + /// if the current one is expired or is about to expire. + /// + /// - Parameters: + /// - request: GraphQL query containing transfer method token and required configuration fields + /// - completion: the callback handler of responses from the Hyperwallet platform + public func retrieveTransferMethodUpdateConfigurationFields( + request: HyperwalletTransferMethodUpdateConfigurationFieldQuery, + completion: @escaping (HyperwalletTransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void) { + httpTransaction.performGraphQl(request, completionHandler: + transferMethodUpdateConfigurationFiledResponseHandler(completion)) + } + /// Returns the transfer method configuration key set, processing times, and fees for the User that is associated /// with the authentication token returned from /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. @@ -846,6 +975,31 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Updates the `HyperwalletPaperCheck` for the User associated with the authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. + /// + /// To identify the `HyperwalletPaperCheck` that is going to be updated, the transfer method token must be + /// set as part of the `HyperwalletPaperCheck` object passed in. + /// + /// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void` + /// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck) + /// or error(HyperwalletErrorType) from processing the request. + /// + /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider` + /// if the current one is expired or is about to expire. + /// + /// - parameters: account: the `HyperwalletPaperCheck` to be updated + /// - parameters: completion: the callback handler of responses from the Hyperwallet platform + public func updatePaperCheck( + account: HyperwalletPaperCheck, + completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) { + let token = account.token ?? "" + httpTransaction.performRest(httpMethod: .put, + urlPath: "users/%@/paper-checks/\(token)", + payload: account, + completionHandler: completion) + } + /// Updates the `HyperwalletBankCard` for the User associated with the authentication token returned from /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. /// @@ -989,8 +1143,19 @@ public final class Hyperwallet: NSObject { private func transferMethodConfigurationFieldResponseHandler(_ completionHandler: @escaping (TransferMethodConfigurationFieldResult?, HyperwalletErrorType?) -> Void) -> (TransferMethodConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in - let result = TransferMethodConfigurationFieldResult(response?.transferMethodUIConfigurations?.nodes, - response?.countries?.nodes?.first) + let result = + TransferMethodConfigurationFieldResult(response?.transferMethodCreateUIConfigurations?.nodes, + response?.countries?.nodes?.first) + completionHandler(result, error) + } + } + + private func transferMethodUpdateConfigurationFiledResponseHandler(_ completionHandler: + @escaping (TransferMethodUpdateConfigurationFieldResult?, HyperwalletErrorType?) -> Void) + -> (TransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in + let result = TransferMethodUpdateConfigurationFieldResult(response? + .transferMethodUpdateUIConfigurations? + .nodes) completionHandler(result, error) } } diff --git a/Sources/Info.plist b/Sources/Info.plist index 8216e844..e344d37e 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -21,6 +21,6 @@ CFBundleVersion $(CURRENT_PROJECT_VERSION) TAG_VERSION - 1.0.0-beta10 + 1.0.0-beta11 diff --git a/Sources/Model/GraphQL/TransferMethodConfiguration.swift b/Sources/Model/GraphQL/HyperwalletTransferMethodConfiguration.swift similarity index 91% rename from Sources/Model/GraphQL/TransferMethodConfiguration.swift rename to Sources/Model/GraphQL/HyperwalletTransferMethodConfiguration.swift index 68d86a3e..e85bef3d 100644 --- a/Sources/Model/GraphQL/TransferMethodConfiguration.swift +++ b/Sources/Model/GraphQL/HyperwalletTransferMethodConfiguration.swift @@ -106,6 +106,8 @@ public struct HyperwalletField: Codable { public let value: String? /// The mask, or nil if none exists public let mask: HyperwalletMask? + /// Indicate if the field is masked, or nil if none exists + public let fieldValueMasked: Bool? } /// Representation of list of HyperwalletField and the group to which it belongs @@ -159,7 +161,11 @@ public struct HyperwalletValidationMessage: Codable { struct TransferMethodConfigurationField: Codable { var countries: Connection? - var transferMethodUIConfigurations: Connection? + var transferMethodCreateUIConfigurations: Connection? +} + +struct TransferMethodUpdateConfigurationField: Codable { + var transferMethodUpdateUIConfigurations: Connection? } struct TransferMethodConfigurationKey: Codable { @@ -167,17 +173,17 @@ struct TransferMethodConfigurationKey: Codable { } /// Representation of the transfer method configuration -public struct TransferMethodConfiguration: Codable { +public struct HyperwalletTransferMethodConfiguration: Codable { /// The country - let country: String? + public let country: String? /// The currency - let currency: String? + public let currency: String? /// The transfer method type - let transferMethodType: String? + public let transferMethodType: String? /// The profile type - let profile: String? + public let profile: String? /// The `HyperwalletFieldGroup`, or nil if none exists - let fieldGroups: Connection? + public let fieldGroups: Connection? } /// Representation of the transfer method configuration field mask diff --git a/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift b/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift index 5146aad5..a0992eff 100644 --- a/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift +++ b/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift @@ -33,16 +33,16 @@ public protocol HyperwalletTransferMethodConfigurationField { } final class TransferMethodConfigurationFieldResult: HyperwalletTransferMethodConfigurationField { - private let transferMethodUIConfigurations: [TransferMethodConfiguration]? + private let transferMethodUIConfigurations: [HyperwalletTransferMethodConfiguration]? private let country: HyperwalletCountry? /// Creates a new instance of the 'HyperwalletTransferMethodConfigurationField' based on the /// transfer method configuration result /// /// - Parameters: - /// - transferMethodUIConfigurations: the GraphQL `[TransferMethodUIConfiguration]` + /// - transferMethodUIConfigurations: the GraphQL `[HyperwalletTransferMethodConfiguration]` /// - country: the GraphQL `HyperwalletCountry` - init(_ transferMethodUIConfigurations: [TransferMethodConfiguration]?, _ country: HyperwalletCountry?) { + init(_ transferMethodUIConfigurations: [HyperwalletTransferMethodConfiguration]?, _ country: HyperwalletCountry?) { self.transferMethodUIConfigurations = transferMethodUIConfigurations self.country = country } diff --git a/Sources/Model/GraphQL/HyperwalletTransferMethodUpdateConfigurationField.swift b/Sources/Model/GraphQL/HyperwalletTransferMethodUpdateConfigurationField.swift new file mode 100644 index 00000000..92a006a0 --- /dev/null +++ b/Sources/Model/GraphQL/HyperwalletTransferMethodUpdateConfigurationField.swift @@ -0,0 +1,45 @@ +// +// Copyright 2018 - Present Hyperwallet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software +// and associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import Foundation + +/// The `HyperwalletTransferMethodUpdateConfigurationField` protocol for processing the update transfer method +/// configuration field result from the Hyperwallet platform. +public protocol HyperwalletTransferMethodUpdateConfigurationField { + /// Returns `HyperwalletTransferMethodConfiguration` + /// + /// - Returns: `HyperwalletTransferMethodConfiguration` + func transferMethodUpdateConfiguration() -> HyperwalletTransferMethodConfiguration? +} + +final class TransferMethodUpdateConfigurationFieldResult: HyperwalletTransferMethodUpdateConfigurationField { + private let transferMethodUpdateUIConfigurations: [HyperwalletTransferMethodConfiguration]? + + /// Creates a new instance of the 'TransferMethodUpdateConfigurationFieldResult' based on the + /// transfer method configuration result + /// + /// - Parameters: + /// - transferMethodUpdateUIConfigurations: the GraphQL `[HyperwalletTransferMethodConfiguration]` + init(_ transferMethodUpdateUIConfigurations: [HyperwalletTransferMethodConfiguration]?) { + self.transferMethodUpdateUIConfigurations = transferMethodUpdateUIConfigurations + } + + func transferMethodUpdateConfiguration() -> HyperwalletTransferMethodConfiguration? { + transferMethodUpdateUIConfigurations?.first + } +} diff --git a/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift b/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift index 4ca7b003..b74fab07 100644 --- a/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift +++ b/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift @@ -28,14 +28,14 @@ public struct HyperwalletTransferMethodConfigurationFieldQuery: GraphQlQuery, Ha private var profile: String private var query = """ query QueryCreateTransferMethod( - $idToken: String = "%@", + $usrToken: String = "%@", $profileType: Profile = %@ $country: Country = %@ $currency: Currency = %@ $transferMethodType: TransferMethodType = %@ ){ - transferMethodUIConfigurations (idToken: $idToken, + transferMethodCreateUIConfigurations (usrToken: $usrToken, profileType: $profileType country: $country, currency: $currency, @@ -81,7 +81,7 @@ public struct HyperwalletTransferMethodConfigurationFieldQuery: GraphQlQuery, Ha } } }, - countries (idToken: $idToken, + countries (idToken: $usrToken, code: $country){ nodes { code diff --git a/Sources/Model/GraphQL/Query/HyperwalletTransferMethodUpdateConfigurationQueries.swift b/Sources/Model/GraphQL/Query/HyperwalletTransferMethodUpdateConfigurationQueries.swift new file mode 100644 index 00000000..dc487977 --- /dev/null +++ b/Sources/Model/GraphQL/Query/HyperwalletTransferMethodUpdateConfigurationQueries.swift @@ -0,0 +1,96 @@ +// +// Copyright 2018 - Present Hyperwallet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software +// and associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import Foundation + +/// The `HyperwalletTransferMethodUpdateConfigurationFieldQuery` +/// struct defines and builds a query to retrieve the fields +/// required to update a transfer method (Bank Account, Bank Card, PayPal Account, Prepaid Card, Paper Check and Venmo) +/// with the Hyperwallet platform. +public struct HyperwalletTransferMethodUpdateConfigurationFieldQuery: GraphQlQuery, Hashable { + private var transferMethodToken: String + private var query = """ + query QueryUpdateTransferMethod( + $trmToken: String = "%@" + ){ + transferMethodUpdateUIConfigurations ( + trmToken: $trmToken + ) { + nodes { + country + currency + transferMethodType + profile + fieldGroups { + nodes { + group + isEditable + fields { + category + value + dataType + isRequired + isEditable + label + maxLength + minLength + name + placeholder + regularExpression + fieldSelectionOptions { + label + value + } + validationMessage { + length + pattern + empty + } + fieldValueMasked + mask { + conditionalPatterns { + pattern + regex + } + defaultPattern + scrubRegex + } + } + } + } + } + } + } + """ + + /// Create a new `HyperwalletTransferMethodUpdateConfigurationFieldQuery` from the transferMethodToken + /// + /// - Parameters: + /// - transferMethodToken: token from the transfer method + public init(transferMethodToken: String) { + self.transferMethodToken = transferMethodToken + } + + public func toGraphQl(userToken: String) -> String { + String(format: query, transferMethodToken) + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(transferMethodToken) + } +} diff --git a/Sources/Model/Receipt/HyperwalletReceipt.swift b/Sources/Model/Receipt/HyperwalletReceipt.swift index 1016c2ba..554ccf82 100644 --- a/Sources/Model/Receipt/HyperwalletReceipt.swift +++ b/Sources/Model/Receipt/HyperwalletReceipt.swift @@ -23,7 +23,7 @@ public struct HyperwalletReceiptDetails: Decodable { /// The bank account number, IBAN or equivalent public let bankAccountId: String? /// The bank account type, e.g. CHECKING or SAVINGS - public let bankAccountPurpose: HyperwalletReceipt.BankAccountPurposeType? + public let bankAccountPurpose: String? /// The bank code, BIC/SWIFT or equivalent public let bankId: String? /// The bank name @@ -406,13 +406,6 @@ public struct HyperwalletReceipt: Decodable, Equatable { /// The debit entry type case debit = "DEBIT" } - /// The bank account purpose type - public enum BankAccountPurposeType: String, Decodable { - /// The bank account checking type - case checking = "CHECKING" - /// The bank account savings type - case savings = "SAVINGS" - } } extension HyperwalletReceipt.HyperwalletReceiptType { diff --git a/Sources/Model/TransferMethod/HyperwalletBankAccount.swift b/Sources/Model/TransferMethod/HyperwalletBankAccount.swift index 18e672e8..5b35b68d 100644 --- a/Sources/Model/TransferMethod/HyperwalletBankAccount.swift +++ b/Sources/Model/TransferMethod/HyperwalletBankAccount.swift @@ -29,64 +29,6 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { try super.init(from: decoder) } - /// Representation of the bank account holder's role in the organization - public enum BusinessContactRole: String { - /// The director role - case director = "DIRECTOR" - /// The owner role - case owner = "OWNER" - /// The other role - case other = "OTHER" - } - - /// Representation of the bank account holder's business type. - public enum BusinessType: String { - /// The corporation business type - case corporation = "CORPORATION" - /// The partnership business type - case partnership = "PARTNERSHIP" - } - - /// Representation of the bank account holder's gender. - public enum Gender: String { - /// The male - case male = "MALE" - /// The female - case female = "FEMALE" - } - - /// Representation of the bank account holder's government ID type - public enum GovernmentIdType: String { - /// The passport Id - case passport = "PASSPORT" - /// The national Id Card - case nationalIdCard = "NATIONAL_ID_CARD" - } - - /// Representation of the user's profile type. - public enum ProfileType: String { - /// The business profile type - case business = "BUSINESS" - /// The Individual profile type - case individual = "INDIVIDUAL" - } - - /// Representation of the bank account's purpose type. - public enum PurposeType: String { - /// When the user's bank account purpose is checking - case checking = "CHECKING" - /// When the user's bank account purpose is savings - case savings = "SAVINGS" - } - - /// Representation of the user's relationship with the bank account holder. - public enum RelationshipType: String { - /// When the user owns the bank account - case `self` = "SELF" - /// When the bank account is owned by the user's business - case ownCompany = "OWN_COMPANY" - } - /// The bank account holder's street address. public var addressLine1: String? { getField(TransferMethodField.addressLine1.rawValue) @@ -179,6 +121,11 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { getField(TransferMethodField.countryOfBirth.rawValue) } + /// The bank account holder's nationality country. + public var countryOfNationality: String? { + getField(TransferMethodField.countryOfNationality.rawValue) + } + /// The bank account holder's date of birth (All users must be at least 13 years old). public var dateOfBirth: String? { getField(TransferMethodField.dateOfBirth.rawValue) @@ -361,8 +308,8 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Parameter purpose: The `PurposeType` /// - Returns: a self `HyperwalletBankAccount.Builder` instance. - public func bankAccountPurpose(_ purpose: PurposeType) -> Builder { - storage[TransferMethodField.bankAccountPurpose.rawValue] = AnyCodable(value: purpose.rawValue) + public func bankAccountPurpose(_ purpose: String) -> Builder { + storage[TransferMethodField.bankAccountPurpose.rawValue] = AnyCodable(value: purpose) return self } @@ -370,8 +317,8 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Parameter relationship: The `RelationshipType` /// - Returns: a self `HyperwalletBankAccount.Builder` instance. - public func bankAccountRelationship(_ relationship: RelationshipType) -> Builder { - storage[TransferMethodField.bankAccountRelationship.rawValue] = AnyCodable(value: relationship.rawValue) + public func bankAccountRelationship(_ relationship: String) -> Builder { + storage[TransferMethodField.bankAccountRelationship.rawValue] = AnyCodable(value: relationship) return self } @@ -415,8 +362,8 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Parameter businessContactRole: The bank account holder's role in the organization. /// - Returns: a self `HyperwalletBankAccount.Builder` instance. - public func businessContactRole(_ businessContactRole: BusinessContactRole) -> Builder { - storage[TransferMethodField.businessContactRole.rawValue] = AnyCodable(value: businessContactRole.rawValue) + public func businessContactRole(_ businessContactRole: String) -> Builder { + storage[TransferMethodField.businessContactRole.rawValue] = AnyCodable(value: businessContactRole) return self } @@ -463,8 +410,8 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Parameter businessType: The bank account holder's business type. /// - Returns: a self `HyperwalletBankAccount.Builder` instance. - public func businessType(_ businessType: BusinessType) -> Builder { - storage[TransferMethodField.businessType.rawValue] = AnyCodable(value: businessType.rawValue) + public func businessType(_ businessType: String) -> Builder { + storage[TransferMethodField.businessType.rawValue] = AnyCodable(value: businessType) return self } @@ -495,6 +442,15 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { return self } + // Sets the bank account holder's nationality country. + /// + /// - Parameter countryOfNationality: The bank account holder's birth country. + /// - Returns: a self `HyperwalletBankAccount.Builder` instance. + public func countryOfNationality(_ countryOfNationality: String) -> Builder { + storage[TransferMethodField.countryOfNationality.rawValue] = AnyCodable(value: countryOfNationality) + return self + } + /// Sets the bank account holder's date of birth (All users must be at least 13 years old). /// /// - Parameter dateOfBirth: The bank account holder's date of birth @@ -535,8 +491,8 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Parameter gender: The bank account holder's gender. /// - Returns: a self `HyperwalletBankAccount.Builder` instance. - public func gender(_ gender: Gender) -> Builder { - storage[TransferMethodField.gender.rawValue] = AnyCodable(value: gender.rawValue) + public func gender(_ gender: String) -> Builder { + storage[TransferMethodField.gender.rawValue] = AnyCodable(value: gender) return self } @@ -553,8 +509,8 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Parameter governmentIdType: The bank account holder's government ID type. /// - Returns: a self `HyperwalletBankAccount.Builder` instance. - public func governmentIdType(_ governmentIdType: GovernmentIdType) -> Builder { - storage[TransferMethodField.governmentIdType.rawValue] = AnyCodable(value: governmentIdType.rawValue) + public func governmentIdType(_ governmentIdType: String) -> Builder { + storage[TransferMethodField.governmentIdType.rawValue] = AnyCodable(value: governmentIdType) return self } diff --git a/Sources/Model/TransferMethod/HyperwalletPaperCheck.swift b/Sources/Model/TransferMethod/HyperwalletPaperCheck.swift new file mode 100644 index 00000000..d53d6b9a --- /dev/null +++ b/Sources/Model/TransferMethod/HyperwalletPaperCheck.swift @@ -0,0 +1,469 @@ +// +// Copyright 2018 - Present Hyperwallet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software +// and associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import Foundation + +/// Representation of the user's paper check +@objcMembers +public class HyperwalletPaperCheck: HyperwalletTransferMethod { + override private init(data: [String: AnyCodable]) { + super.init(data: data) + } + /// The required initializer + public required init(from decoder: Decoder) throws { + try super.init(from: decoder) + } + + /// The user's relationship with the bank account holder. + public var bankAccountRelationship: String? { + getField(TransferMethodField.bankAccountRelationship.rawValue) + } + + /// The bank account holder's street address. + public var addressLine1: String? { + getField(TransferMethodField.addressLine1.rawValue) + } + + /// The bank account holder's address, second line. + public var addressLine2: String? { + getField(TransferMethodField.addressLine2.rawValue) + } + + /// The bank account holder's city. + public var city: String? { + getField(TransferMethodField.city.rawValue) + } + + /// The bank account holder's country. + public var country: String? { + getField(TransferMethodField.country.rawValue) + } + + /// The bank account holder's postal code. + public var postalCode: String? { + getField(TransferMethodField.postalCode.rawValue) + } + + /// The bank account holder's state, province or region. + public var stateProvince: String? { + getField(TransferMethodField.stateProvince.rawValue) + } + + /// The bank account holder's state, province or region. + public var shippingMethod: String? { + getField(TransferMethodField.shippingMethod.rawValue) + } + + /// The name of the bank account holder's business. + public var businessName: String? { + getField(TransferMethodField.businessName.rawValue) + } + + /// The country where the bank account holder's business is registered. + public var businessRegistrationCountry: String? { + getField(TransferMethodField.businessRegistrationCountry.rawValue) + } + + /// The bank account holder's business registration number or identifier, + /// as assigned by the relevant government body. + public var businessRegistrationId: String? { + getField(TransferMethodField.businessRegistrationId.rawValue) + } + + /// The state, province or region where the bank account holder's business is registered. + public var businessRegistrationStateProvince: String? { + getField(TransferMethodField.businessRegistrationStateProvince.rawValue) + } + + /// The bank account holder's business type. + public var businessType: String? { + getField(TransferMethodField.businessType.rawValue) + } + + /// The bank account holder's birth country. + public var countryOfBirth: String? { + getField(TransferMethodField.countryOfBirth.rawValue) + } + + /// The bank account holder's nationality country. + public var countryOfNationality: String? { + getField(TransferMethodField.countryOfNationality.rawValue) + } + + /// The bank account holder's date of birth (All users must be at least 13 years old). + public var dateOfBirth: String? { + getField(TransferMethodField.dateOfBirth.rawValue) + } + + /// The bank account holder's driver's license number. + public var driversLicenseId: String? { + getField(TransferMethodField.driversLicenseId.rawValue) + } + + /// The bank account holder's employer identifier, generally used for tax purposes. + public var employerId: String? { + getField(TransferMethodField.employerId.rawValue) + } + + /// The bank account holder's first name. + public var firstName: String? { + getField(TransferMethodField.firstName.rawValue) + } + + /// The bank account holder's gender. + public var gender: String? { + getField(TransferMethodField.gender.rawValue) + } + + /// The bank account holder's government ID number, such as a Social Security Number. + public var governmentId: String? { + getField(TransferMethodField.governmentId.rawValue) + } + + /// The bank account holder's government ID type. + public var governmentIdType: String? { + getField(TransferMethodField.governmentIdType.rawValue) + } + + /// The bank account holder's phone number. + public var phoneNumber: String? { + getField(TransferMethodField.phoneNumber.rawValue) + } + + /// The bank account holder's cell phone number. + public var mobileNumber: String? { + getField(TransferMethodField.mobileNumber.rawValue) + } + + /// The bank account holder's last name. + public var lastName: String? { + getField(TransferMethodField.lastName.rawValue) + } + + /// The bank account holder's middle name. + public var middleName: String? { + getField(TransferMethodField.middleName.rawValue) + } + + /// The bank account holder's passport number. + public var passportId: String? { + getField(TransferMethodField.passportId.rawValue) + } + + /// A helper class to build the `HyperwalletPaperCheck` instance. + public final class Builder { + private var storage = [String: AnyCodable]() + + /// Creates a new instance of the `HyperwalletPaperCheck.Builder` + /// based on the required parameter to updaate Bank card. + /// + /// - Parameter token: The bank card token. + public init(token: String) { + storage[TransferMethodField.token.rawValue] = AnyCodable(value: token) + } + + /// Creates a new instance of the `HyperwalletPaperCheck.Builder` + /// based on the required parameters to create paper check. + /// + /// - Parameters: + /// - transferMethodCountry: The bank account country. + /// - transferMethodCurrency: The bank account currency. + /// - transferMethodProfileType: The bank account holder's profile type, e.g. INDIVIDUAL or BUSINESS + /// - transferMethodType: The bank account type, i.e, PAPER_CHECK + public init(transferMethodCountry: String, + transferMethodCurrency: String, + transferMethodProfileType: String, + transferMethodType: String) { + storage[TransferMethodField.type.rawValue] = AnyCodable(value: transferMethodType) + storage[TransferMethodField.transferMethodCountry.rawValue] = AnyCodable(value: transferMethodCountry) + storage[TransferMethodField.transferMethodCurrency.rawValue] = AnyCodable(value: transferMethodCurrency) + storage[TransferMethodField.profileType.rawValue] = AnyCodable(value: transferMethodProfileType) + } + + /// Sets the bank account holder's street address. + /// + /// - Parameter addressLine1: The bank account holder's street address. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func addressLine1(_ addressLine1: String) -> Builder { + storage[TransferMethodField.addressLine1.rawValue] = AnyCodable(value: addressLine1) + return self + } + + /// Sets the bank account holder's address, second line. + /// + /// - Parameter addressLine2: The bank account holder's address, second line. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func addressLine2(_ addressLine2: String) -> Builder { + storage[TransferMethodField.addressLine2.rawValue] = AnyCodable(value: addressLine2) + return self + } + + /// Sets the user's relationship with the bank account holder. + /// + /// - Parameter relationship: The `RelationshipType` + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func bankAccountRelationship(_ relationship: String) -> Builder { + storage[TransferMethodField.bankAccountRelationship.rawValue] = AnyCodable(value: relationship) + return self + } + + /// Sets the bank account holder's city. + /// + /// - Parameter city: The bank account holder's city. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func city(_ city: String) -> Builder { + storage[TransferMethodField.city.rawValue] = AnyCodable(value: city) + return self + } + + /// Sets the bank account holder's country. + /// + /// - Parameter country: The bank account holder's country. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func country(_ country: String) -> Builder { + storage[TransferMethodField.country.rawValue] = AnyCodable(value: country) + return self + } + + /// Sets the bank account holder's postal code. + /// + /// - Parameter postalCode: The bank account holder's postal code. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func postalCode(_ postalCode: String) -> Builder { + storage[TransferMethodField.postalCode.rawValue] = AnyCodable(value: postalCode) + return self + } + + /// Sets the shipping method for paper check. + /// + /// - Parameter shippingMethod: The bank account holder's postal code. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func shippingMethod(_ shippingMethod: String) -> Builder { + storage[TransferMethodField.shippingMethod.rawValue] = AnyCodable(value: shippingMethod) + return self + } + + /// Sets the bank account holder's state, province or region. + /// + /// - Parameter stateProvince: The bank account holder's state, province or region. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func stateProvince(_ stateProvince: String) -> Builder { + storage[TransferMethodField.stateProvince.rawValue] = AnyCodable(value: stateProvince) + return self + } + + // Sets the bank account holder's profile type. + /// + /// - Parameter profileType: The bank account holder's profile type, e.g. INDIVIDUAL or BUSINESS + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func profileType(_ profileType: String) -> Builder { + storage[TransferMethodField.profileType.rawValue] = AnyCodable(value: profileType) + return self + } + + /// Sets the bank account holder's last name. + /// + /// - Parameter lastName: The bank account holder's last name. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func lastName(_ lastName: String) -> Builder { + storage[TransferMethodField.lastName.rawValue] = AnyCodable(value: lastName) + return self + } + + /// Sets the bank account holder's middle name. + /// + /// - Parameter middleName: The bank account holder's middle name. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func middleName(_ middleName: String) -> Builder { + storage[TransferMethodField.middleName.rawValue] = AnyCodable(value: middleName) + return self + } + + /// Sets the bank account holder's cell phone number. + /// + /// - Parameter mobileNumber: The bank account holder's cell phone number. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func mobileNumber(_ mobileNumber: String) -> Builder { + storage[TransferMethodField.mobileNumber.rawValue] = AnyCodable(value: mobileNumber) + return self + } + + /// Sets the bank account holder's passport number. + /// + /// - Parameter passportId: The bank account holder's passport number. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func passportId(_ passportId: String) -> Builder { + storage[TransferMethodField.passportId.rawValue] = AnyCodable(value: passportId) + return self + } + + /// Sets the bank account holder's phone number. + /// + /// - Parameter phoneNumber: The bank account holder's phone number. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func phoneNumber(_ phoneNumber: String) -> Builder { + storage[TransferMethodField.phoneNumber.rawValue] = AnyCodable(value: phoneNumber) + return self + } + + /// Sets the bank account holder's birth country. + /// + /// - Parameter countryOfBirth: The bank account holder's birth country. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func countryOfBirth(_ countryOfBirth: String) -> Builder { + storage[TransferMethodField.countryOfBirth.rawValue] = AnyCodable(value: countryOfBirth) + return self + } + + // Sets the bank account holder's nationality country. + /// + /// - Parameter countryOfNationality: The bank account holder's birth country. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func countryOfNationality(_ countryOfNationality: String) -> Builder { + storage[TransferMethodField.countryOfNationality.rawValue] = AnyCodable(value: countryOfNationality) + return self + } + + /// Sets the bank account holder's date of birth (All users must be at least 13 years old). + /// + /// - Parameter dateOfBirth: The bank account holder's date of birth + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func dateOfBirth(_ dateOfBirth: String) -> Builder { + storage[TransferMethodField.dateOfBirth.rawValue] = AnyCodable(value: dateOfBirth) + return self + } + + /// Sets the bank account holder's driver's license number. + /// + /// - Parameter driversLicenseId: The bank account holder's driver's license number. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func driversLicenseId(_ driversLicenseId: String) -> Builder { + storage[TransferMethodField.driversLicenseId.rawValue] = AnyCodable(value: driversLicenseId) + return self + } + + /// Sets the bank account holder's employer identifier, generally used for tax purposes. + /// + /// - Parameter employerId: The bank account holder's employer identifier, generally used for tax purposes. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func employerId(_ employerId: String) -> Builder { + storage[TransferMethodField.employerId.rawValue] = AnyCodable(value: employerId) + return self + } + + /// Sets the bank account holder's first name. + /// + /// - Parameter firstName: The bank account holder's first name. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func firstName(_ firstName: String) -> Builder { + storage[TransferMethodField.firstName.rawValue] = AnyCodable(value: firstName) + return self + } + + /// Sets the bank account holder's gender. + /// + /// - Parameter gender: The bank account holder's gender. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func gender(_ gender: String) -> Builder { + storage[TransferMethodField.gender.rawValue] = AnyCodable(value: gender) + return self + } + + /// Sets the bank account holder's government ID number, such as a Social Security Number. + /// + /// - Parameter governmentId: The bank account holder's government ID number, such as a Social Security Number. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func governmentId(_ governmentId: String) -> Builder { + storage[TransferMethodField.governmentId.rawValue] = AnyCodable(value: governmentId) + return self + } + + /// Sets the bank account holder's government ID type. + /// + /// - Parameter governmentIdType: The bank account holder's government ID type. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func governmentIdType(_ governmentIdType: String) -> Builder { + storage[TransferMethodField.governmentIdType.rawValue] = AnyCodable(value: governmentIdType) + return self + } + + /// Sets the bank account holder's role in the organization. + /// + /// - Parameter businessContactRole: The bank account holder's role in the organization. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func businessContactRole(_ businessContactRole: String) -> Builder { + storage[TransferMethodField.businessContactRole.rawValue] = AnyCodable(value: businessContactRole) + return self + } + + /// Sets the name of the bank account holder's business. + /// + /// - Parameter businessName: The name of the bank account holder's business. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func businessName(_ businessName: String) -> Builder { + storage[TransferMethodField.businessName.rawValue] = AnyCodable(value: businessName) + return self + } + + /// Sets the country where the bank account holder's business is registered. + /// + /// - Parameter businessRegistrationCountry: The country where the bank account holder's business is registered. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func businessRegistrationCountry(_ country: String) -> Builder { + storage[TransferMethodField.businessRegistrationCountry.rawValue] = AnyCodable(value: country) + return self + } + + /// Sets the bank account holder's business registration number or identifier, + /// as assigned by the relevant government body. + /// + /// - Parameter businessRegistrationId: The bank account holder's business + /// registration number or identifier, as assigned by the relevant government body. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func businessRegistrationId(_ businessRegistrationId: String) -> Builder { + storage[TransferMethodField.businessRegistrationId.rawValue] = AnyCodable(value: businessRegistrationId) + return self + } + + /// Sets the state, province or region where the bank account holder's business is registered. + /// + /// - Parameter businessRegistrationStateProvince: The state, province or region + /// where the bank account holder's business is registered. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func businessRegistrationStateProvince(_ stateProvince: String) -> Builder { + storage[TransferMethodField.businessRegistrationStateProvince.rawValue] = AnyCodable(value: stateProvince) + return self + } + + /// Sets the bank account holder's business type. + /// + /// - Parameter businessType: The bank account holder's business type. + /// - Returns: a self `HyperwalletPaperCheck.Builder` instance. + public func businessType(_ businessType: String) -> Builder { + storage[TransferMethodField.businessType.rawValue] = AnyCodable(value: businessType) + return self + } + + /// Builds a new instance of the `HyperwalletPaperCheck`. + /// + /// - Returns: a new instance of the `HyperwalletPaperCheck`. + public func build() -> HyperwalletPaperCheck { + HyperwalletPaperCheck(data: self.storage) + } + } +} diff --git a/Sources/Model/TransferMethod/HyperwalletPaperCheckQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletPaperCheckQueryParam.swift new file mode 100644 index 00000000..ffaf0000 --- /dev/null +++ b/Sources/Model/TransferMethod/HyperwalletPaperCheckQueryParam.swift @@ -0,0 +1,31 @@ +// +// Copyright 2018 - Present Hyperwallet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software +// and associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import Foundation + +/// Representation of the paper check query parameters. +public class HyperwalletPaperCheckQueryParam: HyperwalletTransferMethodQueryParam { + override public func toQuery() -> [String: String] { + var query = super.toQuery() + + if type != nil { + query[QueryParam.type.rawValue] = QueryType.paperCheck.rawValue + } + return query + } +} diff --git a/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift b/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift index 11ea9e96..4c4b8b4a 100644 --- a/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift +++ b/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift @@ -163,6 +163,10 @@ public class HyperwalletTransferMethod: NSObject, Codable { case cardPackage /// The user token case userToken + + // Paper check related fields + /// The shipping method + case shippingMethod } internal init(data: [String: AnyCodable]) { @@ -183,6 +187,8 @@ public class HyperwalletTransferMethod: NSObject, Codable { case prepaidCard = "PREPAID_CARD" /// When the transfer method is Venmo Account case venmoAccount = "VENMO_ACCOUNT" + /// when transfer method is paper check + case paperCheck = "PAPER_CHECK" } /// Creates a new instance of the `HyperwalletTransferMethod` diff --git a/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift index db461c6f..25cd790f 100644 --- a/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift +++ b/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift @@ -74,6 +74,8 @@ public class HyperwalletTransferMethodQueryParam: QueryParam { case prepaidCard = "PREPAID_CARD" /// When the transfer method is Venmo Account case venmoAccount = "VENMO_ACCOUNT" + /// When the transfer method is Paper Check + case paperCheck = "PAPER_CHECK" } override public func toQuery() -> [String: String] { diff --git a/Sources/TransactionType.swift b/Sources/TransactionType.swift index d1447f85..3f1b8dde 100644 --- a/Sources/TransactionType.swift +++ b/Sources/TransactionType.swift @@ -63,7 +63,7 @@ internal enum TransactionType { httpBody: Body?) throws -> URLRequest where Body: Encodable { let formattedPath = String(format: path, configuration.userToken) let baseURL = URL(string: configuration.restUrl + formattedPath) - //let baseURL = url(configuration, path) + // let baseURL = url(configuration, path) guard let url = addQueryIfRequired(baseURL, query) else { throw ErrorTypeHelper.invalidUrl() } diff --git a/Tests/AnyCodableTests.swift b/Tests/AnyCodableTests.swift index 32a9c42c..1677e813 100644 --- a/Tests/AnyCodableTests.swift +++ b/Tests/AnyCodableTests.swift @@ -12,7 +12,7 @@ class AnyCodableTests: XCTestCase { transferMethodType: "BANK_ACCOUNT") .bankAccountId("12345") .branchId("123456") - .bankAccountPurpose(.checking) + .bankAccountPurpose("CHECKING") .build() // When diff --git a/Tests/GraphQL/HyperwalletTransferMethodUpdateConfigurationTests.swift b/Tests/GraphQL/HyperwalletTransferMethodUpdateConfigurationTests.swift new file mode 100644 index 00000000..2e7dcc5e --- /dev/null +++ b/Tests/GraphQL/HyperwalletTransferMethodUpdateConfigurationTests.swift @@ -0,0 +1,281 @@ +// +// Copyright 2018 - Present Hyperwallet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software +// and associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import Hippolyte +@testable import HyperwalletSDK +import XCTest + +class HyperwalletTransferMethodUpdateConfigurationTests: XCTestCase { + override func setUp() { + Hyperwallet.setup(HyperwalletTestHelper.authenticationProvider) + } + + override func tearDown() { + if Hippolyte.shared.isStarted { + Hippolyte.shared.stop() + } + } + + //swiftlint:disable function_body_length + func testRetrieveTransferMethodUpdateConfigurationFields_bankAccount() { + // Given + let request = setUpTransferMethodUpdateConfigurationRequest("TransferMethodUpdateConfigurationFieldsResponse") + HyperwalletTestHelper.setUpMockServer(request: request) + + let expectation = self.expectation(description: "Retrieve update transfer method configuration fields") + + var graphQlResponse: HyperwalletTransferMethodUpdateConfigurationField? + var errorResponse: HyperwalletErrorType? + // When + let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000001") + + Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in + graphQlResponse = result + errorResponse = error + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + + let fieldGroups = graphQlResponse?.transferMethodUpdateConfiguration()?.fieldGroups?.nodes + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(graphQlResponse) + XCTAssertEqual(fieldGroups?.count, + 3, + "`fieldGroups()` should be 3") + + let bankAccount = fieldGroups? + .first(where: { $0.group == "ACCOUNT_INFORMATION" })?.fields? + .first(where: { $0.name == "bankAccountId" }) + XCTAssertNotNil(bankAccount) + XCTAssertEqual(bankAccount?.value, "****9822") + XCTAssertEqual(bankAccount?.dataType, HyperwalletDataType.number.rawValue) + XCTAssertEqual(bankAccount?.isRequired, true) + XCTAssertEqual(bankAccount?.isEditable, true) + XCTAssertEqual(bankAccount?.label, "Account Number") + XCTAssertEqual(bankAccount?.regularExpression, "^(?![0-]+$)[0-9-]{3,17}$") + XCTAssertEqual(bankAccount?.validationMessage?.length, + "The minimum length of this field is 3 and maximum length is 17.") + XCTAssertEqual(bankAccount?.fieldValueMasked, true) + + let firstName = fieldGroups? + .first(where: { $0.group == "ACCOUNT_HOLDER" })?.fields? + .first(where: { $0.name == "firstName" }) + XCTAssertEqual(firstName?.value, "Cheng") + XCTAssertEqual(firstName?.dataType, HyperwalletDataType.text.rawValue) + XCTAssertEqual(firstName?.isRequired, true) + XCTAssertEqual(firstName?.isEditable, true) + XCTAssertEqual(firstName?.label, "First Name") + XCTAssertEqual(firstName?.regularExpression, + "^[\\sa-zA-Z0-9\\-.,'\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{1,50}$") + XCTAssertEqual(firstName?.validationMessage?.empty, + "You must provide a value for this field") + XCTAssertEqual(firstName?.fieldValueMasked, false) + + let postalCode = fieldGroups? + .first(where: { $0.group == "ADDRESS" })?.fields? + .first(where: { $0.name == "postalCode" }) + XCTAssertEqual(postalCode?.value, "12345") + XCTAssertEqual(postalCode?.dataType, HyperwalletDataType.text.rawValue) + XCTAssertEqual(postalCode?.isRequired, true) + XCTAssertEqual(postalCode?.isEditable, true) + XCTAssertEqual(postalCode?.label, "Zip/Postal Code") + XCTAssertEqual(postalCode?.regularExpression, + "^(?![\\-]+$)[\\sa-zA-Z0-9\\-]{2,16}$") + XCTAssertEqual(postalCode?.validationMessage?.pattern, + "is invalid length or format.") + XCTAssertEqual(postalCode?.fieldValueMasked, false) + } + + func testRetrieveTransferMethodUpdateConfigurationFields_payPal() { + // Given + let request = setUpTransferMethodUpdateConfigurationRequest( + "TransferMethodUpdateConfigurationFieldsPaypalResponse") + HyperwalletTestHelper.setUpMockServer(request: request) + + let expectation = self.expectation(description: + "Retrieve update transfer method configuration fields for Paypal") + + var graphQlResponse: HyperwalletTransferMethodUpdateConfigurationField? + var errorResponse: HyperwalletErrorType? + // When + let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000002") + + Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in + graphQlResponse = result + errorResponse = error + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + + let fieldGroups = graphQlResponse?.transferMethodUpdateConfiguration()?.fieldGroups?.nodes + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(graphQlResponse) + XCTAssertEqual(fieldGroups?.count, + 1, + "`fieldGroups()` should be 1") + + let email = fieldGroups? + .first(where: { $0.group == "CONTACT_INFORMATION" })?.fields? + .first(where: { $0.name == "email" }) + XCTAssertNotNil(email) + XCTAssertEqual(email?.value, "hello@hw.com") + XCTAssertEqual(email?.dataType, HyperwalletDataType.text.rawValue) + XCTAssertEqual(email?.isRequired, true) + XCTAssertEqual(email?.isEditable, true) + XCTAssertEqual(email?.label, "Email") + XCTAssertEqual(email?.validationMessage?.length, + "The minimum length of this field is 3 and maximum length is 200.") + XCTAssertEqual(email?.fieldValueMasked, false) + } + + func testRetrieveTransferMethodUpdateConfigurationFields_bankCard() { + // Given + let request = setUpTransferMethodUpdateConfigurationRequest( + "TransferMethodUpdateConfigurationFieldsBankCardResponse") + HyperwalletTestHelper.setUpMockServer(request: request) + + let expectation = self.expectation(description: + "Retrieve update transfer method configuration fields for Bank Card") + + var graphQlResponse: HyperwalletTransferMethodUpdateConfigurationField? + var errorResponse: HyperwalletErrorType? + // When + let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000003") + + Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in + graphQlResponse = result + errorResponse = error + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + + let fieldGroups = graphQlResponse?.transferMethodUpdateConfiguration()?.fieldGroups?.nodes + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(graphQlResponse) + XCTAssertEqual(fieldGroups?.count, + 1, + "`fieldGroups()` should be 1") + + let cardNumber = fieldGroups? + .first(where: { $0.group == "ACCOUNT_INFORMATION" })?.fields? + .first(where: { $0.name == "cardNumber" }) + XCTAssertNotNil(cardNumber) + XCTAssertEqual(cardNumber?.value, "****0006") + XCTAssertEqual(cardNumber?.dataType, HyperwalletDataType.number.rawValue) + XCTAssertEqual(cardNumber?.isRequired, true) + XCTAssertEqual(cardNumber?.isEditable, true) + XCTAssertEqual(cardNumber?.label, "Card Number") + XCTAssertEqual(cardNumber?.regularExpression, "^[0-9]{13,19}$") + XCTAssertEqual(cardNumber?.validationMessage?.length, + "The minimum length of this field is 13 and maximum length is 19.") + XCTAssertEqual(cardNumber?.fieldValueMasked, true) + XCTAssertEqual(cardNumber?.mask?.defaultPattern, "#### #### #### ####") + + let dateOfExpiry = fieldGroups? + .first(where: { $0.group == "ACCOUNT_INFORMATION" })?.fields? + .first(where: { $0.name == "dateOfExpiry" }) + XCTAssertNotNil(dateOfExpiry) + XCTAssertEqual(dateOfExpiry?.value, "2024-10-01") + XCTAssertEqual(dateOfExpiry?.dataType, HyperwalletDataType.expiryDate.rawValue) + XCTAssertEqual(dateOfExpiry?.isRequired, true) + XCTAssertEqual(dateOfExpiry?.isEditable, true) + XCTAssertEqual(dateOfExpiry?.label, "Expiration Date") + XCTAssertEqual(dateOfExpiry?.regularExpression, "^[0-9]{4}-(1[0-2]|0[1-9])$") + XCTAssertEqual(dateOfExpiry?.validationMessage?.length, + "The exact length of this field is 7.") + XCTAssertEqual(dateOfExpiry?.fieldValueMasked, false) + + let cvv = fieldGroups? + .first(where: { $0.group == "ACCOUNT_INFORMATION" })?.fields? + .first(where: { $0.name == "cvv" }) + XCTAssertNotNil(cvv) + XCTAssertEqual(cvv?.dataType, HyperwalletDataType.number.rawValue) + XCTAssertEqual(cvv?.isRequired, true) + XCTAssertEqual(cvv?.isEditable, true) + XCTAssertEqual(cvv?.label, "CVV (Card Security Code)") + XCTAssertEqual(cvv?.regularExpression, "^[0-9]{3,4}$") + XCTAssertEqual(cvv?.validationMessage?.length, + "The minimum length of this field is 3 and maximum length is 4.") + XCTAssertEqual(cvv?.fieldValueMasked, false) + XCTAssertEqual(cvv?.mask?.defaultPattern, "###") + } + + func testRetrieveTransferMethodUpdateConfigurationFields_venmo() { + // Given + let request = setUpTransferMethodUpdateConfigurationRequest( + "TransferMethodUpdateConfigurationFieldsVenmoResponse") + HyperwalletTestHelper.setUpMockServer(request: request) + + let expectation = self.expectation(description: + "Retrieve update transfer method configuration fields for Venmo") + + var graphQlResponse: HyperwalletTransferMethodUpdateConfigurationField? + var errorResponse: HyperwalletErrorType? + // When + let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000004") + + Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in + graphQlResponse = result + errorResponse = error + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + + let fieldGroups = graphQlResponse?.transferMethodUpdateConfiguration()?.fieldGroups?.nodes + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(graphQlResponse) + XCTAssertEqual(fieldGroups?.count, + 1, + "`fieldGroups()` should be 1") + + let accountId = fieldGroups? + .first(where: { $0.group == "ACCOUNT_INFORMATION" })?.fields? + .first(where: { $0.name == "accountId" }) + XCTAssertNotNil(accountId) + XCTAssertEqual(accountId?.value, "5555555555") + XCTAssertEqual(accountId?.dataType, HyperwalletDataType.text.rawValue) + XCTAssertEqual(accountId?.isRequired, true) + XCTAssertEqual(accountId?.isEditable, true) + XCTAssertEqual(accountId?.label, "Mobile Number") + XCTAssertEqual(accountId?.regularExpression, "^([0-9]{10})$") + XCTAssertEqual(accountId?.validationMessage?.length, + "The exact length of this field is 10.") + XCTAssertEqual(accountId?.fieldValueMasked, false) + } + + private func setUpTransferMethodUpdateConfigurationRequest(_ responseFile: String, + _ error: NSError? = nil) + -> StubRequest { + let data = HyperwalletTestHelper.getDataFromJson(responseFile) + return HyperwalletTestHelper.buildPostRequest(baseUrl: HyperwalletTestHelper.graphQlURL, + HyperwalletTestHelper.setUpMockedResponse(payload: data, + error: error)) + } +} diff --git a/Tests/GraphQL/Query/HyperwalletTransferMethodConfigurationFieldQueryTests.swift b/Tests/GraphQL/Query/HyperwalletTransferMethodConfigurationFieldQueryTests.swift index 50ab7237..63bca615 100644 --- a/Tests/GraphQL/Query/HyperwalletTransferMethodConfigurationFieldQueryTests.swift +++ b/Tests/GraphQL/Query/HyperwalletTransferMethodConfigurationFieldQueryTests.swift @@ -34,4 +34,11 @@ class HyperwalletTransferMethodConfigurationFieldQueryTests: XCTestCase { XCTAssertNotEqual(usUsdFieldQuery, usCadFieldQuery) XCTAssertNotEqual(usUsdFieldQuery.hashValue, usCadFieldQuery.hashValue) } + + func testHashable_editFieldQueryNotEqual() { + let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-93939939393") + let fieldQuery1 = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-93939939398") + XCTAssertNotEqual(fieldQuery, fieldQuery1) + XCTAssertNotEqual(fieldQuery.hashValue, fieldQuery1.hashValue) + } } diff --git a/Tests/GraphQL/TransferMethodConfigurationFieldResultTests.swift b/Tests/GraphQL/TransferMethodConfigurationFieldResultTests.swift index fce3a4d9..2aef8ee6 100644 --- a/Tests/GraphQL/TransferMethodConfigurationFieldResultTests.swift +++ b/Tests/GraphQL/TransferMethodConfigurationFieldResultTests.swift @@ -10,7 +10,7 @@ class TransferMethodConfigurationFieldResultTests: XCTestCase { transferMethodConfigurationField = hyperwalletGraphQlField(data: HyperwalletTestHelper.getDataFromJson("TransferMethodConfigurationFieldsResponse"))! fieldResult = TransferMethodConfigurationFieldResult(transferMethodConfigurationField? - .transferMethodUIConfigurations?.nodes, transferMethodConfigurationField.countries?.nodes?.first) + .transferMethodCreateUIConfigurations?.nodes, transferMethodConfigurationField.countries?.nodes?.first) } func testFees_success() { diff --git a/Tests/HTTPTransactionTests.swift b/Tests/HTTPTransactionTests.swift index 46404a5b..87c308ae 100644 --- a/Tests/HTTPTransactionTests.swift +++ b/Tests/HTTPTransactionTests.swift @@ -147,7 +147,7 @@ class HTTPTransactionTests: XCTestCase { func testPerformGraphQl_responseWithErrorsAndData_returnOnlyData() { // Given - SDK is initialized - var response: Connection? + var response: Connection? var hyperwalletError: HyperwalletErrorType? httpClientMock.data = HyperwalletTestHelper.getDataFromJson("TransferMethodConfigurationGraphQlResponse") @@ -161,13 +161,13 @@ class HTTPTransactionTests: XCTestCase { transferMethodType: "BANK_ACCOUNT", profile: "INDIVIDUAL") // When - an API call request is made - let completionHandler = { (data: Connection?, error: HyperwalletErrorType?) - -> Void in + let handler = { (data: Connection?, error: HyperwalletErrorType?) + -> Void in response = data hyperwalletError = error } - transaction.performGraphQl(request, completionHandler: completionHandler) + transaction.performGraphQl(request, completionHandler: handler) // Then XCTAssertNotNil(response) @@ -180,7 +180,7 @@ class HTTPTransactionTests: XCTestCase { let graphQlResponse = """ {} """.data(using: .utf8) - var response: Connection? + var response: Connection? var hyperwalletError: HyperwalletErrorType? httpClientMock.data = graphQlResponse @@ -194,13 +194,13 @@ class HTTPTransactionTests: XCTestCase { transferMethodType: "BANK_ACCOUNT", profile: "INDIVIDUAL") // When - an API call request is made - let completionHandler = { (data: Connection?, error: HyperwalletErrorType?) + let handler = { (data: Connection?, error: HyperwalletErrorType?) -> Void in response = data hyperwalletError = error } - transaction.performGraphQl(request, completionHandler: completionHandler) + transaction.performGraphQl(request, completionHandler: handler) // Then diff --git a/Tests/Receipt/HyperwalletReceiptTests.swift b/Tests/Receipt/HyperwalletReceiptTests.swift index 6647cd73..9a48c2ec 100644 --- a/Tests/Receipt/HyperwalletReceiptTests.swift +++ b/Tests/Receipt/HyperwalletReceiptTests.swift @@ -42,7 +42,7 @@ class HyperwalletReceiptTests: XCTestCase { // Then XCTAssertNil(errorResponse, "The `errorResponse` should be nil") XCTAssertNotNil(userReceiptList, "The `payPalAccountList` should not be nil") - XCTAssertEqual(userReceiptList?.count, 4, "The `count` should be 4") + XCTAssertEqual(userReceiptList?.count, 8, "The `count` should be 8") XCTAssertNotNil(userReceiptList?.data, "The `data` should be not nil") XCTAssertNotNil(userReceiptList?.links, "The `links` should be not nil") XCTAssertNotNil(userReceiptList?.links?.first?.params?.rel) @@ -86,12 +86,15 @@ class HyperwalletReceiptTests: XCTestCase { let lastReceipt = userReceiptList?.data?[5] XCTAssertEqual(lastReceipt?.type?.rawValue, "UNKNOWN_RECEIPT_TYPE") - let transferToBankCardReceipt = userReceiptList?.data?.last! - XCTAssertNotNil(transferToBankCardReceipt, "transferToBankCardReceipt should not be nil") - receiptType = HyperwalletReceipt.HyperwalletReceiptType.transferToBankCard.rawValue - XCTAssertEqual(transferToBankCardReceipt?.type?.rawValue, + let transferToBankAccountReceipt = userReceiptList?.data?.last! + XCTAssertNotNil(transferToBankAccountReceipt, "transferToBankAccountReceipt should not be nil") + receiptType = HyperwalletReceipt.HyperwalletReceiptType.transferToBankAccount.rawValue + XCTAssertEqual(transferToBankAccountReceipt?.type?.rawValue, receiptType, - "Type should be TRANSFER_TO_BANK_CARD") + "Type should be TRANSFER_TO_BANK_ACCOUNT") + XCTAssertEqual(transferToBankAccountReceipt?.details?.bankAccountPurpose, + "Current Account (Tōza yokin, 当座預金)", + "Bank Account purpose should be Current Account (Tōza yokin, 当座預金)") } func testListPrepaidCardReceipts_success() { diff --git a/Tests/Responses/ListBankAccountResponse.json b/Tests/Responses/ListBankAccountResponse.json index be5928c8..245906dc 100644 --- a/Tests/Responses/ListBankAccountResponse.json +++ b/Tests/Responses/ListBankAccountResponse.json @@ -1,5 +1,5 @@ { - "count":204, + "count":2, "offset":0, "limit":10, "data":[ diff --git a/Tests/Responses/ListUserReceiptResponse.json b/Tests/Responses/ListUserReceiptResponse.json index 3925fe6e..8719c6fc 100644 --- a/Tests/Responses/ListUserReceiptResponse.json +++ b/Tests/Responses/ListUserReceiptResponse.json @@ -1,8 +1,9 @@ { - "count" : 4, + "count" : 8, "offset" : 0, "limit" : 10, "data" : [ { + "token": "rcpToken1", "journalId" : "51660665", "type" : "PAYMENT", "createdOn" : "2019-05-27T15:42:07", @@ -15,8 +16,17 @@ "details" : { "clientPaymentId" : "trans-0001", "payeeName" : "Vasya Pupkin" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken1" + } + ] }, { + "token": "rcpToken2", "journalId" : "51660666", "type" : "TRANSFER_TO_BANK_ACCOUNT", "createdOn" : "2019-05-27T15:57:49", @@ -29,8 +39,17 @@ "details" : { "payeeName" : "Vasya Pupkin", "bankAccountId" : "jen@sample.net" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken2" + } + ] }, { + "token": "rcpToken3", "journalId" : "51660667", "type" : "PAYMENT", "createdOn" : "2019-05-27T16:01:10", @@ -43,8 +62,17 @@ "details" : { "clientPaymentId" : "trans-02", "payeeName" : "Vasya Pupkin" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken3" + } + ] }, { + "token": "rcpToken4", "journalId": "CC002F14A573", "type": "TRANSFER_TO_DEBIT_CARD", "createdOn": "2017-11-01T17:12:19", @@ -54,8 +82,17 @@ "currency": "USD", "details": { "cardNumber": "************7917" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken4" + } + ] }, { + "token": "rcpToken5", "journalId": "CC002F14A574", "type": "TRANSFER_TO_PAYPAL_ACCOUNT", "createdOn": "2017-11-01T17:12:19", @@ -65,8 +102,17 @@ "currency": "USD", "details": { "cardNumber": "************7917" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken5" + } + ] }, { + "token": "rcpToken6", "journalId" : "51660667", "type" : "UNKNOWN_TYPE", "createdOn" : "2019-05-27T16:01:10", @@ -79,8 +125,17 @@ "details" : { "clientPaymentId" : "trans-02", "payeeName" : "Vasya Pupkin" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken6" + } + ] },{ + "token": "rcpToken7", "journalId": "CC002F14A500", "type": "TRANSFER_TO_BANK_CARD", "createdOn": "2017-02-01T17:12:19", @@ -90,7 +145,41 @@ "currency": "USD", "details": { "cardNumber": "************7917" - } + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken7" + } + ] + }, + { + "token": "rcpToken8", + "journalId": "64450180", + "type": "TRANSFER_TO_BANK_ACCOUNT", + "createdOn": "2020-12-02T01:59:57", + "entry": "DEBIT", + "sourceToken": "usrToken", + "destinationToken": "trmToken", + "amount": "82899", + "fee": "205", + "currency": "JPY", + "details": { + "payeeName": "Test Test test", + "branchId": "8689", + "bankAccountId": "**3445", + "bankAccountPurpose": "Current Account (Tōza yokin, 当座預金)" + }, + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/receipts/rcpToken8" + } + ] }], "links" : [ { "params" : { diff --git a/Tests/Responses/PaperCheck/ListPaperCheckResponse.json b/Tests/Responses/PaperCheck/ListPaperCheckResponse.json new file mode 100644 index 00000000..03391998 --- /dev/null +++ b/Tests/Responses/PaperCheck/ListPaperCheckResponse.json @@ -0,0 +1,103 @@ +{ + "count":2, + "offset":0, + "limit":10, + "data":[ + { + "token":"trm-001", + "type":"PAPER_CHECK", + "status":"ACTIVATED", + "createdOn":"2017-10-31T16:47:15", + "transferMethodCountry":"US", + "transferMethodCurrency":"USD", + "profileType":"INDIVIDUAL", + "firstName":"Some", + "lastName":"Guy", + "middleName": "Good", + "dateOfBirth": "1991-01-01", + "addressLine1": "575 Market Street", + "addressLine2": "57 Market Street", + "city":"San Francisco", + "stateProvince":"CA", + "country":"US", + "postalCode":"94105", + "phoneNumber": "604-345-1777", + "mobileNumber": "604-345-1888", + "countryOfBirth": "US", + "driversLicenseId": "1234", + "employerId": "1234", + "governmentId": "12898", + "governmentIdType": "PASSPORT", + "gender": "MALE", + "passportId": "112323", + "shippingMethod": "STANDARD", + "bankAccountRelationship": "SELF", + "links":[ + { + "params":{ + "rel":"self" + }, + "href":"https://localhost/rest/v3/users/usr-0000/paper-checks/trm-001" + } + ] + }, + { + "token":"trm-002", + "type":"PAPER_CHECK", + "status":"ACTIVATED", + "createdOn":"2017-10-31T16:47:15", + "transferMethodCountry":"US", + "transferMethodCurrency":"USD", + "profileType":"INDIVIDUAL", + "firstName":"Some", + "lastName":"Guy", + "middleName": "Good", + "dateOfBirth": "1991-01-01", + "addressLine1": "575 Market Street", + "addressLine2": "57 Market Street", + "city":"San Francisco", + "stateProvince":"CA", + "country":"US", + "postalCode":"94105", + "phoneNumber": "604-345-1777", + "mobileNumber": "604-345-1888", + "countryOfBirth": "US", + "driversLicenseId": "1234", + "employerId": "1234", + "governmentId": "12898", + "governmentIdType": "PASSPORT", + "gender": "MALE", + "passportId": "112323", + "shippingMethod": "STANDARD", + "bankAccountRelationship": "SELF", + "links":[ + { + "params":{ + "rel":"self" + }, + "href":"https://localhost/rest/v3/users/usr-0000/paper-checks/trm-002" + } + ] + } + ], + "links":[ + { + "params":{ + "rel":"self" + }, + "href":"https://localhost/rest/v3/users/usr-0000/paper-checks?offset=0&limit=10" + }, + { + "params":{ + "rel":"next" + }, + "href":"https://localhost/rest/v3/users/usr-0000/paper-checks?offset=10&limit=10" + }, + { + "params":{ + "rel":"last" + }, + "href":"https://localhost/rest/v3/users/usr-0000/paper-checks?offset=194&limit=10" + } + ] +} diff --git a/Tests/Responses/PaperCheck/PaperCheckBusinessResponse.json b/Tests/Responses/PaperCheck/PaperCheckBusinessResponse.json new file mode 100644 index 00000000..c4665727 --- /dev/null +++ b/Tests/Responses/PaperCheck/PaperCheckBusinessResponse.json @@ -0,0 +1,46 @@ +{ + "token": "trm-000", + "type": "PAPER_CHECK", + "status": "ACTIVATED", + "verificationStatus": "NOT_REQUIRED", + "createdOn": "2019-05-22T11:30:39", + "transferMethodCountry": "US", + "transferMethodCurrency": "USD", + "profileType": "BUSINESS", + "businessType": "CORPORATION", + "businessName": "US BANK NA", + "businessRegistrationId": "123455511", + "businessRegistrationStateProvince": "BC", + "businessRegistrationCountry": "CA", + "businessContactRole": "OWNER", + "businessOperatingName": "AZaz09お元ですか你好ผซอéüõäÄÜÖ-ßḑņžÇĞÿĀſƀɏɐʯʰͰϿЀӿꙀꚗ", + "firstName": "Shyang", + "middleName": "Alma", + "lastName": "Koong", + "dateOfBirth": "2001-01-01", + "countryOfBirth": "US", + "countryOfNationality": "FR", + "gender": "FEMALE", + "phoneNumber": "604-345-1777", + "mobileNumber": "604-345-1888", + "governmentId": "999000999", + "passportId": "123456789", + "driversLicenseId": "234234243", + "employerId": "123456789", + "addressLine1": "1234, Broadway", + "addressLine2": "57 Market Street", + "city": "Test City", + "stateProvince": "WA", + "country": "US", + "postalCode": "12345", + "shippingMethod": "STANDARD", + "bankAccountRelationship": "OWN_COMPANY", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost/rest/v3/users/usr-0000/paper-checks/trm-0000" + } + ] +} diff --git a/Tests/Responses/PaperCheck/PaperCheckErrorResponseWithMissingStateProvince.json b/Tests/Responses/PaperCheck/PaperCheckErrorResponseWithMissingStateProvince.json new file mode 100644 index 00000000..f9675cb7 --- /dev/null +++ b/Tests/Responses/PaperCheck/PaperCheckErrorResponseWithMissingStateProvince.json @@ -0,0 +1,9 @@ +{ + "errors": [ + { + "message": "You have to provide a value for this field", + "fieldName": "stateProvince", + "code": "CONSTRAINT_VALIDATION" + } + ] +} diff --git a/Tests/Responses/PaperCheck/PaperCheckIndividualResponse.json b/Tests/Responses/PaperCheck/PaperCheckIndividualResponse.json new file mode 100644 index 00000000..032ffdfb --- /dev/null +++ b/Tests/Responses/PaperCheck/PaperCheckIndividualResponse.json @@ -0,0 +1,38 @@ +{ + "token":"trm-12345", + "type":"PAPER_CHECK", + "status":"ACTIVATED", + "createdOn":"2017-10-31T16:47:15", + "transferMethodCountry":"US", + "transferMethodCurrency":"USD", + "profileType":"INDIVIDUAL", + "firstName":"Some", + "lastName":"Guy", + "middleName": "Good", + "dateOfBirth": "1991-01-01", + "addressLine1": "575 Market Street", + "addressLine2": "57 Market Street", + "city":"San Francisco", + "stateProvince":"CA", + "country":"US", + "postalCode":"94105", + "phoneNumber": "604-345-1777", + "mobileNumber": "604-345-1888", + "countryOfBirth": "US", + "driversLicenseId": "1234", + "employerId": "1234", + "governmentId": "12898", + "governmentIdType": "PASSPORT", + "gender": "MALE", + "passportId": "112323", + "shippingMethod": "STANDARD", + "bankAccountRelationship": "SELF", + "links":[ + { + "params":{ + "rel":"self" + }, + "href":"https://localhost/rest/v3/users/usr-0000/paper-checks/trm-12345" + } + ] +} diff --git a/Tests/Responses/TransferMethodConfigurationFieldsResponse.json b/Tests/Responses/TransferMethodConfigurationFieldsResponse.json index 5e6a1f7a..60d60e36 100644 --- a/Tests/Responses/TransferMethodConfigurationFieldsResponse.json +++ b/Tests/Responses/TransferMethodConfigurationFieldsResponse.json @@ -1,6 +1,6 @@ { "data": { - "transferMethodUIConfigurations": { + "transferMethodCreateUIConfigurations": { "nodes": [ { "country": "US", diff --git a/Tests/Responses/TransferMethodUpdateConfigurationFieldsBankCardResponse.json b/Tests/Responses/TransferMethodUpdateConfigurationFieldsBankCardResponse.json new file mode 100644 index 00000000..b2111ea6 --- /dev/null +++ b/Tests/Responses/TransferMethodUpdateConfigurationFieldsBankCardResponse.json @@ -0,0 +1,90 @@ +{ + "data": { + "transferMethodUpdateUIConfigurations": { + "nodes": [ + { + "country": "US", + "currency": "USD", + "transferMethodType": "BANK_CARD", + "profile": "INDIVIDUAL", + "fieldGroups": { + "nodes": [ + { + "group": "ACCOUNT_INFORMATION", + "isEditable": true, + "instruction": { + "textBottom": "CVV is a 3 digit number, typically found on the back of a debit card." + }, + "fields": [ + { + "category": "ACCOUNT", + "value": "****0006", + "dataType": "NUMBER", + "isRequired": true, + "isEditable": true, + "label": "Card Number", + "maxLength": 19, + "minLength": 13, + "name": "cardNumber", + "placeholder": "", + "regularExpression": "^[0-9]{13,19}$", + "validationMessage": { + "length": "The minimum length of this field is 13 and maximum length is 19.", + "pattern": "is invalid length or format.", + "empty": "You must provide a value for this field" + }, + "fieldValueMasked": true, + "mask": { + "defaultPattern": "#### #### #### ####", + "scrubRegex": " " + } + }, + { + "category": "ACCOUNT", + "value": "2024-10-01", + "dataType": "EXPIRY_DATE", + "isRequired": true, + "isEditable": true, + "label": "Expiration Date", + "maxLength": 7, + "minLength": 7, + "name": "dateOfExpiry", + "placeholder": "", + "regularExpression": "^[0-9]{4}-(1[0-2]|0[1-9])$", + "validationMessage": { + "length": "The exact length of this field is 7.", + "pattern": "is invalid length or format.", + "empty": "You must provide a value for this field" + }, + "fieldValueMasked": false + }, + { + "category": "ACCOUNT", + "dataType": "NUMBER", + "isRequired": true, + "isEditable": true, + "label": "CVV (Card Security Code)", + "maxLength": 4, + "minLength": 3, + "name": "cvv", + "placeholder": "", + "regularExpression": "^[0-9]{3,4}$", + "validationMessage": { + "length": "The minimum length of this field is 3 and maximum length is 4.", + "pattern": "is invalid length or format.", + "empty": "You must provide a value for this field" + }, + "fieldValueMasked": false, + "mask": { + "defaultPattern": "###" + } + } + ] + } + ] + } + } + ] + } + } +} diff --git a/Tests/Responses/TransferMethodUpdateConfigurationFieldsPaypalResponse.json b/Tests/Responses/TransferMethodUpdateConfigurationFieldsPaypalResponse.json new file mode 100644 index 00000000..f209143b --- /dev/null +++ b/Tests/Responses/TransferMethodUpdateConfigurationFieldsPaypalResponse.json @@ -0,0 +1,47 @@ +{ + "data": { + "transferMethodUpdateUIConfigurations": { + "nodes": [ + { + "country": "CA", + "currency": "CAD", + "transferMethodType": "PAYPAL_ACCOUNT", + "profile": "INDIVIDUAL", + "fieldGroups": { + "nodes": [ + { + "group": "CONTACT_INFORMATION", + "isEditable": true, + "instruction": { + "textBottom": "Email address associated with your PayPal account." + }, + "fields": [ + { + "category": "ACCOUNT", + "value": "hello@hw.com", + "dataType": "TEXT", + "isRequired": true, + "isEditable": true, + "label": "Email", + "maxLength": 200, + "minLength": 3, + "name": "email", + "placeholder": "", + "regularExpression": "^(?:[a-zA-Z0-9]{1}|[a-zA-Z0-9\\_]{1}[a-zA-Z0-9\\_\\!#$%&\\'*\\/=?^{|}~`\\-\\.+]{0,64}[a-zA-Z0-9\\_\\-+]{1})[@]{1}(?:[a-zA-Z0-9]{1}(?=.*?[\\.])([a-zA-Z0-9-\\.](?!\\.\\.)){0,133})([a-zA-Z0-9]){2}$", + "validationMessage": { + "length": "The minimum length of this field is 3 and maximum length is 200.", + "pattern": "is invalid length or format.", + "empty": "You must provide a value for this field" + }, + "fieldValueMasked": false + } + ] + } + ] + } + } + ] + } + } +} + diff --git a/Tests/Responses/TransferMethodUpdateConfigurationFieldsResponse.json b/Tests/Responses/TransferMethodUpdateConfigurationFieldsResponse.json new file mode 100644 index 00000000..3fb34584 --- /dev/null +++ b/Tests/Responses/TransferMethodUpdateConfigurationFieldsResponse.json @@ -0,0 +1,1194 @@ +{ + "data":{ + "transferMethodUpdateUIConfigurations":{ + "nodes":[ + { + "country":"US", + "currency":"USD", + "transferMethodType":"BANK_ACCOUNT", + "profile":"INDIVIDUAL", + "fieldGroups":{ + "nodes":[ + { + "group":"ACCOUNT_INFORMATION", + "isEditable":true, + "instruction":{ + "textBottom":"On a paper check, the routing number is printed as the first 9 digits on the bottom of the check, followed by 4-17 digits for the account number." + }, + "fields":[ + { + "category":"ACCOUNT", + "value":"021000021", + "dataType":"NUMBER", + "isRequired":true, + "isEditable":true, + "label":"Routing Number", + "maxLength":9, + "minLength":9, + "name":"branchId", + "placeholder":"", + "regularExpression":"^[0-9]{9}$", + "validationMessage":{ + "length":"The exact length of this field is 9.", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"ACCOUNT", + "value":"****9822", + "dataType":"NUMBER", + "isRequired":true, + "isEditable":true, + "label":"Account Number", + "maxLength":17, + "minLength":3, + "name":"bankAccountId", + "placeholder":"", + "regularExpression":"^(?![0-]+$)[0-9-]{3,17}$", + "validationMessage":{ + "length":"The minimum length of this field is 3 and maximum length is 17.", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":true + }, + { + "category":"ACCOUNT", + "value":"SAVINGS", + "dataType":"SELECTION", + "isRequired":true, + "isEditable":true, + "label":"Account Type", + "name":"bankAccountPurpose", + "placeholder":"", + "fieldSelectionOptions":[ + { + "label":"Checking", + "value":"CHECKING" + }, + { + "label":"Savings", + "value":"SAVINGS" + } + ], + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + } + ] + }, + { + "group":"ACCOUNT_HOLDER", + "isEditable":true, + "instruction":{ + + }, + "fields":[ + { + "category":"PROFILE", + "value":"Cheng", + "dataType":"TEXT", + "isRequired":true, + "isEditable":true, + "label":"First Name", + "name":"firstName", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\-.,'\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{1,50}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"PROFILE", + "dataType":"TEXT", + "isRequired":false, + "isEditable":true, + "label":"Middle Name", + "name":"middleName", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\-.,'\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{1,50}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"PROFILE", + "value":"Chang", + "dataType":"TEXT", + "isRequired":true, + "isEditable":true, + "label":"Last Name", + "name":"lastName", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\-.,'\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{1,50}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + } + ] + }, + { + "group":"ADDRESS", + "isEditable":true, + "instruction":{ + + }, + "fields":[ + { + "category":"ADDRESS", + "value":"US", + "dataType":"SELECTION", + "isRequired":true, + "isEditable":true, + "label":"Country", + "name":"country", + "placeholder":"", + "fieldSelectionOptions":[ + { + "label":"Afghanistan", + "value":"AF" + }, + { + "label":"Åland Islands", + "value":"AX" + }, + { + "label":"Albania", + "value":"AL" + }, + { + "label":"Algeria", + "value":"DZ" + }, + { + "label":"American Samoa", + "value":"AS" + }, + { + "label":"Andorra", + "value":"AD" + }, + { + "label":"Angola", + "value":"AO" + }, + { + "label":"Anguilla", + "value":"AI" + }, + { + "label":"Antarctica", + "value":"AQ" + }, + { + "label":"Antigua & Barbuda", + "value":"AG" + }, + { + "label":"Argentina", + "value":"AR" + }, + { + "label":"Armenia", + "value":"AM" + }, + { + "label":"Aruba", + "value":"AW" + }, + { + "label":"Australia", + "value":"AU" + }, + { + "label":"Austria", + "value":"AT" + }, + { + "label":"Azerbaijan", + "value":"AZ" + }, + { + "label":"Bahamas", + "value":"BS" + }, + { + "label":"Bahrain", + "value":"BH" + }, + { + "label":"Bangladesh", + "value":"BD" + }, + { + "label":"Barbados", + "value":"BB" + }, + { + "label":"Belgium", + "value":"BE" + }, + { + "label":"Belize", + "value":"BZ" + }, + { + "label":"Benin", + "value":"BJ" + }, + { + "label":"Bermuda", + "value":"BM" + }, + { + "label":"Bhutan", + "value":"BT" + }, + { + "label":"Bolivia", + "value":"BO" + }, + { + "label":"Caribbean Netherlands", + "value":"BQ" + }, + { + "label":"Bosnia & Herzegovina", + "value":"BA" + }, + { + "label":"Botswana", + "value":"BW" + }, + { + "label":"Bouvet Island", + "value":"BV" + }, + { + "label":"Brazil", + "value":"BR" + }, + { + "label":"British Indian Ocean Territory", + "value":"IO" + }, + { + "label":"Brunei", + "value":"BN" + }, + { + "label":"Bulgaria", + "value":"BG" + }, + { + "label":"Burkina Faso", + "value":"BF" + }, + { + "label":"Burundi", + "value":"BI" + }, + { + "label":"Cambodia", + "value":"KH" + }, + { + "label":"Cameroon", + "value":"CM" + }, + { + "label":"Canada", + "value":"CA" + }, + { + "label":"Cape Verde", + "value":"CV" + }, + { + "label":"Cayman Islands", + "value":"KY" + }, + { + "label":"Chad", + "value":"TD" + }, + { + "label":"Chile", + "value":"CL" + }, + { + "label":"China", + "value":"CN" + }, + { + "label":"Christmas Island", + "value":"CX" + }, + { + "label":"Cocos (Keeling) Islands", + "value":"CC" + }, + { + "label":"Colombia", + "value":"CO" + }, + { + "label":"Comoros", + "value":"KM" + }, + { + "label":"Congo - Brazzaville", + "value":"CG" + }, + { + "label":"Cook Islands", + "value":"CK" + }, + { + "label":"Costa Rica", + "value":"CR" + }, + { + "label":"Côte d’Ivoire", + "value":"CI" + }, + { + "label":"Croatia", + "value":"HR" + }, + { + "label":"Curaçao", + "value":"CW" + }, + { + "label":"Cyprus", + "value":"CY" + }, + { + "label":"Czechia", + "value":"CZ" + }, + { + "label":"Denmark", + "value":"DK" + }, + { + "label":"Djibouti", + "value":"DJ" + }, + { + "label":"Dominica", + "value":"DM" + }, + { + "label":"Dominican Republic", + "value":"DO" + }, + { + "label":"Timor-Leste", + "value":"TL" + }, + { + "label":"Ecuador", + "value":"EC" + }, + { + "label":"Egypt", + "value":"EG" + }, + { + "label":"El Salvador", + "value":"SV" + }, + { + "label":"Equatorial Guinea", + "value":"GQ" + }, + { + "label":"Estonia", + "value":"EE" + }, + { + "label":"Ethiopia", + "value":"ET" + }, + { + "label":"Falkland Islands", + "value":"FK" + }, + { + "label":"Faroe Islands", + "value":"FO" + }, + { + "label":"Fiji", + "value":"FJ" + }, + { + "label":"Finland", + "value":"FI" + }, + { + "label":"France", + "value":"FR" + }, + { + "label":"French Guiana", + "value":"GF" + }, + { + "label":"French Polynesia", + "value":"PF" + }, + { + "label":"French Southern Territories", + "value":"TF" + }, + { + "label":"Gabon", + "value":"GA" + }, + { + "label":"Gambia", + "value":"GM" + }, + { + "label":"Georgia", + "value":"GE" + }, + { + "label":"Germany", + "value":"DE" + }, + { + "label":"Ghana", + "value":"GH" + }, + { + "label":"Gibraltar", + "value":"GI" + }, + { + "label":"Greece", + "value":"GR" + }, + { + "label":"Greenland", + "value":"GL" + }, + { + "label":"Grenada", + "value":"GD" + }, + { + "label":"Guadeloupe", + "value":"GP" + }, + { + "label":"Guam", + "value":"GU" + }, + { + "label":"Guatemala", + "value":"GT" + }, + { + "label":"Guernsey", + "value":"GG" + }, + { + "label":"Guinea", + "value":"GN" + }, + { + "label":"Guyana", + "value":"GY" + }, + { + "label":"Haiti", + "value":"HT" + }, + { + "label":"Heard & McDonald Islands", + "value":"HM" + }, + { + "label":"Honduras", + "value":"HN" + }, + { + "label":"Hong Kong SAR China", + "value":"HK" + }, + { + "label":"Hungary", + "value":"HU" + }, + { + "label":"Iceland", + "value":"IS" + }, + { + "label":"India", + "value":"IN" + }, + { + "label":"Indonesia", + "value":"ID" + }, + { + "label":"Ireland", + "value":"IE" + }, + { + "label":"Isle of Man", + "value":"IM" + }, + { + "label":"Israel", + "value":"IL" + }, + { + "label":"Italy", + "value":"IT" + }, + { + "label":"Jamaica", + "value":"JM" + }, + { + "label":"Japan", + "value":"JP" + }, + { + "label":"Jersey", + "value":"JE" + }, + { + "label":"Jordan", + "value":"JO" + }, + { + "label":"Kazakhstan", + "value":"KZ" + }, + { + "label":"Kenya", + "value":"KE" + }, + { + "label":"Kiribati", + "value":"KI" + }, + { + "label":"South Korea", + "value":"KR" + }, + { + "label":"Kosovo", + "value":"XK" + }, + { + "label":"Kuwait", + "value":"KW" + }, + { + "label":"Kyrgyzstan", + "value":"KG" + }, + { + "label":"Laos", + "value":"LA" + }, + { + "label":"Latvia", + "value":"LV" + }, + { + "label":"Lesotho", + "value":"LS" + }, + { + "label":"Liechtenstein", + "value":"LI" + }, + { + "label":"Lithuania", + "value":"LT" + }, + { + "label":"Luxembourg", + "value":"LU" + }, + { + "label":"Macao SAR China", + "value":"MO" + }, + { + "label":"North Macedonia", + "value":"MK" + }, + { + "label":"Madagascar", + "value":"MG" + }, + { + "label":"Malawi", + "value":"MW" + }, + { + "label":"Malaysia", + "value":"MY" + }, + { + "label":"Maldives", + "value":"MV" + }, + { + "label":"Mali", + "value":"ML" + }, + { + "label":"Malta", + "value":"MT" + }, + { + "label":"Marshall Islands", + "value":"MH" + }, + { + "label":"Martinique", + "value":"MQ" + }, + { + "label":"Mauritania", + "value":"MR" + }, + { + "label":"Mauritius", + "value":"MU" + }, + { + "label":"Mayotte", + "value":"YT" + }, + { + "label":"Mexico", + "value":"MX" + }, + { + "label":"Micronesia", + "value":"FM" + }, + { + "label":"Moldova", + "value":"MD" + }, + { + "label":"Monaco", + "value":"MC" + }, + { + "label":"Mongolia", + "value":"MN" + }, + { + "label":"Montenegro", + "value":"ME" + }, + { + "label":"Montserrat", + "value":"MS" + }, + { + "label":"Morocco", + "value":"MA" + }, + { + "label":"Mozambique", + "value":"MZ" + }, + { + "label":"Namibia", + "value":"NA" + }, + { + "label":"Nauru", + "value":"NR" + }, + { + "label":"Nepal", + "value":"NP" + }, + { + "label":"Netherlands", + "value":"NL" + }, + { + "label":"Curaçao", + "value":"AN" + }, + { + "label":"New Caledonia", + "value":"NC" + }, + { + "label":"New Zealand", + "value":"NZ" + }, + { + "label":"Nicaragua", + "value":"NI" + }, + { + "label":"Niger", + "value":"NE" + }, + { + "label":"Nigeria", + "value":"NG" + }, + { + "label":"Niue", + "value":"NU" + }, + { + "label":"Norfolk Island", + "value":"NF" + }, + { + "label":"Northern Mariana Islands", + "value":"MP" + }, + { + "label":"Norway", + "value":"NO" + }, + { + "label":"Oman", + "value":"OM" + }, + { + "label":"Pakistan", + "value":"PK" + }, + { + "label":"Palau", + "value":"PW" + }, + { + "label":"Palestinian Territories", + "value":"PS" + }, + { + "label":"Panama", + "value":"PA" + }, + { + "label":"Papua New Guinea", + "value":"PG" + }, + { + "label":"Paraguay", + "value":"PY" + }, + { + "label":"Peru", + "value":"PE" + }, + { + "label":"Philippines", + "value":"PH" + }, + { + "label":"Pitcairn Islands", + "value":"PN" + }, + { + "label":"Poland", + "value":"PL" + }, + { + "label":"Portugal", + "value":"PT" + }, + { + "label":"Puerto Rico", + "value":"PR" + }, + { + "label":"Qatar", + "value":"QA" + }, + { + "label":"Réunion", + "value":"RE" + }, + { + "label":"Romania", + "value":"RO" + }, + { + "label":"Russia", + "value":"RU" + }, + { + "label":"Rwanda", + "value":"RW" + }, + { + "label":"St. Kitts & Nevis", + "value":"KN" + }, + { + "label":"St. Lucia", + "value":"LC" + }, + { + "label":"St. Martin", + "value":"MF" + }, + { + "label":"St. Vincent & Grenadines", + "value":"VC" + }, + { + "label":"Samoa", + "value":"WS" + }, + { + "label":"San Marino", + "value":"SM" + }, + { + "label":"São Tomé & Príncipe", + "value":"ST" + }, + { + "label":"Saudi Arabia", + "value":"SA" + }, + { + "label":"Senegal", + "value":"SN" + }, + { + "label":"Serbia", + "value":"RS" + }, + { + "label":"Seychelles", + "value":"SC" + }, + { + "label":"Sierra Leone", + "value":"SL" + }, + { + "label":"Singapore", + "value":"SG" + }, + { + "label":"Sint Maarten", + "value":"SX" + }, + { + "label":"Slovakia", + "value":"SK" + }, + { + "label":"Slovenia", + "value":"SI" + }, + { + "label":"Solomon Islands", + "value":"SB" + }, + { + "label":"South Africa", + "value":"ZA" + }, + { + "label":"South Georgia & South Sandwich Islands", + "value":"GS" + }, + { + "label":"South Sudan", + "value":"SS" + }, + { + "label":"Spain", + "value":"ES" + }, + { + "label":"Sri Lanka", + "value":"LK" + }, + { + "label":"St. Barthélemy", + "value":"BL" + }, + { + "label":"St. Helena", + "value":"SH" + }, + { + "label":"St. Pierre & Miquelon", + "value":"PM" + }, + { + "label":"Suriname", + "value":"SR" + }, + { + "label":"Svalbard & Jan Mayen", + "value":"SJ" + }, + { + "label":"Eswatini", + "value":"SZ" + }, + { + "label":"Sweden", + "value":"SE" + }, + { + "label":"Switzerland", + "value":"CH" + }, + { + "label":"Taiwan", + "value":"TW" + }, + { + "label":"Tajikistan", + "value":"TJ" + }, + { + "label":"Tanzania", + "value":"TZ" + }, + { + "label":"Thailand", + "value":"TH" + }, + { + "label":"Togo", + "value":"TG" + }, + { + "label":"Tokelau", + "value":"TK" + }, + { + "label":"Tonga", + "value":"TO" + }, + { + "label":"Trinidad & Tobago", + "value":"TT" + }, + { + "label":"Tunisia", + "value":"TN" + }, + { + "label":"Turkey", + "value":"TR" + }, + { + "label":"Turkmenistan", + "value":"TM" + }, + { + "label":"Turks & Caicos Islands", + "value":"TC" + }, + { + "label":"Tuvalu", + "value":"TV" + }, + { + "label":"Uganda", + "value":"UG" + }, + { + "label":"Ukraine", + "value":"UA" + }, + { + "label":"United Arab Emirates", + "value":"AE" + }, + { + "label":"United Kingdom", + "value":"GB" + }, + { + "label":"United States", + "value":"US" + }, + { + "label":"U.S. Outlying Islands", + "value":"UM" + }, + { + "label":"Uruguay", + "value":"UY" + }, + { + "label":"Uzbekistan", + "value":"UZ" + }, + { + "label":"Vanuatu", + "value":"VU" + }, + { + "label":"Vatican City", + "value":"VA" + }, + { + "label":"Venezuela", + "value":"VE" + }, + { + "label":"Vietnam", + "value":"VN" + }, + { + "label":"British Virgin Islands", + "value":"VG" + }, + { + "label":"U.S. Virgin Islands", + "value":"VI" + }, + { + "label":"Wallis & Futuna", + "value":"WF" + }, + { + "label":"Western Sahara", + "value":"EH" + }, + { + "label":"Zambia", + "value":"ZM" + } + ], + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"ADDRESS", + "value":"CA", + "dataType":"TEXT", + "isRequired":true, + "isEditable":true, + "label":"State/Province", + "name":"stateProvince", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\-().,'\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{2,50}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"ADDRESS", + "value":"1234 IndividualAddress St", + "dataType":"TEXT", + "isRequired":true, + "isEditable":true, + "label":"Address Line 1", + "name":"addressLine1", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\/\\-:().,#;'°&\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{2,100}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"ADDRESS", + "value":"1234 AddressLineTwo St", + "dataType":"TEXT", + "isRequired":false, + "isEditable":true, + "label":"Address Line 2", + "name":"addressLine2", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\/\\-:().,#;'°&\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{2,100}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"ADDRESS", + "value":"Test", + "dataType":"TEXT", + "isRequired":true, + "isEditable":true, + "label":"City", + "name":"city", + "placeholder":"", + "regularExpression":"^[\\sa-zA-Z0-9\\-().,'\\u00C0-\\u00FF\\u0100-\\u017F\\u0180-\\u024F]{2,50}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + }, + { + "category":"ADDRESS", + "value":"12345", + "dataType":"TEXT", + "isRequired":true, + "isEditable":true, + "label":"Zip/Postal Code", + "name":"postalCode", + "placeholder":"", + "regularExpression":"^(?![\\-]+$)[\\sa-zA-Z0-9\\-]{2,16}$", + "validationMessage":{ + "length":"", + "pattern":"is invalid length or format.", + "empty":"You must provide a value for this field" + }, + "fieldValueMasked":false + } + ] + } + ] + } + } + ] + } + } +} diff --git a/Tests/Responses/TransferMethodUpdateConfigurationFieldsVenmoResponse.json b/Tests/Responses/TransferMethodUpdateConfigurationFieldsVenmoResponse.json new file mode 100644 index 00000000..cb00a90e --- /dev/null +++ b/Tests/Responses/TransferMethodUpdateConfigurationFieldsVenmoResponse.json @@ -0,0 +1,46 @@ +{ + "data": { + "transferMethodUpdateUIConfigurations": { + "nodes": [ + { + "country": "US", + "currency": "USD", + "transferMethodType": "VENMO_ACCOUNT", + "profile": "INDIVIDUAL", + "fieldGroups": { + "nodes": [ + { + "group": "ACCOUNT_INFORMATION", + "isEditable": true, + "instruction": { + }, + "fields": [ + { + "category": "ACCOUNT", + "value": "5555555555", + "dataType": "TEXT", + "isRequired": true, + "isEditable": true, + "label": "Mobile Number", + "maxLength": 10, + "minLength": 10, + "name": "accountId", + "placeholder": "", + "regularExpression": "^([0-9]{10})$", + "validationMessage": { + "length": "The exact length of this field is 10.", + "pattern": "is invalid. The number you provided is not a valid US mobile number. Please use this format: 5555555555", + "empty": "You must provide a value for this field" + }, + "fieldValueMasked": false + } + ] + } + ] + } + } + ] + } + } +} + diff --git a/Tests/TransferMethod/HyperwalletBankAccountTests.swift b/Tests/TransferMethod/HyperwalletBankAccountTests.swift index 4aadc124..e616d07c 100644 --- a/Tests/TransferMethod/HyperwalletBankAccountTests.swift +++ b/Tests/TransferMethod/HyperwalletBankAccountTests.swift @@ -143,7 +143,7 @@ class HyperwalletBankAccountIndividualTests: XCTestCase { transferMethodType: "BANK_ACCOUNT") .bankAccountId("12345") .branchId("123456") - .bankAccountPurpose(.checking) + .bankAccountPurpose("CHECKING") .build() Hyperwallet.shared.createBankAccount(account: bankAccount, completion: { (result, error) in @@ -332,7 +332,7 @@ class HyperwalletBankAccountIndividualTests: XCTestCase { // Then XCTAssertNil(errorResponse, "The `errorResponse` should be nil") XCTAssertNotNil(bankAccountList, "The `bankAccountList` should not be nil") - XCTAssertEqual(bankAccountList?.count, 204, "The `count` should be 204") + XCTAssertEqual(bankAccountList?.count, 2, "The `count` should be 2") XCTAssertNotNil(bankAccountList?.data, "The `data` should be not nil") XCTAssertNotNil(bankAccountList?.links, "The `links` should be not nil") @@ -386,8 +386,8 @@ private extension HyperwalletBankAccountIndividualTests { .branchName("XYZ") .bankId("123") .bankName("ABC") - .bankAccountRelationship(.self) - .bankAccountPurpose(.checking) + .bankAccountRelationship("SELF") + .bankAccountPurpose("CHECKING") .intermediaryBankAccountId("123") .intermediaryBankId("12675") .passportId("112323") @@ -395,11 +395,11 @@ private extension HyperwalletBankAccountIndividualTests { .middleName("Good") .lastName("Guy") .countryOfBirth("US") - .gender(.male) + .gender("MALE") .driversLicenseId("1234") .employerId("1234") .governmentId("12898") - .governmentIdType(.passport) + .governmentIdType("PASSPORT") .phoneNumber("604-345-1777") .mobileNumber("604-345-1888") .dateOfBirth("1991-01-01") @@ -420,13 +420,13 @@ private extension HyperwalletBankAccountIndividualTests { transferMethodType: "BANK_ACCOUNT") .bankAccountId("7861012345") .branchId("102000021") - .bankAccountRelationship(.ownCompany) - .bankAccountPurpose(.checking) - .businessContactRole(.owner) + .bankAccountRelationship("OWN_COMPANY") + .bankAccountPurpose("CHECKING") + .businessContactRole("OWNER") .businessRegistrationCountry("US") .businessRegistrationId("1234") .businessRegistrationStateProvince("WA") - .businessType(.corporation) + .businessType("CORPORATION") .businessName("US BANK NA") .phoneNumber("604-345-1777") .mobileNumber("604-345-1888") @@ -447,8 +447,8 @@ private extension HyperwalletBankAccountIndividualTests { transferMethodType: "WIRE_ACCOUNT") .bankAccountId("675825207") .branchId("026009593") - .bankAccountRelationship(.self) - .bankAccountPurpose(.checking) + .bankAccountRelationship("SELF") + .bankAccountPurpose("CHECKING") .firstName("Tommy") .lastName("Gray") .phoneNumber("604-345-1777") @@ -483,13 +483,13 @@ private extension HyperwalletBankAccountIndividualTests { .bankName("US BANK NA") .branchId("026009593") .bankAccountId("675825208") - .bankAccountRelationship(.ownCompany) - .bankAccountPurpose(.checking) + .bankAccountRelationship("OWN_COMPANY") + .bankAccountPurpose("") .businessName("Some company") .businessRegistrationId("123455511") .businessRegistrationStateProvince("BC") .businessRegistrationCountry("CA") - .businessContactRole(.owner) + .businessContactRole("OWNER") .phoneNumber("604-345-1777") .mobileNumber("604-345-1888") .country("US") @@ -520,11 +520,9 @@ private extension HyperwalletBankAccountIndividualTests { XCTAssertEqual(bankAccountResponse?.profileType, "BUSINESS") XCTAssertEqual(bankAccountResponse?.bankAccountId, "7861012345") XCTAssertEqual(bankAccountResponse?.branchId, "102000021") - - verifyRelationship(.ownCompany, in: bankAccountResponse) - verifyPurpose(.checking, in: bankAccountResponse) - verifyBusinessType(.corporation, in: bankAccountResponse) - + XCTAssertEqual(bankAccountResponse?.bankAccountRelationship, "OWN_COMPANY") + XCTAssertEqual(bankAccountResponse?.bankAccountPurpose, "CHECKING") + XCTAssertEqual(bankAccountResponse?.businessType, "CORPORATION") XCTAssertEqual(bankAccountResponse?.businessName, "US BANK NA") XCTAssertEqual(bankAccountResponse?.phoneNumber, "604-345-1777") XCTAssertEqual(bankAccountResponse?.mobileNumber, "604-345-1888") @@ -542,12 +540,9 @@ private extension HyperwalletBankAccountIndividualTests { XCTAssertNotNil(bankAccountResponse?.getFields()) XCTAssertEqual(bankAccountResponse?.bankAccountId, "675825206") XCTAssertEqual(bankAccountResponse?.branchId, "026009593") - - verifyRelationship(.self, in: bankAccountResponse) - verifyPurpose(.checking, in: bankAccountResponse) - verifyGender(.male, in: bankAccountResponse) - verifyGovernmentIdType(.passport, in: bankAccountResponse) - + XCTAssertEqual(bankAccountResponse?.bankAccountRelationship, "SELF") + XCTAssertEqual(bankAccountResponse?.bankAccountPurpose, "CHECKING") + XCTAssertEqual(bankAccountResponse?.gender, "MALE") XCTAssertEqual(bankAccountResponse?.firstName, "Some") XCTAssertEqual(bankAccountResponse?.middleName, "Good") XCTAssertEqual(bankAccountResponse?.lastName, "Guy") @@ -575,10 +570,8 @@ private extension HyperwalletBankAccountIndividualTests { XCTAssertNotNil(wireAccountResponse?.getFields()) XCTAssertEqual(wireAccountResponse?.bankAccountId, "675825207") XCTAssertEqual(wireAccountResponse?.branchId, "026009593") - - verifyRelationship(.self, in: wireAccountResponse) - verifyPurpose(.checking, in: wireAccountResponse) - + XCTAssertEqual(wireAccountResponse?.bankAccountRelationship, "SELF") + XCTAssertEqual(wireAccountResponse?.bankAccountPurpose, "CHECKING") XCTAssertEqual(wireAccountResponse?.firstName, "Tommy") XCTAssertEqual(wireAccountResponse?.lastName, "Gray") XCTAssertEqual(wireAccountResponse?.phoneNumber, "604-345-1777") @@ -616,11 +609,9 @@ private extension HyperwalletBankAccountIndividualTests { XCTAssertEqual(bankAccountResponse?.branchId, "026009593") XCTAssertEqual(bankAccountResponse?.bankId, "13254687") XCTAssertEqual(bankAccountResponse?.branchId, "026009593") - - verifyRelationship(.ownCompany, in: bankAccountResponse) - verifyPurpose(.checking, in: bankAccountResponse) - verifyRole(.owner, in: bankAccountResponse) - + XCTAssertEqual(bankAccountResponse?.bankAccountRelationship, "OWN_COMPANY") + XCTAssertEqual(bankAccountResponse?.bankAccountPurpose, "CHECKING") + XCTAssertEqual(bankAccountResponse?.businessContactRole, "OWNER") XCTAssertEqual(bankAccountResponse?.businessName, "Some company") XCTAssertEqual(bankAccountResponse?.businessRegistrationId, "123455511") XCTAssertEqual(bankAccountResponse?.businessRegistrationCountry, "CA") @@ -650,34 +641,4 @@ private extension HyperwalletBankAccountIndividualTests { XCTAssertEqual(bankAccountResponse?.type, "WIRE_ACCOUNT") XCTAssertEqual(bankAccountResponse?.bankName, "Bank of America NA") } - - func verifyRelationship(_ relationship: HyperwalletBankAccount.RelationshipType, - in bankAccountResponse: HyperwalletBankAccount?) { - XCTAssertEqual(bankAccountResponse?.bankAccountRelationship, relationship.rawValue) - } - - func verifyPurpose(_ purpose: HyperwalletBankAccount.PurposeType, - in bankAccountResponse: HyperwalletBankAccount?) { - XCTAssertEqual(bankAccountResponse?.bankAccountPurpose, purpose.rawValue) - } - - func verifyRole(_ role: HyperwalletBankAccount.BusinessContactRole, - in bankAccountResponse: HyperwalletBankAccount?) { - XCTAssertEqual(bankAccountResponse?.businessContactRole, role.rawValue) - } - - func verifyBusinessType(_ type: HyperwalletBankAccount.BusinessType, - in bankAccountResponse: HyperwalletBankAccount?) { - XCTAssertEqual(bankAccountResponse?.businessType, type.rawValue) - } - - func verifyGender(_ gender: HyperwalletBankAccount.Gender, - in bankAccountResponse: HyperwalletBankAccount?) { - XCTAssertEqual(bankAccountResponse?.gender, gender.rawValue) - } - - func verifyGovernmentIdType(_ governmentIdType: HyperwalletBankAccount.GovernmentIdType, - in bankAccountResponse: HyperwalletBankAccount?) { - XCTAssertEqual(bankAccountResponse?.governmentIdType, governmentIdType.rawValue) - } } diff --git a/Tests/TransferMethod/HyperwalletPaperCheckTests.swift b/Tests/TransferMethod/HyperwalletPaperCheckTests.swift new file mode 100644 index 00000000..028ef19c --- /dev/null +++ b/Tests/TransferMethod/HyperwalletPaperCheckTests.swift @@ -0,0 +1,423 @@ +import Hippolyte +@testable import HyperwalletSDK +import XCTest + +class HyperwalletPaperCheckTests: XCTestCase { + override func setUp() { + Hyperwallet.setup(HyperwalletTestHelper.authenticationProvider) + } + + override func tearDown() { + if Hippolyte.shared.isStarted { + Hippolyte.shared.stop() + } + } + + func testCreatePaperCheck_individual_success() { + // Given + let expectation = self.expectation(description: "Create paper check completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "PaperCheckIndividualResponse") + let url = String(format: "%@/paper-checks", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckResponse: HyperwalletPaperCheck? + var errorResponse: HyperwalletErrorType? + + // When + let paperCheck = buildIndividualPaperCheck() + + Hyperwallet.shared.createPaperCheck(account: paperCheck, completion: { (result, error) in + paperCheckResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(paperCheck) + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + + verifyIndividualResponse(paperCheckResponse) + } + + func testCreatePaperCheck_business_success() { + // Given + let expectation = self.expectation(description: "Create paper check completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "PaperCheckBusinessResponse") + let url = String(format: "%@/paper-checks", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckResponse: HyperwalletPaperCheck? + var errorResponse: HyperwalletErrorType? + + // When + let paperCheck = buildBusinessPaperCheck() + + Hyperwallet.shared.createPaperCheck(account: paperCheck, completion: { (result, error) in + paperCheckResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(paperCheck) + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + + verifyBusinessResponse(paperCheckResponse) + } + + func testCreatePaperCheck_missingMandatoryField_returnBadRequest() { + // Given + let expectation = self.expectation(description: "Create paper check failed") + let response = + HyperwalletTestHelper.badRequestHTTPResponse(for: "PaperCheckErrorResponseWithMissingStateProvince") + let url = String(format: "%@/paper-checks", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckResponse: HyperwalletPaperCheck? + var errorResponse: HyperwalletErrorType? + + // When + let paperCheck = HyperwalletPaperCheck.Builder(transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "INDIVIDUAL", + transferMethodType: "PAPER_CHECK") + .build() + + Hyperwallet.shared.createPaperCheck(account: paperCheck, completion: { (result, error) in + paperCheckResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(errorResponse, "The `errorResponse` should not be nil") + XCTAssertNil(paperCheckResponse) + XCTAssertEqual(errorResponse?.getHttpCode(), 400) + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.fieldName, "stateProvince") + } + + func testGetPaperCheck_success() { + // Given + let expectation = self.expectation(description: "Get paper check completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "PaperCheckIndividualResponse") + let url = String(format: "%@/paper-checks/trm-12345", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckResponse: HyperwalletPaperCheck? + var errorResponse: HyperwalletErrorType? + + // When + Hyperwallet.shared.getPaperCheck(transferMethodToken: "trm-12345", completion: { (result, error) in + paperCheckResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(paperCheckResponse?.getFields()) + XCTAssertEqual(paperCheckResponse?.shippingMethod, "STANDARD") + } + + func testUpdatePaperCheck_success() { + // Given + let expectation = self.expectation(description: "Update paper check completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "PaperCheckIndividualResponse") + let url = String(format: "%@/paper-checks/trm-12345", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPutRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckResponse: HyperwalletPaperCheck? + var errorResponse: HyperwalletErrorType? + + // When + let paperCheck = HyperwalletPaperCheck + .Builder(token: "trm-12345") + .shippingMethod("STANDARD") + .build() + + Hyperwallet.shared.updatePaperCheck(account: paperCheck, completion: { (result, error) in + paperCheckResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(paperCheckResponse?.getFields()) + XCTAssertEqual(paperCheckResponse?.shippingMethod, "STANDARD") + } + + func testUpdatePaperCheck_invalidStateProvince() { + // Given + let expectation = self.expectation(description: "Update paper check failed") + let response = + HyperwalletTestHelper.badRequestHTTPResponse(for: "PaperCheckErrorResponseWithMissingStateProvince") + let url = String(format: "%@/paper-checks/trm-12345", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPutRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckResponse: HyperwalletPaperCheck? + var errorResponse: HyperwalletErrorType? + + // When + let paperCheck = HyperwalletPaperCheck + .Builder(token: "trm-12345") + .shippingMethod("STANDARD") + .build() + + Hyperwallet.shared.updatePaperCheck(account: paperCheck, completion: { (result, error) in + paperCheckResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(errorResponse, "The `errorResponse` should not be nil") + XCTAssertNil(paperCheckResponse, "The paperCheckResponse should be nil") + XCTAssertEqual(errorResponse?.getHttpCode(), 400) + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.fieldName, "stateProvince") + } + + func testDeactivatePaperCheck_success() { + // Given + let expectation = self.expectation(description: "Deactivate paper check completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "StatusTransitionMockedResponseSuccess") + let url = String(format: "%@/paper-checks/trm-12345/status-transitions", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var statusTransitionResponse: HyperwalletStatusTransition? + var errorResponse: HyperwalletErrorType? + + // When + Hyperwallet.shared.deactivatePaperCheck(transferMethodToken: "trm-12345", + notes: "deactivate paper check", + completion: { (result, error) in + statusTransitionResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(statusTransitionResponse) + XCTAssertEqual(statusTransitionResponse?.transition, HyperwalletStatusTransition.Status.deactivated) + } + + func testDeactivatePaperCheck_invalidTransition() { + // Given + let expectation = self.expectation(description: "Deactivate paper check failed") + let response = HyperwalletTestHelper + .badRequestHTTPResponse(for: "StatusTransitionMockedResponseInvalidTransition") + let url = String(format: "%@/paper-checks/trm-12345/status-transitions", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var statusTransitionResponse: HyperwalletStatusTransition? + var errorResponse: HyperwalletErrorType? + + // When + Hyperwallet.shared.deactivatePaperCheck(transferMethodToken: "trm-12345", + notes: "deactivate paper check", + completion: { (result, error) in + statusTransitionResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(errorResponse, "The `errorResponse` should not be nil") + XCTAssertNil(statusTransitionResponse, "The statusTransitionResponse should be nil") + XCTAssertEqual(errorResponse?.getHttpCode(), 400) + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.code, "INVALID_FIELD_VALUE") + } + + func testListPaperChecks_success() { + // Given + let expectation = self.expectation(description: "List paper check completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "ListPaperCheckResponse") + let url = String(format: "%@/paper-checks?+", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckList: HyperwalletPageList? + var errorResponse: HyperwalletErrorType? + + // When + let paperCheckQueryParam = HyperwalletPaperCheckQueryParam() + paperCheckQueryParam.status = HyperwalletPaperCheckQueryParam.QueryStatus.deActivated.rawValue + paperCheckQueryParam.type = HyperwalletPaperCheckQueryParam.QueryType.paperCheck.rawValue + paperCheckQueryParam.sortBy = + HyperwalletPaperCheckQueryParam.QuerySortable.ascendantCreatedOn.rawValue + paperCheckQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-15T00:30:11") + paperCheckQueryParam.createdBefore = + ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-18T00:30:11") + + Hyperwallet.shared.listPaperChecks(queryParam: paperCheckQueryParam) { (result, error) in + paperCheckList = result + errorResponse = error + expectation.fulfill() + } + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(paperCheckList, "The `PaperCheckList` should not be nil") + XCTAssertEqual(paperCheckList?.count, 2, "The `count` should be 2") + XCTAssertNotNil(paperCheckList?.data, "The `data` should be not nil") + + XCTAssertNotNil(paperCheckList?.links, "The `links` should be not nil") + let linkNext = paperCheckList?.links?.first { $0.params?.rel == "next" } + XCTAssertNotNil(linkNext?.href) + + let paperCheck = paperCheckList?.data?.first + XCTAssertEqual(paperCheck?.type, "PAPER_CHECK") + XCTAssertEqual(paperCheck?.token, "trm-001") + XCTAssertEqual(paperCheck?.dateOfBirth, "1991-01-01") + } + + func testListPaperChecks_emptyResult() { + // Given + let expectation = self.expectation(description: "List paper check completed") + let response = HyperwalletTestHelper.noContentHTTPResponse() + let url = String(format: "%@/paper-checks?+", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var paperCheckList: HyperwalletPageList? + var errorResponse: HyperwalletErrorType? + let paperCheckQueryParam = HyperwalletPaperCheckQueryParam() + paperCheckQueryParam.status = HyperwalletPaperCheckQueryParam.QueryStatus.activated.rawValue + paperCheckQueryParam.type = HyperwalletPaperCheckQueryParam.QueryType.wireAccount.rawValue + + // When + Hyperwallet.shared.listPaperChecks(queryParam: paperCheckQueryParam) { (result, error) in + paperCheckList = result + errorResponse = error + expectation.fulfill() + } + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNil(paperCheckList, "The `PaperCheckList` should be nil") + } +} + +private extension HyperwalletPaperCheckTests { + func buildIndividualPaperCheck() -> HyperwalletPaperCheck { + HyperwalletPaperCheck + .Builder(transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "INDIVIDUAL", + transferMethodType: "{PAPER_CHECK}") + .bankAccountRelationship("SELF") + .passportId("112323") + .firstName("Some") + .middleName("Good") + .lastName("Guy") + .countryOfBirth("US") + .gender("MALE") + .driversLicenseId("1234") + .employerId("1234") + .governmentId("12898") + .governmentIdType("PASSPORT") + .phoneNumber("604-345-1777") + .mobileNumber("604-345-1888") + .dateOfBirth("1991-01-01") + .addressLine1("575 Market Street") + .addressLine2("57 Market Street") + .city("San Francisco") + .stateProvince("CA") + .country("US") + .postalCode("94105") + .shippingMethod("EXPEDITED") + .build() + } + + func buildBusinessPaperCheck() -> HyperwalletPaperCheck { + HyperwalletPaperCheck + .Builder(transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "BUSINESS", + transferMethodType: "PAPER_CHECK") + .bankAccountRelationship("OWN_COMPANY") + .businessContactRole("OWNER") + .businessRegistrationCountry("US") + .businessRegistrationId("1234") + .businessRegistrationStateProvince("WA") + .businessType("CORPORATION") + .businessName("US BANK NA") + .phoneNumber("604-345-1777") + .mobileNumber("604-345-1888") + .country("US") + .stateProvince("WA") + .addressLine1("1234, Broadway") + .addressLine2("57 Market Street") + .city("Test City") + .postalCode("12345") + .shippingMethod("EXPEDITED") + .build() + } +} + +private extension HyperwalletPaperCheckTests { + func verifyBusinessResponse(_ paperCheckResponse: HyperwalletPaperCheck?) { + XCTAssertNotNil(paperCheckResponse?.getFields()) + XCTAssertEqual(paperCheckResponse?.transferMethodCountry, "US") + XCTAssertEqual(paperCheckResponse?.transferMethodCurrency, "USD") + XCTAssertEqual(paperCheckResponse?.profileType, "BUSINESS") + XCTAssertEqual(paperCheckResponse?.bankAccountRelationship, "OWN_COMPANY") + XCTAssertEqual(paperCheckResponse?.businessType, "CORPORATION") + XCTAssertEqual(paperCheckResponse?.businessName, "US BANK NA") + XCTAssertEqual(paperCheckResponse?.phoneNumber, "604-345-1777") + XCTAssertEqual(paperCheckResponse?.mobileNumber, "604-345-1888") + XCTAssertEqual(paperCheckResponse?.country, "US") + XCTAssertEqual(paperCheckResponse?.stateProvince, "WA") + XCTAssertEqual(paperCheckResponse?.addressLine1, "1234, Broadway") + XCTAssertEqual(paperCheckResponse?.addressLine2, "57 Market Street") + XCTAssertEqual(paperCheckResponse?.city, "Test City") + XCTAssertEqual(paperCheckResponse?.postalCode, "12345") + XCTAssertEqual(paperCheckResponse?.profileType, "BUSINESS") + XCTAssertEqual(paperCheckResponse?.type, "PAPER_CHECK") + } + + func verifyIndividualResponse(_ paperCheckResponse: HyperwalletPaperCheck?) { + XCTAssertNotNil(paperCheckResponse?.getFields()) + XCTAssertEqual(paperCheckResponse?.bankAccountRelationship, "SELF") + XCTAssertEqual(paperCheckResponse?.gender, "MALE") + XCTAssertEqual(paperCheckResponse?.governmentIdType, "PASSPORT") + XCTAssertEqual(paperCheckResponse?.firstName, "Some") + XCTAssertEqual(paperCheckResponse?.middleName, "Good") + XCTAssertEqual(paperCheckResponse?.lastName, "Guy") + XCTAssertEqual(paperCheckResponse?.phoneNumber, "604-345-1777") + XCTAssertEqual(paperCheckResponse?.mobileNumber, "604-345-1888") + XCTAssertEqual(paperCheckResponse?.dateOfBirth, "1991-01-01") + XCTAssertEqual(paperCheckResponse?.addressLine1, "575 Market Street") + XCTAssertEqual(paperCheckResponse?.addressLine2, "57 Market Street") + XCTAssertEqual(paperCheckResponse?.city, "San Francisco") + XCTAssertEqual(paperCheckResponse?.stateProvince, "CA") + XCTAssertEqual(paperCheckResponse?.country, "US") + XCTAssertEqual(paperCheckResponse?.postalCode, "94105") + XCTAssertEqual(paperCheckResponse?.profileType, "INDIVIDUAL") + XCTAssertEqual(paperCheckResponse?.type, "PAPER_CHECK") + XCTAssertEqual(paperCheckResponse?.countryOfBirth, "US") + XCTAssertEqual(paperCheckResponse?.driversLicenseId, "1234") + XCTAssertEqual(paperCheckResponse?.employerId, "1234") + XCTAssertEqual(paperCheckResponse?.governmentId, "12898") + XCTAssertEqual(paperCheckResponse?.passportId, "112323") + } +} diff --git a/Tests/TransferMethod/HyperwalletTransferMethodTests.swift b/Tests/TransferMethod/HyperwalletTransferMethodTests.swift index 35b76538..43d19ebb 100644 --- a/Tests/TransferMethod/HyperwalletTransferMethodTests.swift +++ b/Tests/TransferMethod/HyperwalletTransferMethodTests.swift @@ -54,7 +54,7 @@ class HyperwalletTransferMethodTests: XCTestCase { XCTAssertNotNil(linkNext?.href) // check the bank card - let bankCard = transferMethods?.data?.first { ($0.type ?? "") == "BANK_CARD" } + let bankCard = transferMethods?.data?.first { ($0.type ?? "") == "BANK_CARD" } XCTAssertEqual(bankCard?.type, "BANK_CARD") XCTAssertEqual(bankCard?.token, "trm-00002") @@ -72,7 +72,7 @@ class HyperwalletTransferMethodTests: XCTestCase { XCTAssertEqual(bankCard?.getField(cardBrandFieldName), "VISA") // check the bank account - let bankAccount = transferMethods?.data?.first { ($0.type ?? "") == "BANK_ACCOUNT" } + let bankAccount = transferMethods?.data?.first { ($0.type ?? "") == "BANK_ACCOUNT" } XCTAssertEqual(bankAccount?.type, "BANK_ACCOUNT") XCTAssertEqual(bankAccount?.token, "trm-00001")