Skip to content

Commit 52c1ed1

Browse files
algolia-botshortcutsmillotp
committed
fix(clients): highlight and snippet results e2e (generated)
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]>
1 parent f70a6e8 commit 52c1ed1

13 files changed

+72
-58
lines changed

src/main/scala/algoliasearch/abtesting/AddABTestsVariant.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ object AddABTestsVariantSerializer extends Serializer[AddABTestsVariant] {
3838

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

4748
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AddABTestsVariant =>
4849
value match {
49-
case value: AbTestsVariant => Extraction.decompose(value)(format - this)
5050
case value: AbTestsVariantSearchParams => Extraction.decompose(value)(format - this)
51+
case value: AbTestsVariant => Extraction.decompose(value)(format - this)
5152
}
5253
}
5354
}

src/main/scala/algoliasearch/ingestion/AuthInput.scala

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,27 @@ object AuthInputSerializer extends Serializer[AuthInput] {
3838

3939
case (TypeInfo(clazz, _), json) if clazz == classOf[AuthInput] =>
4040
json match {
41-
case value: JObject => Extraction.extract[AuthGoogleServiceAccount](value)
42-
case value: JObject => Extraction.extract[AuthBasic](value)
43-
case value: JObject => Extraction.extract[AuthAPIKey](value)
44-
case value: JObject => Extraction.extract[AuthOAuth](value)
45-
case value: JObject => Extraction.extract[AuthAlgolia](value)
46-
case value: JObject => Extraction.extract[AuthAlgoliaInsights](value)
47-
case _ => throw new MappingException("Can't convert " + json + " to AuthInput")
41+
case value: JObject
42+
if value.obj.exists(_._1 == "url") && value.obj
43+
.exists(_._1 == "client_id") && value.obj.exists(_._1 == "client_secret") =>
44+
Extraction.extract[AuthOAuth](value)
45+
case value: JObject if value.obj.exists(_._1 == "clientEmail") && value.obj.exists(_._1 == "privateKey") =>
46+
Extraction.extract[AuthGoogleServiceAccount](value)
47+
case value: JObject if value.obj.exists(_._1 == "username") && value.obj.exists(_._1 == "password") =>
48+
Extraction.extract[AuthBasic](value)
49+
case value: JObject if value.obj.exists(_._1 == "key") => Extraction.extract[AuthAPIKey](value)
50+
case value: JObject => Extraction.extract[AuthAlgolia](value)
51+
case value: JObject => Extraction.extract[AuthAlgoliaInsights](value)
52+
case _ => throw new MappingException("Can't convert " + json + " to AuthInput")
4853
}
4954
}
5055

5156
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AuthInput =>
5257
value match {
58+
case value: AuthOAuth => Extraction.decompose(value)(format - this)
5359
case value: AuthGoogleServiceAccount => Extraction.decompose(value)(format - this)
5460
case value: AuthBasic => Extraction.decompose(value)(format - this)
5561
case value: AuthAPIKey => Extraction.decompose(value)(format - this)
56-
case value: AuthOAuth => Extraction.decompose(value)(format - this)
5762
case value: AuthAlgolia => Extraction.decompose(value)(format - this)
5863
case value: AuthAlgoliaInsights => Extraction.decompose(value)(format - this)
5964
}

