diff --git a/Skyflow/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj b/Skyflow/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj index b06950f8..47bf5f75 100644 --- a/Skyflow/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj +++ b/Skyflow/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj @@ -29,8 +29,8 @@ 9818DEA329239C1C004C72AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 9818DEA529239C1C004C72AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9818DEAB29239C87004C72AE /* ResponseStructs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseStructs.swift; sourceTree = ""; }; - 9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleTokenProvider.swift; path = ../../Upsert/Upsert/ExampleTokenProvider.swift; sourceTree = ""; }; - 9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleAPICallback.swift; path = ../../Upsert/Upsert/ExampleAPICallback.swift; sourceTree = ""; }; + 9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = ""; }; + 9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleAPICallback.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ diff --git a/Skyflow/Samples/UpsertFeature/UpsertFeature/ExampleAPICallback.swift b/Skyflow/Samples/UpsertFeature/UpsertFeature/ExampleAPICallback.swift new file mode 100644 index 00000000..6d0bbb21 --- /dev/null +++ b/Skyflow/Samples/UpsertFeature/UpsertFeature/ExampleAPICallback.swift @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Skyflow + */ + +import Foundation +import Skyflow + +public class ExampleAPICallback: Skyflow.Callback { + private var updateSuccess: ((SuccessResponse) -> Void)? + private var updateFailure: (() -> Void)? + private var decoder: JSONDecoder? + + internal init(updateSuccess: @escaping (SuccessResponse) -> Void, updateFailure: @escaping () -> Void) { + self.updateSuccess = updateSuccess + self.updateFailure = updateFailure + self.decoder = JSONDecoder() + } + + internal init() { + } + + public func onSuccess(_ responseBody: Any) { + if updateSuccess == nil { + print("success:", responseBody) + return + } + do { + let dataString = String(data: try! JSONSerialization.data(withJSONObject: responseBody), encoding: .utf8) + let responseData = Data(dataString!.utf8) + let jsonResponse = try decoder!.decode(SuccessResponse.self, from: responseData) + + updateSuccess!(jsonResponse) + + print("success:", jsonResponse) + } catch { + print("error deserializing", error) + } + } + + public func onFailure(_ error: Any) { + print(error) + if let updateFailure = updateFailure { + updateFailure() + return + } + print("onfailure", error) + } +} diff --git a/Skyflow/Samples/UpsertFeature/UpsertFeature/ExampleTokenProvider.swift b/Skyflow/Samples/UpsertFeature/UpsertFeature/ExampleTokenProvider.swift new file mode 100644 index 00000000..75a0efee --- /dev/null +++ b/Skyflow/Samples/UpsertFeature/UpsertFeature/ExampleTokenProvider.swift @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Skyflow + */ + +import Foundation +import Skyflow + +public class ExampleTokenProvider: TokenProvider { + public func getBearerToken(_ apiCallback: Skyflow.Callback) { + if let url = URL(string: "") { + let session = URLSession(configuration: .default) + let task = session.dataTask(with: url) { data, _, error in + if error != nil { + print(error!) + return + } + if let safeData = data { + do { + let x = try JSONSerialization.jsonObject(with: safeData, options: []) as? [String: String] + if let accessToken = x?["accessToken"] { + apiCallback.onSuccess(accessToken) + } + } catch { + print("access token wrong format") + } + } + } + task.resume() + } + } +} diff --git a/Skyflow/Samples/UpsertFeature/UpsertFeature/ViewController.swift b/Skyflow/Samples/UpsertFeature/UpsertFeature/ViewController.swift index 86f38902..9c1b6925 100644 --- a/Skyflow/Samples/UpsertFeature/UpsertFeature/ViewController.swift +++ b/Skyflow/Samples/UpsertFeature/UpsertFeature/ViewController.swift @@ -40,7 +40,7 @@ class ViewController: UIViewController { textAlignment: .left, textColor: .blue ) - let focusStyle = Skyflow.Style(borderColor: .blue) ̰ + let focusStyle = Skyflow.Style(borderColor: .blue) let completedStyle = Skyflow.Style(borderColor: UIColor.green, textColor: UIColor.green) let invalidStyle = Skyflow.Style(borderColor: UIColor.red, textColor: UIColor.red) let styles = Skyflow.Styles( diff --git a/Skyflow/Samples/Validations/Validations.xcodeproj/project.pbxproj b/Skyflow/Samples/Validations/Validations.xcodeproj/project.pbxproj index afc0c387..ba4de380 100644 --- a/Skyflow/Samples/Validations/Validations.xcodeproj/project.pbxproj +++ b/Skyflow/Samples/Validations/Validations.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 965D96070B64549FC9188C80 /* ExampleTokenProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C27061F816370F5D626963B /* ExampleTokenProvider.swift */; }; F1030006274E0A0D008F614B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030005274E0A0D008F614B /* AppDelegate.swift */; }; F1030008274E0A0D008F614B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030007274E0A0D008F614B /* SceneDelegate.swift */; }; F103000A274E0A0D008F614B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030009274E0A0D008F614B /* ViewController.swift */; }; @@ -16,6 +17,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 7C27061F816370F5D626963B /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = ""; }; F1030002274E0A0D008F614B /* Validations.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Validations.app; sourceTree = BUILT_PRODUCTS_DIR; }; F1030005274E0A0D008F614B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; F1030007274E0A0D008F614B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -55,6 +57,7 @@ F103000E274E0A12008F614B /* Assets.xcassets */, F1030010274E0A12008F614B /* LaunchScreen.storyboard */, F1030013274E0A12008F614B /* Info.plist */, + 7C27061F816370F5D626963B /* ExampleTokenProvider.swift */, ); path = Validations; sourceTree = ""; @@ -140,6 +143,7 @@ F103000A274E0A0D008F614B /* ViewController.swift in Sources */, F1030006274E0A0D008F614B /* AppDelegate.swift in Sources */, F1030008274E0A0D008F614B /* SceneDelegate.swift in Sources */, + 965D96070B64549FC9188C80 /* ExampleTokenProvider.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Skyflow/Samples/Validations/Validations/ExampleAPICallback.swift b/Skyflow/Samples/Validations/Validations/ExampleAPICallback.swift deleted file mode 100644 index 18703254..00000000 --- a/Skyflow/Samples/Validations/Validations/ExampleAPICallback.swift +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022 Skyflow - */ - -// -// ExampleAPICallback.swift -// Validations -// -// Created by Akhil Anil Mangala on 24/11/21. -// - -import Foundation -import Skyflow - -public class ExampleAPICallback: Skyflow.Callback { - internal init() { - } - - public func onSuccess(_ responseBody: Any) { - print("success:", responseBody) - } - - public func onFailure(_ error: Any) { - print("failure:", error) - } -} diff --git a/Skyflow/Samples/Validations/Validations/ViewController.swift b/Skyflow/Samples/Validations/Validations/ViewController.swift index b2da5958..e791f493 100644 --- a/Skyflow/Samples/Validations/Validations/ViewController.swift +++ b/Skyflow/Samples/Validations/Validations/ViewController.swift @@ -13,8 +13,6 @@ class ViewController: UIViewController { private var skyflowClient: Skyflow.Client? private var container: Skyflow.Container? private var b: UIButton? - private var confirmPasswordElement: Skyflow.TextField? - private var stackView: UIStackView! override func loadView() { @@ -99,15 +97,9 @@ class ViewController: UIViewController { validations: ValidationSet(rules: [strongPasswordRule, lengthRule, elementValueMatchRule]) ) let confirmPassword = container?.create(input: confirmPasswordInput, options: collectElementOptions) - self.confirmPasswordElement = confirmPassword // mount elements on screen - errors will be shown if any of the validaitons fail stackView.addArrangedSubview(password!) stackView.addArrangedSubview(confirmPassword!) - let resetButton = UIButton(frame: CGRect(x: 100, y: 400, width: 100, height: 40)) - resetButton.backgroundColor = .blue - resetButton.setTitle("Reset Password", for: .normal) - resetButton.addTarget(self, action: #selector(resetPassword), for: .touchUpInside) - stackView.addArrangedSubview(resetButton) stackView.axis = .vertical stackView.distribution = .fill stackView.spacing = 10 @@ -119,22 +111,4 @@ class ViewController: UIViewController { stackView.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -10).isActive = true } } - - @objc func resetPassword() { - let url = "" - let requestHeaders = ["Content-Type": "application/json ", "Authorization": ""] - let requestBody: [String: Any] = [ - // Other fields... - "password": self.confirmPasswordElement! - ] - let responseBody: [String: Any] = [:] - let connectionConfig = ConnectionConfig( - connectionURL: url, - method: .POST, - requestBody: requestBody, - requestHeader: requestHeaders, - responseBody: responseBody - ) - self.skyflowClient?.invokeConnection(config: connectionConfig, callback: ExampleAPICallback()) - } } diff --git a/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample.xcodeproj/project.pbxproj b/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample.xcodeproj/project.pbxproj index 7178318f..413c3382 100644 --- a/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample.xcodeproj/project.pbxproj +++ b/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 6CAC82BEF157325DE8024E2E /* libPods-CollectAndRevealSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F5C5B124A49D66E3C560B0D /* libPods-CollectAndRevealSample.a */; }; 7C2C89D82C89C9520076C641 /* CardBrandChoiceSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C2C89D72C89C9520076C641 /* CardBrandChoiceSampleViewController.swift */; }; 7C2C89DE2C8F23C30076C641 /* CollectAndRevealViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C2C89DD2C8F23C30076C641 /* CollectAndRevealViewController.swift */; }; - 7C2C89E52C8F25C50076C641 /* libSkyflow.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C2C89E42C8F25C50076C641 /* libSkyflow.a */; }; F1613E50272565CF0042C130 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1613E4F272565CF0042C130 /* AppDelegate.swift */; }; F1613E52272565CF0042C130 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1613E51272565CF0042C130 /* SceneDelegate.swift */; }; F1613E54272565CF0042C130 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1613E53272565CF0042C130 /* ViewController.swift */; }; @@ -24,8 +23,6 @@ 267485426163B1ACCD8ED25D /* Pods-CollectAndRevealSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollectAndRevealSample.debug.xcconfig"; path = "Target Support Files/Pods-CollectAndRevealSample/Pods-CollectAndRevealSample.debug.xcconfig"; sourceTree = ""; }; 7C2C89D72C89C9520076C641 /* CardBrandChoiceSampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardBrandChoiceSampleViewController.swift; sourceTree = ""; }; 7C2C89DD2C8F23C30076C641 /* CollectAndRevealViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectAndRevealViewController.swift; sourceTree = ""; }; - 7C2C89E22C8F25BC0076C641 /* libSkyflow.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSkyflow.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 7C2C89E42C8F25C50076C641 /* libSkyflow.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSkyflow.a; sourceTree = BUILT_PRODUCTS_DIR; }; 7F5C5B124A49D66E3C560B0D /* libPods-CollectAndRevealSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CollectAndRevealSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; F1613E4C272565CF0042C130 /* CollectAndRevealSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectAndRevealSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; F1613E4F272565CF0042C130 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -44,7 +41,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7C2C89E52C8F25C50076C641 /* libSkyflow.a in Frameworks */, 6CAC82BEF157325DE8024E2E /* libPods-CollectAndRevealSample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -55,8 +51,6 @@ A94C3CD833597CC577C83A7A /* Frameworks */ = { isa = PBXGroup; children = ( - 7C2C89E42C8F25C50076C641 /* libSkyflow.a */, - 7C2C89E22C8F25BC0076C641 /* libSkyflow.a */, 7F5C5B124A49D66E3C560B0D /* libPods-CollectAndRevealSample.a */, ); name = Frameworks; diff --git a/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CardBrandChoiceSampleViewController.swift b/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CardBrandChoiceSampleViewController.swift index aad636c3..0318b9c6 100644 --- a/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CardBrandChoiceSampleViewController.swift +++ b/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CardBrandChoiceSampleViewController.swift @@ -39,7 +39,7 @@ class CardBrandChoiceSampleViewController: UIViewController { let iconStyles = SkyflowFlowVault.Styles(base: Style(cardIconAlignment: .right)) // create card number element - let collectCardNumberInput = SkyflowFlowVault.CollectElementInput(table: "", column: "", inputStyles: inputStyles, iconStyles: Styles(base: Style(cardIconAlignment: .right)),label: "Card Number", placeholder: "XXXXXXXXXXXXX", type: SkyflowFlowVault.ElementType.CARD_NUMBER) + let collectCardNumberInput = SkyflowFlowVault.CollectElementInput(tableName: "", column: "", inputStyles: inputStyles, iconStyles: Styles(base: Style(cardIconAlignment: .right)),label: "Card Number", placeholder: "XXXXXXXXXXXXX", type: SkyflowFlowVault.ElementType.CARD_NUMBER) let requiredOption = SkyflowFlowVault.CollectElementOptions(required: true, enableCardIcon: true, enableCopy: false) collectCardNumberElement = container?.create(input: collectCardNumberInput, options: requiredOption) diff --git a/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CollectAndRevealViewController.swift b/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CollectAndRevealViewController.swift index 69cde866..0969252c 100644 --- a/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CollectAndRevealViewController.swift +++ b/SkyflowFlowVault/Samples/CollectAndRevealSample/CollectAndRevealSample/CollectAndRevealViewController.swift @@ -10,7 +10,6 @@ class CollectAndRevealViewController: UIViewController { private var skyflow: SkyflowFlowVault.Client? private var container: SkyflowFlowVault.Container? private var revealContainer: SkyflowFlowVault.Container? - private var b: UIButton? private var stackView: UIStackView! @@ -23,7 +22,6 @@ class CollectAndRevealViewController: UIViewController { private var revealed = false - override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white @@ -67,7 +65,7 @@ class CollectAndRevealViewController: UIViewController { ) let collectCardNumberInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "card_number", inputStyles: styles, label: "Card Number", @@ -75,7 +73,7 @@ class CollectAndRevealViewController: UIViewController { type: SkyflowFlowVault.ElementType.CARD_NUMBER ) let collectNameInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "cardholder_name", inputStyles: styles, label: "Card Holder Name", @@ -83,7 +81,7 @@ class CollectAndRevealViewController: UIViewController { type: SkyflowFlowVault.ElementType.CARDHOLDER_NAME ) let collectCVVInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "cvv", inputStyles: styles, label: "CVV", @@ -91,7 +89,7 @@ class CollectAndRevealViewController: UIViewController { type: .CVV ) let collectExpMonthInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "expiry_month", inputStyles: styles, label: "Expiration Month", @@ -99,7 +97,7 @@ class CollectAndRevealViewController: UIViewController { type: .EXPIRATION_MONTH ) let collectExpYearInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "expiry_year", inputStyles: styles, label: "Expiration Year", @@ -157,7 +155,10 @@ class CollectAndRevealViewController: UIViewController { callback: RevealCallback( onSuccess: { (response: RevealResponse) in print("success:", response) }, onFailure: { (error: SkyflowError) in print("failure:", error) } - ) + ), + options: SkyflowFlowVault.RevealOptions(tokenGroupRedactions: [ + SkyflowFlowVault.TokenGroupRedaction(tokenGroupName: "", redaction: "") + ]) ) } @objc func submitForm() { @@ -166,7 +167,7 @@ class CollectAndRevealViewController: UIViewController { onSuccess: { [weak self] (response: CollectResponse) in self?.updateSuccess(response) }, onFailure: { [weak self] (error: SkyflowError) in self?.updateFailure(error: error) } ), - options: SkyflowFlowVault.CollectOptions(tokens: true) + options: SkyflowFlowVault.CollectOptions() ) } internal func updateSuccess(_ response: CollectResponse) { @@ -208,8 +209,7 @@ class CollectAndRevealViewController: UIViewController { let revealCardNumberInput = SkyflowFlowVault.RevealElementInput( token: token(for: "card_number"), inputStyles: revealStyles, - label: "Card Number", - redaction: .REDACTED + label: "Card Number" ) self.revealCardNumber = self.revealContainer?.create( input: revealCardNumberInput, @@ -218,23 +218,19 @@ class CollectAndRevealViewController: UIViewController { let revealCVVtInput = SkyflowFlowVault.RevealElementInput( token: token(for: "cvv"), inputStyles: revealStyles, - label: "CVV", - redaction: .MASKED + label: "CVV" ) self.revealCVV = self.revealContainer?.create(input: revealCVVtInput) let revealNameInput = SkyflowFlowVault.RevealElementInput( token: token(for: "cardholder_name"), inputStyles: revealStyles, - label: "Card Holder Name", - redaction: .DEFAULT - + label: "Card Holder Name" ) self.revealName = self.revealContainer?.create(input: revealNameInput) let revealExpirationMonthInput = SkyflowFlowVault.RevealElementInput( token: token(for: "expiry_month"), inputStyles: revealStyles, - label: "Expiration Month", - redaction: .PLAIN_TEXT + label: "Expiration Month" ) self.revealExpirationMonth = self.revealContainer?.create(input: revealExpirationMonthInput) let revealExpirationYearInput = SkyflowFlowVault.RevealElementInput( diff --git a/SkyflowFlowVault/Samples/ComposableElements/ComposableElements.xcodeproj/project.pbxproj b/SkyflowFlowVault/Samples/ComposableElements/ComposableElements.xcodeproj/project.pbxproj index 19f868a0..7f0fb353 100644 --- a/SkyflowFlowVault/Samples/ComposableElements/ComposableElements.xcodeproj/project.pbxproj +++ b/SkyflowFlowVault/Samples/ComposableElements/ComposableElements.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 67D8C91FAB59F1B52D6AAD3E /* ExampleTokenProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51739068CD4F85D3D45E427 /* ExampleTokenProvider.swift */; }; 7C5748C72A7B71DF002D64AA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C5748C62A7B71DF002D64AA /* AppDelegate.swift */; }; 7C5748C92A7B71DF002D64AA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C5748C82A7B71DF002D64AA /* SceneDelegate.swift */; }; 7C5748CB2A7B71DF002D64AA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C5748CA2A7B71DF002D64AA /* ViewController.swift */; }; @@ -49,6 +50,7 @@ 7C5748E32A7B71DF002D64AA /* ComposableElementsUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ComposableElementsUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 7C5748E72A7B71DF002D64AA /* ComposableElementsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposableElementsUITests.swift; sourceTree = ""; }; 7C5748E92A7B71DF002D64AA /* ComposableElementsUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposableElementsUITestsLaunchTests.swift; sourceTree = ""; }; + B51739068CD4F85D3D45E427 /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -106,6 +108,7 @@ 7C5748CF2A7B71DF002D64AA /* Assets.xcassets */, 7C5748D12A7B71DF002D64AA /* LaunchScreen.storyboard */, 7C5748D42A7B71DF002D64AA /* Info.plist */, + B51739068CD4F85D3D45E427 /* ExampleTokenProvider.swift */, ); path = ComposableElements; sourceTree = ""; @@ -261,6 +264,7 @@ 7C5748CB2A7B71DF002D64AA /* ViewController.swift in Sources */, 7C5748C72A7B71DF002D64AA /* AppDelegate.swift in Sources */, 7C5748C92A7B71DF002D64AA /* SceneDelegate.swift in Sources */, + 67D8C91FAB59F1B52D6AAD3E /* ExampleTokenProvider.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SkyflowFlowVault/Samples/ComposableElements/ComposableElements/ViewController.swift b/SkyflowFlowVault/Samples/ComposableElements/ComposableElements/ViewController.swift index e9955043..8c21925d 100644 --- a/SkyflowFlowVault/Samples/ComposableElements/ComposableElements/ViewController.swift +++ b/SkyflowFlowVault/Samples/ComposableElements/ComposableElements/ViewController.swift @@ -8,9 +8,8 @@ import SkyflowFlowVault class ViewController: UIViewController { var retryCount = 0 private var skyflow: SkyflowFlowVault.Client? - private var container: SkyflowFlowVault.Container? + private var container: SkyflowFlowVault.Container? private var revealContainer: SkyflowFlowVault.Container? - private var b: UIButton? private var stackView: UIStackView! @@ -73,7 +72,7 @@ class ViewController: UIViewController { ) let collectCardNumberInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "card_number", inputStyles: styles, label: "Card Number", @@ -81,7 +80,7 @@ class ViewController: UIViewController { type: SkyflowFlowVault.ElementType.CARD_NUMBER ) let collectNameInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "cardholder_name", inputStyles: styles, label: "Card Holder Name", @@ -89,7 +88,7 @@ class ViewController: UIViewController { type: SkyflowFlowVault.ElementType.CARDHOLDER_NAME ) let collectCVVInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "cvv", inputStyles: styles, label: "CVV", @@ -97,7 +96,7 @@ class ViewController: UIViewController { type: .CVV ) let collectExpMonthInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "expiry_month", inputStyles: styles, label: "Expiration Month", @@ -105,7 +104,7 @@ class ViewController: UIViewController { type: .EXPIRATION_MONTH ) let collectExpYearInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "expiry_year", inputStyles: styles, label: "Expiration Year", @@ -129,8 +128,9 @@ class ViewController: UIViewController { revealButton.addTarget(self, action: #selector(revealForm), for: .touchUpInside) do { - let composableView = try container?.getComposableView() - stackView.addArrangedSubview(composableView) + if let composableView = try container?.getComposableView() { + stackView.addArrangedSubview(composableView) + } } catch { print(error) } @@ -174,7 +174,10 @@ class ViewController: UIViewController { callback: RevealCallback( onSuccess: { (response: RevealResponse) in print("success:", response) }, onFailure: { (error: SkyflowError) in print("failure:", error) } - ) + ), + options: SkyflowFlowVault.RevealOptions(tokenGroupRedactions: [ + SkyflowFlowVault.TokenGroupRedaction(tokenGroupName: "", redaction: "") + ]) ) } @objc func submitForm() { @@ -183,7 +186,7 @@ class ViewController: UIViewController { onSuccess: { [weak self] (response: CollectResponse) in self?.updateSuccess(response) }, onFailure: { [weak self] (error: SkyflowError) in self?.updateFailure(error: error) } ), - options: SkyflowFlowVault.CollectOptions(tokens: true) + options: SkyflowFlowVault.CollectOptions() ) } internal func updateSuccess(_ response: CollectResponse) { @@ -225,8 +228,7 @@ class ViewController: UIViewController { let revealCardNumberInput = SkyflowFlowVault.RevealElementInput( token: token(for: "card_number"), inputStyles: revealStyles, - label: "Card Number", - redaction: .REDACTED + label: "Card Number" ) self.revealCardNumber = self.revealContainer?.create( input: revealCardNumberInput, @@ -235,23 +237,19 @@ class ViewController: UIViewController { let revealCVVtInput = SkyflowFlowVault.RevealElementInput( token: token(for: "cvv"), inputStyles: revealStyles, - label: "CVV", - redaction: .MASKED + label: "CVV" ) self.revealCVV = self.revealContainer?.create(input: revealCVVtInput) let revealNameInput = SkyflowFlowVault.RevealElementInput( token: token(for: "cardholder_name"), inputStyles: revealStyles, - label: "Card Holder Name", - redaction: .DEFAULT - + label: "Card Holder Name" ) self.revealName = self.revealContainer?.create(input: revealNameInput) let revealExpirationMonthInput = SkyflowFlowVault.RevealElementInput( token: token(for: "expiry_month"), inputStyles: revealStyles, - label: "Expiration Month", - redaction: .PLAIN_TEXT + label: "Expiration Month" ) self.revealExpirationMonth = self.revealContainer?.create(input: revealExpirationMonthInput) let revealExpirationYearInput = SkyflowFlowVault.RevealElementInput( diff --git a/SkyflowFlowVault/Samples/InputFormatting/InputFormatting/ViewController.swift b/SkyflowFlowVault/Samples/InputFormatting/InputFormatting/ViewController.swift index 2a3eb25f..0c497182 100644 --- a/SkyflowFlowVault/Samples/InputFormatting/InputFormatting/ViewController.swift +++ b/SkyflowFlowVault/Samples/InputFormatting/InputFormatting/ViewController.swift @@ -11,7 +11,6 @@ class ViewController: UIViewController { private var skyflow: SkyflowFlowVault.Client? private var container: SkyflowFlowVault.Container? private var revealContainer: SkyflowFlowVault.Container? - private var b: UIButton? private var stackView: UIStackView! @@ -77,7 +76,7 @@ class ViewController: UIViewController { ) let collectCardNumberInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "card_number", inputStyles: styles, label: "Card Number", @@ -85,7 +84,7 @@ class ViewController: UIViewController { type: SkyflowFlowVault.ElementType.CARD_NUMBER ) let collectNameInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "cardholder_name", inputStyles: styles, label: "Card Holder Name", @@ -93,7 +92,7 @@ class ViewController: UIViewController { type: SkyflowFlowVault.ElementType.CARDHOLDER_NAME ) let collectCVVInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "cvv", inputStyles: styles, label: "CVV", @@ -101,7 +100,7 @@ class ViewController: UIViewController { type: .CVV ) let collectExpMonthInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "expiry_month", inputStyles: styles, label: "Expiration Month", @@ -109,7 +108,7 @@ class ViewController: UIViewController { type: .EXPIRATION_MONTH ) let collectExpYearInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "expiry_year", inputStyles: styles, label: "Expiration Year", @@ -117,7 +116,7 @@ class ViewController: UIViewController { type: .EXPIRATION_YEAR ) let collectSSNInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "ssn", inputStyles: styles, label: "SSN", @@ -125,7 +124,7 @@ class ViewController: UIViewController { type: .INPUT_FIELD ) let collectPhoneNumberInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "phone_number", inputStyles: styles, label: "Phone Number", @@ -133,7 +132,7 @@ class ViewController: UIViewController { type: .INPUT_FIELD ) let collectLicenseNumberInput = SkyflowFlowVault.CollectElementInput( - table: "table", + tableName: "table", column: "license_number", inputStyles: styles, label: "License Number", @@ -214,7 +213,7 @@ class ViewController: UIViewController { onSuccess: { [weak self] (response: CollectResponse) in self?.updateSuccess(response) }, onFailure: { [weak self] (error: SkyflowError) in self?.updateFailure(error: error) } ), - options: SkyflowFlowVault.CollectOptions(tokens: true) + options: SkyflowFlowVault.CollectOptions() ) } internal func updateSuccess(_ response: CollectResponse) { diff --git a/SkyflowFlowVault/Samples/UpdateDataUsingElements/UpdateDataUsingElements/ViewController.swift b/SkyflowFlowVault/Samples/UpdateDataUsingElements/UpdateDataUsingElements/ViewController.swift index 31ceed84..87c1e691 100644 --- a/SkyflowFlowVault/Samples/UpdateDataUsingElements/UpdateDataUsingElements/ViewController.swift +++ b/SkyflowFlowVault/Samples/UpdateDataUsingElements/UpdateDataUsingElements/ViewController.swift @@ -8,8 +8,7 @@ import SkyflowFlowVault class ViewController: UIViewController { var retryCount = 0 private var skyflow: SkyflowFlowVault.Client? - private var container: SkyflowFlowVault.Container? - private var b: UIButton? + private var container: SkyflowFlowVault.Container? private var stackView: UIStackView! @@ -63,51 +62,51 @@ class ViewController: UIViewController { ) let collectCardNumberInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "card_number", inputStyles: styles, label: "Card Number", placeholder: "4111-1111-1111-1111", type: SkyflowFlowVault.ElementType.CARD_NUMBER, - skyflowID: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input + skyflowId: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input ) let collectNameInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "cardholder_name", inputStyles: styles, label: "Card Holder Name", placeholder: "John Doe", type: SkyflowFlowVault.ElementType.CARDHOLDER_NAME, - skyflowID: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input + skyflowId: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input ) let collectCVVInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "cvv", inputStyles: styles, label: "CVV", placeholder: "***", type: .CVV, - skyflowID: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input + skyflowId: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input ) let collectExpMonthInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "expiry_month", inputStyles: styles, label: "Expiration Month", placeholder: "MM", type: .EXPIRATION_MONTH, - skyflowID: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input + skyflowId: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input ) let collectExpYearInput = SkyflowFlowVault.CollectElementInput( - table: "credit_cards", + tableName: "credit_cards", column: "expiry_year", inputStyles: styles, label: "Expiration Year", placeholder: "YYYY", type: .EXPIRATION_YEAR, - skyflowID: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input + skyflowId: "" // replace it with actual skyflowID if you want to test update with elements functionality, otherwise you can remove skyflowID field from input ) let requiredOption = SkyflowFlowVault.CollectElementOptions(required: true) @@ -122,8 +121,9 @@ class ViewController: UIViewController { collectButton.addTarget(self, action: #selector(submitForm), for: .touchUpInside) do { - let composableView = try container?.getComposableView() - stackView.addArrangedSubview(composableView) + if let composableView = try container?.getComposableView() { + stackView.addArrangedSubview(composableView) + } } catch { print(error) } @@ -169,7 +169,7 @@ class ViewController: UIViewController { onSuccess: { [weak self] (response: CollectResponse) in self?.updateSuccess(response) }, onFailure: { [weak self] (error: SkyflowError) in self?.updateFailure(error: error) } ), - options: SkyflowFlowVault.CollectOptions(tokens: true) + options: SkyflowFlowVault.CollectOptions() ) } internal func updateSuccess(_ response: CollectResponse) { diff --git a/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj b/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj index 9387c88a..23f1b1d3 100644 --- a/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj +++ b/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 9818DEA129239C1C004C72AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9818DEA029239C1C004C72AE /* Assets.xcassets */; }; 9818DEA429239C1C004C72AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9818DEA229239C1C004C72AE /* LaunchScreen.storyboard */; }; 9818DEB029239CD0004C72AE /* ExampleTokenProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */; }; - 9818DEB229239CD9004C72AE /* ExampleAPICallback.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */; }; 9818DEB82923B61D004C72AE /* Skyflow in Frameworks */ = {isa = PBXBuildFile; productRef = 9818DEB72923B61D004C72AE /* Skyflow */; }; /* End PBXBuildFile section */ @@ -27,8 +26,7 @@ 9818DEA029239C1C004C72AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 9818DEA329239C1C004C72AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 9818DEA529239C1C004C72AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleTokenProvider.swift; path = ../../Upsert/Upsert/ExampleTokenProvider.swift; sourceTree = ""; }; - 9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleAPICallback.swift; path = ../../Upsert/Upsert/ExampleAPICallback.swift; sourceTree = ""; }; + 9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -65,7 +63,6 @@ 9818DE9729239C17004C72AE /* AppDelegate.swift */, 9818DE9929239C17004C72AE /* SceneDelegate.swift */, 9818DE9B29239C17004C72AE /* ViewController.swift */, - 9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */, 9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */, 9818DE9D29239C17004C72AE /* Main.storyboard */, 9818DEA029239C1C004C72AE /* Assets.xcassets */, @@ -154,7 +151,6 @@ 9818DE9C29239C17004C72AE /* ViewController.swift in Sources */, 9818DEB029239CD0004C72AE /* ExampleTokenProvider.swift in Sources */, 9818DE9829239C17004C72AE /* AppDelegate.swift in Sources */, - 9818DEB229239CD9004C72AE /* ExampleAPICallback.swift in Sources */, 9818DE9A29239C17004C72AE /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ExampleTokenProvider.swift b/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ExampleTokenProvider.swift new file mode 100644 index 00000000..a170d9fe --- /dev/null +++ b/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ExampleTokenProvider.swift @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Skyflow + */ + +import Foundation +import SkyflowFlowVault + +public class ExampleTokenProvider: TokenProvider { + public func getBearerToken(_ apiCallback: SkyflowFlowVault.Callback) { + if let url = URL(string: "") { + let session = URLSession(configuration: .default) + let task = session.dataTask(with: url) { data, _, error in + if error != nil { + print(error!) + return + } + if let safeData = data { + do { + let x = try JSONSerialization.jsonObject(with: safeData, options: []) as? [String: String] + if let accessToken = x?["accessToken"] { + apiCallback.onSuccess(accessToken) + } + } catch { + print("access token wrong format") + } + } + } + task.resume() + } + } +} diff --git a/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ViewController.swift b/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ViewController.swift index 3a971da6..ce1ab57f 100644 --- a/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ViewController.swift +++ b/SkyflowFlowVault/Samples/UpsertFeature/UpsertFeature/ViewController.swift @@ -9,7 +9,6 @@ class ViewController: UIViewController { private var skyflow: SkyflowFlowVault.Client? private var container: SkyflowFlowVault.Container? private var revealContainer: SkyflowFlowVault.Container? - private var b: UIButton? private var stackView: UIStackView! private var revealCardNumber: Label? private var revealCvv: Label? @@ -40,7 +39,7 @@ class ViewController: UIViewController { textAlignment: .left, textColor: .blue ) - let focusStyle = SkyflowFlowVault.Style(borderColor: .blue) ̰ + let focusStyle = SkyflowFlowVault.Style(borderColor: .blue) let completedStyle = SkyflowFlowVault.Style(borderColor: UIColor.green, textColor: UIColor.green) let invalidStyle = SkyflowFlowVault.Style(borderColor: UIColor.red, textColor: UIColor.red) let styles = SkyflowFlowVault.Styles( @@ -85,7 +84,7 @@ class ViewController: UIViewController { ) // keep card number as unique column for testing upsert feature let collectCardNumberInput = SkyflowFlowVault.CollectElementInput( - table: "persons", + tableName: "persons", column: "cardnumber", inputStyles: styles, labelStyles: labelStyles, @@ -97,7 +96,7 @@ class ViewController: UIViewController { let requiredOption = SkyflowFlowVault.CollectElementOptions(required: true) let collectCardNumber = container?.create(input: collectCardNumberInput, options: requiredOption) let collectCvvInput = SkyflowFlowVault.CollectElementInput( - table: "persons", + tableName: "persons", column: "cvv", inputStyles: styles, label: "Cvv", @@ -154,18 +153,20 @@ class ViewController: UIViewController { callback: RevealCallback( onSuccess: { (response: RevealResponse) in print("success:", response) }, onFailure: { (error: SkyflowError) in print("failure:", error) } - ) + ), + options: SkyflowFlowVault.RevealOptions(tokenGroupRedactions: [ + SkyflowFlowVault.TokenGroupRedaction(tokenGroupName: "", redaction: "") + ]) ) } @objc func submitForm() { - let upsertOptions = [["table": "persons", "column": "cardnumber"]] as [[String: Any]] container!.collect( callback: CollectCallback( onSuccess: { [weak self] (response: CollectResponse) in self?.updateSuccess(response) }, onFailure: { [weak self] (_: SkyflowError) in self?.updateFailure() } ), - options: SkyflowFlowVault.CollectOptions(tokens: true) + options: SkyflowFlowVault.CollectOptions() ) } @@ -204,8 +205,7 @@ class ViewController: UIViewController { let revealCardNumberInput = SkyflowFlowVault.RevealElementInput( token: token(for: "cardnumber"), inputStyles: revealStyles, - label: "Card Number", - redaction: .DEFAULT + label: "Card Number" ) self.revealCardNumber = self.revealContainer?.create( input: revealCardNumberInput, @@ -214,8 +214,7 @@ class ViewController: UIViewController { let revealCvvInput = SkyflowFlowVault.RevealElementInput( token: token(for: "cvv"), inputStyles: revealStyles, - label: "Cvv", - redaction: .DEFAULT + label: "Cvv" ) self.revealCvv = self.revealContainer?.create( input: revealCvvInput, diff --git a/SkyflowFlowVault/Samples/Validations/Validations.xcodeproj/project.pbxproj b/SkyflowFlowVault/Samples/Validations/Validations.xcodeproj/project.pbxproj index afc0c387..0fdc1230 100644 --- a/SkyflowFlowVault/Samples/Validations/Validations.xcodeproj/project.pbxproj +++ b/SkyflowFlowVault/Samples/Validations/Validations.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 61BA6DDEE43670E58D668441 /* ExampleTokenProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47B16B92A54F283C62D4E02 /* ExampleTokenProvider.swift */; }; F1030006274E0A0D008F614B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030005274E0A0D008F614B /* AppDelegate.swift */; }; F1030008274E0A0D008F614B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030007274E0A0D008F614B /* SceneDelegate.swift */; }; F103000A274E0A0D008F614B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030009274E0A0D008F614B /* ViewController.swift */; }; @@ -24,6 +25,7 @@ F103000E274E0A12008F614B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; F1030011274E0A12008F614B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; F1030013274E0A12008F614B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F47B16B92A54F283C62D4E02 /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -55,6 +57,7 @@ F103000E274E0A12008F614B /* Assets.xcassets */, F1030010274E0A12008F614B /* LaunchScreen.storyboard */, F1030013274E0A12008F614B /* Info.plist */, + F47B16B92A54F283C62D4E02 /* ExampleTokenProvider.swift */, ); path = Validations; sourceTree = ""; @@ -140,6 +143,7 @@ F103000A274E0A0D008F614B /* ViewController.swift in Sources */, F1030006274E0A0D008F614B /* AppDelegate.swift in Sources */, F1030008274E0A0D008F614B /* SceneDelegate.swift in Sources */, + 61BA6DDEE43670E58D668441 /* ExampleTokenProvider.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SkyflowFlowVault/Samples/Validations/Validations/ExampleAPICallback.swift b/SkyflowFlowVault/Samples/Validations/Validations/ExampleAPICallback.swift deleted file mode 100644 index 48f4c77a..00000000 --- a/SkyflowFlowVault/Samples/Validations/Validations/ExampleAPICallback.swift +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022 Skyflow - */ - -// -// ExampleAPICallback.swift -// Validations -// -// Created by Akhil Anil Mangala on 24/11/21. -// - -import Foundation -import SkyflowFlowVault - -public class ExampleAPICallback: SkyflowFlowVault.Callback { - internal init() { - } - - public func onSuccess(_ responseBody: Any) { - print("success:", responseBody) - } - - public func onFailure(_ error: Any) { - print("failure:", error) - } -} diff --git a/SkyflowFlowVault/Samples/Validations/Validations/ViewController.swift b/SkyflowFlowVault/Samples/Validations/Validations/ViewController.swift index 972262ff..3064b205 100644 --- a/SkyflowFlowVault/Samples/Validations/Validations/ViewController.swift +++ b/SkyflowFlowVault/Samples/Validations/Validations/ViewController.swift @@ -12,9 +12,6 @@ import SkyflowFlowVault class ViewController: UIViewController { private var skyflowClient: SkyflowFlowVault.Client? private var container: SkyflowFlowVault.Container? - private var b: UIButton? - private var confirmPasswordElement: SkyflowFlowVault.TextField? - private var stackView: UIStackView! override func loadView() { @@ -99,15 +96,9 @@ class ViewController: UIViewController { validations: ValidationSet(rules: [strongPasswordRule, lengthRule, elementValueMatchRule]) ) let confirmPassword = container?.create(input: confirmPasswordInput, options: collectElementOptions) - self.confirmPasswordElement = confirmPassword // mount elements on screen - errors will be shown if any of the validaitons fail stackView.addArrangedSubview(password!) stackView.addArrangedSubview(confirmPassword!) - let resetButton = UIButton(frame: CGRect(x: 100, y: 400, width: 100, height: 40)) - resetButton.backgroundColor = .blue - resetButton.setTitle("Reset Password", for: .normal) - resetButton.addTarget(self, action: #selector(resetPassword), for: .touchUpInside) - stackView.addArrangedSubview(resetButton) stackView.axis = .vertical stackView.distribution = .fill stackView.spacing = 10 @@ -119,22 +110,4 @@ class ViewController: UIViewController { stackView.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -10).isActive = true } } - - @objc func resetPassword() { - let url = "" - let requestHeaders = ["Content-Type": "application/json ", "Authorization": ""] - let requestBody: [String: Any] = [ - // Other fields... - "password": self.confirmPasswordElement! - ] - let responseBody: [String: Any] = [:] - let connectionConfig = ConnectionConfig( - connectionURL: url, - method: .POST, - requestBody: requestBody, - requestHeader: requestHeaders, - responseBody: responseBody - ) - self.skyflowClient?.invokeConnection(config: connectionConfig, callback: ExampleAPICallback()) - } }