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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.constructor.data.model.common

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.io.Serializable

/**
* Models a Recommendation Strategy object
*/
@JsonClass(generateAdapter = true)
data class RecommendationStrategy(
@Json(name = "id") val id: String,
) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class Result(
@Json(name = "matched_terms") val matchedTerms: List<String>?,
@Json(name = "variations") val variations: List<Result>?,
@Json(name = "variations_map") val variationsMap: Any?,
@Json(name = "strategy") val strategy: RecommendationStrategy?,
@Json(name = "value") val value: String,
@Json(name = "is_slotted") val isSlotted: Boolean?,
@Json(name = "labels") val labels: Map<String, Any>?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ConstructorIoRecommendationsTest {
assertEquals(recommendationResponse?.response?.results!![0].data.id, "960189161")
assertEquals(recommendationResponse?.response?.results!![0].data.imageUrl, "https://d17bbgoo3npfov.cloudfront.net/images/farmstand-960189161.png")
assertEquals(recommendationResponse?.response?.results!![0].data.metadata?.get("price"), 1.11)
assertEquals(recommendationResponse?.response?.results!![0].strategy?.id, "bestsellers")
assertEquals(recommendationResponse?.response?.resultCount, 225)

val request = mockServer.takeRequest()
Expand Down
5 changes: 4 additions & 1 deletion library/src/test/resources/recommendation_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"url": "/"
},
"is_slotted": false,
"strategy": {
"id": "bestsellers"
},
"matched_terms": [],
"value": "LaCroix Sparkling Water Pure Cans - 12-12 Fl. Oz."
}, {
Expand Down Expand Up @@ -795,4 +798,4 @@
}
},
"result_id": "49eb05c2-a3a3-4080-b238-82c5a44f8cf5"
}
}