Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sagishm committed Oct 11, 2021
2 parents c4956ef + 26ebbc9 commit b9f2417
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 88 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ Developer Preview 0.1.2
* Updated Android Core SDK v5.1.4
* Forgot password bug fix.
* Added manual initSDK interface.

# 0.1.3
Developer Preview 0.1.3

* iOS: Fixed crash in forgotPassword.
* iOS: Fixed bug in link account.
171 changes: 86 additions & 85 deletions ios/Classes/GigyaSdkWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {

init(accountSchema: T.Type) {
// Initializing the Gigya SDK instance.
GigyaDefinitions.versionPrefix = "flutter_0.1.2_"
GigyaDefinitions.versionPrefix = "flutter_0.1.3_"
sdk = Gigya.sharedInstance(accountSchema)
}

Expand All @@ -31,9 +31,9 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
func sendRequest(arguments: [String: Any], result: @escaping FlutterResult) {
guard let endpoint = arguments["endpoint"] as? String,
let parameters = arguments["parameters"] as? [String:Any] else {
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}

sdk?.send(api: endpoint, params: parameters) { (gigyaResponse) in
switch gigyaResponse {
Expand All @@ -57,9 +57,9 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
func loginWithCredentials(arguments: [String: Any], result: @escaping FlutterResult) {
guard let loginId = arguments["loginId"] as? String,
let password = arguments["password"] as? String else {
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}

resolverHelper.currentResult = result

Expand Down Expand Up @@ -91,9 +91,9 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
func registerWithCredentials(arguments: [String: Any], result: @escaping FlutterResult) {
guard let email = arguments["email"] as? String,
let password = arguments["password"] as? String else {
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}

resolverHelper.currentResult = result

Expand Down Expand Up @@ -198,10 +198,11 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}
sdk?.forgotPassword(loginId: loginId, completion: { gigyaResponse in
sdk?.forgotPassword(loginId: loginId, completion: { [weak self] gigyaResponse in
switch gigyaResponse {
case .success(let data):
result(data)
let mapped = self?.mapObject(data)
result(mapped)
case .failure(let error):
switch error {
case .gigyaError(let d):
Expand All @@ -212,7 +213,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
}
})
}

/**
Init SDK
*/
Expand All @@ -226,7 +227,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
return
}
sdk?.initFor(apiKey: apiKey, apiDomain: apiDomain)

result(["success": true])
}

Expand All @@ -251,24 +252,24 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
with: provider,
viewController: viewController,
params: parameters) { [weak self] (gigyaResponse) in
switch gigyaResponse {
case .success(let data):

let mapped = self?.mapObject(data)
self?.resolverHelper.currentResult?(mapped)

self?.resolverHelper.dispose()
case .failure(let error):
self?.saveResolvesIfNeeded(interruption: error.interruption)

switch error.error {
case .gigyaError(let d):
self?.resolverHelper.currentResult?(FlutterError(code: "\(d.errorCode)", message: d.errorMessage, details: d.toDictionary()))
default:
self?.resolverHelper.currentResult?(FlutterError(code: "", message: error.error.localizedDescription, details: nil))
switch gigyaResponse {
case .success(let data):

let mapped = self?.mapObject(data)
self?.resolverHelper.currentResult?(mapped)

self?.resolverHelper.dispose()
case .failure(let error):
self?.saveResolvesIfNeeded(interruption: error.interruption)

switch error.error {
case .gigyaError(let d):
self?.resolverHelper.currentResult?(FlutterError(code: "\(d.errorCode)", message: d.errorMessage, details: d.toDictionary()))
default:
self?.resolverHelper.currentResult?(FlutterError(code: "", message: error.error.localizedDescription, details: nil))
}
}
}
}
}

func addConnection(arguments: [String: Any], result: @escaping FlutterResult) {
Expand All @@ -287,20 +288,20 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
provider: provider,
viewController: viewController,
params: parameters) { [weak self] gigyaResponse in
switch gigyaResponse {
case .success(let data):

let mapped = self?.mapObject(data)
result(mapped)
case .failure(let error):
switch error {
case .gigyaError(let d):
result(FlutterError(code: "\(d.errorCode)", message: d.errorMessage, details: d.toDictionary()))
default:
result(FlutterError(code: PluginErrors.generalError, message: error.localizedDescription, details: nil))
switch gigyaResponse {
case .success(let data):

let mapped = self?.mapObject(data)
result(mapped)
case .failure(let error):
switch error {
case .gigyaError(let d):
result(FlutterError(code: "\(d.errorCode)", message: d.errorMessage, details: d.toDictionary()))
default:
result(FlutterError(code: PluginErrors.generalError, message: error.localizedDescription, details: nil))
}
}
}
}
}

func removeConnection(arguments: [String: Any], result: @escaping FlutterResult) {
Expand Down Expand Up @@ -337,11 +338,11 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
guard
let viewController = getDisplayedViewController(),
let screenSet = arguments["screenSet"] as? String else {
return
}

return
}
let parameters = arguments["parameters"] as? [String: Any] ?? [:]

// Create streamer
var screenSetsEventHandler: ScreenSetsStreamHandler? = ScreenSetsStreamHandler()
let eventChannel = FlutterEventChannel(name: "screensetEvents", binaryMessenger: SwiftGigyaFlutterPlugin.registrar!.messenger())
Expand All @@ -356,43 +357,43 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
with: screenSet,
viewController: viewController,
params: parameters) { [weak self] event in
switch event {
case .error(let event):
screenSetsEventHandler?.sink?(["event":"onError", "data" : event])
case .onHide(let event):
screenSetsEventHandler?.sink?(["event":"onHide", "data" : event])
screenSetsEventHandler?.destroy()
screenSetsEventHandler = nil
case .onLogin(account: let account):
screenSetsEventHandler?.sink?(["event":"onLogin", "data" : self?.mapObject(account) ?? [:]])
case .onLogout:
screenSetsEventHandler?.sink?(["event":"onLogout"])
case .onConnectionAdded:
screenSetsEventHandler?.sink?(["event":"onConnectionAdded"])
case .onConnectionRemoved:
screenSetsEventHandler?.sink?(["event":"onConnectionRemoved"])
case .onBeforeScreenLoad(let event):
screenSetsEventHandler?.sink?(["event":"onBeforeScreenLoad", "data" : event])
case .onAfterScreenLoad(let event):
screenSetsEventHandler?.sink?(["event":"onAfterScreenLoad", "data" : event])
case .onBeforeValidation(let event):
screenSetsEventHandler?.sink?(["event":"onBeforeValidation", "data" : event])
case .onAfterValidation(let event):
screenSetsEventHandler?.sink?(["event":"onAfterValidation", "data" : event])
case .onBeforeSubmit(let event):
screenSetsEventHandler?.sink?(["event":"onBeforeSubmit", "data" : event])
case .onSubmit(let event):
screenSetsEventHandler?.sink?(["event":"onSubmit", "data" : event])
case .onAfterSubmit(let event):
screenSetsEventHandler?.sink?(["event":"onAfterSubmit", "data" : event])
case .onFieldChanged(let event):
screenSetsEventHandler?.sink?(["event":"onFieldChanged", "data" : event])
case .onCanceled:
screenSetsEventHandler?.sink?(["event":"onCanceled", "data" : [:]])
screenSetsEventHandler?.destroy()
screenSetsEventHandler = nil
switch event {
case .error(let event):
screenSetsEventHandler?.sink?(["event":"onError", "data" : event])
case .onHide(let event):
screenSetsEventHandler?.sink?(["event":"onHide", "data" : event])
screenSetsEventHandler?.destroy()
screenSetsEventHandler = nil
case .onLogin(account: let account):
screenSetsEventHandler?.sink?(["event":"onLogin", "data" : self?.mapObject(account) ?? [:]])
case .onLogout:
screenSetsEventHandler?.sink?(["event":"onLogout"])
case .onConnectionAdded:
screenSetsEventHandler?.sink?(["event":"onConnectionAdded"])
case .onConnectionRemoved:
screenSetsEventHandler?.sink?(["event":"onConnectionRemoved"])
case .onBeforeScreenLoad(let event):
screenSetsEventHandler?.sink?(["event":"onBeforeScreenLoad", "data" : event])
case .onAfterScreenLoad(let event):
screenSetsEventHandler?.sink?(["event":"onAfterScreenLoad", "data" : event])
case .onBeforeValidation(let event):
screenSetsEventHandler?.sink?(["event":"onBeforeValidation", "data" : event])
case .onAfterValidation(let event):
screenSetsEventHandler?.sink?(["event":"onAfterValidation", "data" : event])
case .onBeforeSubmit(let event):
screenSetsEventHandler?.sink?(["event":"onBeforeSubmit", "data" : event])
case .onSubmit(let event):
screenSetsEventHandler?.sink?(["event":"onSubmit", "data" : event])
case .onAfterSubmit(let event):
screenSetsEventHandler?.sink?(["event":"onAfterSubmit", "data" : event])
case .onFieldChanged(let event):
screenSetsEventHandler?.sink?(["event":"onFieldChanged", "data" : event])
case .onCanceled:
screenSetsEventHandler?.sink?(["event":"onCanceled", "data" : [:]])
screenSetsEventHandler?.destroy()
screenSetsEventHandler = nil
}
}
}
}


Expand Down Expand Up @@ -428,9 +429,9 @@ extension GigyaSdkWrapper {
guard
let loginId = arguments["loginId"] as? String ,
let password = arguments["password"] as? String else {
result(FlutterError(code: PluginErrors.generalError, message: PluginErrors.generalErrorMessage, details: nil))
return
}
result(FlutterError(code: PluginErrors.generalError, message: PluginErrors.generalErrorMessage, details: nil))
return
}

resolver.linkToSite(loginId: loginId, password: password)

Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/SwiftGigyaFlutterPluginTyped.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SwiftGigyaFlutterPluginTyped<T: GigyaAccountProtocol> : NSObject, F
// intteruptions cases
case getConflictingAccounts
case linkToSite
case linkToScoial
case linkToSocial
case resolveSetAccount
case forgotPassword
}
Expand Down Expand Up @@ -89,7 +89,7 @@ public class SwiftGigyaFlutterPluginTyped<T: GigyaAccountProtocol> : NSObject, F
sdk?.removeConnection(arguments: args, result: result)
case .linkToSite:
sdk?.resolveLinkToSite(arguments: args, result: result)
case .linkToScoial:
case .linkToSocial:
sdk?.resolveLinkToSocial(arguments: args, result: result)
case .resolveSetAccount:
sdk?.resolveSetAccount(arguments: args, result: result)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: gigya_flutter_plugin
description: SAP Gigya Flutter plugin
version: 0.1.2
version: 0.1.3
homepage: https://github.com/SAP/gigya-flutter-plugin

environment:
Expand Down

0 comments on commit b9f2417

Please sign in to comment.