src/main/scala/algoliasearch/ingestion/AuthInputPartial.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ object AuthInputPartialSerializer extends Serializer[AuthInputPartial] {
3838

3939
case (TypeInfo(clazz, _), json) if clazz == classOf[AuthInputPartial] =>
4040
json match {
41-
case value: JObject => Extraction.extract[AuthGoogleServiceAccountPartial](value)
42-
case value: JObject => Extraction.extract[AuthBasicPartial](value)
43-
case value: JObject => Extraction.extract[AuthAPIKeyPartial](value)
44-
case value: JObject => Extraction.extract[AuthOAuthPartial](value)
45-
case value: JObject => Extraction.extract[AuthAlgoliaPartial](value)
41+
case value: JObject if value.obj.exists(_._1 == "clientEmail") =>
42+
Extraction.extract[AuthGoogleServiceAccountPartial](value)
43+
case value: JObject if value.obj.exists(_._1 == "username") => Extraction.extract[AuthBasicPartial](value)
44+
case value: JObject if value.obj.exists(_._1 == "key") => Extraction.extract[AuthAPIKeyPartial](value)
45+
case value: JObject if value.obj.exists(_._1 == "url") => Extraction.extract[AuthOAuthPartial](value)
46+
case value: JObject => Extraction.extract[AuthAlgoliaPartial](value)
4647
case value: JObject => Extraction.extract[AuthAlgoliaInsightsPartial](value)
4748
case _ => throw new MappingException("Can't convert " + json + " to AuthInputPartial")
4849
}

src/main/scala/algoliasearch/ingestion/SourceInput.scala

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,35 @@ object SourceInputSerializer extends Serializer[SourceInput] {
4444

4545
case (TypeInfo(clazz, _), json) if clazz == classOf[SourceInput] =>
4646
json match {
47-
case value: JObject if value.obj.exists(_._1 == "projectKey") => Extraction.extract[SourceCommercetools](value)
48-
case value: JObject if value.obj.exists(_._1 == "storeHash") => Extraction.extract[SourceBigCommerce](value)
49-
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
47+
case value: JObject
48+
if value.obj.exists(_._1 == "registry") && value.obj.exists(_._1 == "image") && value.obj.exists(
49+
_._1 == "imageType"
50+
) && value.obj.exists(_._1 == "configuration") =>
51+
Extraction.extract[SourceDocker](value)
5052
case value: JObject
5153
if value.obj.exists(_._1 == "projectID") && value.obj
5254
.exists(_._1 == "datasetID") && value.obj.exists(_._1 == "tablePrefix") =>
5355
Extraction.extract[SourceGA4BigQueryExport](value)
54-
case value: JObject => Extraction.extract[SourceJSON](value)
55-
case value: JObject => Extraction.extract[SourceCSV](value)
56-
case value: JObject => Extraction.extract[SourceDocker](value)
57-
case value: JObject => Extraction.extract[SourceShopify](value)
58-
case _ => throw new MappingException("Can't convert " + json + " to SourceInput")
56+
case value: JObject if value.obj.exists(_._1 == "projectKey") => Extraction.extract[SourceCommercetools](value)
57+
case value: JObject if value.obj.exists(_._1 == "storeHash") => Extraction.extract[SourceBigCommerce](value)
58+
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
59+
case value: JObject if value.obj.exists(_._1 == "shopURL") => Extraction.extract[SourceShopify](value)
60+
case value: JObject => Extraction.extract[SourceJSON](value)
61+
case value: JObject => Extraction.extract[SourceCSV](value)
62+
case _ => throw new MappingException("Can't convert " + json + " to SourceInput")
5963
}
6064
}
6165

6266
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: SourceInput =>
6367
value match {
68+
case value: SourceDocker => Extraction.decompose(value)(format - this)
69+
case value: SourceGA4BigQueryExport => Extraction.decompose(value)(format - this)
6470
case value: SourceCommercetools => Extraction.decompose(value)(format - this)
6571
case value: SourceBigCommerce => Extraction.decompose(value)(format - this)
6672
case value: SourceBigQuery => Extraction.decompose(value)(format - this)
67-
case value: SourceGA4BigQueryExport => Extraction.decompose(value)(format - this)
73+
case value: SourceShopify => Extraction.decompose(value)(format - this)
6874
case value: SourceJSON => Extraction.decompose(value)(format - this)
6975
case value: SourceCSV => Extraction.decompose(value)(format - this)
70-
case value: SourceDocker => Extraction.decompose(value)(format - this)
71-
case value: SourceShopify => Extraction.decompose(value)(format - this)
7276
}
7377
}
7478
}

src/main/scala/algoliasearch/ingestion/SourceUpdateInput.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,29 @@ object SourceUpdateInputSerializer extends Serializer[SourceUpdateInput] {
4343

4444
case (TypeInfo(clazz, _), json) if clazz == classOf[SourceUpdateInput] =>
4545
json match {
46-
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
4746
case value: JObject
4847
if value.obj.exists(_._1 == "projectID") && value.obj
4948
.exists(_._1 == "datasetID") && value.obj.exists(_._1 == "tablePrefix") =>
5049
Extraction.extract[SourceGA4BigQueryExport](value)
50+
case value: JObject if value.obj.exists(_._1 == "projectID") => Extraction.extract[SourceBigQuery](value)
51+
case value: JObject if value.obj.exists(_._1 == "configuration") =>
52+
Extraction.extract[SourceUpdateDocker](value)
5153
case value: JObject => Extraction.extract[SourceUpdateCommercetools](value)
5254
case value: JObject => Extraction.extract[SourceJSON](value)
5355
case value: JObject => Extraction.extract[SourceCSV](value)
54-
case value: JObject => Extraction.extract[SourceUpdateDocker](value)
5556
case value: JObject => Extraction.extract[SourceUpdateShopify](value)
5657
case _ => throw new MappingException("Can't convert " + json + " to SourceUpdateInput")
5758
}
5859
}
5960

6061
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: SourceUpdateInput =>
6162
value match {
62-
case value: SourceBigQuery => Extraction.decompose(value)(format - this)
6363
case value: SourceGA4BigQueryExport => Extraction.decompose(value)(format - this)
64+
case value: SourceBigQuery => Extraction.decompose(value)(format - this)
65+
case value: SourceUpdateDocker => Extraction.decompose(value)(format - this)
6466
case value: SourceUpdateCommercetools => Extraction.decompose(value)(format - this)
6567
case value: SourceJSON => Extraction.decompose(value)(format - this)
6668
case value: SourceCSV => Extraction.decompose(value)(format - this)
67-
case value: SourceUpdateDocker => Extraction.decompose(value)(format - this)
6869
case value: SourceUpdateShopify => Extraction.decompose(value)(format - this)
6970
}
7071
}

src/main/scala/algoliasearch/ingestion/TaskCreateTrigger.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ object TaskCreateTriggerSerializer extends Serializer[TaskCreateTrigger] {
4040

4141
case (TypeInfo(clazz, _), json) if clazz == classOf[TaskCreateTrigger] =>
4242
json match {
43-
case value: JObject => Extraction.extract[OnDemandTriggerInput](value)
44-
case value: JObject => Extraction.extract[ScheduleTriggerInput](value)
45-
case value: JObject => Extraction.extract[SubscriptionTrigger](value)
46-
case value: JObject => Extraction.extract[StreamingTrigger](value)
47-
case _ => throw new MappingException("Can't convert " + json + " to TaskCreateTrigger")
43+
case value: JObject if value.obj.exists(_._1 == "cron") => Extraction.extract[ScheduleTriggerInput](value)
44+
case value: JObject => Extraction.extract[OnDemandTriggerInput](value)
45+
case value: JObject => Extraction.extract[SubscriptionTrigger](value)
46+
case value: JObject => Extraction.extract[StreamingTrigger](value)
47+
case _ => throw new MappingException("Can't convert " + json + " to TaskCreateTrigger")
4848
}
4949
}
5050

5151
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: TaskCreateTrigger =>
5252
value match {
53-
case value: OnDemandTriggerInput => Extraction.decompose(value)(format - this)
5453
case value: ScheduleTriggerInput => Extraction.decompose(value)(format - this)
54+
case value: OnDemandTriggerInput => Extraction.decompose(value)(format - this)
5555
case value: SubscriptionTrigger => Extraction.decompose(value)(format - this)
5656
case value: StreamingTrigger => Extraction.decompose(value)(format - this)
5757
}

src/main/scala/algoliasearch/ingestion/TaskInput.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ object TaskInputSerializer extends Serializer[TaskInput] {
3838

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

src/main/scala/algoliasearch/insights/EventsItems.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ object EventsItemsSerializer extends Serializer[EventsItems] {
4444

4545
case (TypeInfo(clazz, _), json) if clazz == classOf[EventsItems] =>
4646
json match {
47-
case value: JObject
48-
if value.obj.exists(_._1 == "positions") && value.obj
49-
.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
50-
Extraction.extract[ClickedObjectIDsAfterSearch](value)
5147
case value: JObject
5248
if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "eventSubtype") && value.obj.exists(
5349
_._1 == "queryID"
@@ -58,10 +54,10 @@ object EventsItemsSerializer extends Serializer[EventsItems] {
5854
_._1 == "objectIDs"
5955
) && value.obj.exists(_._1 == "objectData") =>
6056
Extraction.extract[PurchasedObjectIDsAfterSearch](value)
61-
case value: JObject if value.obj.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
62-
Extraction.extract[ConvertedObjectIDsAfterSearch](value)
63-
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "objectIDs") =>
64-
Extraction.extract[ClickedObjectIDs](value)
57+
case value: JObject
58+
if value.obj.exists(_._1 == "positions") && value.obj
59+
.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
60+
Extraction.extract[ClickedObjectIDsAfterSearch](value)
6561
case value: JObject
6662
if value.obj.exists(_._1 == "eventType") && value.obj
6763
.exists(_._1 == "eventSubtype") && value.obj.exists(_._1 == "objectIDs") =>
@@ -70,6 +66,10 @@ object EventsItemsSerializer extends Serializer[EventsItems] {
7066
if value.obj.exists(_._1 == "eventType") && value.obj
7167
.exists(_._1 == "eventSubtype") && value.obj.exists(_._1 == "objectIDs") =>
7268
Extraction.extract[AddedToCartObjectIDs](value)
69+
case value: JObject if value.obj.exists(_._1 == "queryID") && value.obj.exists(_._1 == "eventType") =>
70+
Extraction.extract[ConvertedObjectIDsAfterSearch](value)
71+
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "objectIDs") =>
72+
Extraction.extract[ClickedObjectIDs](value)
7373
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "objectIDs") =>
7474
Extraction.extract[ConvertedObjectIDs](value)
7575
case value: JObject if value.obj.exists(_._1 == "eventType") && value.obj.exists(_._1 == "filters") =>
@@ -86,13 +86,13 @@ object EventsItemsSerializer extends Serializer[EventsItems] {
8686

8787
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: EventsItems =>
8888
value match {
89-
case value: ClickedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
9089
case value: AddedToCartObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
9190
case value: PurchasedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
92-
case value: ConvertedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
93-
case value: ClickedObjectIDs => Extraction.decompose(value)(format - this)
91+
case value: ClickedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
9492
case value: PurchasedObjectIDs => Extraction.decompose(value)(format - this)
9593
case value: AddedToCartObjectIDs => Extraction.decompose(value)(format - this)
94+
case value: ConvertedObjectIDsAfterSearch => Extraction.decompose(value)(format - this)
95+
case value: ClickedObjectIDs => Extraction.decompose(value)(format - this)
9696
case value: ConvertedObjectIDs => Extraction.decompose(value)(format - this)
9797
case value: ClickedFilters => Extraction.decompose(value)(format - this)
9898
case value: ConvertedFilters => Extraction.decompose(value)(format - this)

src/main/scala/algoliasearch/recommend/HighlightResult.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ object HighlightResultSerializer extends Serializer[HighlightResult] {
7373

7474
case (TypeInfo(clazz, _), json) if clazz == classOf[HighlightResult] =>
7575
json match {
76+
case value: JObject if value.obj.exists(_._1 == "matchLevel") && value.obj.exists(_._1 == "matchedWords") =>
77+
Extraction.extract[HighlightResultOption](value)
7678
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResult]](value))
77-
case value: JObject => Extraction.extract[HighlightResultOption](value)
7879
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResultOption]](value))
7980
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
8081
HighlightResult.SeqOfHighlightResultOption(value.map(_.extract))

src/main/scala/algoliasearch/recommend/SnippetResult.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ object SnippetResultSerializer extends Serializer[SnippetResult] {
7373

7474
case (TypeInfo(clazz, _), json) if clazz == classOf[SnippetResult] =>
7575
json match {
76+
case value: JObject if value.obj.exists(_._1 == "matchLevel") => Extraction.extract[SnippetResultOption](value)
7677
case value: JObject => SnippetResult.apply(Extraction.extract[Map[String, SnippetResult]](value))
77-
case value: JObject => Extraction.extract[SnippetResultOption](value)
7878
case value: JObject => SnippetResult.apply(Extraction.extract[Map[String, SnippetResultOption]](value))
7979
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
8080
SnippetResult.SeqOfSnippetResultOption(value.map(_.extract))

src/main/scala/algoliasearch/search/HighlightResult.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ object HighlightResultSerializer extends Serializer[HighlightResult] {
7777

7878
case (TypeInfo(clazz, _), json) if clazz == classOf[HighlightResult] =>
7979
json match {
80+
case value: JObject if value.obj.exists(_._1 == "matchLevel") && value.obj.exists(_._1 == "matchedWords") =>
81+
Extraction.extract[HighlightResultOption](value)
8082
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResult]](value))
81-
case value: JObject => Extraction.extract[HighlightResultOption](value)
8283
case value: JObject => HighlightResult.apply(Extraction.extract[Map[String, HighlightResultOption]](value))
8384
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
8485
HighlightResult.SeqOfHighlightResultOption(value.map(_.extract))

0 commit comments

Comments
 (0)