Skip to content

Commit

Permalink
chore: make iOS module code compatible with latest sdk updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuskurgonasativy committed Feb 23, 2024
1 parent d25300f commit f25c62c
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions ios/GetivySdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ import React
@objc(GetivySdk)
class GetivySdk: RCTEventEmitter {

func convertEnvToNumber(env: String) -> Environment? {
switch env.lowercased() {
case "sandbox":
return .sandbox
case "production":
return .production
default:
return nil
}
}

var sdkHandler: UIHandler? = nil

override func supportedEvents() -> [String]! {
Expand All @@ -32,11 +21,7 @@ class GetivySdk: RCTEventEmitter {
@objc(initializeDataSession:withEnvironment:withResolver:withRejecter:)
func initializeDataSession(dataSessionId: String, environment: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
sdkHandler = nil
guard let env = convertEnvToNumber(env: environment) else {
reject(nil, "Wrong environment value", nil);
return
}
let config = GetivyConfiguration(dataSessionId: dataSessionId, environment: env) { result in
let config = GetivyConfiguration(dataSessionId: dataSessionId, environment: environment) { result in
let convertedResult = ["referenceId": result.referenceId ?? "", "dataSessionId": result.dataSessionId ?? "", "checkoutSessionId": result.checkoutSessionId ?? ""];
self.emitSuccessEvent(withDetails: NSDictionary(dictionary: convertedResult))
} onError: { error in
Expand All @@ -57,11 +42,7 @@ class GetivySdk: RCTEventEmitter {
@objc(initializeCheckoutSession:withEnvironment:withResolver:withRejecter:)
func initializeCheckoutSession(checkoutSessionId: String, environment: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
sdkHandler = nil
guard let env = convertEnvToNumber(env: environment) else {
reject(nil, "Wrong environment value", nil);
return
}
let config = GetivyConfiguration(checkoutId: checkoutSessionId, environment: env) { result in
let config = GetivyConfiguration(checkoutId: checkoutSessionId, environment: environment) { result in
let convertedResult = ["referenceId": result.referenceId ?? "", "sessionId": result.dataSessionId ?? result.checkoutSessionId ?? ""];
self.emitSuccessEvent(withDetails: NSDictionary(dictionary: convertedResult))
} onError: { error in
Expand Down

0 comments on commit f25c62c

Please sign in to comment.