All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cohort.CohortMembershipApi.kt Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
package com.amplitude.experiment.cohort

import com.amplitude.experiment.util.get
import okhttp3.HttpUrl
import okhttp3.OkHttpClient

internal interface CohortMembershipApi {
    fun getCohortMemberships(groupType: String, groupName: String): Set
}

internal class ProxyCohortMembershipApi(
    private val deploymentKey: String,
    private val serverUrl: HttpUrl,
    private val httpClient: OkHttpClient,
) : CohortMembershipApi {

    override fun getCohortMemberships(groupType: String, groupName: String): Set {
        return httpClient.get>(
            serverUrl,
            "sdk/v2/memberships/$groupType/$groupName",
            headers = mapOf(
                "Authorization" to "Api-Key $deploymentKey",
            )
        ).get()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy