Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Changes:
- Fix: Added configurable ApiKey and Environment parameters
-
### 2.12.17
- Fix: fixed issue with shoe item recommended size

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ object VirtusizeApi {
currentUserId = userId
}

fun setApiKey(newApiKey: String) {
apiKey = newApiKey
}

fun setEnvironment(env: VirtusizeEnvironment) {
environment = env
}

fun setStoreId(storeId: StoreId) {
currentStoreId = storeId
}
Expand Down
13 changes: 13 additions & 0 deletions virtusize/src/main/java/com/virtusize/android/Virtusize.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.virtusize.android

import android.content.Context
import com.virtusize.android.data.local.VirtusizeEnvironment
import com.virtusize.android.data.local.VirtusizeError
import com.virtusize.android.data.local.VirtusizeLanguage
import com.virtusize.android.data.local.VirtusizeMessageHandler
Expand Down Expand Up @@ -79,6 +80,18 @@ interface Virtusize {
*/
fun setUserId(userId: String)

/**
* Use this function to set up the apiKey in the app when the user changes country
* @param apiKey unique store Api Key
*/
fun setApiKey(newApiKey: String)

/**
* Use this function to change API environment
* @param env unique API environment
*/
fun setEnvironment(env: VirtusizeEnvironment)

/**
* Registers a message handler.
* The registered message handlers will receive Virtusize errors, events, and the close action for Fit Illustrator.
Expand Down
21 changes: 21 additions & 0 deletions virtusize/src/main/java/com/virtusize/android/VirtusizeImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.lifecycle.AtomicReference
import com.virtusize.android.data.local.SizeComparisonRecommendedSize
import com.virtusize.android.data.local.SizeRecommendationType
import com.virtusize.android.data.local.VirtusizeEnvironment
import com.virtusize.android.data.local.VirtusizeError
import com.virtusize.android.data.local.VirtusizeErrorType
import com.virtusize.android.data.local.VirtusizeEvent
Expand Down Expand Up @@ -318,6 +319,26 @@ internal class VirtusizeImpl(
}
}

/**
* @see Virtusize.setApiKey
*/
override fun setApiKey(apiKey: String) {
VirtusizeApi.setApiKey(apiKey)
virtusizeViews.forEach { virtusizeView ->
virtusizeView.virtusizeParams.apiKey = apiKey
}
}

/**
* @see Virtusize.setEnvironment
*/
override fun setEnvironment(env: VirtusizeEnvironment) {
VirtusizeApi.setEnvironment(env)
virtusizeViews.forEach { virtusizeView ->
virtusizeView.virtusizeParams.environment = env
}
}

/**
* @see Virtusize.registerMessageHandler
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ internal class VirtusizeFlutterImpl(
*/
override fun setUserId(userId: String) {
VirtusizeApi.setUserId(userId)
// params.externalUserId = userId
params.externalUserId = userId
virtusizeViews.forEach { virtusizeView ->
virtusizeView.virtusizeParams.externalUserId = userId
}
Expand Down