Skip to content

Commit

Permalink
Revert "Added bulk traits update (#45)"
Browse files Browse the repository at this point in the history
This reverts commit 027cc76.
  • Loading branch information
matthewelwell authored Apr 9, 2024
1 parent 027cc76 commit 782328b
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 61 deletions.
7 changes: 1 addition & 6 deletions FlagsmithClient/src/main/java/com/flagsmith/Flagsmith.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ class Flagsmith constructor(
}.also { lastUsedIdentity = identity }

fun setTrait(trait: Trait, identity: String, result: (Result<TraitWithIdentity>) -> Unit) =
retrofit.postTrait(TraitWithIdentity(trait.key, trait.traitValue, Identity(identity))).enqueueWithResult(result = result)

fun setTraits(traits: List<Trait>, identity: String, result: (Result<List<TraitWithIdentity>>) -> Unit) {
val request = traits.map { TraitWithIdentity(it.key, it.traitValue, Identity(identity)) }
retrofit.postTraits(request).enqueueWithResult(result = result)
}
retrofit.postTraits(TraitWithIdentity(trait.key, trait.traitValue, Identity(identity))).enqueueWithResult(result = result)

fun getIdentity(identity: String, result: (Result<IdentityFlagsAndTraits>) -> Unit) =
retrofit.getIdentityFlagsAndTraits(identity).enqueueWithResult(defaults = null, result = result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Query

interface FlagsmithRetrofitService {
Expand All @@ -26,10 +25,7 @@ interface FlagsmithRetrofitService {
fun getFlags() : Call<List<Flag>>

@POST("traits/")
fun postTrait(@Body trait: TraitWithIdentity) : Call<TraitWithIdentity>

@PUT("traits/bulk/")
fun postTraits(@Body traits: List<TraitWithIdentity>) : Call<List<TraitWithIdentity>>
fun postTraits(@Body trait: TraitWithIdentity) : Call<TraitWithIdentity>

@POST("analytics/flags/")
fun postAnalytics(@Body eventMap: Map<String, Int?>) : Call<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ suspend fun Flagsmith.getTraitSync(id: String, identity: String): Result<Trait?>
suspend fun Flagsmith.setTraitSync(trait: Trait, identity: String) : Result<TraitWithIdentity>
= suspendCoroutine { cont -> this.setTrait(trait, identity) { cont.resume(it) } }

suspend fun Flagsmith.setTraitsSync(traits: List<Trait>, identity: String) : Result<List<TraitWithIdentity>>
= suspendCoroutine { cont -> this.setTraits(traits, identity) { cont.resume(it) } }

suspend fun Flagsmith.getIdentitySync(identity: String): Result<IdentityFlagsAndTraits>
= suspendCoroutine { cont -> this.getIdentity(identity) { cont.resume(it) } }

13 changes: 0 additions & 13 deletions FlagsmithClient/src/test/java/com/flagsmith/TraitsTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,6 @@ class TraitsTests {
}
}

@Test
fun testSetTraits() {
mockServer.mockResponseFor(MockEndpoint.SET_TRAITS)
runBlocking {
val result =
flagsmith.setTraitsSync(listOf(Trait(key = "set-from-client", value = "12345")), "person")
assertTrue(result.isSuccess)
assertEquals("set-from-client", result.getOrThrow().first().key)
assertEquals("12345", result.getOrThrow().first().stringValue)
assertEquals("person", result.getOrThrow().first().identity.identifier)
}
}

@Test
fun testSetTraitInteger() {
mockServer.mockResponseFor(MockEndpoint.SET_TRAIT_INTEGER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.flagsmith.mockResponses
import com.flagsmith.entities.Trait
import com.flagsmith.mockResponses.endpoints.FlagsEndpoint
import com.flagsmith.mockResponses.endpoints.IdentityFlagsAndTraitsEndpoint
import com.flagsmith.mockResponses.endpoints.TraitsBulkEndpoint
import com.flagsmith.mockResponses.endpoints.TraitsEndpoint
import org.mockserver.integration.ClientAndServer
import org.mockserver.matchers.Times
Expand All @@ -17,7 +16,6 @@ enum class MockEndpoint(val path: String, val body: String) {
GET_IDENTITIES(IdentityFlagsAndTraitsEndpoint("").path, MockResponses.getIdentities),
GET_FLAGS(FlagsEndpoint.path, MockResponses.getFlags),
SET_TRAIT(TraitsEndpoint(Trait(key = "", traitValue = ""), "").path, MockResponses.setTrait),
SET_TRAITS(TraitsBulkEndpoint(listOf(Trait(key = "", traitValue = "")), "").path, MockResponses.setTraits),
SET_TRAIT_INTEGER(TraitsEndpoint(Trait(key = "", traitValue = ""), "").path, MockResponses.setTraitInteger),
SET_TRAIT_DOUBLE(TraitsEndpoint(Trait(key = "", traitValue = ""), "").path, MockResponses.setTraitDouble),
SET_TRAIT_BOOLEAN(TraitsEndpoint(Trait(key = "", traitValue = ""), "").path, MockResponses.setTraitBoolean),
Expand Down Expand Up @@ -168,18 +166,6 @@ object MockResponses {
}
""".trimIndent()

val setTraits = """
[
{
"trait_key": "set-from-client",
"trait_value": "12345",
"identity": {
"identifier": "person"
}
}
]
""".trimIndent()

val setTraitInteger = """
{
"trait_key": "set-from-client",
Expand Down

This file was deleted.

0 comments on commit 782328b

Please sign in to comment.