-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d5d6ae
commit fae16ea
Showing
5 changed files
with
163 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/AuthParamsWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.JsonParser | ||
|
||
class AuthParamsWrapper( | ||
val environment: String, | ||
val appVersion: String?, | ||
val enableV3: Boolean = false, | ||
val dbDirectory: String?, | ||
val historySyncUrl: String?, | ||
) { | ||
companion object { | ||
fun authParamsFromJson(authParams: String): AuthParamsWrapper { | ||
val jsonOptions = JsonParser.parseString(authParams).asJsonObject | ||
return AuthParamsWrapper( | ||
jsonOptions.get("environment").asString, | ||
if (jsonOptions.has("appVersion")) jsonOptions.get("appVersion").asString else null, | ||
if (jsonOptions.has("enableV3")) jsonOptions.get("enableV3").asBoolean else false, | ||
if (jsonOptions.has("dbDirectory")) jsonOptions.get("dbDirectory").asString else null, | ||
if (jsonOptions.has("historySyncUrl")) jsonOptions.get("historySyncUrl").asString else null | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// AuthParamsWrapper.swift | ||
// XMTPReactNative | ||
// | ||
// Created by Naomi Plasterer on 6/24/24. | ||
// | ||
|
||
import Foundation | ||
import XMTP | ||
|
||
class AuthParamsWrapper { | ||
let environment: String | ||
let appVersion: String? | ||
let enableV3: Bool | ||
let dbDirectory: String? | ||
let historySyncUrl: String? | ||
|
||
init(environment: String, appVersion: String?, enableV3: Bool, dbDirectory: String?, historySyncUrl: String?) { | ||
self.environment = environment | ||
self.appVersion = appVersion | ||
self.enableV3 = enableV3 | ||
self.dbDirectory = dbDirectory | ||
self.historySyncUrl = historySyncUrl | ||
} | ||
|
||
static func authParamsFromJson(_ authParams: String) -> AuthParamsWrapper? { | ||
guard let data = authParams.data(using: .utf8), | ||
let jsonOptions = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { | ||
return nil | ||
} | ||
|
||
let environment = jsonOptions["environment"] as? String ?? "" | ||
let appVersion = jsonOptions["appVersion"] as? String | ||
let enableV3 = jsonOptions["enableV3"] as? Bool ?? false | ||
let dbDirectory = jsonOptions["dbDirectory"] as? String | ||
let historySyncUrl = jsonOptions["historySyncUrl"] as? String | ||
|
||
return AuthParamsWrapper( | ||
environment: environment, | ||
appVersion: appVersion, | ||
enableV3: enableV3, | ||
dbDirectory: dbDirectory, | ||
historySyncUrl: historySyncUrl | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters