From e27e8965ecc9cd46c178f263aee68213bf5abfbc Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Mon, 15 Mar 2021 16:53:18 -0400 Subject: [PATCH] Issue #9895: Expose getExperimentBranches in NimbusClientInterface --- .../mozilla/components/service/nimbus/Nimbus.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt b/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt index 797d3a93d65..97d54afb2a9 100644 --- a/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt +++ b/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +@file:Suppress("TooManyFunctions") + package mozilla.components.service.nimbus import android.content.Context @@ -26,6 +28,7 @@ import mozilla.components.support.base.utils.NamedThreadFactory import mozilla.components.support.locale.getLocaleTag import org.mozilla.experiments.nimbus.AppContext import org.mozilla.experiments.nimbus.AvailableRandomizationUnits +import org.mozilla.experiments.nimbus.Branch import org.mozilla.experiments.nimbus.EnrolledExperiment import org.mozilla.experiments.nimbus.EnrollmentChangeEvent import org.mozilla.experiments.nimbus.EnrollmentChangeEventType @@ -63,6 +66,15 @@ interface NimbusApi : Observable { @AnyThread fun getExperimentBranch(experimentId: String): String? = null + /** + * Get the list of experiment branches for the given experiment + * + * @param experimentId The string experiment-id or "slug" for which to retrieve the branch + * + * @return A list of [Branch]s + */ + fun getExperimentBranches(experimentId: String): List + /** * Refreshes the experiments from the endpoint. Should be called at least once after * initialization @@ -252,6 +264,10 @@ class Nimbus( return nimbus.getExperimentBranch(experimentId) } + @WorkerThread + override fun getExperimentBranches(experimentId: String): List = + nimbus.getExperimentBranches(experimentId) + override fun updateExperiments() { fetchScope.launch { fetchExperimentsOnThisThread()