Skip to content

Commit

Permalink
fix(clients): highlight and snippet results e2e (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3567

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
3 people committed Aug 21, 2024
1 parent f70a6e8 commit 52c1ed1
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ object AddABTestsVariantSerializer extends Serializer[AddABTestsVariant] {

case (TypeInfo(clazz, _), json) if clazz == classOf[AddABTestsVariant] =>
json match {
case value: JObject if value.obj.exists(_._1 == "customSearchParameters") =>
Extraction.extract[AbTestsVariantSearchParams](value)
case value: JObject => Extraction.extract[AbTestsVariant](value)
case value: JObject => Extraction.extract[AbTestsVariantSearchParams](value)
case _ => throw new MappingException("Can't convert " + json + " to AddABTestsVariant")
}
}

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AddABTestsVariant =>
value match {
case value: AbTestsVariant => Extraction.decompose(value)(format - this)
case value: AbTestsVariantSearchParams => Extraction.decompose(value)(format - this)
case value: AbTestsVariant => Extraction.decompose(value)(format - this)
}
}
}
21 changes: 13 additions & 8 deletions src/main/scala/algoliasearch/ingestion/AuthInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,27 @@ object AuthInputSerializer extends Serializer[AuthInput] {

case (TypeInfo(clazz, _), json) if clazz == classOf[AuthInput] =>
json match {
case value: JObject => Extraction.extract[AuthGoogleServiceAccount](value)
case value: JObject => Extraction.extract[AuthBasic](value)
case value: JObject => Extraction.extract[AuthAPIKey](value)
case value: JObject => Extraction.extract[AuthOAuth](value)
case value: JObject => Extraction.extract[AuthAlgolia](value)
case value: JObject => Extraction.extract[AuthAlgoliaInsights](value)
case _ => throw new MappingException("Can't convert " + json + " to AuthInput")
case value: JObject
if value.obj.exists(_._1 == "url") && value.obj
.exists(_._1 == "client_id") && value.obj.exists(_._1 == "client_secret") =>
Extraction.extract[AuthOAuth](value)
case value: JObject if value.obj.exists(_._1 == "clientEmail") && value.obj.exists(_._1 == "privateKey") =>
Extraction.extract[AuthGoogleServiceAccount](value)
case value: JObject if value.obj.exists(_._1 == "username") && value.obj.exists(_._1 == "password") =>
Extraction.extract[AuthBasic](value)
case value: JObject if value.obj.exists(_._1 == "key") => Extraction.extract[AuthAPIKey](value)
case value: JObject => Extraction.extract[AuthAlgolia](value)
case value: JObject => Extraction.extract[AuthAlgoliaInsights](value)
case _ => throw new MappingException("Can't convert " + json + " to AuthInput")
}
}

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AuthInput =>
value match {
case value: AuthOAuth => Extraction.decompose(value)(format - this)
case value: AuthGoogleServiceAccount => Extraction.decompose(value)(format - this)
case value: AuthBasic => Extraction.decompose(value)(format - this)
case value: AuthAPIKey => Extraction.decompose(value)(format - this)
case value: AuthOAuth => Extraction.decompose(value)(format - this)
case value: AuthAlgolia => Extraction.decompose(value)(format - this)
case value: AuthAlgoliaInsights => Extraction.decompose(value)(format - this)
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/algoliasearch/ingestion/AuthInputPartial.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ object AuthInputPartialSerializer extends Serializer[AuthInputPartial] {

case (TypeInfo(clazz, _), json) if clazz == classOf[AuthInputPartial] =>
json match {
case value: JObject => Extraction.extract[AuthGoogleServiceAccountPartial](value)
case value: JObject => Extraction.extract[AuthBasicPartial](value)
case value: JObject => Extraction.extract[AuthAPIKeyPartial](value)
case value: JObject => Extraction.extract[AuthOAuthPartial](value)
case value: JObject => Extraction.extract[AuthAlgoliaPartial](value)
case value: JObject if value.obj.exists(_._1 == "clientEmail") =>
Extraction.extract[AuthGoogleServiceAccountPartial](value)
case value: JObject if value.obj.exists(_._1 == "username") => Extraction.extract[AuthBasicPartial](value)
case value: JObject if value.obj.exists(_._1 == "key") => Extraction.extract[AuthAPIKeyPartial](value)
case value: JObject if value.obj.exists(_._1 == "url") => Extraction.extract[AuthOAuthPartial](value)
case value: JObject => Extraction.extract[AuthAlgoliaPartial](value)
case value: JObject => Extraction.extract[AuthAlgoliaInsightsPartial](value)
case _ => throw new MappingException("Can't convert " + json + " to AuthInputPartial")
}
Expand Down
26 changes: 15 additions & 11 deletions src/main/scala/algoliasearch/ingestion/SourceInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,35 @@ object SourceInputSerializer extends Serializer[SourceInput] {

case (TypeInfo(clazz, _), json) if clazz == classOf[SourceInput] =>
json match {
case value: JObject if value.obj.exists(_._1 == "projectKey") => Extraction.extract[SourceCommercetools](value)
case value: JObject if value.obj.exists(_._1 == "storeHash") => Extraction.extract[SourceBigCommerce](value)
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
case value: JObject
if value.obj.exists(_._1 == "registry") && value.obj.exists(_._1 == "image") && value.obj.exists(
_._1 == "imageType"
) && value.obj.exists(_._1 == "configuration") =>
Extraction.extract[SourceDocker](value)
case value: JObject
if value.obj.exists(_._1 == "projectID") && value.obj
.exists(_._1 == "datasetID") && value.obj.exists(_._1 == "tablePrefix") =>
Extraction.extract[SourceGA4BigQueryExport](value)
case value: JObject => Extraction.extract[SourceJSON](value)
case value: JObject => Extraction.extract[SourceCSV](value)
case value: JObject => Extraction.extract[SourceDocker](value)
case value: JObject => Extraction.extract[SourceShopify](value)
case _ => throw new MappingException("Can't convert " + json + " to SourceInput")
case value: JObject if value.obj.exists(_._1 == "projectKey") => Extraction.extract[SourceCommercetools](value)
case value: JObject if value.obj.exists(_._1 == "storeHash") => Extraction.extract[SourceBigCommerce](value)
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
case value: JObject if value.obj.exists(_._1 == "shopURL") => Extraction.extract[SourceShopify](value)
case value: JObject => Extraction.extract[SourceJSON](value)
case value: JObject => Extraction.extract[SourceCSV](value)
case _ => throw new MappingException("Can't convert " + json + " to SourceInput")
}
}

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: SourceInput =>
value match {
case value: SourceDocker => Extraction.decompose(value)(format - this)
case value: SourceGA4BigQueryExport => Extraction.decompose(value)(format - this)
case value: SourceCommercetools => Extraction.decompose(value)(format - this)
case value: SourceBigCommerce => Extraction.decompose(value)(format - this)
case value: SourceBigQuery => Extraction.decompose(value)(format - this)
case value: SourceGA4BigQueryExport => Extraction.decompose(value)(format - this)
case value: SourceShopify => Extraction.decompose(value)(format - this)
case value: SourceJSON => Extraction.decompose(value)(format - this)
case value: SourceCSV => Extraction.decompose(value)(format - this)
case value: SourceDocker => Extraction.decompose(value)(format - this)
case value: SourceShopify => Extraction.decompose(value)(format - this)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,29 @@ object SourceUpdateInputSerializer extends Serializer[SourceUpdateInput] {

case (TypeInfo(clazz, _), json) if clazz == classOf[SourceUpdateInput] =>
json match {
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
case value: JObject
if value.obj.exists(_._1 == "projectID") && value.obj
.exists(_._1 == "datasetID") && value.obj.exists(_._1 == "tablePrefix") =>
Extraction.extract[SourceGA4BigQueryExport](value)
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
case value: JObject if value.obj.exists(_._1 == "configuration") =>
Extraction.extract[SourceUpdateDocker](value)
case value: JObject => Extraction.extract[SourceUpdateCommercetools](value)
case value: JObject => Extraction.extract[SourceJSON](value)
case value: JObject => Extraction.extract[SourceCSV](value)
case value: JObject => Extraction.extract[SourceUpdateDocker](value)
case value: JObject => Extraction.extract[SourceUpdateShopify](value)
case _ => throw new MappingException("Can't convert " + json + " to SourceUpdateInput")
}
}

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: SourceUpdateInput =>
value match {
case value: SourceBigQuery => Extraction.decompose(value)(format - this)
case value: SourceGA4BigQueryExport => Extraction.decompose(value)(format - this)
case value: SourceBigQuery => Extraction.decompose(value)(format - this)
case value: SourceUpdateDocker => Extraction.decompose(value)(format - this)
case value: SourceUpdateCommercetools => Extraction.decompose(value)(format - this)
case value: SourceJSON => Extraction.decompose(value)(format - this)
case value: SourceCSV => Extraction.decompose(value)(format - this)
case value: SourceUpdateDocker => Extraction.decompose(value)(format - this)
case value: SourceUpdateShopify => Extraction.decompose(value)(format - this)
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/algoliasearch/ingestion/TaskCreateTrigger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ object TaskCreateTriggerSerializer extends Serializer[TaskCreateTrigger] {

case (TypeInfo(clazz, _), json) if clazz == classOf[TaskCreateTrigger] =>
json match {
case value: JObject => Extraction.extract[OnDemandTriggerInput](value)
case value: JObject => Extraction.extract[ScheduleTriggerInput](value)
case value: JObject => Extraction.extract[SubscriptionTrigger](value)
case value: JObject => Extraction.extract[StreamingTrigger](value)
case _ => throw new MappingException("Can't convert " + json + " to TaskCreateTrigger")
case value: JObject if value.obj.exists(_._1 == "cron") => Extraction.extract[ScheduleTriggerInput](value)
case value: JObject => Extraction.extract[OnDemandTriggerInput](value)
case value: JObject => Extraction.extract[SubscriptionTrigger](value)
case value: JObject => Extraction.extract[StreamingTrigger](value)
case _ => throw new MappingException("Can't convert " + json + " to TaskCreateTrigger")
}
}

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: TaskCreateTrigger =>
value match {
case value: OnDemandTriggerInput => Extraction.decompose(value)(format - this)
case value: ScheduleTriggerInput => Extraction.decompose(value)(format - this)
case value: OnDemandTriggerInput => Extraction.decompose(value)(format - this)
case value: SubscriptionTrigger => Extraction.decompose(value)(format - this)
case value: StreamingTrigger => Extraction.decompose(value)(format - this)
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/algoliasearch/ingestion/TaskInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ object TaskInputSerializer extends Serializer[TaskInput] {

case (TypeInfo(clazz, _), json) if clazz == classOf[TaskInput] =>
json match {
case value: JObject => Extraction.extract[StreamingInput](value)
case value: JObject => Extraction.extract[DockerStreamsInput](value)
case value: JObject => Extraction.extract[ShopifyInput](value)
case _ => throw new MappingException("Can't convert " + json + " to TaskInput")
case value: JObject if value.obj.exists(_._1 == "mapping") => Extraction.extract[StreamingInput](value)
case value: JObject if value.obj.exists(_._1 == "streams") => Extraction.extract[DockerStreamsInput](value)
case value: JObject => Extraction.extract[ShopifyInput](value)
case _ => throw new MappingException("Can't convert " + json + " to TaskInput")
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/main/scala/algoliasearch/insights/EventsItems.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ object EventsItemsSerializer extends Serializer[EventsItems] {

case (TypeInfo(clazz, _), json) if clazz == classOf[EventsItems] =>
json match {
case value: JObject
if value.obj.exists(_._1 == "positions") && value.obj
.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
Extraction.extract[ClickedObjectIDsAfterSearch](value)
case value: JObject
if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "eventSubtype") && value.obj.exists(
_._1 == "queryID"
Expand All @@ -58,10 +54,10 @@ object EventsItemsSerializer extends Serializer[EventsItems] {
_._1 == "objectIDs"
) && value.obj.exists(_._1 == "objectData") =>
Extraction.extract[PurchasedObjectIDsAfterSearch](value)
case value: JObject if value.obj.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
Extraction.extract[ConvertedObjectIDsAfterSearch](value)
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "objectIDs") =>
Extraction.extract[ClickedObjectIDs](value)
case value: JObject
if value.obj.exists(_._1 == "positions") && value.obj
.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
Extraction.extract[ClickedObjectIDsAfterSearch](value)
case value: JObject
if value.obj.exists(_._1 == "eventType") && value.obj
.exists(_._1 == "eventSubtype") && value.obj.exists(_._1 == "objectIDs") =>
Expand All @@ -70,6 +66,10 @@ object EventsItemsSerializer extends Serializer[EventsItems] {
if value.obj.exists(_._1 == "eventType") && value.obj
.exists(_._1 == "eventSubtype") && value.obj.exists(_._1 == "objectIDs") =>
Extraction.extract[AddedToCartObjectIDs](value)
case value: JObject if value.obj.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
Extraction.extract[ConvertedObjectIDsAfterSearch](value)
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "objectIDs") =>
Extraction.extract[ClickedObjectIDs](value)
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "objectIDs") =>
Extraction.extract[ConvertedObjectIDs](value)
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "filters") =>
Expand All @@ -86,13 +86,13 @@ object EventsItemsSerializer extends Serializer[EventsItems] {

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: EventsItems =>
value match {
case value: ClickedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
case value: AddedToCartObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
case value: PurchasedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
case value: ConvertedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
case value: ClickedObjectIDs => Extraction.decompose(value)(format - this)
case value: ClickedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
case value: PurchasedObjectIDs => Extraction.decompose(value)(format - this)
case value: AddedToCartObjectIDs => Extraction.decompose(value)(format - this)
case value: ConvertedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
case value: ClickedObjectIDs => Extraction.decompose(value)(format - this)
case value: ConvertedObjectIDs => Extraction.decompose(value)(format - this)
case value: ClickedFilters => Extraction.decompose(value)(format - this)
case value: ConvertedFilters => Extraction.decompose(value)(format - this)
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/algoliasearch/recommend/HighlightResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ object HighlightResultSerializer extends Serializer[HighlightResult] {

case (TypeInfo(clazz, _), json) if clazz == classOf[HighlightResult] =>
json match {
case value: JObject if value.obj.exists(_._1 == "matchLevel") && value.obj.exists(_._1 == "matchedWords") =>
Extraction.extract[HighlightResultOption](value)
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResult]](value))
case value: JObject => Extraction.extract[HighlightResultOption](value)
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResultOption]](value))
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
HighlightResult.SeqOfHighlightResultOption(value.map(_.extract))
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/algoliasearch/recommend/SnippetResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ object SnippetResultSerializer extends Serializer[SnippetResult] {

case (TypeInfo(clazz, _), json) if clazz == classOf[SnippetResult] =>
json match {
case value: JObject if value.obj.exists(_._1 == "matchLevel") => Extraction.extract[SnippetResultOption](value)
case value: JObject => SnippetResult.apply(Extraction.extract[Map[String, SnippetResult]](value))
case value: JObject => Extraction.extract[SnippetResultOption](value)
case value: JObject => SnippetResult.apply(Extraction.extract[Map[String, SnippetResultOption]](value))
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
SnippetResult.SeqOfSnippetResultOption(value.map(_.extract))
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/algoliasearch/search/HighlightResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ object HighlightResultSerializer extends Serializer[HighlightResult] {

case (TypeInfo(clazz, _), json) if clazz == classOf[HighlightResult] =>
json match {
case value: JObject if value.obj.exists(_._1 == "matchLevel") && value.obj.exists(_._1 == "matchedWords") =>
Extraction.extract[HighlightResultOption](value)
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResult]](value))
case value: JObject => Extraction.extract[HighlightResultOption](value)
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResultOption]](value))
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
HighlightResult.SeqOfHighlightResultOption(value.map(_.extract))
Expand Down
Loading

0 comments on commit 52c1ed1

Please sign in to comment.