diff --git a/.travis.yml b/.travis.yml index 13ce9a63..595d3181 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: swift -osx_image: xcode11.1 +osx_image: xcode11.7 os: osx branches: only: @@ -15,7 +15,7 @@ env: - IOS_FRAMEWORK_SCHEME="HyperwalletSDK" matrix: - - ios_version='13.1' ios_device='iPhone 11' scheme="$IOS_FRAMEWORK_SCHEME" platform='iOS Simulator' + - ios_version='13.7' ios_device='iPhone 11' scheme="$IOS_FRAMEWORK_SCHEME" platform='iOS Simulator' before_install: # Boot the emulator by ID - | diff --git a/CHANGELOG.md b/CHANGELOG.md index a998ed56..fedf0577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +[1.0.0-beta10](https://github.com/hyperwallet/hyperwallet-ios-sdk/releases/tag/1.0.0-beta10) +------------------- +- Added Venmo as a Transfer method +- Added support for List Prepaid Card Balances +- Enhancements + + [1.0.0-beta09](https://github.com/hyperwallet/hyperwallet-ios-sdk/releases/tag/1.0.0-beta09) ------------------- - Increased API response timeout diff --git a/HyperwalletSDK.podspec b/HyperwalletSDK.podspec index d7cd858f..e3f2c203 100644 --- a/HyperwalletSDK.podspec +++ b/HyperwalletSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'HyperwalletSDK' - spec.version = '1.0.0-beta09' + spec.version = '1.0.0-beta10' 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 1d19cc34..d280634a 100644 --- a/HyperwalletSDK.xcodeproj/project.pbxproj +++ b/HyperwalletSDK.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 2B5433FD229EF11A00F900D2 /* ListPayPalAccountResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 07C00B542278EFB200E0930C /* ListPayPalAccountResponse.json */; }; 2B5433FE229EF11F00F900D2 /* ListUserReceiptResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 2B5433F8229EDDED00F900D2 /* ListUserReceiptResponse.json */; }; 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 */; }; 4A77C703229BD74A00DA644D /* HyperwalletReceipt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A77C702229BD74A00DA644D /* HyperwalletReceipt.swift */; }; 4A88E43E229D438700CD857B /* HyperwalletReceiptQueryParam.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A88E43D229D438700CD857B /* HyperwalletReceiptQueryParam.swift */; }; @@ -41,9 +42,12 @@ 64D2493C22BD011600561C14 /* HyperwalletTransferTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64D2493B22BD011600561C14 /* HyperwalletTransferTests.swift */; }; 64D2493F22BD0FA300561C14 /* CreateTransferResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 64D2493E22BD0FA300561C14 /* CreateTransferResponse.json */; }; 9807B74522642BEA0028A280 /* OSLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9807B74422642BEA0028A280 /* OSLog.swift */; }; + 980B9AE7251C0A2400653D1C /* PrepaidCardResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 980B9AE5251C052600653D1C /* PrepaidCardResponse.json */; }; 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 */; }; + B062EAC060764557C3C10497 /* ListPrepaidCardBalancesResponseSuccess.json in Resources */ = {isa = PBXBuildFile; fileRef = B062E2EA3710B0D9432C055C /* ListPrepaidCardBalancesResponseSuccess.json */; }; + B062EDD6B61D1A2D118183F7 /* HyperwalletPrepaidCardBalanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B062ED9C3E0C8A8D1F1146DE /* HyperwalletPrepaidCardBalanceTests.swift */; }; 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 */; }; @@ -117,6 +121,17 @@ DBCA37BC225D6DD900CD4137 /* BankCardErrorResponseWithMissingCardNumber.json in Resources */ = {isa = PBXBuildFile; fileRef = DBCA37BB225D6DD900CD4137 /* BankCardErrorResponseWithMissingCardNumber.json */; }; DBCA37BE225D6E1900CD4137 /* BankCardResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = DBCA37BD225D6E1900CD4137 /* BankCardResponse.json */; }; DBCA37C0225D6E3A00CD4137 /* TransferMethodMockedSuccessResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = DBCA37BF225D6E3A00CD4137 /* TransferMethodMockedSuccessResponse.json */; }; + E84381C0BBE7F7A6D9AD04E8 /* HyperwalletVenmoQueryParam.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8438F714A2ED30BE185DE8C /* HyperwalletVenmoQueryParam.swift */; }; + E84382073237BBFB9B03C00C /* VenmoAccountMissingAccountId.json in Resources */ = {isa = PBXBuildFile; fileRef = E8438A5AF96BD0809F4B8287 /* VenmoAccountMissingAccountId.json */; }; + E84382CC1BE536B23E3F8EEA /* VenmoAccountWrongFormatAccountId.json in Resources */ = {isa = PBXBuildFile; fileRef = E84381CE41DDB491C2F2B63D /* VenmoAccountWrongFormatAccountId.json */; }; + E84382D7D9B88D30117E833F /* HyperwalletVenmoAccountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84387C963FD99B5F8D69E49 /* HyperwalletVenmoAccountTests.swift */; }; + E843832E81E184EC95C632CA /* VenmoAccountList.json in Resources */ = {isa = PBXBuildFile; fileRef = E8438B2F7AA2659EA914914B /* VenmoAccountList.json */; }; + E84384B6EEE1B33A35A8A5E4 /* VenmoAccountList.json in Resources */ = {isa = PBXBuildFile; fileRef = E8438B2F7AA2659EA914914B /* VenmoAccountList.json */; }; + E84386A084517B13701D478D /* VenmoAccountResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = E843856BD0D7E5295973780D /* VenmoAccountResponse.json */; }; + E8438B2A7A266EEF5106635D /* VenmoAccountMissingAccountId.json in Resources */ = {isa = PBXBuildFile; fileRef = E8438A5AF96BD0809F4B8287 /* VenmoAccountMissingAccountId.json */; }; + 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 */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -146,6 +161,7 @@ 2B5433F8229EDDED00F900D2 /* ListUserReceiptResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ListUserReceiptResponse.json; sourceTree = ""; }; 2B5433FA229EDF0900F900D2 /* HyperwalletReceiptTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletReceiptTests.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 = ""; }; 4A77C702229BD74A00DA644D /* HyperwalletReceipt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletReceipt.swift; sourceTree = ""; }; 4A88E43D229D438700CD857B /* HyperwalletReceiptQueryParam.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletReceiptQueryParam.swift; sourceTree = ""; }; @@ -164,11 +180,14 @@ 64D2493B22BD011600561C14 /* HyperwalletTransferTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletTransferTests.swift; sourceTree = ""; }; 64D2493E22BD0FA300561C14 /* CreateTransferResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = CreateTransferResponse.json; sourceTree = ""; }; 9807B74422642BEA0028A280 /* OSLog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSLog.swift; sourceTree = ""; }; + 980B9AE5251C052600653D1C /* PrepaidCardResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PrepaidCardResponse.json; sourceTree = ""; }; 980C15DA2273BF91004C60D6 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; 98101DBA2238A2F000BA04CA /* HyperwalletSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = HyperwalletSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 98101DBE2238A2F000BA04CA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 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 = ""; }; + 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 = ""; }; B327ED8523C688A00007EF58 /* HyperwalletBalanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperwalletBalanceTests.swift; sourceTree = ""; }; @@ -243,6 +262,13 @@ DBCA37BB225D6DD900CD4137 /* BankCardErrorResponseWithMissingCardNumber.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BankCardErrorResponseWithMissingCardNumber.json; sourceTree = ""; }; DBCA37BD225D6E1900CD4137 /* BankCardResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BankCardResponse.json; sourceTree = ""; }; DBCA37BF225D6E3A00CD4137 /* TransferMethodMockedSuccessResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransferMethodMockedSuccessResponse.json; sourceTree = ""; }; + E84381CE41DDB491C2F2B63D /* VenmoAccountWrongFormatAccountId.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = VenmoAccountWrongFormatAccountId.json; sourceTree = ""; }; + E843856BD0D7E5295973780D /* VenmoAccountResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = VenmoAccountResponse.json; sourceTree = ""; }; + E84387C963FD99B5F8D69E49 /* HyperwalletVenmoAccountTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperwalletVenmoAccountTests.swift; sourceTree = ""; }; + E8438A5AF96BD0809F4B8287 /* VenmoAccountMissingAccountId.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = VenmoAccountMissingAccountId.json; sourceTree = ""; }; + 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 = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -399,6 +425,8 @@ DB1A03F5225D3DE40080C8D6 /* HyperwalletTransferMethodQueryParam.swift */, 07B1FE5F22C29BCD00F461D0 /* HyperwalletPrepaidCard.swift */, 07B1FE6122C2A11F00F461D0 /* HyperwalletPrepaidCardQueryParam.swift */, + E8438FACD77368B4A83CCA41 /* HyperwalletVenmoAccount.swift */, + E8438F714A2ED30BE185DE8C /* HyperwalletVenmoQueryParam.swift */, ); path = TransferMethod; sourceTree = ""; @@ -436,6 +464,7 @@ 0733FE2A2277C743000FB92A /* HyperwalletPayPalAccountTests.swift */, 07B1FE6622C2C67500F461D0 /* HyperwalletPrepaidCardTests.swift */, DBCA3773225D6A8D00CD4137 /* HyperwalletTransferMethodTests.swift */, + E84387C963FD99B5F8D69E49 /* HyperwalletVenmoAccountTests.swift */, ); path = TransferMethod; sourceTree = ""; @@ -472,6 +501,7 @@ children = ( B327ED7E23C66B6B0007EF58 /* HyperwalletBalance.swift */, B327ED8023C66D350007EF58 /* HyperwalletBalanceQueryParam.swift */, + 2EFBE4CC24FEB89800F5228A /* HyperwalletPrepaidCardBalanceQueryParam.swift */, ); path = Balance; sourceTree = ""; @@ -483,6 +513,8 @@ B327ED8823C691880007EF58 /* ListUserBalancesResponseWithCurrencyFilter.json */, B327ED8A23C6A5C60007EF58 /* ListUserBalancesResponseSuccess.json */, B327ED8C23C6B43E0007EF58 /* ListUserBalancesResponseSortCurrencyDesc.json */, + B062ED9C3E0C8A8D1F1146DE /* HyperwalletPrepaidCardBalanceTests.swift */, + B062E2EA3710B0D9432C055C /* ListPrepaidCardBalancesResponseSuccess.json */, ); path = Balance; sourceTree = ""; @@ -589,6 +621,7 @@ 07C00B57227A11CB00E0930C /* PayPalAccountResponseNotProfileEmail.json */, 07C00B502278EC3500E0930C /* PayPalAccountResponseWithInvalidEmail.json */, 07C00B092277D5CB00E0930C /* PayPalAccountResponseWithMissingEmail.json */, + 980B9AE5251C052600653D1C /* PrepaidCardResponse.json */, DBCA37A7225D6D1700CD4137 /* StatusTransitionMockedResponseInvalidTransition.json */, DBCA37A3225D6D1600CD4137 /* StatusTransitionMockedResponseSuccess.json */, DBCA37A9225D6D1700CD4137 /* TransferMethodConfigurationFieldsResponse.json */, @@ -596,6 +629,10 @@ DBCA37AD225D6D1700CD4137 /* TransferMethodConfigurationKeysResponse.json */, DBCA37AB225D6D1700CD4137 /* TransferMethodConfigurationKeysWithoutFeeResponse.json */, DBCA37BF225D6E3A00CD4137 /* TransferMethodMockedSuccessResponse.json */, + E843856BD0D7E5295973780D /* VenmoAccountResponse.json */, + E8438A5AF96BD0809F4B8287 /* VenmoAccountMissingAccountId.json */, + E84381CE41DDB491C2F2B63D /* VenmoAccountWrongFormatAccountId.json */, + E8438B2F7AA2659EA914914B /* VenmoAccountList.json */, ); path = Responses; sourceTree = ""; @@ -709,6 +746,10 @@ DB866F2A2261EE28003C41F6 /* README.md in Resources */, DB866F292261EE28003C41F6 /* LICENSE in Resources */, DB866F262261EE28003C41F6 /* Cartfile.resolved in Resources */, + E8438CA7F43C3CB6FD545187 /* VenmoAccountResponse.json in Resources */, + E84382073237BBFB9B03C00C /* VenmoAccountMissingAccountId.json in Resources */, + E8438DB98656EB3F69DE0776 /* VenmoAccountWrongFormatAccountId.json in Resources */, + E843832E81E184EC95C632CA /* VenmoAccountList.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -752,7 +793,13 @@ 641EBE9E2292E2B600D718F4 /* BankAccountBusinessResponse.json in Resources */, DBCA37B1225D6D1700CD4137 /* TransferMethodConfigurationGraphQlResponse.json in Resources */, DBCA37B4225D6D1700CD4137 /* StatusTransitionMockedResponseInvalidTransition.json in Resources */, + 980B9AE7251C0A2400653D1C /* PrepaidCardResponse.json in Resources */, B327ED8D23C6B43E0007EF58 /* ListUserBalancesResponseSortCurrencyDesc.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 */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -813,6 +860,7 @@ 9807B74522642BEA0028A280 /* OSLog.swift in Sources */, 4ADC55D7229E7291007B11CA /* ISO8601DateFormatter.swift in Sources */, DB1A03E3225D3DD80080C8D6 /* Hyperwallet.swift in Sources */, + 2EFBE4CD24FEB89800F5228A /* HyperwalletPrepaidCardBalanceQueryParam.swift in Sources */, DB1A040B225D3DE40080C8D6 /* HyperwalletBankCardQueryParam.swift in Sources */, DB1A03E0225D3DD80080C8D6 /* HTTPTransaction.swift in Sources */, DB1A040D225D3DE40080C8D6 /* HyperwalletStatusTransition.swift in Sources */, @@ -824,6 +872,8 @@ 07B1FE6022C29BCD00F461D0 /* HyperwalletPrepaidCard.swift in Sources */, 0733FE092277C191000FB92A /* HyperwalletPayPalAccount.swift in Sources */, DB1A03D9225D3DD80080C8D6 /* HTTPClient.swift in Sources */, + E8438C4BD714EB191BF7A98B /* HyperwalletVenmoAccount.swift in Sources */, + E84381C0BBE7F7A6D9AD04E8 /* HyperwalletVenmoQueryParam.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -855,6 +905,8 @@ 641324DB22954D4F00512816 /* HyperwalletBankAccountTests.swift in Sources */, DBCA3778225D6A8D00CD4137 /* HyperwalletBankCardTests.swift in Sources */, 2B5433FB229EDF0900F900D2 /* HyperwalletReceiptTests.swift in Sources */, + E84382D7D9B88D30117E833F /* HyperwalletVenmoAccountTests.swift in Sources */, + B062EDD6B61D1A2D118183F7 /* HyperwalletPrepaidCardBalanceTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1019,6 +1071,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; + TAG_VERSION = "1.0.0-beta09"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1048,6 +1101,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; + TAG_VERSION = "1.0.0-beta09"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/README.md b/README.md index 08b258bf..5fa90567 100644 --- a/README.md +++ b/README.md @@ -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-beta09" +github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta10" ``` ### CocoaPods Specify it in your Podfile: ```ruby -pod 'HyperwalletSDK', '~> 1.0.0-beta09' +pod 'HyperwalletSDK', '~> 1.0.0-beta10' ``` ## Initialization @@ -119,7 +119,7 @@ let payPalAccount = HyperwalletPayPalAccount.Builder(transferMethodCountry: "US" Hyperwallet.shared.createPayPalAccount(account: payPalAccount, completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletPayPalAccount in this case) will contain information about the user’s PayPal account + // On successful creation, response (HyperwalletPayPalAccount in this case) will contain information about the user’s PayPal account // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of PayPal account creation }) ``` @@ -127,7 +127,7 @@ Hyperwallet.shared.createPayPalAccount(account: payPalAccount, completion: { (re ### Get PayPal Account ```swift Hyperwallet.shared.getPayPalAccount(transferMethodToken: "123123", completion: { (result, error) in - // In case of successful, response (HyperwalletPayPalAccount? in this case) will contain information about the user’s PayPal account or nil if not exist. + // On success, response (HyperwalletPayPalAccount? in this case) will contain information about the user’s PayPal account or nil if not exist. // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure }) ``` @@ -140,7 +140,7 @@ let payPalAccount = HyperwalletPayPalAccount.Builder(token: "trm-12345") Hyperwallet.shared.updatePayPalAccount(account: payPalAccount, completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletPayPalAccount in this case) will contain information about the user’s PayPal account + // On successful update, response (HyperwalletPayPalAccount in this case) will contain information about the user’s PayPal account // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of PayPal account updating }) ``` @@ -149,7 +149,7 @@ Hyperwallet.shared.updatePayPalAccount(account: payPalAccount, completion: { (re ```swift Hyperwallet.shared.deactivatePayPalAccount(transferMethodToken: "trm-12345", notes: "deactivate PayPal account", completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletStatusTransition in this case) will contain information about the status transition + // 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 of PayPal account deactivation }) ``` @@ -157,17 +157,17 @@ Hyperwallet.shared.deactivatePayPalAccount(transferMethodToken: "trm-12345", not ### List PayPal Account ```swift let payPalQueryParam = HyperwalletPayPalAccountQueryParam() -payPalQueryParam.status = .activated -payPalQueryParam.sortBy = .ascendantCreatedOn +payPalQueryParam.status = HyperwalletPayPalAccountQueryParam.QueryStatus.activated.rawValue +payPalQueryParam.sortBy = HyperwalletTransferMethodQueryParam.QuerySortable.ascendantCreatedOn.rawValue -Hyperwallet.shared.listPayPalAccount(queryParam: payPalQueryParam) { (result, error) in +Hyperwallet.shared.listPayPalAccounts(queryParam: payPalQueryParam) { (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 } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let payPalAccounts = result?.data { for payPalAccount in payPalAccounts { print(payPalAccount.getField(fieldName: .token) ?? "") @@ -176,6 +176,71 @@ Hyperwallet.shared.listPayPalAccount(queryParam: payPalQueryParam) { (result, er } ``` +### Create Venmo Account +```swift +let venmoAccount = HyperwalletVenmoAccount.Builder(transferMethodCountry: "US", transferMethodCurrency: "USD") + .accountId("9876543210") + .build() + +Hyperwallet.shared.createVenmoAccount(account: venmoAccount, completion: { (result, error) in + // Code to handle successful response or error + // On successful creation, response (HyperwalletVenmoAccount in this case) will contain information about the user’s Venmo account + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of Venmo account creation +}) +``` + +### Get Venmo Account +```swift +Hyperwallet.shared.getVenmoAccount(transferMethodToken: "123123", completion: { (result, error) in + // On success, response (HyperwalletVenmoAccount? in this case) will contain information about the user’s Venmo account or nil if not exist. + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure +}) +``` + +### Update Venmo Account +```swift +let venmoAccount = HyperwalletVenmoAccount.Builder(token: "trm-12345") + .accountId("9876543210") + .build() + +Hyperwallet.shared.updateVenmoAccount(account: venmoAccount, completion: { (result, error) in + // Code to handle successful response or error + // On successful update, response (HyperwalletVenmoAccount in this case) will contain information about the user’s Venmo account + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of Venmo account updating +}) +``` + +### Deactivate Venmo Account +```swift +Hyperwallet.shared.deactivateVenmoAccount(transferMethodToken: "trm-12345", notes: "deactivate Venmo account", 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 of Venmo account deactivation +}) +``` + +### List Venmo Account +```swift +let venmoQueryParam = HyperwalletVenmoQueryParam() +venmoQueryParam.status = HyperwalletVenmoQueryParam.QueryStatus.activated.rawValue +venmoQueryParam.sortBy = HyperwalletVenmoQueryParam.QuerySortable.ascendantCreatedOn.rawValue + +Hyperwallet.shared.listVenmoAccounts(queryParam: venmoQueryParam) { (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 venmoAccounts = result?.data { + for venmoAccount in venmoAccounts { + print(venmoAccount.getField(fieldName: .token) ?? "") + } + } +} +``` + ### Create Bank Account ```swift @@ -194,14 +259,14 @@ Hyperwallet.shared.createBankAccount(account: bankAccount, completion: { (result return } - // In case of successful creation, response (HyperwalletBankAccount in this case) payload will contain information about the account created + // On successful creation, response (HyperwalletBankAccount in this case) payload will contain information about the account created print(result) }) ``` ### Get Bank Account ```swift Hyperwallet.shared.getBankAccount(transferMethodToken: "123123", completion: { (result, error) in - // In case of successful, response (HyperwalletBankCard? in this case) will contain information about the user’s bank account or nil if not exist. + // On success, response (HyperwalletBankCard? in this case) will contain information about the user’s bank account or nil if not exist. // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure }) ``` @@ -216,7 +281,7 @@ let bankAccount = HyperwalletBankAccount Hyperwallet.shared.updateBankAccount(account: bankAccount, completion: { (response, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletBankAccount in this case) payload will contain information about the account updated + // On successful update, response (HyperwalletBankAccount in this case) payload will contain information about the account updated // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account updating }) ``` @@ -226,7 +291,7 @@ Hyperwallet.shared.updateBankAccount(account: bankAccount, completion: { (respon ```swift Hyperwallet.shared.deactivateBankAccount(transferMethodToken: "trm-12345", notes: "deactivate bank account", completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletStatusTransition in this case) will contain information about the status transition + // 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 of account deactivation }) ``` @@ -234,8 +299,8 @@ Hyperwallet.shared.deactivateBankAccount(transferMethodToken: "trm-12345", notes ### List Bank Account ```swift let bankAccountQueryParam = HyperwalletBankAccountQueryParam() -bankAccountQueryParam.status = .activated -bankAccountQueryParam.sortBy = .ascendantCreatedOn +bankAccountQueryParam.status = HyperwalletBankAccountQueryParam.QueryStatus.activated.rawValue +bankAccountQueryParam.sortBy = HyperwalletBankAccountQueryParam.QuerySortable.ascendantCreatedOn.rawValue Hyperwallet.shared.listBankAccounts(queryParam: bankAccountQueryParam) { (result, error) in // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure @@ -244,7 +309,7 @@ Hyperwallet.shared.listBankAccounts(queryParam: bankAccountQueryParam) { (result return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let bankAccounts = result?.data { for bankAccount in bankAccounts { print(bankAccount.token ?? "") @@ -265,7 +330,7 @@ let bankCard = HyperwalletBankCard.Builder(transferMethodCountry: "US", Hyperwallet.shared.createBankCard(account: bankCard, completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletBankCard in this case) will contain information about the user’s bank card + // On successful creation, response (HyperwalletBankCard in this case) will contain information about the user’s bank card // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of bank card creation }) ``` @@ -273,7 +338,7 @@ Hyperwallet.shared.createBankCard(account: bankCard, completion: { (result, erro ### Get Bank Card ```swift Hyperwallet.shared.getBankCard(transferMethodToken: "123123", completion: { (result, error) in - // In case of successful, response (HyperwalletBankCard? in this case) will contain information about the user’s bank card or nil if not exist. + // On success, response (HyperwalletBankCard? in this case) will contain information about the user’s bank card or nil if not exist. // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure }) ``` @@ -287,7 +352,7 @@ let bankCard = HyperwalletBankCard Hyperwallet.shared.updateBankCard(account: bankCard, completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletBankCard in this case) will contain information about the user’s bank card + // On successful update, response (HyperwalletBankCard in this case) will contain information about the user’s bank card // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of bank card updating }) ``` @@ -296,7 +361,7 @@ Hyperwallet.shared.updateBankCard(account: bankCard, completion: { (result, erro ```swift Hyperwallet.shared.deactivateBankCard(transferMethodToken: "trm-12345", notes: "deactivate bank card", completion: { (result, error) in // Code to handle successful response or error - // In case of successful creation, response (HyperwalletStatusTransition in this case) will contain information about the status transition + // 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 of bank card deactivation }) ``` @@ -304,8 +369,8 @@ Hyperwallet.shared.deactivateBankCard(transferMethodToken: "trm-12345", notes: " ### List Bank Card ```swift let bankCardQueryParam = HyperwalletBankCardQueryParam() -bankCardQueryParam.status = .activated -bankCardQueryParam.sortBy = .ascendantCreatedOn +bankCardQueryParam.status = HyperwalletBankCardQueryParam.QueryStatus.activated.rawValue +bankCardQueryParam.sortBy = HyperwalletBankCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue Hyperwallet.shared.listBankCards(queryParam: bankCardQueryParam) { (result, error) in // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure @@ -314,7 +379,7 @@ Hyperwallet.shared.listBankCards(queryParam: bankCardQueryParam) { (result, erro return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let bankCards = result?.data { for bankCard in bankCards { print(bankCard.token ?? "") @@ -323,11 +388,19 @@ Hyperwallet.shared.listBankCards(queryParam: bankCardQueryParam) { (result, erro } ``` +### Get Prepaid Card +```swift +Hyperwallet.shared.getPrepaidCard(transferMethodToken: "123123", completion: { (result, error) in + // On success, response (HyperwalletPrepaidCard? in this case) will contain information about the user’s prepaid card or nil if not exist. + // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure +}) +``` + ### List Prepaid Cards ```swift let prepaidCardQueryParam = HyperwalletPrepaidCardQueryParam() -prepaidCardQueryParam.status = .activated -prepaidCardQueryParam.sortBy = .ascendantCreatedOn +prepaidCardQueryParam.status = HyperwalletPrepaidCardQueryParam.QueryStatus.activated.rawValue +prepaidCardQueryParam.sortBy = HyperwalletPrepaidCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue Hyperwallet.shared.listPrepaidCards(queryParam: prepaidCardQueryParam) { (result, error) in // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure @@ -336,7 +409,7 @@ Hyperwallet.shared.listPrepaidCards(queryParam: prepaidCardQueryParam) { (result return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let prepaidCards = result?.data { for prepaidCard in prepaidCards { print(prepaidCard.token) @@ -359,7 +432,7 @@ Hyperwallet.shared.listPrepaidCardReceipts(prepaidCardToken: prepaidCardToken, return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let receipts = result?.data { for receipt in receipts { print(receipt.destinationToken ?? "") @@ -382,7 +455,7 @@ Hyperwallet.shared.listUserReceipts(queryParam: receiptQueryParam) { (result, er return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let receipts = result?.data { for receipt in receipts { print(receipt.destinationToken ?? "") @@ -394,7 +467,7 @@ Hyperwallet.shared.listUserReceipts(queryParam: receiptQueryParam) { (result, er ### List Transfer Methods ```swift let transferMethodQueryParam = HyperwalletTransferMethodQueryParam() -transferMethodQueryParam.sortBy = .ascendantCreatedOn +transferMethodQueryParam.sortBy = HyperwalletTransferMethodQueryParam.QuerySortable.ascendantCreatedOn.rawValue Hyperwallet.shared.listTransferMethods(queryParam: transferMethodQueryParam) { (result, error) in // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure @@ -403,7 +476,7 @@ Hyperwallet.shared.listTransferMethods(queryParam: transferMethodQueryParam) { ( return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let transferMethods = result?.data { for transferMethod in transferMethods { print(transferMethod.token ?? "") @@ -427,7 +500,7 @@ let transfer = HyperwalletTransfer.Builder(clientTransferId: "6712348070812", Hyperwallet.shared.createTransfer(transfer: transfer, completion: { (result, error) in //Code to handle successful response or error - //In case of successfull creation, response (HyperwalletTransfer in this case) will contain information about the transfer + //On successfull creation, response (HyperwalletTransfer in this case) will contain information about the transfer //in case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of transfer creation }) ``` @@ -436,7 +509,7 @@ Hyperwallet.shared.createTransfer(transfer: transfer, completion: { (result, err ```swift Hyperwallet.shared.scheduleTransfer(transferToken: "trf-123456", completion: { (result, error) in //Code to handle successful response or error - // In case of successful scheduling, response (HyperwalletStatusTransition in this case) will contain information about the status transition + // On successful scheduling, 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 of transfer creation }) ``` @@ -444,7 +517,7 @@ Hyperwallet.shared.scheduleTransfer(transferToken: "trf-123456", completion: { ( ### Get Transfer ```swift Hyperwallet.shared.getTransfer(transferToken: "trf-123456", completion: { (result, error) in - // In case of successful, response (HyperwalletTransfer? in this case) will contain information about the transfer or nil if not exist. + // On success, response (HyperwalletTransfer? in this case) will contain information about the transfer or nil if not exist. // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure }) ``` @@ -458,7 +531,7 @@ Hyperwallet.shared.listTransfers { (result, error) in return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. if let transfers = result?.data { for transfer in transfers { print(transfer.token ?? "") @@ -480,7 +553,28 @@ Hyperwallet.shared.listUserBalances(queryParam: balanceQueryParam) { (result, er return } - // In case of successful, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + // On success, response (HyperwalletPageList? in this case) will contain information about or nil if not exist. + if let balances = result?.data { + for balance in balances { + print(balance.amount ?? "") + } + } +} +``` + +### List Prepaid Card Balances +```swift +let prepaidCardBalanceQueryParam = HyperwalletPrepaidCardBalanceQueryParam() +prepaidCardBalanceQueryParam.sortBy = HyperwalletPrepaidCardBalanceQueryParam.QuerySortable.descendantAmount.rawValue + +Hyperwallet.shared.listPrepaidCardBalances(prepaidCardToken: "trm-1234", queryParam: prepaidCardBalanceQueryParam) { (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 balances = result?.data { for balance in balances { print(balance.amount ?? "") diff --git a/Sources/Configuration.swift b/Sources/Configuration.swift index 65ff2cab..698d2216 100644 --- a/Sources/Configuration.swift +++ b/Sources/Configuration.swift @@ -33,6 +33,8 @@ public struct Configuration: Codable { public let issuer: String /// The user token public let userToken: String + /// The program model + public let programModel: String? var authorization: String! private static let stalePeriod = 30.0 // 30 seconds private let createOnBootTime = ProcessInfo.processInfo.systemUptime @@ -47,6 +49,7 @@ public struct Configuration: Codable { case restUrl = "rest-uri" case insightsUrl = "insights-uri" case environment = "environment" + case programModel = "program-model" } func isTokenStale() -> Bool { diff --git a/Sources/HTTPTransaction.swift b/Sources/HTTPTransaction.swift index 804f98c6..a90ac5d6 100644 --- a/Sources/HTTPTransaction.swift +++ b/Sources/HTTPTransaction.swift @@ -18,6 +18,7 @@ import Foundation import os.log +import UIKit /// Builds and performs the HTTP request final class HTTPTransaction { @@ -142,8 +143,7 @@ final class HTTPTransaction { @escaping (_ response: Response?, _ error: HyperwalletErrorType?) -> Void) -> (GraphQlResult?, HyperwalletErrorType?) -> Void - where Response: Decodable { - { (result, error) in + where Response: Decodable { { (result, error) in if let error = error { completionHandler(nil, error) } @@ -159,8 +159,7 @@ final class HTTPTransaction { /// Handles the callback has been performed by HTTPClient static func requestHandler( _ completionHandler: @escaping (_ response: Response?, _ error: HyperwalletErrorType?) -> Void) - -> HTTPClientProtocol.ResultHandler where Response: Decodable { - return { (data, response, error) in + -> HTTPClientProtocol.ResultHandler where Response: Decodable { { (data, response, error) in // Check the transport error has occurred; guard error == nil, let httpResponse = response as? HTTPURLResponse else { completionHandler(nil, ErrorTypeHelper.connectionError(for: error)) @@ -214,8 +213,8 @@ final class HTTPTransaction { _ payload: Request?, _ completionHandler: @escaping ((_ response: Response?, _ error: HyperwalletErrorType?) -> Void) - ) -> HyperwalletAuthenticationTokenProvider.CompletionHandler where Request: Encodable, Response: Decodable { - return { [weak self] (authenticationToken, error) in + ) -> HyperwalletAuthenticationTokenProvider.CompletionHandler + where Request: Encodable, Response: Decodable { { [weak self] (authenticationToken, error) in guard let strongSelf = self else { completionHandler(nil, ErrorTypeHelper.transactionAborted()) return @@ -245,6 +244,10 @@ final class HTTPTransaction { } } + private static let sdkVersion: String = { + Bundle(for: Hyperwallet.self).infoDictionary?["TAG_VERSION"] as? String ?? "Unknown" + }() + /// Returns the `User-Agent` header. /// Returns the Hyperwallet SDK `User-Agent` header. /// @@ -255,11 +258,15 @@ final class HTTPTransaction { let version = ProcessInfo.processInfo.operatingSystemVersion let osVersion = "\(version.majorVersion).\(version.minorVersion).\(version.patchVersion)" - let executable = info[kCFBundleExecutableKey as String] as? String ?? "Unknown" - let sdkVersion = info["CFBundleShortVersionString"] as? String ?? "Unknown" + var displayName = info["CFBundleDisplayName"] as? String ?? "Unknown" + if let appInfo = Bundle.main.infoDictionary as NSDictionary?, + let appDisplayName = appInfo["CFBundleDisplayName"] as? String { + displayName = appDisplayName + } let sdkBuild = info[kCFBundleVersionKey as String] as? String ?? "Unknown" - let sdkBuildVersion = "\(sdkVersion).\(sdkBuild)" - return "HyperwalletSDK/iOS/\(sdkBuildVersion); App: \(executable); iOS: \(osVersion)" + let deviceName = UIDevice.current.model + + return "HyperwalletSDK/iOS/\(sdkVersion); App: \(displayName); iOS: \(osVersion); \(deviceName)" }() /// Returns the accept content type. @@ -277,6 +284,11 @@ final class HTTPTransaction { Locale.preferredLanguages.prefix(6).first ?? "en-US" }() + /// Returns the sdk type. + private static let sdkType: String = { + "ios" + }() + /// Builds the HTTP header configuration static let urlSessionConfiguration: URLSessionConfiguration = { let configuration = URLSessionConfiguration.ephemeral @@ -284,6 +296,9 @@ final class HTTPTransaction { configuration.timeoutIntervalForRequest = HTTPTransaction.defaultTimeout configuration.httpAdditionalHeaders = [ "User-Agent": userAgent, + "x-sdk-version": sdkVersion, + "x-sdk-type": sdkType, + "x-sdk-contextId": UUID().uuidString, "Accept-Language": acceptLanguage, "Accept": contentType, "Content-Type": contentType diff --git a/Sources/Hyperwallet.swift b/Sources/Hyperwallet.swift index e3e3e719..0ad8cdd8 100644 --- a/Sources/Hyperwallet.swift +++ b/Sources/Hyperwallet.swift @@ -184,6 +184,27 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Creates a `HyperwalletVenmoAccount` for the User associated with the authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. + /// + /// The `completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void` that is passed in to this + /// method invocation will receive the successful response(HyperwalletVenmoAccount) 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 `HyperwalletVenmoAccount` to be created + /// - completion: the callback handler of responses from the Hyperwallet platform + public func createVenmoAccount(account: HyperwalletVenmoAccount, + completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .post, + urlPath: "users/%@/venmo-accounts", + payload: account, + completionHandler: completion) + } + /// Deactivates the `HyperwalletBankAccount` linked to the transfer method token specified. The /// `HyperwalletBankAccount` being deactivated must belong to the User that is associated with the /// authentication token returned from @@ -268,6 +289,34 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Deactivates the `HyperwalletVenmoAccount` linked to the transfer method token specified. The + /// `HyperwalletVenmoAccount` 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 `HyperwalletVenmoAccount` + /// being deactivated + /// - notes: a note regarding the status change + /// - completion: the callback handler of responses from the Hyperwallet platform + public func deactivateVenmoAccount(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/%@/venmo-accounts/\(transferMethodToken)/status-transitions", + payload: statusTransition, + completionHandler: completion) + } + /// Schedules the `HyperwalletTransfer` linked to the transfer method token specified. /// /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to @@ -349,6 +398,27 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Returns the `HyperwalletPrepaidCard` linked to the transfer method token specified, or nil if none exists. + /// + /// The `completion: @escaping (HyperwalletPrepaidCard?, HyperwalletErrorType?) -> Void` that is passed in to + /// this method invocation will receive the successful response(HyperwalletPrepaidCard) 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 `HyperwalletPrepaidCard` + /// being requested + /// - completion: the callback handler of responses from the Hyperwallet platform + public func getPrepaidCard(transferMethodToken: String, + completion: @escaping (HyperwalletPrepaidCard?, HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .get, + urlPath: "users/%@/prepaid-cards/\(transferMethodToken)", + payload: "", + completionHandler: completion) + } + /// Returns the `HyperwalletTransfer` linked to the transfer method token specified, or nil if none exists. /// /// The `completion: @escaping (HyperwalletTransfer?, HyperwalletErrorType?) -> Void` that is passed in to this @@ -367,6 +437,24 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Returns the `HyperwalletVenmoAccount` linked to the transfer method token specified, or nil if none exists. + /// + /// The `completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void` that is passed in to this + /// method invocation will receive the successful response(HyperwalletVenmoAccount) or error(HyperwalletErrorType) + /// from processing the request. + /// + /// - Parameters: + /// - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletVenmoAccount` + /// being requested + /// - completion: the callback handler of responses from the Hyperwallet platform + public func getVenmoAccount(transferMethodToken: String, + completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .get, + urlPath: "users/%@/venmo-accounts/\(transferMethodToken)", + payload: "", + completionHandler: completion) + } + /// Returns the list of `HyperwalletBankAccount`s for the User associated with the authentication token /// returned from /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`, @@ -521,7 +609,7 @@ public final class Hyperwallet: NSObject { /// or nil if non exist. /// /// The ordering and filtering of `HyperwalletPrepaidCard` will be based on the criteria specified within the - /// `HyperwalletPrepaidCardQueryParm` object, if it is not nil. Otherwise the default ordering and + /// `HyperwalletPrepaidCardQueryParam` object, if it is not nil. Otherwise the default ordering and /// filtering will be applied. /// /// * Offset: 0 @@ -542,7 +630,7 @@ public final class Hyperwallet: NSObject { /// - Parameters: /// - queryParam: the ordering and filtering criteria /// - completion: the callback handler of responses from the Hyperwallet platform - public func listPrepaidCards(queryParam: HyperwalletPrepaidCardQueryParm? = nil, + public func listPrepaidCards(queryParam: HyperwalletPrepaidCardQueryParam? = nil, completion: @escaping (HyperwalletPageList?, HyperwalletErrorType?) -> Void) { httpTransaction.performRest(httpMethod: .get, @@ -552,6 +640,42 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Returns the `HyperwalletVenmoAccount` for the User associated with the authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`, + /// or nil if non exist. + /// + /// The ordering and filtering of `HyperwalletVenmoAccount` will be based on the criteria specified within the + /// `HyperwalletVenmoQueryParam` 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 + /// * 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 listVenmoAccounts(queryParam: HyperwalletVenmoQueryParam? = nil, + completion: @escaping (HyperwalletPageList?, + HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .get, + urlPath: "users/%@/venmo-accounts", + payload: "", + queryParam: queryParam, + completionHandler: completion) + } + /// Returns the list of receipts for the User associated with the authentication token. /// /// The ordering and filtering of `HyperwalletReceipt` will be based on the criteria specified within the @@ -772,6 +896,31 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } + /// Updates the `HyperwalletVenmoAccount` for the User associated with the authentication token returned from + /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`. + /// + /// To identify the `HyperwalletVenmoAccount` that is going to be updated, the transfer method token must be + /// set as part of the `HyperwalletVenmoAccount` object passed in. + /// + /// The `completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void` that is passed in to this + /// method invocation will receive the successful response(HyperwalletVenmoAccount) 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 `HyperwalletVenmoAccount` to be updated + /// - completion: the callback handler of responses from the Hyperwallet platform + public func updateVenmoAccount(account: HyperwalletVenmoAccount, + completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void) { + let token = account.token ?? "" + httpTransaction.performRest(httpMethod: .put, + urlPath: "users/%@/venmo-accounts/\(token)", + payload: account, + completionHandler: completion) + } + /// Returns the list of balances for the User associated with the authentication token. /// /// The ordering and filtering of `HyperwalletBalance` will be based on the criteria specified within the @@ -804,28 +953,58 @@ public final class Hyperwallet: NSObject { completionHandler: completion) } - private func transferMethodConfigurationFieldResponseHandler(_ completionHandler: @escaping ( - (TransferMethodConfigurationFieldResult?, HyperwalletErrorType?) -> Void)) - -> (TransferMethodConfigurationField?, HyperwalletErrorType?) -> Void { - return { (response, error) in + /// Returns the list of prepaid card balances for the User associated with the authentication token. + /// + /// The ordering and filtering of `HyperwalletBalance` will be based on the criteria specified within the + /// `HyperwalletPrepaidCardBalanceQueryParam` object, if it is not nil. Otherwise the default ordering and + /// filtering will be applied. + /// + /// * Offset: 0 + /// * Limit: 10 + /// * Sort By: currency + /// + /// 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: + /// - prepaidCardToken: the prepaid card token + /// - queryParam: the ordering and filtering criteria + /// - completion: the callback handler of responses from the Hyperwallet platform + public func listPrepaidCardBalances(prepaidCardToken: String, + queryParam: HyperwalletPrepaidCardBalanceQueryParam? = nil, + completion: @escaping (HyperwalletPageList?, + HyperwalletErrorType?) -> Void) { + httpTransaction.performRest(httpMethod: .get, + urlPath: "users/%@/prepaid-cards/\(prepaidCardToken)/balances", + payload: "", + queryParam: queryParam, + completionHandler: completion) + } + + private func transferMethodConfigurationFieldResponseHandler(_ completionHandler: + @escaping (TransferMethodConfigurationFieldResult?, HyperwalletErrorType?) -> Void) + -> (TransferMethodConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in let result = TransferMethodConfigurationFieldResult(response?.transferMethodUIConfigurations?.nodes, response?.countries?.nodes?.first) completionHandler(result, error) } } - private func transferMethodConfigurationKeyResponseHandler(_ completionHandler: @escaping ( - (TransferMethodConfigurationKeyResult?, HyperwalletErrorType?) -> Void)) - -> (TransferMethodConfigurationKey?, HyperwalletErrorType?) -> Void { - return { (response, error) in + private func transferMethodConfigurationKeyResponseHandler(_ completionHandler: + @escaping (TransferMethodConfigurationKeyResult?, HyperwalletErrorType?) -> Void) + -> (TransferMethodConfigurationKey?, HyperwalletErrorType?) -> Void { { (response, error) in completionHandler(TransferMethodConfigurationKeyResult(response?.countries?.nodes), error) } } private func retrieveAuthenticationTokenResponseHandler( completion: @escaping (Configuration?, HyperwalletErrorType?) -> Void) - -> (String?, Error?) -> Void { - return {(authenticationToken, error) in + -> (String?, Error?) -> Void { {(authenticationToken, error) in guard error == nil else { completion(nil, ErrorTypeHelper.authenticationError( message: "Error occured while retrieving authentication token", diff --git a/Sources/HyperwalletError.swift b/Sources/HyperwalletError.swift index 4929c475..9dd00ad3 100644 --- a/Sources/HyperwalletError.swift +++ b/Sources/HyperwalletError.swift @@ -255,9 +255,9 @@ internal struct ErrorTypeHelper { static func connectionError(message: String = "Please check network connection", for error: Error? = nil) -> HyperwalletErrorType { - return HyperwalletErrorType.connectionError(buildHyperwalletErrors(code: "CONNECTION_ERROR", - message: message, - error: error)) + HyperwalletErrorType.connectionError(buildHyperwalletErrors(code: "CONNECTION_ERROR", + message: message, + error: error)) } static func graphQlErrors(errors: [GraphQlError]) -> HyperwalletErrorType { diff --git a/Sources/Info.plist b/Sources/Info.plist index b9c96a4a..8216e844 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -20,5 +20,7 @@ $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) + TAG_VERSION + 1.0.0-beta10 diff --git a/Sources/Model/Balance/HyperwalletPrepaidCardBalanceQueryParam.swift b/Sources/Model/Balance/HyperwalletPrepaidCardBalanceQueryParam.swift new file mode 100644 index 00000000..758c22a2 --- /dev/null +++ b/Sources/Model/Balance/HyperwalletPrepaidCardBalanceQueryParam.swift @@ -0,0 +1,33 @@ +// +// 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 prepaid card balance QueryParam fields. +public class HyperwalletPrepaidCardBalanceQueryParam: QueryParam { + /// Representation of the sortable fields + public enum QuerySortable: String { + /// Sort the result by ascendant amount + case ascendantAmount = "+amount" + /// Sort the result by ascendant currency + case ascendantCurrency = "+currency" + /// Sort the result by descendant amount + case descendantAmount = "-amount" + /// Sort the result by descendant currency + case descendantCurrency = "-currency" + } +} diff --git a/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift b/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift index e11dc287..5146aad5 100644 --- a/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift +++ b/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationField.swift @@ -48,10 +48,10 @@ final class TransferMethodConfigurationFieldResult: HyperwalletTransferMethodCon } func fieldGroups() -> [HyperwalletFieldGroup]? { - return transferMethodUIConfigurations?.first?.fieldGroups?.nodes + transferMethodUIConfigurations?.first?.fieldGroups?.nodes } func transferMethodType() -> HyperwalletTransferMethodType? { - return country?.currencies?.nodes?.first?.transferMethodTypes?.nodes?.first + country?.currencies?.nodes?.first?.transferMethodTypes?.nodes?.first } } diff --git a/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationKey.swift b/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationKey.swift index 290cf722..3514d477 100644 --- a/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationKey.swift +++ b/Sources/Model/GraphQL/HyperwalletTransferMethodConfigurationKey.swift @@ -57,7 +57,7 @@ final class TransferMethodConfigurationKeyResult: HyperwalletTransferMethodConfi /// /// - Returns: a list of countries func countries() -> [HyperwalletCountry]? { - return hyperwalletCountries + hyperwalletCountries } /// Returns the list of currencies based on the country @@ -65,7 +65,7 @@ final class TransferMethodConfigurationKeyResult: HyperwalletTransferMethodConfi /// - Parameter countryCode: the 2 letter ISO 3166-1 country code /// - Returns: a list of currencies func currencies(from countryCode: String) -> [HyperwalletCurrency]? { - return hyperwalletCountries?.first(where: { $0.code == countryCode })?.currencies?.nodes + hyperwalletCountries?.first(where: { $0.code == countryCode })?.currencies?.nodes } /// Returns the list of transfer method types based on the parameters @@ -75,6 +75,6 @@ final class TransferMethodConfigurationKeyResult: HyperwalletTransferMethodConfi /// - currencyCode: the 3 letter ISO 4217-1 currency code /// - Returns: a list of transfer method types func transferMethodTypes(countryCode: String, currencyCode: String) -> [HyperwalletTransferMethodType]? { - return currencies(from: countryCode)?.first(where: { $0.code == currencyCode })?.transferMethodTypes?.nodes + currencies(from: countryCode)?.first(where: { $0.code == currencyCode })?.transferMethodTypes?.nodes } } diff --git a/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift b/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift index 7898165a..4ca7b003 100644 --- a/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift +++ b/Sources/Model/GraphQL/Query/HyperwalletTransferMethodConfigurationQueries.swift @@ -140,7 +140,7 @@ public struct HyperwalletTransferMethodConfigurationFieldQuery: GraphQlQuery, Ha } public func toGraphQl(userToken: String) -> String { - return String(format: query, userToken, profile, country, currency, transferMethodType) + String(format: query, userToken, profile, country, currency, transferMethodType) } public func hash(into hasher: inout Hasher) { @@ -206,6 +206,6 @@ public struct HyperwalletTransferMethodConfigurationKeysQuery: GraphQlQuery { } public func toGraphQl(userToken: String) -> String { - return String(format: query, userToken, limit) + String(format: query, userToken, limit) } } diff --git a/Sources/Model/Receipt/HyperwalletReceipt.swift b/Sources/Model/Receipt/HyperwalletReceipt.swift index c32757e8..1016c2ba 100644 --- a/Sources/Model/Receipt/HyperwalletReceipt.swift +++ b/Sources/Model/Receipt/HyperwalletReceipt.swift @@ -118,7 +118,7 @@ public struct HyperwalletReceipt: Decodable, Equatable { public let type: HyperwalletReceiptType? public static func == (lhs: HyperwalletReceipt, rhs: HyperwalletReceipt) -> Bool { - return lhs.journalId == rhs.journalId && + lhs.journalId == rhs.journalId && rhs.entry == lhs.entry && rhs.type == lhs.type } @@ -211,10 +211,88 @@ public struct HyperwalletReceipt: Decodable, Equatable { case prepaidCardSaleReversal = "PREPAID_CARD_SALE_REVERSAL" /// The prepaid card unload case prepaidCardUnload = "PREPAID_CARD_UNLOAD" - /// The transfer to debitcard + /// The transfer to debit card case transferToDebitCard = "TRANSFER_TO_DEBIT_CARD" /// The transfer to prepaid card case transferToPrepaidCard = "TRANSFER_TO_PREPAID_CARD" + /// The prepaid card account deposit + case prepaidCardAccountDeposit = "PREPAID_CARD_ACCOUNT_DEPOSIT" + /// The prepaid card account fee + case prepaidCardAccountFee = "PREPAID_CARD_ACCOUNT_FEE" + /// The prepaid card annual fee discount + case prepaidCardAnnualFeeDiscount = "PREPAID_CARD_ANNUAL_FEE_DISCOUNT" + /// The prepaid card bill reprint fee + case prepaidCardBillReprintFee = "PREPAID_CARD_BILL_REPRINT_FEE" + /// The prepaid card atm or cash advance fee + case prepaidCardAtmOrCashAdvanceFee = "PREPAID_CARD_ATM_OR_CASH_ADVANCE_FEE" + /// The prepaid card cash advance chargeback + case prepaidCardCashAdvanceChargeback = "PREPAID_CARD_CASH_ADVANCE_CHARGEBACK" + /// The prepaid card cash advance chargeback reversal + case prepaidCardCashAdvanceChargebackReversal = "PREPAID_CARD_CASH_ADVANCE_CHARGEBACK_REVERSAL" + /// The prepaid card cash advance repress + case prepaidCardCashAdvanceRepress = "PREPAID_CARD_CASH_ADVANCE_REPRESS" + /// The prepaid card cash advance repress reversal + case prepaidCardCashAdvanceRepressReversal = "PREPAID_CARD_CASH_ADVANCE_REPRESS_REVERSAL" + /// The prepaid card chargeback + case prepaidCardChargeback = "PREPAID_CARD_CHARGEBACK" + /// The prepaid card chargeback refund + case prepaidCardChargebackRefund = "PREPAID_CARD_CHARGEBACK_REFUND" + /// The prepaid card chargeback refund reversal + case prepaidCardChargebackRefundReversal = "PREPAID_CARD_CHARGEBACK_REFUND_REVERSAL" + /// The prepaid card chargeback reversal + case prepaidCardChargebackReversal = "PREPAID_CARD_CHARGEBACK_REVERSAL" + /// The prepaid card commission or fee + case prepaidCardCommissionOrFee = "PREPAID_CARD_COMMISSION_OR_FEE" + /// The prepaid card debit transfer + case prepaidCardDebitTransfer = "PREPAID_CARD_DEBIT_TRANSFER" + /// The prepaid card document request fee + case prepaidCardDocumentRequestFee = "PREPAID_CARD_DOCUMENT_REQUEST_FEE" + /// The prepaid card emergency cash + case prepaidCardEmergencyCash = "PREPAID_CARD_EMERGENCY_CASH" + /// The prepaid card emergency card + case prepaidCardEmergencyCard = "PREPAID_CARD_EMERGENCY_CARD" + /// The prepaid card income + case prepaidCardIncome = "PREPAID_CARD_INCOME" + /// The prepaid card load fee + case prepaidCardLoadFee = "PREPAID_CARD_LOAD_FEE" + /// The prepaid card overdue payment interest + case prepaidCardOverduePaymentInterest = "PREPAID_CARD_OVERDUE_PAYMENT_INTEREST" + /// The prepaid card payment + case prepaidCardPayment = "PREPAID_CARD_PAYMENT" + /// The prepaid card pin reprint fee + case prepaidCardPinReprintFee = "PREPAID_CARD_PIN_REPRINT_FEE" + /// The prepaid card priority pass fee + case prepaidCardPriorityPassFee = "PREPAID_CARD_PRIORITY_PASS_FEE" + /// The prepaid card priority pass renewal + case prepaidCardPriorityPassRenewal = "PREPAID_CARD_PRIORITY_PASS_RENEWAL" + /// The prepaid card recurring interest + case prepaidCardRecurringInterest = "PREPAID_CARD_RECURRING_INTEREST" + /// The prepaid card refund repress + case prepaidCardRefundRepress = "PREPAID_CARD_REFUND_REPRESS" + /// The prepaid card refund repress reversal + case prepaidCardRefundRepressReversal = "PREPAID_CARD_REFUND_REPRESS_REVERSAL" + /// The prepaid card statement fee + case prepaidCardStatementFee = "PREPAID_CARD_STATEMENT_FEE" + /// The prepaid card telephone support fee + case prepaidCardTelephoneSupportFee = "PREPAID_CARD_TELEPHONE_SUPPORT_FEE" + /// The prepaid card transfer fee + case prepaidCardTransferFee = "PREPAID_CARD_TRANSFER_FEE" + /// The prepaid card transfer return + case prepaidCardTransferReturn = "PREPAID_CARD_TRANSFER_RETURN" + /// The prepaid card bank withdrawal chargeback + case prepaidCardBankWithdrawalChargeback = "PREPAID_CARD_BANK_WITHDRAWAL_CHARGEBACK" + /// The prepaid card refund fee + case prepaidCardRefundfee = "PREPAID_CARD_REFUND_FEE" + /// The prepaid card monthly maintenance fee + case prepaidCardMonthlyMaintenanceFee = "PREPAID_CARD_MONTHLY_MAINTENANCE_FEE" + /// The prepaid card transaction fee + case prepaidCardTransactionFee = "PREPAID_CARD_TRANSACTION_FEE" + /// The prepaid card sms fee + case prepaidCardSmsFee = "PREPAID_CARD_SMS_FEE" + /// The prepaid card declined authorization fee + case prepaidCardDeclinedAuthorizationFee = "PREPAID_CARD_DECLINED_AUTHORIZATION_FEE" + /// The prepaid card purchases + case fispc = "FISPC" // Donation types /// /// The donation @@ -305,8 +383,18 @@ public struct HyperwalletReceipt: Decodable, Equatable { case prepaidCardSale = "PREPAID_CARD_SALE" // PayPal transfer types /// - /// Transfer to PayPalAccount + /// Transfer to PayPal account case transferToPayPalAccount = "TRANSFER_TO_PAYPAL_ACCOUNT" + /// Return to Paypal Account + case paypalAccountTransferReturn = "PAYPAL_ACCOUNT_TRANSFER_RETURN" + // Venmo transfer type + /// + /// Transfer to Venmo account + case transferToVenmoAccount = "TRANSFER_TO_VENMO_ACCOUNT" + /// Return to Venmo account + case venmoAccountTransferReturn = "VENMO_ACCOUNT_TRANSFER_RETURN" + /// Transfer To Bank Card + case transferToBankCard = "TRANSFER_TO_BANK_CARD" /// Default - unknown transfer type case unknown = "UNKNOWN_RECEIPT_TYPE" } diff --git a/Sources/Model/StatusTransition/HyperwalletStatusTransition.swift b/Sources/Model/StatusTransition/HyperwalletStatusTransition.swift index 5d5d8eea..06d89099 100644 --- a/Sources/Model/StatusTransition/HyperwalletStatusTransition.swift +++ b/Sources/Model/StatusTransition/HyperwalletStatusTransition.swift @@ -117,7 +117,7 @@ public struct HyperwalletStatusTransition: Codable { /// /// - Returns: a new instance of the `HyperwalletTransfer`. public func build() -> HyperwalletStatusTransition { - return HyperwalletStatusTransition(notes: notes, transition: transition) + HyperwalletStatusTransition(notes: notes, transition: transition) } } } diff --git a/Sources/Model/Transfer/HyperwalletTransfer.swift b/Sources/Model/Transfer/HyperwalletTransfer.swift index cf9cde8e..5af8aa67 100644 --- a/Sources/Model/Transfer/HyperwalletTransfer.swift +++ b/Sources/Model/Transfer/HyperwalletTransfer.swift @@ -213,15 +213,15 @@ public struct HyperwalletTransfer: Codable { /// /// - Returns: a new instance of the `HyperwalletTransfer`. public func build() -> HyperwalletTransfer { - return HyperwalletTransfer(clientTransferId: clientTransferId, - destinationAmount: destinationAmount, - destinationCurrency: destinationCurrency, - destinationToken: destinationToken, - memo: memo, - notes: notes, - sourceAmount: sourceAmount, - sourceCurrency: sourceCurrency, - sourceToken: sourceToken) + HyperwalletTransfer(clientTransferId: clientTransferId, + destinationAmount: destinationAmount, + destinationCurrency: destinationCurrency, + destinationToken: destinationToken, + memo: memo, + notes: notes, + sourceAmount: sourceAmount, + sourceCurrency: sourceCurrency, + sourceToken: sourceToken) } } } diff --git a/Sources/Model/TransferMethod/HyperwalletBankAccount.swift b/Sources/Model/TransferMethod/HyperwalletBankAccount.swift index 382dda83..18e672e8 100644 --- a/Sources/Model/TransferMethod/HyperwalletBankAccount.swift +++ b/Sources/Model/TransferMethod/HyperwalletBankAccount.swift @@ -89,214 +89,214 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// The bank account holder's street address. public var addressLine1: String? { - return getField(TransferMethodField.addressLine1.rawValue) + getField(TransferMethodField.addressLine1.rawValue) } /// The bank account holder's address, second line. public var addressLine2: String? { - return getField(TransferMethodField.addressLine2.rawValue) + getField(TransferMethodField.addressLine2.rawValue) } /// The bank account number, IBAN or equivalent. If you are providing an IBAN, the first two /// letters of the IBAN must match the `transferMethodCountry` public var bankAccountId: String? { - return getField(TransferMethodField.bankAccountId.rawValue) + getField(TransferMethodField.bankAccountId.rawValue) } /// The purpose of the bank account (e.g. checking, savings, etc). public var bankAccountPurpose: String? { - return getField(TransferMethodField.bankAccountPurpose.rawValue) + getField(TransferMethodField.bankAccountPurpose.rawValue) } /// The user's relationship with the bank account holder. public var bankAccountRelationship: String? { - return getField(TransferMethodField.bankAccountRelationship.rawValue) + getField(TransferMethodField.bankAccountRelationship.rawValue) } /// The bank code or equivalent (e.g. BIC/SWIFT code). public var bankId: String? { - return getField(TransferMethodField.bankId.rawValue) + getField(TransferMethodField.bankId.rawValue) } /// The bank name. public var bankName: String? { - return getField(TransferMethodField.bankName.rawValue) + getField(TransferMethodField.bankName.rawValue) } /// The branch code, transit number, routing number or equivalent. public var branchId: String? { - return getField(TransferMethodField.branchId.rawValue) + getField(TransferMethodField.branchId.rawValue) } /// The branch name. public var branchName: String? { - return getField(TransferMethodField.branchName.rawValue) + getField(TransferMethodField.branchName.rawValue) } /// The bank account holder's role in the organization. public var businessContactRole: String? { - return getField(TransferMethodField.businessContactRole.rawValue) + getField(TransferMethodField.businessContactRole.rawValue) } /// The name of the bank account holder's business. public var businessName: String? { - return getField(TransferMethodField.businessName.rawValue) + getField(TransferMethodField.businessName.rawValue) } /// The country where the bank account holder's business is registered. public var businessRegistrationCountry: String? { - return getField(TransferMethodField.businessRegistrationCountry.rawValue) + 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? { - return getField(TransferMethodField.businessRegistrationId.rawValue) + getField(TransferMethodField.businessRegistrationId.rawValue) } /// The state, province or region where the bank account holder's business is registered. public var businessRegistrationStateProvince: String? { - return getField(TransferMethodField.businessRegistrationStateProvince.rawValue) + getField(TransferMethodField.businessRegistrationStateProvince.rawValue) } /// The bank account holder's business type. public var businessType: String? { - return getField(TransferMethodField.businessType.rawValue) + getField(TransferMethodField.businessType.rawValue) } /// The bank account holder's city. public var city: String? { - return getField(TransferMethodField.city.rawValue) + getField(TransferMethodField.city.rawValue) } /// The bank account holder's country. public var country: String? { - return getField(TransferMethodField.country.rawValue) + getField(TransferMethodField.country.rawValue) } /// The bank account holder's birth country. public var countryOfBirth: String? { - return getField(TransferMethodField.countryOfBirth.rawValue) + getField(TransferMethodField.countryOfBirth.rawValue) } /// The bank account holder's date of birth (All users must be at least 13 years old). public var dateOfBirth: String? { - return getField(TransferMethodField.dateOfBirth.rawValue) + getField(TransferMethodField.dateOfBirth.rawValue) } /// The bank account holder's driver's license number. public var driversLicenseId: String? { - return getField(TransferMethodField.driversLicenseId.rawValue) + getField(TransferMethodField.driversLicenseId.rawValue) } /// The bank account holder's employer identifier, generally used for tax purposes. public var employerId: String? { - return getField(TransferMethodField.employerId.rawValue) + getField(TransferMethodField.employerId.rawValue) } /// The bank account holder's first name. public var firstName: String? { - return getField(TransferMethodField.firstName.rawValue) + getField(TransferMethodField.firstName.rawValue) } /// The bank account holder's gender. public var gender: String? { - return getField(TransferMethodField.gender.rawValue) + getField(TransferMethodField.gender.rawValue) } /// The bank account holder's government ID number, such as a Social Security Number. public var governmentId: String? { - return getField(TransferMethodField.governmentId.rawValue) + getField(TransferMethodField.governmentId.rawValue) } /// The bank account holder's government ID type. public var governmentIdType: String? { - return getField(TransferMethodField.governmentIdType.rawValue) + getField(TransferMethodField.governmentIdType.rawValue) } /// The account number at the intermediary bank. public var intermediaryBankAccountId: String? { - return getField(TransferMethodField.intermediaryBankAccountId.rawValue) + getField(TransferMethodField.intermediaryBankAccountId.rawValue) } /// The intermediary bank street address. public var intermediaryBankAddressLine1: String? { - return getField(TransferMethodField.intermediaryBankAddressLine1.rawValue) + getField(TransferMethodField.intermediaryBankAddressLine1.rawValue) } /// The intermediary bank street address, second line. public var intermediaryBankAddressLine2: String? { - return getField(TransferMethodField.intermediaryBankAddressLine2.rawValue) + getField(TransferMethodField.intermediaryBankAddressLine2.rawValue) } /// The intermediary bank city. public var intermediaryBankCity: String? { - return getField(TransferMethodField.intermediaryBankCity.rawValue) + getField(TransferMethodField.intermediaryBankCity.rawValue) } /// The intermediary bank country. public var intermediaryBankCountry: String? { - return getField(TransferMethodField.intermediaryBankCountry.rawValue) + getField(TransferMethodField.intermediaryBankCountry.rawValue) } /// The intermediary bank's 11-character SWIFT code. public var intermediaryBankId: String? { - return getField(TransferMethodField.intermediaryBankId.rawValue) + getField(TransferMethodField.intermediaryBankId.rawValue) } /// The intermediary bank name. public var intermediaryBankName: String? { - return getField(TransferMethodField.intermediaryBankName.rawValue) + getField(TransferMethodField.intermediaryBankName.rawValue) } /// The intermediary bank postal code. public var intermediaryBankPostalCode: String? { - return getField(TransferMethodField.intermediaryBankPostalCode.rawValue) + getField(TransferMethodField.intermediaryBankPostalCode.rawValue) } /// The intermediary bank state, province or region. public var intermediaryBankStateProvince: String? { - return getField(TransferMethodField.intermediaryBankStateProvince.rawValue) + getField(TransferMethodField.intermediaryBankStateProvince.rawValue) } /// The bank account holder's last name. public var lastName: String? { - return getField(TransferMethodField.lastName.rawValue) + getField(TransferMethodField.lastName.rawValue) } /// The bank account holder's middle name. public var middleName: String? { - return getField(TransferMethodField.middleName.rawValue) + getField(TransferMethodField.middleName.rawValue) } /// The bank account holder's cell phone number. public var mobileNumber: String? { - return getField(TransferMethodField.mobileNumber.rawValue) + getField(TransferMethodField.mobileNumber.rawValue) } /// The bank account holder's passport number. public var passportId: String? { - return getField(TransferMethodField.passportId.rawValue) + getField(TransferMethodField.passportId.rawValue) } /// The bank account holder's phone number. public var phoneNumber: String? { - return getField(TransferMethodField.phoneNumber.rawValue) + getField(TransferMethodField.phoneNumber.rawValue) } /// The bank account holder's postal code. public var postalCode: String? { - return getField(TransferMethodField.postalCode.rawValue) + getField(TransferMethodField.postalCode.rawValue) } /// The bank account holder's state, province or region. public var stateProvince: String? { - return getField(TransferMethodField.stateProvince.rawValue) + getField(TransferMethodField.stateProvince.rawValue) } /// The wire transfer instructions public var wireInstructions: String? { - return getField(TransferMethodField.wireInstructions.rawValue) + getField(TransferMethodField.wireInstructions.rawValue) } /// A helper class to build the `HyperwalletBankAccount` instance. @@ -733,7 +733,7 @@ public final class HyperwalletBankAccount: HyperwalletTransferMethod { /// /// - Returns: a new instance of the `HyperwalletBankAccount`. public func build() -> HyperwalletBankAccount { - return HyperwalletBankAccount(data: self.storage) + HyperwalletBankAccount(data: self.storage) } } } diff --git a/Sources/Model/TransferMethod/HyperwalletBankAccountQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletBankAccountQueryParam.swift index 75d74d20..9a2e0878 100644 --- a/Sources/Model/TransferMethod/HyperwalletBankAccountQueryParam.swift +++ b/Sources/Model/TransferMethod/HyperwalletBankAccountQueryParam.swift @@ -20,38 +20,14 @@ import Foundation /// Representation of the bank account query parameters. public class HyperwalletBankAccountQueryParam: HyperwalletTransferMethodQueryParam { - private enum QueryParam: String { - case type - } - /// The bank account type. - public var type: QueryType? - - /// Represents the Bank Account types. - public enum QueryType: String { - /// The Bank account type - case bankAccount = "BANK_ACCOUNT" - /// The Wire account type - case wireAccount = "WIRE_ACCOUNT" - } - - /// Representation of the bank account status - public enum QueryStatus: String { - /// Filter by activated bank accounts - case activated = "ACTIVATED" - /// Filter by deActivated bank accounts - case deActivated = "DE_ACTIVATED" - /// Filter only invalid bank accounts - case invalid = "INVALID" - /// Filter only verified bank accounts - case verified = "VERIFIED" - } - override public func toQuery() -> [String: String] { var query = super.toQuery() - if let type = type { - query[QueryParam.type.rawValue] = type.rawValue - } + if let type = type, type == QueryType.wireAccount.rawValue { + query[QueryParam.type.rawValue] = type + } else if type != nil { + query[QueryParam.type.rawValue] = QueryType.bankAccount.rawValue + } return query } } diff --git a/Sources/Model/TransferMethod/HyperwalletBankCard.swift b/Sources/Model/TransferMethod/HyperwalletBankCard.swift index e3dea764..9d4e8d10 100644 --- a/Sources/Model/TransferMethod/HyperwalletBankCard.swift +++ b/Sources/Model/TransferMethod/HyperwalletBankCard.swift @@ -31,22 +31,22 @@ public class HyperwalletBankCard: HyperwalletTransferMethod { /// The card brand public var cardBrand: String? { - return getField(TransferMethodField.cardBrand.rawValue) + getField(TransferMethodField.cardBrand.rawValue) } /// The card number public var cardNumber: String? { - return getField(TransferMethodField.cardNumber.rawValue) + getField(TransferMethodField.cardNumber.rawValue) } /// The card type public var cardType: String? { - return getField(TransferMethodField.cardType.rawValue) + getField(TransferMethodField.cardType.rawValue) } /// The expiration date. public var dateOfExpiry: String? { - return getField(TransferMethodField.dateOfExpiry.rawValue) + getField(TransferMethodField.dateOfExpiry.rawValue) } /// A helper class to build the `HyperwalletBankCard` instance. @@ -79,7 +79,7 @@ public class HyperwalletBankCard: HyperwalletTransferMethod { /// /// - Returns: a new instance of the `HyperwalletBankCard`. public func build() -> HyperwalletBankCard { - return HyperwalletBankCard(data: self.storage) + HyperwalletBankCard(data: self.storage) } /// Sets the card number diff --git a/Sources/Model/TransferMethod/HyperwalletBankCardQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletBankCardQueryParam.swift index 8cc1eedf..dc7abc5a 100644 --- a/Sources/Model/TransferMethod/HyperwalletBankCardQueryParam.swift +++ b/Sources/Model/TransferMethod/HyperwalletBankCardQueryParam.swift @@ -20,14 +20,12 @@ import Foundation /// Representation of the bank card query parameters. public class HyperwalletBankCardQueryParam: HyperwalletTransferMethodQueryParam { - private enum QueryParam: String { - case type - } - override public func toQuery() -> [String: String] { var query = super.toQuery() - query[QueryParam.type.rawValue] = "BANK_CARD" + if type != nil { + query[QueryParam.type.rawValue] = QueryType.bankCard.rawValue + } return query } } diff --git a/Sources/Model/TransferMethod/HyperwalletPayPalAccount.swift b/Sources/Model/TransferMethod/HyperwalletPayPalAccount.swift index 078bb1e7..68fd4e6c 100644 --- a/Sources/Model/TransferMethod/HyperwalletPayPalAccount.swift +++ b/Sources/Model/TransferMethod/HyperwalletPayPalAccount.swift @@ -30,7 +30,7 @@ public final class HyperwalletPayPalAccount: HyperwalletTransferMethod { /// The email address. public var email: String? { - return getField(TransferMethodField.email.rawValue) + getField(TransferMethodField.email.rawValue) } /// A helper class to build the `HyperwalletPayPalAccount` instance. @@ -81,7 +81,7 @@ public final class HyperwalletPayPalAccount: HyperwalletTransferMethod { /// /// - Returns: a new instance of the `HyperwalletPayPalAccount`. public func build() -> HyperwalletPayPalAccount { - return HyperwalletPayPalAccount(data: self.storage) + HyperwalletPayPalAccount(data: self.storage) } } } diff --git a/Sources/Model/TransferMethod/HyperwalletPayPalAccountQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletPayPalAccountQueryParam.swift index 02eec721..66d7ee45 100644 --- a/Sources/Model/TransferMethod/HyperwalletPayPalAccountQueryParam.swift +++ b/Sources/Model/TransferMethod/HyperwalletPayPalAccountQueryParam.swift @@ -20,14 +20,12 @@ import Foundation /// Representation of the PayPal account query parameters. public class HyperwalletPayPalAccountQueryParam: HyperwalletTransferMethodQueryParam { - private enum QueryParam: String { - case type - } - override public func toQuery() -> [String: String] { var query = super.toQuery() - query[QueryParam.type.rawValue] = "PAYPAL_ACCOUNT" + if type != nil { + query[QueryParam.type.rawValue] = QueryType.payPalAccount.rawValue + } return query } } diff --git a/Sources/Model/TransferMethod/HyperwalletPrepaidCard.swift b/Sources/Model/TransferMethod/HyperwalletPrepaidCard.swift index 143a4d56..562e8f94 100644 --- a/Sources/Model/TransferMethod/HyperwalletPrepaidCard.swift +++ b/Sources/Model/TransferMethod/HyperwalletPrepaidCard.swift @@ -30,32 +30,37 @@ public final class HyperwalletPrepaidCard: HyperwalletTransferMethod { /// The prepaid card's type public var cardType: String? { - return getField(TransferMethodField.cardType.rawValue) + getField(TransferMethodField.cardType.rawValue) } /// The prepaid card's package public var cardPackage: String? { - return getField(TransferMethodField.cardPackage.rawValue) + getField(TransferMethodField.cardPackage.rawValue) } /// The prepaid card's number public var cardNumber: String? { - return getField(TransferMethodField.cardNumber.rawValue) + getField(TransferMethodField.cardNumber.rawValue) } /// The prepaid card's brand public var cardBrand: String? { - return getField(TransferMethodField.cardBrand.rawValue) + getField(TransferMethodField.cardBrand.rawValue) } /// The prepaid card's expiry date public var dateOfExpiry: String? { - return getField(TransferMethodField.dateOfExpiry.rawValue) + getField(TransferMethodField.dateOfExpiry.rawValue) + } + + /// The primary prepaid card's token + public var primaryCardToken: String? { + getField(TransferMethodField.primaryCardToken.rawValue) } /// The prepaid card's user token (instant issue cards only) public var userToken: String? { - return getField(TransferMethodField.userToken.rawValue) + getField(TransferMethodField.userToken.rawValue) } /// A helper class to build the `HyperwalletPrepaidCard` instance. @@ -104,7 +109,7 @@ public final class HyperwalletPrepaidCard: HyperwalletTransferMethod { /// /// - Returns: a new instance of the `HyperwalletPrepaidCard`. public func build() -> HyperwalletPrepaidCard { - return HyperwalletPrepaidCard(data: self.storage) + HyperwalletPrepaidCard(data: self.storage) } } } diff --git a/Sources/Model/TransferMethod/HyperwalletPrepaidCardQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletPrepaidCardQueryParam.swift index a3c4f251..4c7b4023 100644 --- a/Sources/Model/TransferMethod/HyperwalletPrepaidCardQueryParam.swift +++ b/Sources/Model/TransferMethod/HyperwalletPrepaidCardQueryParam.swift @@ -19,15 +19,13 @@ import Foundation /// Representation of the prepaid card query parameters. -public class HyperwalletPrepaidCardQueryParm: HyperwalletTransferMethodQueryParam { - private enum QueryParam: String { - case type - } - +public class HyperwalletPrepaidCardQueryParam: HyperwalletTransferMethodQueryParam { override public func toQuery() -> [String: String] { var query = super.toQuery() - query[QueryParam.type.rawValue] = "PREPAID_CARD" + if type != nil { + query[QueryParam.type.rawValue] = QueryType.prepaidCard.rawValue + } return query } } diff --git a/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift b/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift index c58cd377..11ea9e96 100644 --- a/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift +++ b/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift @@ -144,12 +144,19 @@ public class HyperwalletTransferMethod: NSObject, Codable { case cvv /// The expiration date for the card (YYYY-MM). case dateOfExpiry + /// The primary card token + case primaryCardToken // PayPal account related fields /// /// The email address associated with the PayPal account. case email + // Venmo account related field + /// + /// The mobile number associated with the Venmo account. + case accountId + // prepaid card related fields /// /// The card's package @@ -174,6 +181,8 @@ public class HyperwalletTransferMethod: NSObject, Codable { case wireAccount = "WIRE_ACCOUNT" /// When the transfer method is Prepaid Card case prepaidCard = "PREPAID_CARD" + /// When the transfer method is Venmo Account + case venmoAccount = "VENMO_ACCOUNT" } /// Creates a new instance of the `HyperwalletTransferMethod` @@ -201,7 +210,7 @@ public class HyperwalletTransferMethod: NSObject, Codable { /// - Parameter fieldName: The `TransferMethodField` type raw value /// - Returns: Returns the field value, or nil if none exists. public func getField(_ fieldName: String) -> String? { - return self.storage[fieldName]?.value as? String + self.storage[fieldName]?.value as? String } /// Sets the field value based on the key @@ -214,7 +223,7 @@ public class HyperwalletTransferMethod: NSObject, Codable { } internal func getFields() -> [String: AnyCodable] { - return self.storage + self.storage } private struct CodingKeys: CodingKey { @@ -231,42 +240,42 @@ public class HyperwalletTransferMethod: NSObject, Codable { } static func make(key: String) -> CodingKeys { - return CodingKeys(stringValue: key)! + CodingKeys(stringValue: key)! } } /// The transfer method's created time public var createdOn: String? { - return getField(TransferMethodField.createdOn.rawValue) + getField(TransferMethodField.createdOn.rawValue) } /// The transfer method holder's profile type, e.g. INDIVIDUAL or BUSINESS. public var profileType: String? { - return getField(TransferMethodField.profileType.rawValue) + getField(TransferMethodField.profileType.rawValue) } /// The transfer method's status public var status: String? { - return getField(TransferMethodField.status.rawValue) + getField(TransferMethodField.status.rawValue) } /// The transfer method's token public var token: String? { - return getField(TransferMethodField.token.rawValue) + getField(TransferMethodField.token.rawValue) } /// The transfer method's country public var transferMethodCountry: String? { - return getField(TransferMethodField.transferMethodCountry.rawValue) + getField(TransferMethodField.transferMethodCountry.rawValue) } /// The transfer method's currency public var transferMethodCurrency: String? { - return getField(TransferMethodField.transferMethodCurrency.rawValue) + getField(TransferMethodField.transferMethodCurrency.rawValue) } /// The transfer method's type public var type: String? { - return getField(TransferMethodField.type.rawValue) + getField(TransferMethodField.type.rawValue) } } diff --git a/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift index 14a69644..db461c6f 100644 --- a/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift +++ b/Sources/Model/TransferMethod/HyperwalletTransferMethodQueryParam.swift @@ -20,11 +20,15 @@ import Foundation /// Representation of the common transfer method's query parameters. public class HyperwalletTransferMethodQueryParam: QueryParam { - private enum QueryParam: String { + enum QueryParam: String { case status + case type } + /// Returns transfer method with this status. - public var status: QueryStatus? + public var status: String? + /// Returns transfer method of that type + public var type: String? /// Representation of the transfer method status public enum QueryStatus: String { @@ -34,7 +38,7 @@ public class HyperwalletTransferMethodQueryParam: QueryParam { case deActivated = "DE_ACTIVATED" /// Filter only invalid transfer methods case invalid = "INVALID" - /// Filter only lostOrStolen prepaid cards + /// Filter only lost or stolen prepaid cards case lostOrStolen = "LOST_OR_STOLEN" /// Filter by preActivated prepaid cards case preActivated = "PRE_ACTIVATED" @@ -56,11 +60,30 @@ public class HyperwalletTransferMethodQueryParam: QueryParam { case descendantStatus = "-status" } + /// Representation of the transfer method's type + public enum QueryType: String { + /// When the transfer method is Bank Account + case bankAccount = "BANK_ACCOUNT" + /// When the transfer method is Bank Card + case bankCard = "BANK_CARD" + /// When the transfer method is PayPal Account + case payPalAccount = "PAYPAL_ACCOUNT" + /// When the transfer method is Wire Account + case wireAccount = "WIRE_ACCOUNT" + /// When the transfer method is Prepaid Card + case prepaidCard = "PREPAID_CARD" + /// When the transfer method is Venmo Account + case venmoAccount = "VENMO_ACCOUNT" + } + override public func toQuery() -> [String: String] { var query = super.toQuery() if let status = status { - query[QueryParam.status.rawValue] = status.rawValue + query[QueryParam.status.rawValue] = status + } + if let type = type { + query[QueryParam.type.rawValue] = type } return query } diff --git a/Sources/Model/TransferMethod/HyperwalletVenmoAccount.swift b/Sources/Model/TransferMethod/HyperwalletVenmoAccount.swift new file mode 100644 index 00000000..24ca06f7 --- /dev/null +++ b/Sources/Model/TransferMethod/HyperwalletVenmoAccount.swift @@ -0,0 +1,88 @@ +// +// Copyright 2020 - 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 Venmo account +@objcMembers +public final class HyperwalletVenmoAccount: 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 accountId as phone number. + public var accountId: String? { + getField(TransferMethodField.accountId.rawValue) + } + + /// A helper class to build the `HyperwalletVenmoAccount` instance. + public final class Builder { + private var storage = [String: AnyCodable]() + + /// Creates a new instance of the `HyperwalletVenmoAccount` based on the required parameter to update + /// Venmo account. + /// + /// - Parameter token: The Venmo account token. + public init(token: String) { + storage[TransferMethodField.token.rawValue] = AnyCodable(value: token) + } + + /// Creates a new instance of the `HyperwalletVenmoAccount` based on the required parameters to create + /// Venmo account. + /// + /// - Parameters: + /// - transferMethodCountry: The Venmo account country. + /// - transferMethodCurrency: The Venmo account currency. + /// - transferMethodProfileType: The Venmo account holder's profile type, e.g. INDIVIDUAL or BUSINESS + public init(transferMethodCountry: String, transferMethodCurrency: String, transferMethodProfileType: String) { + storage[TransferMethodField.type.rawValue] = AnyCodable(value: TransferMethodType.venmoAccount.rawValue) + storage[TransferMethodField.transferMethodCountry.rawValue] = AnyCodable(value: transferMethodCountry) + storage[TransferMethodField.transferMethodCurrency.rawValue] = AnyCodable(value: transferMethodCurrency) + storage[TransferMethodField.profileType.rawValue] = AnyCodable(value: transferMethodProfileType) + } + + /// Sets the accountId address + /// + /// - Parameter accountId: The accountId as phone number user want to create a Venmo account + /// - Returns: a self `HyperwalletVenmoAccount.Builder` instance. + public func accountId(_ accountId: String) -> Builder { + storage[TransferMethodField.accountId.rawValue] = AnyCodable(value: accountId) + return self + } + + /// Sets the bank account holder's profile type. + /// + /// - Parameter profileType: The Venmo account holder's profile type, e.g. INDIVIDUAL or BUSINESS + /// - Returns: a self `HyperwalletVenmoAccount.Builder` instance. + public func profileType(_ profileType: String) -> Builder { + storage[TransferMethodField.profileType.rawValue] = AnyCodable(value: profileType) + return self + } + + /// Builds a new instance of the `HyperwalletVenmoAccount`. + /// + /// - Returns: a new instance of the `HyperwalletVenmoAccount`. + public func build() -> HyperwalletVenmoAccount { + HyperwalletVenmoAccount(data: self.storage) + } + } +} diff --git a/Sources/Model/TransferMethod/HyperwalletVenmoQueryParam.swift b/Sources/Model/TransferMethod/HyperwalletVenmoQueryParam.swift new file mode 100644 index 00000000..d6e6f55d --- /dev/null +++ b/Sources/Model/TransferMethod/HyperwalletVenmoQueryParam.swift @@ -0,0 +1,31 @@ +// +// Copyright 2020 - 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 common Venmo's query parameters. +public class HyperwalletVenmoQueryParam: HyperwalletTransferMethodQueryParam { + override public func toQuery() -> [String: String] { + var query = super.toQuery() + + if type != nil { + query[QueryParam.type.rawValue] = QueryType.venmoAccount.rawValue + } + return query + } +} diff --git a/Sources/Model/User/HyperwalletUser.swift b/Sources/Model/User/HyperwalletUser.swift index 26700d6e..5d20f423 100644 --- a/Sources/Model/User/HyperwalletUser.swift +++ b/Sources/Model/User/HyperwalletUser.swift @@ -194,37 +194,37 @@ public class HyperwalletUser: NSObject, Codable { /// The user's street address. public var addressLine1: String? { - return getField(UserField.addressLine1.rawValue) + getField(UserField.addressLine1.rawValue) } /// The user's address, second line. public var addressLine2: String? { - return getField(UserField.addressLine2.rawValue) + getField(UserField.addressLine2.rawValue) } /// The business contact's street address. public var businessContactAddressLine1: String? { - return getField(UserField.businessContactAddressLine1.rawValue) + getField(UserField.businessContactAddressLine1.rawValue) } /// The business contact's address, second line. public var businessContactAddressLine2: String? { - return getField(UserField.businessContactAddressLine2.rawValue) + getField(UserField.businessContactAddressLine2.rawValue) } /// The business contact's city. public var businessContactCity: String? { - return getField(UserField.businessContactCity.rawValue) + getField(UserField.businessContactCity.rawValue) } /// The business contact's country, public var businessContactCountry: String? { - return getField(UserField.businessContactCountry.rawValue) + getField(UserField.businessContactCountry.rawValue) } /// The business contact's postal code. public var businessContactPostalCode: String? { - return getField(UserField.businessContactPostalCode.rawValue) + getField(UserField.businessContactPostalCode.rawValue) } /// The user's role in the organization @@ -237,32 +237,32 @@ public class HyperwalletUser: NSObject, Codable { /// The business contact's state, province or region. public var businessContactStateProvince: String? { - return getField(UserField.businessContactStateProvince.rawValue) + getField(UserField.businessContactStateProvince.rawValue) } /// The business name. public var businessName: String? { - return getField(UserField.businessName.rawValue) + getField(UserField.businessName.rawValue) } /// The business' operating name. public var businessOperatingName: String? { - return getField(UserField.businessOperatingName.rawValue) + getField(UserField.businessOperatingName.rawValue) } /// The country where the business is registered. public var businessRegistrationCountry: String? { - return getField(UserField.businessRegistrationCountry.rawValue) + getField(UserField.businessRegistrationCountry.rawValue) } /// The business registration number or identifier assigned by a government body. public var businessRegistrationId: String? { - return getField(UserField.businessRegistrationId.rawValue) + getField(UserField.businessRegistrationId.rawValue) } /// The state, province or region where the business is registered. public var businessRegistrationStateProvince: String? { - return getField(UserField.businessRegistrationStateProvince.rawValue) + getField(UserField.businessRegistrationStateProvince.rawValue) } /// The business type @@ -275,59 +275,59 @@ public class HyperwalletUser: NSObject, Codable { /// The user's city. public var city: String? { - return getField(UserField.city.rawValue) + getField(UserField.city.rawValue) } /// A client-defined identifier for the user. This is the unique ID assigned to the user on your system. public var clientUserId: String? { - return getField(UserField.clientUserId.rawValue) + getField(UserField.clientUserId.rawValue) } /// The user's country. public var country: String? { - return getField(UserField.country.rawValue) + getField(UserField.country.rawValue) } /// The user's birth country. public var countryOfBirth: String? { - return getField(UserField.countryOfBirth.rawValue) + getField(UserField.countryOfBirth.rawValue) } /// The user's country of citizenship or nationality. public var countryOfNationality: String? { - return getField(UserField.countryOfNationality.rawValue) + getField(UserField.countryOfNationality.rawValue) } /// The datetime the user account was created on in ISO 8601 format (YYYY-MM-DDThh:mm:ss). Note that the timezone /// used is UTC, therefore no time offset is returned. public var createdOn: String? { - return getField(UserField.createdOn.rawValue) + getField(UserField.createdOn.rawValue) } /// The user's date of birth (All users must be at least 13 years old). public var dateOfBirth: String? { - return getField(UserField.dateOfBirth.rawValue) + getField(UserField.dateOfBirth.rawValue) } /// The user's driver's license number. public var driversLicenseId: String? { - return getField(UserField.driversLicenseId.rawValue) + getField(UserField.driversLicenseId.rawValue) } /// The contact email address for the user account. This must be unique for your program, so you cannot have two /// users belonging to the same program with the same email address. public var email: String? { - return getField(UserField.email.rawValue) + getField(UserField.email.rawValue) } /// The user's employer identifier, generally used for tax purposes. public var employerId: String? { - return getField(UserField.employerId.rawValue) + getField(UserField.employerId.rawValue) } /// The user's first name. public var firstName: String? { - return getField(UserField.firstName.rawValue) + getField(UserField.firstName.rawValue) } /// The user's gender. @@ -340,47 +340,47 @@ public class HyperwalletUser: NSObject, Codable { /// The user's government ID number, such as a Social Security Number. public var governmentId: String? { - return getField(UserField.governmentId.rawValue) + getField(UserField.governmentId.rawValue) } /// The user's government ID type. public var governmentIdType: String? { - return getField(UserField.governmentIdType.rawValue) + getField(UserField.governmentIdType.rawValue) } /// The preferred language for the user's account. Defaults to English if not provided. public var language: String? { - return getField(UserField.language.rawValue) + getField(UserField.language.rawValue) } /// The user's last name. public var lastName: String? { - return getField(UserField.lastName.rawValue) + getField(UserField.lastName.rawValue) } /// The user's middle name. public var middleName: String? { - return getField(UserField.middleName.rawValue) + getField(UserField.middleName.rawValue) } /// The user's cell phone number. public var mobileNumber: String? { - return getField(UserField.mobileNumber.rawValue) + getField(UserField.mobileNumber.rawValue) } /// The user's passport number. public var passportId: String? { - return getField(UserField.passportId.rawValue) + getField(UserField.passportId.rawValue) } /// The user's phone number. public var phoneNumber: String? { - return getField(UserField.phoneNumber.rawValue) + getField(UserField.phoneNumber.rawValue) } /// The user's postal code. public var postalCode: String? { - return getField(UserField.postalCode.rawValue) + getField(UserField.postalCode.rawValue) } /// The user's profile type. See `ProfileType` @@ -393,12 +393,12 @@ public class HyperwalletUser: NSObject, Codable { /// The unique identifier for the program to which the user will belong. public var programToken: String? { - return getField(UserField.programToken.rawValue) + getField(UserField.programToken.rawValue) } /// The user's state, province or region. public var stateProvince: String? { - return getField(UserField.stateProvince.rawValue) + getField(UserField.stateProvince.rawValue) } /// The user account status. @@ -411,12 +411,12 @@ public class HyperwalletUser: NSObject, Codable { /// The local time of a region or a country. e.g. GMT, PST, ... public var timeZone: String? { - return getField(UserField.timeZone.rawValue) + getField(UserField.timeZone.rawValue) } /// The unique, auto-generated user identifier. Max 64 characters, prefixed with "usr-". public var token: String? { - return getField(UserField.token.rawValue) + getField(UserField.token.rawValue) } /// The user's verification status. A user may be required to verify their identity after a certain @@ -442,7 +442,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter fieldName: The `UserField` type raw value /// - Returns: Returns the field value, or nil if none exists. public func getField(_ fieldName: String) -> String? { - return self.storage[fieldName]?.value as? String + self.storage[fieldName]?.value as? String } /// A helper class to build the `HyperwalletUser` instance. @@ -454,7 +454,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter addressLine1: The user's street address /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func addressLine1(_ addressLine1: String) -> Builder { - return setField(key: UserField.addressLine1, value: addressLine1) + setField(key: UserField.addressLine1, value: addressLine1) } /// Sets the user's address, second line. @@ -462,14 +462,14 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter addressLine2: The user's address, second line. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func addressLine2(_ addressLine2: String) -> Builder { - return setField(key: UserField.addressLine2, value: addressLine2) + setField(key: UserField.addressLine2, value: addressLine2) } /// Builds a new instance of the `HyperwalletUser`. /// /// - Returns: a new instance of the `HyperwalletUser`. public func build() -> HyperwalletUser { - return HyperwalletUser(data: self.storage) + HyperwalletUser(data: self.storage) } /// Sets the business contact's street address. @@ -477,7 +477,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactAddressLine1: The business contact's street address. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactAddressLine1(_ businessContactAddressLine1: String) -> Builder { - return setField(key: UserField.businessContactAddressLine1, value: businessContactAddressLine1) + setField(key: UserField.businessContactAddressLine1, value: businessContactAddressLine1) } /// Sets the business contact's address, second line. @@ -485,7 +485,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactAddressLine2: The business contact's address, second line. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactAddressLine2(_ businessContactAddressLine2: String) -> Builder { - return setField(key: UserField.businessContactAddressLine2, value: businessContactAddressLine2) + setField(key: UserField.businessContactAddressLine2, value: businessContactAddressLine2) } /// Sets the business contact's city. @@ -493,7 +493,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactCity: The business contact's city. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactCity(_ businessContactCity: String) -> Builder { - return setField(key: UserField.businessContactCity, value: businessContactCity) + setField(key: UserField.businessContactCity, value: businessContactCity) } /// Sets the business contact's country. @@ -501,7 +501,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactCountry: The business contact's city. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactCountry(_ businessContactCountry: String) -> Builder { - return setField(key: UserField.businessContactCountry, value: businessContactCountry) + setField(key: UserField.businessContactCountry, value: businessContactCountry) } /// Sets the business contact's postal code. @@ -509,7 +509,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactPostalCode: The business contact's postal code. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactPostalCode(_ businessContactPostalCode: String) -> Builder { - return setField(key: UserField.businessContactPostalCode, value: businessContactPostalCode) + setField(key: UserField.businessContactPostalCode, value: businessContactPostalCode) } /// Sets the user's role in the organization. @@ -517,7 +517,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactPostalCode: The `BusinessContactRole`. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactRole(_ businessContactRole: BusinessContactRole) -> Builder { - return setField(key: UserField.businessContactRole, value: businessContactRole.rawValue) + setField(key: UserField.businessContactRole, value: businessContactRole.rawValue) } /// Sets the business contact's state, province or region. @@ -525,7 +525,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessContactStateProvince: The business contact's state, province or region. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessContactStateProvince(_ businessContactStateProvince: String) -> Builder { - return setField(key: UserField.businessContactStateProvince, value: businessContactStateProvince) + setField(key: UserField.businessContactStateProvince, value: businessContactStateProvince) } /// Sets the business name. @@ -533,7 +533,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessName: The business name. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessName(_ businessName: String) -> Builder { - return setField(key: UserField.businessName, value: businessName) + setField(key: UserField.businessName, value: businessName) } /// Sets the business' operating name. @@ -541,7 +541,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessName: The business' operating name. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessOperatingName(_ businessOperatingName: String) -> Builder { - return setField(key: UserField.businessOperatingName, value: businessOperatingName) + setField(key: UserField.businessOperatingName, value: businessOperatingName) } /// Sets the country where the business is registered. @@ -549,7 +549,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessRegistrationCountry: The country where the business is registered. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessRegistrationCountry(_ businessRegistrationCountry: String) -> Builder { - return setField(key: UserField.businessRegistrationCountry, value: businessRegistrationCountry) + setField(key: UserField.businessRegistrationCountry, value: businessRegistrationCountry) } /// Sets the business registration number or identifier assigned by a government body. @@ -558,7 +558,7 @@ public class HyperwalletUser: NSObject, Codable { /// government body. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessRegistrationId(_ businessRegistrationId: String) -> Builder { - return setField(key: UserField.businessRegistrationId, value: businessRegistrationId) + setField(key: UserField.businessRegistrationId, value: businessRegistrationId) } /// Sets the state, province or region where the business is registered. @@ -567,7 +567,7 @@ public class HyperwalletUser: NSObject, Codable { /// government body. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessRegistrationStateProvince(_ businessRegistrationStateProvince: String) -> Builder { - return setField(key: UserField.businessRegistrationStateProvince, value: businessRegistrationStateProvince) + setField(key: UserField.businessRegistrationStateProvince, value: businessRegistrationStateProvince) } /// Sets the business type. @@ -575,7 +575,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter businessRegistrationStateProvince: The `BusinessType`. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func businessType(_ businessType: BusinessType) -> Builder { - return setField(key: UserField.businessType, value: businessType.rawValue) + setField(key: UserField.businessType, value: businessType.rawValue) } /// Sets the user's city. @@ -583,7 +583,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter city: The user's city. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func city(_ city: String) -> Builder { - return setField(key: UserField.city, value: city) + setField(key: UserField.city, value: city) } /// Sets the user's country. @@ -591,7 +591,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter country: The user's country. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func country(_ country: String) -> Builder { - return setField(key: UserField.country, value: country) + setField(key: UserField.country, value: country) } /// Sets the user's birth country. @@ -599,7 +599,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter country: The user's birth country. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func countryOfBirth(_ countryOfBirth: String) -> Builder { - return setField(key: UserField.countryOfBirth, value: countryOfBirth) + setField(key: UserField.countryOfBirth, value: countryOfBirth) } /// Sets the user's country of citizenship or nationality. @@ -607,7 +607,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter countryOfNationality: The user's country of citizenship or nationality. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func countryOfNationality(_ countryOfNationality: String) -> Builder { - return setField(key: UserField.countryOfNationality, value: countryOfNationality) + setField(key: UserField.countryOfNationality, value: countryOfNationality) } /// Sets the datetime the user account was created on in ISO 8601 format (YYYY-MM-DDThh:mm:ss). Note that the @@ -618,7 +618,7 @@ public class HyperwalletUser: NSObject, Codable { /// offset is returned. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func createdOn(_ createdOn: String) -> Builder { - return setField(key: UserField.createdOn, value: createdOn) + setField(key: UserField.createdOn, value: createdOn) } /// Sets the user's date of birth (All users must be at least 13 years old). @@ -626,7 +626,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter dateOfBirth: The user's date of birth (All users must be at least 13 years old). /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func dateOfBirth(_ dateOfBirth: String) -> Builder { - return setField(key: UserField.dateOfBirth, value: dateOfBirth) + setField(key: UserField.dateOfBirth, value: dateOfBirth) } /// Sets the user's driver's license number. @@ -634,7 +634,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter driversLicenseId: The user's driver's license number. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func driversLicenseId(_ driversLicenseId: String) -> Builder { - return setField(key: UserField.driversLicenseId, value: driversLicenseId) + setField(key: UserField.driversLicenseId, value: driversLicenseId) } /// Sets the contact email address for the user account. This must be unique for your program, so you cannot @@ -645,7 +645,7 @@ public class HyperwalletUser: NSObject, Codable { /// same email address. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func email(_ email: String) -> Builder { - return setField(key: UserField.email, value: email) + setField(key: UserField.email, value: email) } /// Sets the user's employer identifier, generally used for tax purposes. @@ -653,7 +653,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter employerId: The user's employer identifier, generally used for tax purposes. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func employerId(_ employerId: String) -> Builder { - return setField(key: UserField.employerId, value: employerId) + setField(key: UserField.employerId, value: employerId) } /// Sets the user's first name. @@ -661,7 +661,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter firstName: The user's first name. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func firstName(_ firstName: String) -> Builder { - return setField(key: UserField.employerId, value: firstName) + setField(key: UserField.employerId, value: firstName) } /// Sets the user's gender. @@ -669,7 +669,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter gender: The `Gender`. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func gender(_ gender: Gender) -> Builder { - return setField(key: UserField.gender, value: gender.rawValue) + setField(key: UserField.gender, value: gender.rawValue) } /// Sets the user's government ID number, such as a Social Security Number. @@ -677,7 +677,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter governmentId: The user's government ID number, such as a Social Security Number. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func governmentId(_ governmentId: String) -> Builder { - return setField(key: UserField.employerId, value: governmentId) + setField(key: UserField.employerId, value: governmentId) } /// Sets the user's government ID type. @@ -685,7 +685,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter governmentIdType: The user's government ID type. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func governmentIdType(_ governmentIdType: String) -> Builder { - return setField(key: UserField.governmentIdType, value: governmentIdType) + setField(key: UserField.governmentIdType, value: governmentIdType) } /// Sets the preferred language for the user's account. Defaults to English if not provided. @@ -693,7 +693,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter language: The preferred language for the user's account. Defaults to English if not provided. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func language(_ language: String) -> Builder { - return setField(key: UserField.language, value: language) + setField(key: UserField.language, value: language) } /// Sets the user's last name. @@ -701,7 +701,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter lastName: The user's last name. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func lastName(_ lastName: String) -> Builder { - return setField(key: UserField.lastName, value: lastName) + setField(key: UserField.lastName, value: lastName) } /// Sets the user's middle name. @@ -709,7 +709,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter middleName: The user's middle name. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func middleName(_ middleName: String) -> Builder { - return setField(key: UserField.middleName, value: middleName) + setField(key: UserField.middleName, value: middleName) } /// Sets the user's cell phone number. @@ -717,7 +717,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter middleName: The user's middle name. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func mobileNumber(_ mobileNumber: String) -> Builder { - return setField(key: UserField.mobileNumber, value: mobileNumber) + setField(key: UserField.mobileNumber, value: mobileNumber) } /// Sets the user's passport number. @@ -725,7 +725,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter passportId: The user's passport number. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func passportId(_ passportId: String) -> Builder { - return setField(key: UserField.passportId, value: passportId) + setField(key: UserField.passportId, value: passportId) } /// Sets the user's phone number. @@ -733,7 +733,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter passportId: The user's phone number. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func phoneNumber(_ phoneNumber: String) -> Builder { - return setField(key: UserField.phoneNumber, value: phoneNumber) + setField(key: UserField.phoneNumber, value: phoneNumber) } /// Sets the user's postal code. @@ -741,7 +741,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter postalCode: The user's postal code. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func postalCode(_ postalCode: String) -> Builder { - return setField(key: UserField.postalCode, value: postalCode) + setField(key: UserField.postalCode, value: postalCode) } /// Sets the user's profile type. @@ -749,7 +749,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter profileType: The `ProfileType`. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func profileType(_ profileType: ProfileType) -> Builder { - return setField(key: UserField.profileType, value: profileType.rawValue) + setField(key: UserField.profileType, value: profileType.rawValue) } /// Sets the unique identifier for the program to which the user will belong. @@ -757,7 +757,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter programToken: The unique identifier for the program to which the user will belong. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func programToken(_ programToken: String) -> Builder { - return setField(key: UserField.postalCode, value: programToken) + setField(key: UserField.postalCode, value: programToken) } /// Sets the field value based on the `UserField` @@ -766,7 +766,7 @@ public class HyperwalletUser: NSObject, Codable { /// - key: The `UserField` value /// - value: The value public func setField(key: UserField, value: String) -> Builder { - return setField(key: key.rawValue, value: value) + setField(key: key.rawValue, value: value) } /// Sets the field value based on the `UserField.RawValue` @@ -784,7 +784,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter stateProvince: The user's state, province or region. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func stateProvince(_ stateProvince: String) -> Builder { - return setField(key: UserField.stateProvince, value: stateProvince) + setField(key: UserField.stateProvince, value: stateProvince) } /// Sets the user account status. @@ -792,7 +792,7 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter status: The user's state, province or region. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func status(_ status: Status) -> Builder { - return setField(key: UserField.status, value: status.rawValue) + setField(key: UserField.status, value: status.rawValue) } /// Sets the local time of a region or a country. e.g. GMT, PST, ... @@ -800,14 +800,14 @@ public class HyperwalletUser: NSObject, Codable { /// - Parameter timeZone: The local time of a region or a country. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func timeZone(_ timeZone: String) -> Builder { - return setField(key: UserField.timeZone, value: timeZone) + setField(key: UserField.timeZone, value: timeZone) } /// Sets the unique, auto-generated user identifier. Max 64 characters, prefixed with "usr-". /// /// - Parameter token: The unique, auto-generated user identifier. Max 64 characters, prefixed with "usr-". /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func token(_ token: String) -> Builder { - return setField(key: UserField.token, value: token) + setField(key: UserField.token, value: token) } /// Sets the the user's verification status. A user may be required to verify their identity after a certain @@ -817,7 +817,7 @@ public class HyperwalletUser: NSObject, Codable { /// identity after a certainthreshold of payments is reached. /// - Returns: a self reference of `HyperwalletUser.Builder` instance. public func verificationStatus(_ verificationStatus: VerificationStatus) -> Builder { - return setField(key: UserField.verificationStatus, value: verificationStatus.rawValue) + setField(key: UserField.verificationStatus, value: verificationStatus.rawValue) } } @@ -835,7 +835,7 @@ public class HyperwalletUser: NSObject, Codable { } static func make(key: String) -> CodingKeys { - return CodingKeys(stringValue: key)! + CodingKeys(stringValue: key)! } } } diff --git a/Tests/Balance/HyperwalletPrepaidCardBalanceTests.swift b/Tests/Balance/HyperwalletPrepaidCardBalanceTests.swift new file mode 100644 index 00000000..ecbfeb09 --- /dev/null +++ b/Tests/Balance/HyperwalletPrepaidCardBalanceTests.swift @@ -0,0 +1,135 @@ +import Hippolyte +@testable import HyperwalletSDK +import XCTest + +class HyperwalletPrepaidCardBalanceTests: XCTestCase { + private var amount: String? + private var currency: String? + private var expectedCurrency: String? + private var mockResponseFileName: String? + private var sortBy: String? + private var testCaseDescription: String? + private var prepaidCardBalanceCount: String? + + override func setUp() { + Hyperwallet.setup(HyperwalletTestHelper.authenticationProvider) + } + + override func tearDown() { + if Hippolyte.shared.isStarted { + Hippolyte.shared.stop() + } + } + + func testListPrepaidCardBalances_success() { + if testCaseDescription != "Empty Result" { + // Given + let expectation = self.expectation(description: "List Prepaid Card Balances completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: mockResponseFileName!) + let url = String(format: "%@/prepaid-cards/%@/balances", HyperwalletTestHelper.userRestURL, "trm-1234") + let request = HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var prepaidCardBalanceList: HyperwalletPageList? + var errorResponse: HyperwalletErrorType? + + // When + var balanceQueryParam: HyperwalletPrepaidCardBalanceQueryParam? + if sortBy != nil { + balanceQueryParam = HyperwalletPrepaidCardBalanceQueryParam() + balanceQueryParam?.sortBy = sortBy + } + + Hyperwallet.shared.listPrepaidCardBalances(prepaidCardToken: "trm-1234", + queryParam: balanceQueryParam) { (result, error) in + prepaidCardBalanceList = result + errorResponse = error + expectation.fulfill() + } + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "\(testCaseDescription!) - The `errorResponse` should be nil") + XCTAssertNotNil(prepaidCardBalanceList, + "\(testCaseDescription!) - The `prepaidCardBalanceList` should not be nil") + XCTAssertEqual(prepaidCardBalanceList?.count, + Int(prepaidCardBalanceCount!), + "\(testCaseDescription!) - The `count` should be \(prepaidCardBalanceCount!)") + XCTAssertNotNil(prepaidCardBalanceList?.data, "\(testCaseDescription!) - The `data` should be not nil") + XCTAssertNotNil(prepaidCardBalanceList?.links, "\(testCaseDescription!) - The `links` should be not nil") + XCTAssertNotNil(prepaidCardBalanceList?.links?.first?.params?.rel) + + if let prepaidCardBalance = prepaidCardBalanceList?.data?.first { + XCTAssertEqual(prepaidCardBalance.amount, amount) + XCTAssertEqual(prepaidCardBalance.currency, expectedCurrency) + } else { + assertionFailure("\(testCaseDescription!) - The prepaid card balance should be not nil") + } + } + } + + func testListPrepaidACardBalances_emptyResult() { + if testCaseDescription == "Empty Result" { + // Given + let expectation = self.expectation(description: "List Prepaid Card Balances completed") + let response = HyperwalletTestHelper.noContentHTTPResponse() + let url = String(format: "%@/prepaid-cards/%@/balances", HyperwalletTestHelper.userRestURL, "trm-1234") + let request = HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var prepaidCardBalanceList: HyperwalletPageList? + var errorResponse: HyperwalletErrorType? + + //When + Hyperwallet.shared.listPrepaidCardBalances(prepaidCardToken: "trm-1234") { (result, error) in + prepaidCardBalanceList = result + errorResponse = error + expectation.fulfill() + } + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNil(prepaidCardBalanceList, "The `prepaidCardBalanceList` should be nil") + } + } + + override static var defaultTestSuite: XCTestSuite { + let testSuite = XCTestSuite(name: String(describing: self)) + let testParameters = getTestParameters() + + for testCaseParameters in testParameters { + addTest(with: testCaseParameters, toTestSuite: testSuite) + } + return testSuite + } + + private static func addTest(with testCaseParameters: [String?], + toTestSuite testSuite: XCTestSuite) { + testInvocations.forEach { invocation in + let testCase = HyperwalletPrepaidCardBalanceTests(invocation: invocation) + testCase.testCaseDescription = testCaseParameters[0]! + testCase.mockResponseFileName = testCaseParameters[1] + testCase.currency = testCaseParameters[2] + testCase.sortBy = testCaseParameters[3] + testCase.expectedCurrency = testCaseParameters[4] + testCase.amount = testCaseParameters[5] + testCase.prepaidCardBalanceCount = testCaseParameters[6] + testSuite.addTest(testCase) + } + } + + private static func getTestParameters() -> [[String?]] { + // Each test case parameter contains + // testCaseDescription, mockResponseFileName, currency, sortBy, expectedCurrency, amount, + // prepaidCardBalanceCount + let testParameters = [ + [ + "List of balances for USD, sorted on currency", + "ListPrepaidCardBalancesResponseSuccess", "USD", "currency", "USD", "9933.35", "1" + ], + ["Empty Result", nil, nil, nil, nil, nil, nil] + ] + return testParameters + } +} diff --git a/Tests/Balance/ListPrepaidCardBalancesResponseSuccess.json b/Tests/Balance/ListPrepaidCardBalancesResponseSuccess.json new file mode 100644 index 00000000..977f26e8 --- /dev/null +++ b/Tests/Balance/ListPrepaidCardBalancesResponseSuccess.json @@ -0,0 +1,20 @@ +{ + "count": 1, + "offset": 0, + "limit": 10, + "data": [ + { + "currency": "USD", + "amount": "9933.35" + } + ], + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost:8181/rest/v3/users/usr-112233/prepaid-cards/trm-1234/balances?offset=0&limit=10" + } + ] +} + diff --git a/Tests/ConfigurationTests.swift b/Tests/ConfigurationTests.swift index 554b3c36..fe2d22da 100644 --- a/Tests/ConfigurationTests.swift +++ b/Tests/ConfigurationTests.swift @@ -39,15 +39,16 @@ class ConfigurationTests: XCTestCase { } private func getConfiguration(_ expiryOn: Double) -> Configuration { - return Configuration(createOn: issueTime, - clientToken: "client-token", - expiresOn: expiryOn, - graphQlUrl: "https://test/graphql", - restUrl: "https://test/restUrl", - environment: "DEV", - insightsUrl: "https://test/insightsUrl", - issuer: "issuer-token", - userToken: "user-token", - authorization: "") + Configuration(createOn: issueTime, + clientToken: "client-token", + expiresOn: expiryOn, + graphQlUrl: "https://test/graphql", + restUrl: "https://test/restUrl", + environment: "DEV", + insightsUrl: "https://test/insightsUrl", + issuer: "issuer-token", + userToken: "user-token", + programModel: "program-model", + authorization: "") } } diff --git a/Tests/HTTPTransactionTests.swift b/Tests/HTTPTransactionTests.swift index 36482bd2..46404a5b 100644 --- a/Tests/HTTPTransactionTests.swift +++ b/Tests/HTTPTransactionTests.swift @@ -19,10 +19,14 @@ class HTTPTransactionTests: XCTestCase { XCTAssertEqual(configuration.timeoutIntervalForRequest, 10.0) XCTAssertEqual(header?["Content-Type"] as? String, "application/json") XCTAssertTrue((header?["Accept-Language"] as? String ?? "").contains("en")) + XCTAssertNotNil(header?["x-sdk-version"]) + XCTAssertTrue((header?["x-sdk-type"] as? String ?? "").contains("ios")) + XCTAssertNotNil(header?["x-sdk-contextId"]) let userAgent = header?["User-Agent"] as? String XCTAssertTrue(userAgent?.contains("HyperwalletSDK/iOS/") ?? false ) XCTAssertTrue(userAgent?.contains("App:") ?? false) XCTAssertTrue(userAgent?.contains("iOS:") ?? false) + XCTAssertEqual(userAgent?.components(separatedBy: ";").count, 4) } func testPerformRest_newConfiguration() { @@ -62,8 +66,8 @@ class HTTPTransactionTests: XCTestCase { // Given let queryParam = HyperwalletBankAccountQueryParam() queryParam.limit = 80 - queryParam.status = .activated - queryParam.type = .bankAccount + queryParam.status = HyperwalletBankAccountQueryParam.QueryStatus.activated.rawValue + queryParam.type = HyperwalletBankAccountQueryParam.QueryType.bankAccount.rawValue var queryParamsDictionary: [String: String]? var urlValueComponents: URLComponents? // When @@ -157,8 +161,8 @@ class HTTPTransactionTests: XCTestCase { transferMethodType: "BANK_ACCOUNT", profile: "INDIVIDUAL") // When - an API call request is made - let completionHandler = { - (data: Connection?, error: HyperwalletErrorType?) -> Void in + let completionHandler = { (data: Connection?, error: HyperwalletErrorType?) + -> Void in response = data hyperwalletError = error } @@ -190,8 +194,8 @@ class HTTPTransactionTests: XCTestCase { transferMethodType: "BANK_ACCOUNT", profile: "INDIVIDUAL") // When - an API call request is made - let completionHandler = { - (data: Connection?, error: HyperwalletErrorType?) -> Void in + let completionHandler = { (data: Connection?, error: HyperwalletErrorType?) + -> Void in response = data hyperwalletError = error } diff --git a/Tests/Helper/AuthenticationTokenGeneratorMock.swift b/Tests/Helper/AuthenticationTokenGeneratorMock.swift index ab0edcdc..f08929f1 100644 --- a/Tests/Helper/AuthenticationTokenGeneratorMock.swift +++ b/Tests/Helper/AuthenticationTokenGeneratorMock.swift @@ -85,7 +85,7 @@ struct AuthenticationTokenGeneratorMock { /// Returns the Authentication header private var header: String { - return """ + """ { "alg": "ALGORITHM" } diff --git a/Tests/Helper/HyperwalletTestHelper.swift b/Tests/Helper/HyperwalletTestHelper.swift index 639c525c..e99ad1ba 100644 --- a/Tests/Helper/HyperwalletTestHelper.swift +++ b/Tests/Helper/HyperwalletTestHelper.swift @@ -16,7 +16,7 @@ class HyperwalletTestHelper { // MARK: Build Requests static func buildPostRequest(baseUrl: String, _ response: StubResponse) -> StubRequest { - return StubRequest.Builder() + StubRequest.Builder() .stubRequest(withMethod: .POST, url: URL(string: baseUrl)!) .addHeader(withKey: contentType, value: applicationJson) .addResponse(response) @@ -24,7 +24,7 @@ class HyperwalletTestHelper { } static func buildGetRequest(baseUrl: String, _ response: StubResponse) -> StubRequest { - return StubRequest.Builder() + StubRequest.Builder() .stubRequest(withMethod: .GET, url: URL(string: baseUrl)!) .addHeader(withKey: contentType, value: applicationJson) .addResponse(response) @@ -41,7 +41,7 @@ class HyperwalletTestHelper { } static func buildPutRequest(baseUrl: String, _ response: StubResponse) -> StubRequest { - return StubRequest.Builder() + StubRequest.Builder() .stubRequest(withMethod: .PUT, url: URL(string: baseUrl)!) .addHeader(withKey: contentType, value: applicationJson) .addResponse(response) @@ -63,7 +63,7 @@ class HyperwalletTestHelper { /// /// - Returns: the StubResponse static func noContentHTTPResponse() -> StubResponse { - return setUpMockedResponse(payload: Data(), httpCode: 204) + setUpMockedResponse(payload: Data(), httpCode: 204) } /// Builts the stub HTTP 400 - Bad Request @@ -93,7 +93,7 @@ class HyperwalletTestHelper { error: NSError? = nil, httpCode: Int = 200, contentType: String = HyperwalletTestHelper.applicationJson) -> StubResponse { - return responseBuilder(payload, httpCode, error) + responseBuilder(payload, httpCode, error) .addHeader(withKey: HyperwalletTestHelper.contentType, value: contentType) .build() } diff --git a/Tests/Receipt/HyperwalletReceiptTests.swift b/Tests/Receipt/HyperwalletReceiptTests.swift index fd643de3..6647cd73 100644 --- a/Tests/Receipt/HyperwalletReceiptTests.swift +++ b/Tests/Receipt/HyperwalletReceiptTests.swift @@ -83,8 +83,15 @@ class HyperwalletReceiptTests: XCTestCase { receiptType, "Type should be TRANSFER_TO_PAYPAL_ACCOUNT") - let lastReceipt = userReceiptList?.data?.last! + 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, + receiptType, + "Type should be TRANSFER_TO_BANK_CARD") } func testListPrepaidCardReceipts_success() { diff --git a/Tests/Responses/ListPrepaidCardResponse.json b/Tests/Responses/ListPrepaidCardResponse.json index d668e9f9..d175435b 100644 --- a/Tests/Responses/ListPrepaidCardResponse.json +++ b/Tests/Responses/ListPrepaidCardResponse.json @@ -27,6 +27,7 @@ }, { "token": "trm-456", + "primaryCardToken": "trm-123", "type": "PREPAID_CARD", "status": "DEACTIVATED", "verificationStatus": "NOT_REQUIRED", diff --git a/Tests/Responses/ListUserReceiptResponse.json b/Tests/Responses/ListUserReceiptResponse.json index b079b4ee..3925fe6e 100644 --- a/Tests/Responses/ListUserReceiptResponse.json +++ b/Tests/Responses/ListUserReceiptResponse.json @@ -80,6 +80,17 @@ "clientPaymentId" : "trans-02", "payeeName" : "Vasya Pupkin" } + },{ + "journalId": "CC002F14A500", + "type": "TRANSFER_TO_BANK_CARD", + "createdOn": "2017-02-01T17:12:19", + "entry": "CREDIT", + "destinationToken": "trm-97a32", + "amount": "11.00", + "currency": "USD", + "details": { + "cardNumber": "************7917" + } }], "links" : [ { "params" : { diff --git a/Tests/Responses/PrepaidCardResponse.json b/Tests/Responses/PrepaidCardResponse.json new file mode 100644 index 00000000..051173bb --- /dev/null +++ b/Tests/Responses/PrepaidCardResponse.json @@ -0,0 +1,22 @@ +{ + "token": "trm-123", + "type": "PREPAID_CARD", + "status": "DEACTIVATED", + "verificationStatus": "NOT_REQUIRED", + "createdOn": "2019-06-20T21:21:43", + "transferMethodCountry": "CA", + "transferMethodCurrency": "USD", + "cardType": "VIRTUAL", + "cardPackage": "L1", + "cardNumber": "************6198", + "cardBrand": "VISA", + "dateOfExpiry": "2023-06", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost/rest/v3/users/usr-123/prepaid-cards/trm-123" + } + ] +} diff --git a/Tests/Responses/VenmoAccountList.json b/Tests/Responses/VenmoAccountList.json new file mode 100644 index 00000000..75d39e13 --- /dev/null +++ b/Tests/Responses/VenmoAccountList.json @@ -0,0 +1,32 @@ +{ + "count": 1, + "offset": 0, + "limit": 10, + "data": [ + { + "token": "trm-123456789", + "type": "VENMO_ACCOUNT", + "status": "ACTIVATED", + "createdOn": "2020-08-09T22:50:14", + "transferMethodCountry": "US", + "transferMethodCurrency": "USD", + "accountId": "9876543210", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost/rest/v3/users/usr-12345678/venmo-accounts/trm-12345678" + } + ] + } + ], + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost/rest/v3/users/usr-12345678/venmo-accounts?offset=0&limit=10" + } + ] +} \ No newline at end of file diff --git a/Tests/Responses/VenmoAccountMissingAccountId.json b/Tests/Responses/VenmoAccountMissingAccountId.json new file mode 100644 index 00000000..481f5f68 --- /dev/null +++ b/Tests/Responses/VenmoAccountMissingAccountId.json @@ -0,0 +1,6 @@ +{ + "errors" : [ { + "message" : "Mobile Number is required. The Mobile Number cannot be left blank. Please enter a valid US Mobile Number.", + "code" : "CONSTRAINT_VIOLATIONS" + } ] +} \ No newline at end of file diff --git a/Tests/Responses/VenmoAccountResponse.json b/Tests/Responses/VenmoAccountResponse.json new file mode 100644 index 00000000..11073ca6 --- /dev/null +++ b/Tests/Responses/VenmoAccountResponse.json @@ -0,0 +1,16 @@ +{ + "token" : "trm-123456789", + "type" : "VENMO_ACCOUNT", + "status" : "ACTIVATED", + "createdOn" : "2020-08-21T17:12:02", + "transferMethodCountry" : "US", + "transferMethodCurrency" : "USD", + "accountId" : "9876543210", + "userToken" : "usr-123456789", + "links" : [ { + "params" : { + "rel" : "self" + }, + "href" : "https://localhost/rest/v3/users/usr-123456789/venmo-accounts/trm-123456789" + } ] +} \ No newline at end of file diff --git a/Tests/Responses/VenmoAccountWrongFormatAccountId.json b/Tests/Responses/VenmoAccountWrongFormatAccountId.json new file mode 100644 index 00000000..1f2cecb0 --- /dev/null +++ b/Tests/Responses/VenmoAccountWrongFormatAccountId.json @@ -0,0 +1,6 @@ +{ + "errors" : [ { + "message" : "Mobile Number is invalid. The maximum length of this field is 10.", + "code" : "CONSTRAINT_VIOLATIONS" + } ] +} \ No newline at end of file diff --git a/Tests/TransactionTypeTests.swift b/Tests/TransactionTypeTests.swift index 1107d3c2..a80047f4 100644 --- a/Tests/TransactionTypeTests.swift +++ b/Tests/TransactionTypeTests.swift @@ -70,6 +70,7 @@ class TransactionTypeTests: XCTestCase { insightsUrl: "", issuer: "", userToken: "", + programModel: "", authorization: "") XCTAssertThrowsError(try transactionType.createRequest(configuration, @@ -98,6 +99,7 @@ class TransactionTypeTests: XCTestCase { insightsUrl: "", issuer: "", userToken: "", + programModel: "", authorization: "") let urlPath = transactionType == .rest ? "users/%@/bank-account" : "" @@ -146,6 +148,7 @@ class TransactionTypeTests: XCTestCase { insightsUrl: "", issuer: "", userToken: "", + programModel: "", authorization: "") let urlPath = transactionType == .graphQl ? "/graphql" : "" diff --git a/Tests/TransferMethod/HyperwalletBankAccountTests.swift b/Tests/TransferMethod/HyperwalletBankAccountTests.swift index 194b21c6..4aadc124 100644 --- a/Tests/TransferMethod/HyperwalletBankAccountTests.swift +++ b/Tests/TransferMethod/HyperwalletBankAccountTests.swift @@ -316,8 +316,8 @@ class HyperwalletBankAccountIndividualTests: XCTestCase { // When let bankAccountQueryParam = HyperwalletBankAccountQueryParam() - bankAccountQueryParam.status = .deActivated - bankAccountQueryParam.type = .bankAccount + bankAccountQueryParam.status = HyperwalletBankAccountQueryParam.QueryStatus.deActivated.rawValue + bankAccountQueryParam.type = HyperwalletBankAccountQueryParam.QueryType.bankAccount.rawValue bankAccountQueryParam.sortBy = HyperwalletBankAccountQueryParam.QuerySortable.ascendantCreatedOn.rawValue bankAccountQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-15T00:30:11") bankAccountQueryParam.createdBefore = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-18T00:30:11") @@ -357,8 +357,8 @@ class HyperwalletBankAccountIndividualTests: XCTestCase { var bankAccountList: HyperwalletPageList? var errorResponse: HyperwalletErrorType? let bankAccountQueryParam = HyperwalletBankAccountQueryParam() - bankAccountQueryParam.status = .activated - bankAccountQueryParam.type = .wireAccount + bankAccountQueryParam.status = HyperwalletBankAccountQueryParam.QueryStatus.activated.rawValue + bankAccountQueryParam.type = HyperwalletBankAccountQueryParam.QueryType.wireAccount.rawValue // When Hyperwallet.shared.listBankAccounts(queryParam: bankAccountQueryParam) { (result, error) in @@ -376,7 +376,7 @@ class HyperwalletBankAccountIndividualTests: XCTestCase { private extension HyperwalletBankAccountIndividualTests { func buildIndividualBankAccount() -> HyperwalletBankAccount { - return HyperwalletBankAccount + HyperwalletBankAccount .Builder(transferMethodCountry: "US", transferMethodCurrency: "USD", transferMethodProfileType: "INDIVIDUAL", @@ -413,7 +413,7 @@ private extension HyperwalletBankAccountIndividualTests { } func buildBusinessBankAccount() -> HyperwalletBankAccount { - return HyperwalletBankAccount + HyperwalletBankAccount .Builder(transferMethodCountry: "US", transferMethodCurrency: "USD", transferMethodProfileType: "BUSINESS", @@ -440,7 +440,7 @@ private extension HyperwalletBankAccountIndividualTests { } func buildIndividualWireAccount() -> HyperwalletBankAccount { - return HyperwalletBankAccount + HyperwalletBankAccount .Builder(transferMethodCountry: "US", transferMethodCurrency: "USD", transferMethodProfileType: "INDIVIDUAL", @@ -474,7 +474,7 @@ private extension HyperwalletBankAccountIndividualTests { } func buildBusinessWireAccount() -> HyperwalletBankAccount { - return HyperwalletBankAccount + HyperwalletBankAccount .Builder(transferMethodCountry: "US", transferMethodCurrency: "USD", transferMethodProfileType: "BUSINESS", diff --git a/Tests/TransferMethod/HyperwalletBankCardTests.swift b/Tests/TransferMethod/HyperwalletBankCardTests.swift index 3a718fe7..3dff1092 100644 --- a/Tests/TransferMethod/HyperwalletBankCardTests.swift +++ b/Tests/TransferMethod/HyperwalletBankCardTests.swift @@ -242,7 +242,8 @@ class HyperwalletBankCardTests: XCTestCase { // When let bankCardQueryParam = HyperwalletBankCardQueryParam() - bankCardQueryParam.status = HyperwalletBankCardQueryParam.QueryStatus.deActivated + bankCardQueryParam.status = HyperwalletBankCardQueryParam.QueryStatus.deActivated.rawValue + bankCardQueryParam.type = HyperwalletBankCardQueryParam.QueryType.bankCard.rawValue bankCardQueryParam.sortBy = HyperwalletBankCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue bankCardQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-15T00:30:11") bankCardQueryParam.createdBefore = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-18T00:30:11") @@ -285,7 +286,7 @@ class HyperwalletBankCardTests: XCTestCase { // When let bankCardQueryParam = HyperwalletBankCardQueryParam() - bankCardQueryParam.status = HyperwalletBankCardQueryParam.QueryStatus.activated + bankCardQueryParam.status = HyperwalletBankCardQueryParam.QueryStatus.activated.rawValue bankCardQueryParam.sortBy = HyperwalletBankCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue bankCardQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2019-01-01T00:30:11") diff --git a/Tests/TransferMethod/HyperwalletPayPalAccountTests.swift b/Tests/TransferMethod/HyperwalletPayPalAccountTests.swift index 3f2b23c0..2562af61 100644 --- a/Tests/TransferMethod/HyperwalletPayPalAccountTests.swift +++ b/Tests/TransferMethod/HyperwalletPayPalAccountTests.swift @@ -265,8 +265,10 @@ class HyperwalletPayPalAccountTests: XCTestCase { // When let payPalAccountQueryParam = HyperwalletPayPalAccountQueryParam() - payPalAccountQueryParam.status = .activated + payPalAccountQueryParam.status = HyperwalletPayPalAccountQueryParam.QueryStatus.activated.rawValue + payPalAccountQueryParam.type = HyperwalletPayPalAccountQueryParam.QueryType.payPalAccount.rawValue payPalAccountQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-15T00:30:11") + payPalAccountQueryParam.sortBy = HyperwalletTransferMethodQueryParam.QuerySortable.ascendantCreatedOn.rawValue Hyperwallet.shared.listPayPalAccounts(queryParam: payPalAccountQueryParam) { (result, error) in payPalAccountList = result @@ -302,7 +304,7 @@ class HyperwalletPayPalAccountTests: XCTestCase { // When let payPalAccountQueryParam = HyperwalletPayPalAccountQueryParam() - payPalAccountQueryParam.status = .deActivated + payPalAccountQueryParam.status = HyperwalletPayPalAccountQueryParam.QueryStatus.deActivated.rawValue // When Hyperwallet.shared.listPayPalAccounts(queryParam: payPalAccountQueryParam) { (result, error) in diff --git a/Tests/TransferMethod/HyperwalletPrepaidCardTests.swift b/Tests/TransferMethod/HyperwalletPrepaidCardTests.swift index b145c1b3..06a8b140 100644 --- a/Tests/TransferMethod/HyperwalletPrepaidCardTests.swift +++ b/Tests/TransferMethod/HyperwalletPrepaidCardTests.swift @@ -13,6 +13,33 @@ class HyperwalletPrepaidCardTests: XCTestCase { } } + func testGetPrepaidCard_success() { + // Given + let expectation = self.expectation(description: "Get prepaid card completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "PrepaidCardResponse") + let url = String(format: "%@/prepaid-cards/trm-123", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var prepaidCardResponse: HyperwalletPrepaidCard? + var errorResponse: HyperwalletErrorType? + + // When + Hyperwallet.shared.getPrepaidCard(transferMethodToken: "trm-123", completion: { (result, error) in + prepaidCardResponse = result + errorResponse = error + expectation.fulfill() + }) + + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(prepaidCardResponse?.getFields()) + XCTAssertEqual(prepaidCardResponse?.cardBrand, "VISA") + XCTAssertEqual(prepaidCardResponse?.type, HyperwalletTransferMethod.TransferMethodType.prepaidCard.rawValue) + } + //swiftlint:disable function_body_length func testListPrepaidCards_success() { // Given @@ -26,9 +53,10 @@ class HyperwalletPrepaidCardTests: XCTestCase { var errorResponse: HyperwalletErrorType? // When - let prepaidCardQueryParam = HyperwalletPrepaidCardQueryParm() - prepaidCardQueryParam.status = HyperwalletPrepaidCardQueryParm.QueryStatus.deActivated - prepaidCardQueryParam.sortBy = HyperwalletPrepaidCardQueryParm.QuerySortable.ascendantCreatedOn.rawValue + let prepaidCardQueryParam = HyperwalletPrepaidCardQueryParam() + prepaidCardQueryParam.status = HyperwalletPrepaidCardQueryParam.QueryStatus.deActivated.rawValue + prepaidCardQueryParam.type = HyperwalletPrepaidCardQueryParam.QueryType.prepaidCard.rawValue + prepaidCardQueryParam.sortBy = HyperwalletPrepaidCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue prepaidCardQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2019-06-20T21:21:43") prepaidCardQueryParam.createdBefore = ISO8601DateFormatter.ignoreTimeZone.date(from: "2019-06-20T23:21:43") @@ -41,7 +69,7 @@ class HyperwalletPrepaidCardTests: XCTestCase { // Then XCTAssertNil(errorResponse, "The `errorResponse` should be nil") - XCTAssertNotNil(prepaidCardList, "The `bankAccountList` should not be nil") + XCTAssertNotNil(prepaidCardList, "The `prepaidCardList` should not be nil") XCTAssertEqual(prepaidCardList?.count, 2, "The `count` should be 2") XCTAssertNotNil(prepaidCardList?.data, "The `data` should be not nil") @@ -64,6 +92,7 @@ class HyperwalletPrepaidCardTests: XCTestCase { let lastPrepaidCard = prepaidCardList?.data?.last XCTAssertEqual(lastPrepaidCard?.type, "PREPAID_CARD", "The type should be PREPAID_CARD") XCTAssertEqual(lastPrepaidCard?.token, "trm-456", "The token should be trm-456") + XCTAssertEqual(lastPrepaidCard?.primaryCardToken, "trm-123", "The primary card token should be trm-123") XCTAssertEqual(lastPrepaidCard?.cardNumber, "************2345", "The cardNumber should be ************2345") XCTAssertEqual(lastPrepaidCard?.dateOfExpiry, "2023-06", "The dateOfExpiry should be 2023-06") XCTAssertEqual(lastPrepaidCard?.cardPackage, "L1", "The cardPackage should be L1") @@ -84,9 +113,9 @@ class HyperwalletPrepaidCardTests: XCTestCase { var errorResponse: HyperwalletErrorType? // When - let prepaidCardQueryParam = HyperwalletPrepaidCardQueryParm() - prepaidCardQueryParam.status = HyperwalletPrepaidCardQueryParm.QueryStatus.activated - prepaidCardQueryParam.sortBy = HyperwalletPrepaidCardQueryParm.QuerySortable.ascendantCreatedOn.rawValue + let prepaidCardQueryParam = HyperwalletPrepaidCardQueryParam() + prepaidCardQueryParam.status = HyperwalletPrepaidCardQueryParam.QueryStatus.activated.rawValue + prepaidCardQueryParam.sortBy = HyperwalletPrepaidCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue prepaidCardQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2019-01-01T00:30:11") Hyperwallet.shared.listPrepaidCards(queryParam: prepaidCardQueryParam) { (result, error) in diff --git a/Tests/TransferMethod/HyperwalletTransferMethodTests.swift b/Tests/TransferMethod/HyperwalletTransferMethodTests.swift index 1893344a..35b76538 100644 --- a/Tests/TransferMethod/HyperwalletTransferMethodTests.swift +++ b/Tests/TransferMethod/HyperwalletTransferMethodTests.swift @@ -31,7 +31,7 @@ class HyperwalletTransferMethodTests: XCTestCase { from: "2018-12-15T00:30:11") transferMethodQueryParam.createdBefore = ISO8601DateFormatter.ignoreTimeZone.date( from: "2018-12-18T00:30:11") - transferMethodQueryParam.status = HyperwalletTransferMethodQueryParam.QueryStatus.activated + transferMethodQueryParam.status = HyperwalletTransferMethodQueryParam.QueryStatus.activated.rawValue // When Hyperwallet.shared.listTransferMethods(queryParam: transferMethodQueryParam) { (result, error) in diff --git a/Tests/TransferMethod/HyperwalletVenmoAccountTests.swift b/Tests/TransferMethod/HyperwalletVenmoAccountTests.swift new file mode 100644 index 00000000..23fc8a7d --- /dev/null +++ b/Tests/TransferMethod/HyperwalletVenmoAccountTests.swift @@ -0,0 +1,335 @@ +import Hippolyte +@testable import HyperwalletSDK +import XCTest + +class HyperwalletVenmoAccountTests: XCTestCase { + override func setUp() { + Hyperwallet.setup(HyperwalletTestHelper.authenticationProvider) + } + + override func tearDown() { + if Hippolyte.shared.isStarted { + Hippolyte.shared.stop() + } + } + + // create + func testCreateVenmoAccount_success() { + // Given + let expectation = self.expectation(description: "Create Venmo account completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "VenmoAccountResponse") + let url = String(format: "%@/venmo-accounts", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoAccountResponse: HyperwalletVenmoAccount? + var errorResponse: HyperwalletErrorType? + + // When + let venmoAccount = HyperwalletVenmoAccount + .Builder(transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "INDIVIDUAL") + .accountId("9876543210") + .build() + + Hyperwallet.shared.createVenmoAccount(account: venmoAccount, completion: { (result, error) in + venmoAccountResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(venmoAccount) + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(venmoAccountResponse?.getFields()) + XCTAssertEqual(venmoAccountResponse?.accountId, "9876543210") + } + + func testCreateVenmoAccount_missingMandatoryField_returnBadRequest() { + // Given + let expectation = self.expectation(description: "Create Venmo account failed") + let response = HyperwalletTestHelper.badRequestHTTPResponse(for: "VenmoAccountMissingAccountId") + let url = String(format: "%@/venmo-accounts", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoResponse: HyperwalletVenmoAccount? + var errorResponse: HyperwalletErrorType? + + // When + let venmoAccount = HyperwalletVenmoAccount.Builder( + transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "INDIVIDUAL") + .build() + + Hyperwallet.shared.createVenmoAccount(account: venmoAccount, completion: { (result, error) in + venmoResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(errorResponse, "The `errorResponse` should not be nil") + XCTAssertNil(venmoResponse) + XCTAssertEqual(errorResponse?.getHttpCode(), 400) + XCTAssertEqual( + errorResponse?.getHyperwalletErrors()?.errorList?.first?.message, + "Mobile Number is required. The Mobile Number cannot be left blank. " + + "Please enter a valid US Mobile Number.") + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.code, "CONSTRAINT_VIOLATIONS") + } + + func testCreateVenmoAccount_wrongFormatPhone_returnBadRequest() { + // Given + let expectation = self.expectation(description: "Create Venmo account failed") + let response = HyperwalletTestHelper.badRequestHTTPResponse(for: "VenmoAccountWrongFormatAccountId") + let url = String(format: "%@/venmo-accounts", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPostRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoResponse: HyperwalletVenmoAccount? + var errorResponse: HyperwalletErrorType? + + // When + let venmoAccount = HyperwalletVenmoAccount.Builder( + transferMethodCountry: "US", + transferMethodCurrency: "USD", + transferMethodProfileType: "INDIVIDUAL") + .accountId("my-phone-number") + .build() + + Hyperwallet.shared.createVenmoAccount(account: venmoAccount, completion: { (result, error) in + venmoResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(errorResponse, "The `errorResponse` should not be nil") + XCTAssertNil(venmoResponse) + XCTAssertEqual(errorResponse?.getHttpCode(), 400) + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.message, + "Mobile Number is invalid. The maximum length of this field is 10.") + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.code, "CONSTRAINT_VIOLATIONS") + } + + // get + func testGetVenmoAccount_success() { + // Given + let expectation = self.expectation(description: "Get Venmo account completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "VenmoAccountResponse") + let url = String(format: "%@/venmo-accounts/trm-12345", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoResponse: HyperwalletVenmoAccount? + var errorResponse: HyperwalletErrorType? + + // When + Hyperwallet.shared.getVenmoAccount(transferMethodToken: "trm-12345", completion: { (result, error) in + venmoResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(venmoResponse?.getFields()) + XCTAssertEqual(venmoResponse?.accountId, "9876543210") + XCTAssertEqual(venmoResponse?.status, "ACTIVATED") + } + + // list + func testListVenmoAccounts_success() { + // Given + let expectation = self.expectation(description: "List Venmo account completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "VenmoAccountList") + let url = String(format: "%@/venmo-accounts?+", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoAccounts: HyperwalletPageList? + var errorResponse: HyperwalletErrorType? + + // When + let venmoQuery = HyperwalletVenmoQueryParam() + venmoQuery.status = HyperwalletVenmoQueryParam.QueryStatus.activated.rawValue + venmoQuery.type = HyperwalletVenmoQueryParam.QueryType.venmoAccount.rawValue + venmoQuery.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-15T00:30:11") + + Hyperwallet.shared.listVenmoAccounts(queryParam: venmoQuery) { (result, error) in + venmoAccounts = result + errorResponse = error + expectation.fulfill() + } + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(venmoAccounts, "The `venmoAccounts` should not be nil") + XCTAssertEqual(venmoAccounts?.count, 1, "The `count` should be 1") + XCTAssertNotNil(venmoAccounts?.data, "The `data` should be not nil") + + XCTAssertNotNil(venmoAccounts?.links, "The `links` should be not nil") + XCTAssertNotNil(venmoAccounts?.links?.first?.params?.rel) + + let venmoAccount = venmoAccounts?.data?.first + XCTAssertEqual(venmoAccount?.token, "trm-123456789") + XCTAssertEqual(venmoAccount?.accountId, "9876543210") + } + + func testListVenmoAccounts_emptyResult() { + // Given + let expectation = self.expectation(description: "List Venmo account completed") + let response = HyperwalletTestHelper.noContentHTTPResponse() + let url = String(format: "%@/venmo-accounts?+", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildGetRequestRegexMatcher(pattern: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoAccounts: HyperwalletPageList? + var errorResponse: HyperwalletErrorType? + + // When + let venmoQuery = HyperwalletVenmoQueryParam() + venmoQuery.status = HyperwalletVenmoQueryParam.QueryStatus.deActivated.rawValue + + // When + Hyperwallet.shared.listVenmoAccounts(queryParam: venmoQuery) { (result, error) in + venmoAccounts = result + errorResponse = error + expectation.fulfill() + } + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNil(venmoAccounts, "The `venmoAccounts` should be nil") + } + + // update + func testUpdateVenmoAccount_success() { + // Given + let expectation = self.expectation(description: "Update Venmo account completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "VenmoAccountResponse") + let url = String(format: "%@/venmo-accounts/trm-123456789", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPutRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoResponse: HyperwalletVenmoAccount? + var errorResponse: HyperwalletErrorType? + + // When + let venmoAccount = HyperwalletVenmoAccount + .Builder(token: "trm-123456789") + .accountId("9876543210") + .profileType("INDIVIDUAL") + .build() + + Hyperwallet.shared.updateVenmoAccount(account: venmoAccount, completion: { (result, error) in + venmoResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNil(errorResponse, "The `errorResponse` should be nil") + XCTAssertNotNil(venmoResponse?.getFields()) + XCTAssertEqual(venmoResponse?.accountId, "9876543210") + } + + func testUpdateVenmoAccount_wrongFormatPhone() { + // Given + let expectation = self.expectation(description: "Update Venmo account failed") + let response = HyperwalletTestHelper.badRequestHTTPResponse(for: "VenmoAccountWrongFormatAccountId") + let url = String(format: "%@/venmo-accounts/trm-12345", HyperwalletTestHelper.userRestURL) + let request = HyperwalletTestHelper.buildPutRequest(baseUrl: url, response) + HyperwalletTestHelper.setUpMockServer(request: request) + + var venmoResponse: HyperwalletVenmoAccount? + var errorResponse: HyperwalletErrorType? + + // When + let venmoAccount = HyperwalletVenmoAccount.Builder(token: "trm-12345").accountId("9876543210").build() + + Hyperwallet.shared.updateVenmoAccount(account: venmoAccount, completion: { (result, error) in + venmoResponse = result + errorResponse = error + expectation.fulfill() + }) + wait(for: [expectation], timeout: 1) + + // Then + XCTAssertNotNil(errorResponse, "The `errorResponse` should not be nil") + XCTAssertNil(venmoResponse, "The `venmoResponse` should be nil") + XCTAssertEqual(errorResponse?.getHttpCode(), 400) + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.message, + "Mobile Number is invalid. The maximum length of this field is 10.") + XCTAssertEqual(errorResponse?.getHyperwalletErrors()?.errorList?.first?.code, "CONSTRAINT_VIOLATIONS") + } + + // deactivate + func testDeactivateVenmoAccount_success() { + // Given + let expectation = self.expectation(description: "Deactivate Venmo account completed") + let response = HyperwalletTestHelper.okHTTPResponse(for: "StatusTransitionMockedResponseSuccess") + let url = String(format: "%@/venmo-accounts/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.deactivateVenmoAccount( + transferMethodToken: "trm-12345", + notes: "deactivate Venmo account", + 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 testDeactivateVenmoAccount_invalidTransition() { + // Given + let expectation = self.expectation(description: "Deactivate Venmo account failed") + let response = HyperwalletTestHelper + .badRequestHTTPResponse(for: "StatusTransitionMockedResponseInvalidTransition") + let url = String(format: "%@/venmo-accounts/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.deactivateVenmoAccount( + transferMethodToken: "trm-12345", + notes: "deactivate Venmo account", + 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") + } +} diff --git a/fastlane/Fastfile b/fastlane/Fastfile index cb39c781..f40ca433 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -17,7 +17,7 @@ def updateVersion(type) version = last_git_tag if type == "beta" then version_components = version.split("beta") - last_component = Integer(version_components[-1]) + 1 + last_component = version_components[-1].to_i + 1 last_component_string = last_component.to_s if last_component_string.size == 1 then last_component_string = "0" + last_component_string @@ -28,10 +28,13 @@ def updateVersion(type) end def update(type, version) + # Update the TAG_VERSION property + info_plist_path = "Sources/Info.plist" + set_info_plist_value(path: info_plist_path, key: "TAG_VERSION", value: version) podspec_name = "HyperwalletSDK.podspec" pod_lib_lint(allow_warnings: true, skip_tests: true) version_bump_podspec(version_number: version, path: podspec_name) - git_add(path: podspec_name) - git_commit(path: [podspec_name], message: "#{version} release") + git_add(path: [podspec_name, info_plist_path, "*.md"]) + git_commit(path: [podspec_name, info_plist_path, "*.md"], message: "#{version} release") push_to_git_remote end