From 5f536fb3184ddf2eefc76a25cea691571c1e279e Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Wed, 22 Jan 2025 08:32:47 +0000 Subject: [PATCH] feat(specs): rename composition to composition-full (private) and add composition (public) (generated) https://github.com/algolia/api-clients-automation/pull/4357 Co-authored-by: algolia-bot Co-authored-by: Emmanuel Krebs Co-authored-by: shortcuts Co-authored-by: Pierre Millot --- .../algoliasearch/api/CompositionClient.scala | 146 +++++++++ .../composition/AroundPrecision.scala | 48 +++ .../composition/AroundRadius.scala | 50 +++ .../composition/AroundRadiusAll.scala | 38 +++ .../algoliasearch/composition/Banner.scala | 15 + .../composition/BannerImage.scala | 15 + .../composition/BannerImageUrl.scala | 14 + .../composition/BannerLink.scala | 14 + .../composition/BaseSearchResponse.scala | 152 +++++++++ .../CompositionBaseSearchResponse.scala | 54 +++ .../CompositionIdRankingInfo.scala | 15 + .../composition/CompositionRankingInfo.scala | 14 + .../CompositionRunAppliedRules.scala | 17 + .../CompositionRunSearchResponse.scala | 58 ++++ .../CompositionsSearchResponse.scala | 54 +++ .../algoliasearch/composition/ErrorBase.scala | 50 +++ .../composition/Exhaustive.scala | 39 +++ .../composition/FacetFilters.scala | 52 +++ .../algoliasearch/composition/FacetHits.scala | 24 ++ .../composition/FacetOrdering.scala | 18 + .../composition/FacetStats.scala | 26 ++ .../algoliasearch/composition/Facets.scala | 18 + .../composition/HighlightResult.scala | 54 +++ .../composition/HighlightResultOption.scala | 26 ++ .../scala/algoliasearch/composition/Hit.scala | 62 ++++ .../composition/HitRankingInfo.scala | 51 +++ .../composition/InsideBoundingBox.scala | 48 +++ .../composition/JsonSupport.scala | 42 +++ .../composition/MatchLevel.scala | 44 +++ .../composition/MatchedGeoLocation.scala | 23 ++ .../composition/NumericFilters.scala | 51 +++ .../composition/OptionalFilters.scala | 54 +++ .../algoliasearch/composition/Params.scala | 118 +++++++ .../composition/Personalization.scala | 23 ++ .../algoliasearch/composition/Range.scala | 20 ++ .../composition/RankingInfo.scala | 50 +++ .../algoliasearch/composition/Redirect.scala | 16 + .../composition/RedirectRuleIndexData.scala | 14 + .../RedirectRuleIndexMetadata.scala | 27 ++ .../composition/RedirectURL.scala | 14 + .../composition/RenderingContent.scala | 17 + .../composition/RequestBody.scala | 14 + .../ResultsCompositionInfoResponse.scala | 14 + .../ResultsCompositionsResponse.scala | 54 +++ ...InjectedItemAppliedRulesInfoResponse.scala | 17 + .../ResultsInjectedItemInfoResponse.scala | 55 ++++ .../SearchForFacetValuesParams.scala | 22 ++ .../SearchForFacetValuesRequest.scala | 14 + .../SearchForFacetValuesResponse.scala | 17 + .../SearchForFacetValuesResults.scala | 26 ++ .../composition/SearchHits.scala | 60 ++++ .../composition/SearchPagination.scala | 26 ++ .../composition/SearchResponse.scala | 18 + .../composition/SearchResults.scala | 17 + .../composition/SearchResultsItem.scala | 112 +++++++ .../composition/SnippetResult.scala | 53 +++ .../composition/SnippetResultOption.scala | 20 ++ .../composition/SortRemainingBy.scala | 46 +++ .../composition/SupportedLanguage.scala | 308 ++++++++++++++++++ .../algoliasearch/composition/Value.scala | 24 ++ .../algoliasearch/composition/Widgets.scala | 17 + 61 files changed, 2619 insertions(+) create mode 100644 src/main/scala/algoliasearch/api/CompositionClient.scala create mode 100644 src/main/scala/algoliasearch/composition/AroundPrecision.scala create mode 100644 src/main/scala/algoliasearch/composition/AroundRadius.scala create mode 100644 src/main/scala/algoliasearch/composition/AroundRadiusAll.scala create mode 100644 src/main/scala/algoliasearch/composition/Banner.scala create mode 100644 src/main/scala/algoliasearch/composition/BannerImage.scala create mode 100644 src/main/scala/algoliasearch/composition/BannerImageUrl.scala create mode 100644 src/main/scala/algoliasearch/composition/BannerLink.scala create mode 100644 src/main/scala/algoliasearch/composition/BaseSearchResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/CompositionBaseSearchResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/CompositionIdRankingInfo.scala create mode 100644 src/main/scala/algoliasearch/composition/CompositionRankingInfo.scala create mode 100644 src/main/scala/algoliasearch/composition/CompositionRunAppliedRules.scala create mode 100644 src/main/scala/algoliasearch/composition/CompositionRunSearchResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/CompositionsSearchResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/ErrorBase.scala create mode 100644 src/main/scala/algoliasearch/composition/Exhaustive.scala create mode 100644 src/main/scala/algoliasearch/composition/FacetFilters.scala create mode 100644 src/main/scala/algoliasearch/composition/FacetHits.scala create mode 100644 src/main/scala/algoliasearch/composition/FacetOrdering.scala create mode 100644 src/main/scala/algoliasearch/composition/FacetStats.scala create mode 100644 src/main/scala/algoliasearch/composition/Facets.scala create mode 100644 src/main/scala/algoliasearch/composition/HighlightResult.scala create mode 100644 src/main/scala/algoliasearch/composition/HighlightResultOption.scala create mode 100644 src/main/scala/algoliasearch/composition/Hit.scala create mode 100644 src/main/scala/algoliasearch/composition/HitRankingInfo.scala create mode 100644 src/main/scala/algoliasearch/composition/InsideBoundingBox.scala create mode 100644 src/main/scala/algoliasearch/composition/JsonSupport.scala create mode 100644 src/main/scala/algoliasearch/composition/MatchLevel.scala create mode 100644 src/main/scala/algoliasearch/composition/MatchedGeoLocation.scala create mode 100644 src/main/scala/algoliasearch/composition/NumericFilters.scala create mode 100644 src/main/scala/algoliasearch/composition/OptionalFilters.scala create mode 100644 src/main/scala/algoliasearch/composition/Params.scala create mode 100644 src/main/scala/algoliasearch/composition/Personalization.scala create mode 100644 src/main/scala/algoliasearch/composition/Range.scala create mode 100644 src/main/scala/algoliasearch/composition/RankingInfo.scala create mode 100644 src/main/scala/algoliasearch/composition/Redirect.scala create mode 100644 src/main/scala/algoliasearch/composition/RedirectRuleIndexData.scala create mode 100644 src/main/scala/algoliasearch/composition/RedirectRuleIndexMetadata.scala create mode 100644 src/main/scala/algoliasearch/composition/RedirectURL.scala create mode 100644 src/main/scala/algoliasearch/composition/RenderingContent.scala create mode 100644 src/main/scala/algoliasearch/composition/RequestBody.scala create mode 100644 src/main/scala/algoliasearch/composition/ResultsCompositionInfoResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/ResultsCompositionsResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/ResultsInjectedItemAppliedRulesInfoResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/ResultsInjectedItemInfoResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchForFacetValuesParams.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchForFacetValuesRequest.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchForFacetValuesResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchForFacetValuesResults.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchHits.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchPagination.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchResponse.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchResults.scala create mode 100644 src/main/scala/algoliasearch/composition/SearchResultsItem.scala create mode 100644 src/main/scala/algoliasearch/composition/SnippetResult.scala create mode 100644 src/main/scala/algoliasearch/composition/SnippetResultOption.scala create mode 100644 src/main/scala/algoliasearch/composition/SortRemainingBy.scala create mode 100644 src/main/scala/algoliasearch/composition/SupportedLanguage.scala create mode 100644 src/main/scala/algoliasearch/composition/Value.scala create mode 100644 src/main/scala/algoliasearch/composition/Widgets.scala diff --git a/src/main/scala/algoliasearch/api/CompositionClient.scala b/src/main/scala/algoliasearch/api/CompositionClient.scala new file mode 100644 index 00000000..16c6eed9 --- /dev/null +++ b/src/main/scala/algoliasearch/api/CompositionClient.scala @@ -0,0 +1,146 @@ +/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on + * https://github.com/algolia/api-clients-automation. DO NOT EDIT. + */ +package algoliasearch.api + +import algoliasearch.composition.ErrorBase +import algoliasearch.composition.RequestBody +import algoliasearch.composition.SearchForFacetValuesRequest +import algoliasearch.composition.SearchForFacetValuesResponse +import algoliasearch.composition.SearchResponse +import algoliasearch.composition._ +import algoliasearch.ApiClient +import algoliasearch.api.CompositionClient.hosts +import algoliasearch.api.CompositionClient.readTimeout +import algoliasearch.api.CompositionClient.writeTimeout +import algoliasearch.api.CompositionClient.connectTimeout +import algoliasearch.config._ +import algoliasearch.internal.util._ + +import java.util.concurrent.TimeUnit +import scala.concurrent.duration.Duration +import scala.concurrent.{ExecutionContext, Future} +import scala.util.Random + +object CompositionClient { + + /** Creates a new CompositionClient instance using default hosts. + * + * @param appId + * application ID + * @param apiKey + * api key + * + * @param clientOptions + * client options + */ + def apply( + appId: String, + apiKey: String, + clientOptions: ClientOptions = ClientOptions() + ) = new CompositionClient( + appId = appId, + apiKey = apiKey, + clientOptions = clientOptions + ) + + private def readTimeout(): Duration = { + Duration(5000, TimeUnit.MILLISECONDS) + } + + private def connectTimeout(): Duration = { + Duration(2000, TimeUnit.MILLISECONDS) + } + + private def writeTimeout(): Duration = { + Duration(30000, TimeUnit.MILLISECONDS) + } + + private def hosts(appId: String): Seq[Host] = { + val commonHosts = Random.shuffle( + List( + Host(appId + "-1.algolianet.com", Set(CallType.Read, CallType.Write)), + Host(appId + "-2.algolianet.com", Set(CallType.Read, CallType.Write)), + Host(appId + "-3.algolianet.com", Set(CallType.Read, CallType.Write)) + ) + ) + List( + Host(appId + "-dsn.algolia.net", Set(CallType.Read)), + Host(appId + ".algolia.net", Set(CallType.Write)) + ) ++ commonHosts + } +} + +class CompositionClient( + appId: String, + apiKey: String, + clientOptions: ClientOptions = ClientOptions() +) extends ApiClient( + appId = appId, + apiKey = apiKey, + clientName = "Composition", + defaultHosts = hosts(appId), + defaultReadTimeout = readTimeout(), + defaultWriteTimeout = writeTimeout(), + defaultConnectTimeout = connectTimeout(), + formats = JsonSupport.format, + options = clientOptions + ) { + + /** Runs a query on a single composition and returns matching results. + * + * Required API Key ACLs: + * - search + * + * @param compositionID + * Unique Composition ObjectID. + */ + def search(compositionID: String, requestBody: RequestBody, requestOptions: Option[RequestOptions] = None)(implicit + ec: ExecutionContext + ): Future[SearchResponse] = Future { + requireNotNull(compositionID, "Parameter `compositionID` is required when calling `search`.") + requireNotNull(requestBody, "Parameter `requestBody` is required when calling `search`.") + + val request = HttpRequest + .builder() + .withMethod("POST") + .withPath(s"/1/compositions/${escape(compositionID)}/run") + .withBody(requestBody) + .withRead(true) + .build() + execute[SearchResponse](request, requestOptions) + } + + /** Searches for values of a specified facet attribute on the composition's main source's index. - By default, facet + * values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for + * facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**. + * + * Required API Key ACLs: + * - search + * + * @param compositionID + * Unique Composition ObjectID. + * @param facetName + * Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` + * index setting with the `searchable()` modifier. + */ + def searchForFacetValues( + compositionID: String, + facetName: String, + searchForFacetValuesRequest: Option[SearchForFacetValuesRequest] = None, + requestOptions: Option[RequestOptions] = None + )(implicit ec: ExecutionContext): Future[SearchForFacetValuesResponse] = Future { + requireNotNull(compositionID, "Parameter `compositionID` is required when calling `searchForFacetValues`.") + requireNotNull(facetName, "Parameter `facetName` is required when calling `searchForFacetValues`.") + + val request = HttpRequest + .builder() + .withMethod("POST") + .withPath(s"/1/compositions/${escape(compositionID)}/facets/${escape(facetName)}/query") + .withBody(searchForFacetValuesRequest) + .withRead(true) + .build() + execute[SearchForFacetValuesResponse](request, requestOptions) + } + +} diff --git a/src/main/scala/algoliasearch/composition/AroundPrecision.scala b/src/main/scala/algoliasearch/composition/AroundPrecision.scala new file mode 100644 index 00000000..3b2dc7b4 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/AroundPrecision.scala @@ -0,0 +1,48 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +/** Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion + * considers all matches within the same range of distances to be equal. + */ +sealed trait AroundPrecision + +object AroundPrecision { + + case class IntValue(value: Int) extends AroundPrecision + case class SeqOfRange(value: Seq[Range]) extends AroundPrecision + + def apply(value: Int): AroundPrecision = { + AroundPrecision.IntValue(value) + } + def apply(value: Seq[Range]): AroundPrecision = { + AroundPrecision.SeqOfRange(value) + } + +} + +object AroundPrecisionSerializer extends Serializer[AroundPrecision] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), AroundPrecision] = { + + case (TypeInfo(clazz, _), json) if clazz == classOf[AroundPrecision] => + json match { + case JInt(value) => AroundPrecision.IntValue(value.toInt) + case JArray(value) if value.forall(_.isInstanceOf[JArray]) => AroundPrecision.SeqOfRange(value.map(_.extract)) + case _ => throw new MappingException("Can't convert " + json + " to AroundPrecision") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AroundPrecision => + value match { + case AroundPrecision.IntValue(value) => JInt(value) + case AroundPrecision.SeqOfRange(value) => JArray(value.map(Extraction.decompose).toList) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/AroundRadius.scala b/src/main/scala/algoliasearch/composition/AroundRadius.scala new file mode 100644 index 00000000..e6b87552 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/AroundRadius.scala @@ -0,0 +1,50 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.AroundRadiusAll._ + +import org.json4s._ + +/** Maximum radius for a search around a central location. This parameter works in combination with the `aroundLatLng` + * and `aroundLatLngViaIP` parameters. By default, the search radius is determined automatically from the density of + * hits around the central location. The search radius is small if there are many hits close to the central + * coordinates. + */ +sealed trait AroundRadius + +trait AroundRadiusTrait extends AroundRadius + +object AroundRadius { + + case class IntValue(value: Int) extends AroundRadius + + def apply(value: Int): AroundRadius = { + AroundRadius.IntValue(value) + } + +} + +object AroundRadiusSerializer extends Serializer[AroundRadius] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), AroundRadius] = { + + case (TypeInfo(clazz, _), json) if clazz == classOf[AroundRadius] => + json match { + case JInt(value) => AroundRadius.IntValue(value.toInt) + case value: JString => Extraction.extract[AroundRadiusAll](value) + case _ => throw new MappingException("Can't convert " + json + " to AroundRadius") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AroundRadius => + value match { + case AroundRadius.IntValue(value) => JInt(value) + case value: AroundRadiusAll => JString(value.toString) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/AroundRadiusAll.scala b/src/main/scala/algoliasearch/composition/AroundRadiusAll.scala new file mode 100644 index 00000000..bdd5ce45 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/AroundRadiusAll.scala @@ -0,0 +1,38 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +sealed trait AroundRadiusAll extends AroundRadiusTrait + +/** Return all records with a valid `_geoloc` attribute. Don't filter by distance. + */ +object AroundRadiusAll { + case object All extends AroundRadiusAll { + override def toString = "all" + } + val values: Seq[AroundRadiusAll] = Seq(All) + + def withName(name: String): AroundRadiusAll = AroundRadiusAll.values + .find(_.toString == name) + .getOrElse(throw new MappingException(s"Unknown AroundRadiusAll value: $name")) +} + +class AroundRadiusAllSerializer + extends CustomSerializer[AroundRadiusAll](_ => + ( + { + case JString(value) => AroundRadiusAll.withName(value) + case JNull => null + }, + { case value: AroundRadiusAll => + JString(value.toString) + } + ) + ) diff --git a/src/main/scala/algoliasearch/composition/Banner.scala b/src/main/scala/algoliasearch/composition/Banner.scala new file mode 100644 index 00000000..07444a8e --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Banner.scala @@ -0,0 +1,15 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Banner with image and link to redirect users. + */ +case class Banner( + image: Option[BannerImage] = scala.None, + link: Option[BannerLink] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/BannerImage.scala b/src/main/scala/algoliasearch/composition/BannerImage.scala new file mode 100644 index 00000000..2741e48b --- /dev/null +++ b/src/main/scala/algoliasearch/composition/BannerImage.scala @@ -0,0 +1,15 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Image to show inside a banner. + */ +case class BannerImage( + urls: Option[Seq[BannerImageUrl]] = scala.None, + title: Option[String] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/BannerImageUrl.scala b/src/main/scala/algoliasearch/composition/BannerImageUrl.scala new file mode 100644 index 00000000..48e0af54 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/BannerImageUrl.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** URL for an image to show inside a banner. + */ +case class BannerImageUrl( + url: Option[String] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/BannerLink.scala b/src/main/scala/algoliasearch/composition/BannerLink.scala new file mode 100644 index 00000000..88152554 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/BannerLink.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Link for a banner defined in the Merchandising Studio. + */ +case class BannerLink( + url: Option[String] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/BaseSearchResponse.scala b/src/main/scala/algoliasearch/composition/BaseSearchResponse.scala new file mode 100644 index 00000000..0d65ba29 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/BaseSearchResponse.scala @@ -0,0 +1,152 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** BaseSearchResponse + * + * @param abTestID + * A/B test ID. This is only included in the response for indices that are part of an A/B test. + * @param abTestVariantID + * Variant ID. This is only included in the response for indices that are part of an A/B test. + * @param aroundLatLng + * Computed geographical location. + * @param automaticRadius + * Distance from a central coordinate provided by `aroundLatLng`. + * @param appliedRules + * Rules applied to the query. + * @param exhaustiveFacetsCount + * See the `facetsCount` field of the `exhaustive` object in the response. + * @param exhaustiveNbHits + * See the `nbHits` field of the `exhaustive` object in the response. + * @param exhaustiveTypo + * See the `typo` field of the `exhaustive` object in the response. + * @param facets + * Facet counts. + * @param facetsStats + * Statistics for numerical facets. + * @param index + * Index name used for the query. + * @param indexUsed + * Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query. + * @param message + * Warnings about the query. + * @param nbSortedHits + * Number of hits selected and sorted by the relevant sort algorithm. + * @param parsedQuery + * Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) + * query string that will be searched. + * @param processingTimeMS + * Time the server took to process the request, in milliseconds. + * @param processingTimingsMS + * Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate + * performance issues. + * @param queryAfterRemoval + * Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set. + * @param serverTimeMS + * Time the server took to process the request, in milliseconds. + * @param serverUsed + * Host name of the server that processed the request. + * @param userData + * An object with custom data. You can store up to 32kB as custom data. + * @param queryID + * Unique identifier for the query. This is used for [click + * analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/). + * @param automaticInsights + * Whether automatic events collection is enabled for the application. + */ +case class BaseSearchResponse( + abTestID: Option[Int] = scala.None, + abTestVariantID: Option[Int] = scala.None, + aroundLatLng: Option[String] = scala.None, + automaticRadius: Option[String] = scala.None, + exhaustive: Option[Exhaustive] = scala.None, + appliedRules: Option[Seq[Any]] = scala.None, + exhaustiveFacetsCount: Option[Boolean] = scala.None, + exhaustiveNbHits: Option[Boolean] = scala.None, + exhaustiveTypo: Option[Boolean] = scala.None, + facets: Option[Map[String, Map[String, Int]]] = scala.None, + facetsStats: Option[Map[String, FacetStats]] = scala.None, + index: Option[String] = scala.None, + indexUsed: Option[String] = scala.None, + message: Option[String] = scala.None, + nbSortedHits: Option[Int] = scala.None, + parsedQuery: Option[String] = scala.None, + processingTimeMS: Int, + processingTimingsMS: Option[Any] = scala.None, + queryAfterRemoval: Option[String] = scala.None, + redirect: Option[Redirect] = scala.None, + renderingContent: Option[RenderingContent] = scala.None, + serverTimeMS: Option[Int] = scala.None, + serverUsed: Option[String] = scala.None, + userData: Option[Any] = scala.None, + queryID: Option[String] = scala.None, + automaticInsights: Option[Boolean] = scala.None, + additionalProperties: Option[List[JField]] = None +) + +class BaseSearchResponseSerializer extends Serializer[BaseSearchResponse] { + + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), BaseSearchResponse] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[BaseSearchResponse] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[BaseSearchResponse] + val obj = Extraction.extract[BaseSearchResponse](jobject)(formats, mf) + + val fields = Set( + "abTestID", + "abTestVariantID", + "aroundLatLng", + "automaticRadius", + "exhaustive", + "appliedRules", + "exhaustiveFacetsCount", + "exhaustiveNbHits", + "exhaustiveTypo", + "facets", + "facetsStats", + "index", + "indexUsed", + "message", + "nbSortedHits", + "parsedQuery", + "processingTimeMS", + "processingTimingsMS", + "queryAfterRemoval", + "redirect", + "renderingContent", + "serverTimeMS", + "serverUsed", + "userData", + "queryID", + "automaticInsights" + ) + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as BaseSearchResponse") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: BaseSearchResponse => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/CompositionBaseSearchResponse.scala b/src/main/scala/algoliasearch/composition/CompositionBaseSearchResponse.scala new file mode 100644 index 00000000..0be9c6a4 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/CompositionBaseSearchResponse.scala @@ -0,0 +1,54 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** CompositionBaseSearchResponse + */ +case class CompositionBaseSearchResponse( + compositions: Option[CompositionsSearchResponse] = scala.None, + additionalProperties: Option[List[JField]] = None +) + +class CompositionBaseSearchResponseSerializer extends Serializer[CompositionBaseSearchResponse] { + + override def deserialize(implicit + format: Formats + ): PartialFunction[(TypeInfo, JValue), CompositionBaseSearchResponse] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[CompositionBaseSearchResponse] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[CompositionBaseSearchResponse] + val obj = Extraction.extract[CompositionBaseSearchResponse](jobject)(formats, mf) + + val fields = Set("compositions") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as CompositionBaseSearchResponse") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case value: CompositionBaseSearchResponse => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => + Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/CompositionIdRankingInfo.scala b/src/main/scala/algoliasearch/composition/CompositionIdRankingInfo.scala new file mode 100644 index 00000000..1ebb9f77 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/CompositionIdRankingInfo.scala @@ -0,0 +1,15 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** CompositionIdRankingInfo + */ +case class CompositionIdRankingInfo( + index: String, + injectedItemKey: String +) diff --git a/src/main/scala/algoliasearch/composition/CompositionRankingInfo.scala b/src/main/scala/algoliasearch/composition/CompositionRankingInfo.scala new file mode 100644 index 00000000..8b0b0755 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/CompositionRankingInfo.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** CompositionRankingInfo + */ +case class CompositionRankingInfo( + composed: Option[Map[String, CompositionIdRankingInfo]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/CompositionRunAppliedRules.scala b/src/main/scala/algoliasearch/composition/CompositionRunAppliedRules.scala new file mode 100644 index 00000000..c25825a4 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/CompositionRunAppliedRules.scala @@ -0,0 +1,17 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** CompositionRunAppliedRules + * + * @param objectID + * Unique record identifier. + */ +case class CompositionRunAppliedRules( + objectID: String +) diff --git a/src/main/scala/algoliasearch/composition/CompositionRunSearchResponse.scala b/src/main/scala/algoliasearch/composition/CompositionRunSearchResponse.scala new file mode 100644 index 00000000..2163274a --- /dev/null +++ b/src/main/scala/algoliasearch/composition/CompositionRunSearchResponse.scala @@ -0,0 +1,58 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** CompositionRunSearchResponse + * + * @param objectID + * Unique record identifier. + */ +case class CompositionRunSearchResponse( + objectID: String, + appliedRules: Option[Seq[CompositionRunAppliedRules]] = scala.None, + additionalProperties: Option[List[JField]] = None +) + +class CompositionRunSearchResponseSerializer extends Serializer[CompositionRunSearchResponse] { + + override def deserialize(implicit + format: Formats + ): PartialFunction[(TypeInfo, JValue), CompositionRunSearchResponse] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[CompositionRunSearchResponse] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[CompositionRunSearchResponse] + val obj = Extraction.extract[CompositionRunSearchResponse](jobject)(formats, mf) + + val fields = Set("objectID", "appliedRules") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as CompositionRunSearchResponse") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case value: CompositionRunSearchResponse => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => + Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/CompositionsSearchResponse.scala b/src/main/scala/algoliasearch/composition/CompositionsSearchResponse.scala new file mode 100644 index 00000000..a67123af --- /dev/null +++ b/src/main/scala/algoliasearch/composition/CompositionsSearchResponse.scala @@ -0,0 +1,54 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** CompositionsSearchResponse + */ +case class CompositionsSearchResponse( + run: Seq[CompositionRunSearchResponse], + additionalProperties: Option[List[JField]] = None +) + +class CompositionsSearchResponseSerializer extends Serializer[CompositionsSearchResponse] { + + override def deserialize(implicit + format: Formats + ): PartialFunction[(TypeInfo, JValue), CompositionsSearchResponse] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[CompositionsSearchResponse] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[CompositionsSearchResponse] + val obj = Extraction.extract[CompositionsSearchResponse](jobject)(formats, mf) + + val fields = Set("run") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as CompositionsSearchResponse") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case value: CompositionsSearchResponse => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => + Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/ErrorBase.scala b/src/main/scala/algoliasearch/composition/ErrorBase.scala new file mode 100644 index 00000000..0608e553 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/ErrorBase.scala @@ -0,0 +1,50 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** Error. + */ +case class ErrorBase( + message: Option[String] = scala.None, + additionalProperties: Option[List[JField]] = None +) + +class ErrorBaseSerializer extends Serializer[ErrorBase] { + + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), ErrorBase] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[ErrorBase] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[ErrorBase] + val obj = Extraction.extract[ErrorBase](jobject)(formats, mf) + + val fields = Set("message") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as ErrorBase") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: ErrorBase => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/Exhaustive.scala b/src/main/scala/algoliasearch/composition/Exhaustive.scala new file mode 100644 index 00000000..1318dc8d --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Exhaustive.scala @@ -0,0 +1,39 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Whether certain properties of the search response are calculated exhaustive (exact) or approximated. + * + * @param facetsCount + * Whether the facet count is exhaustive (`true`) or approximate (`false`). See the [related + * discussion](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-). + * @param facetValues + * The value is `false` if not all facet values are retrieved. + * @param nbHits + * Whether the `nbHits` is exhaustive (`true`) or approximate (`false`). When the query takes more than 50ms to be + * processed, the engine makes an approximation. This can happen when using complex filters on millions of records, + * when typo-tolerance was not exhaustive, or when enough hits have been retrieved (for example, after the engine + * finds 10,000 exact matches). `nbHits` is reported as non-exhaustive whenever an approximation is made, even if the + * approximation didn’t, in the end, impact the exhaustivity of the query. + * @param rulesMatch + * Rules matching exhaustivity. The value is `false` if rules were enable for this query, and could not be fully + * processed due a timeout. This is generally caused by the number of alternatives (such as typos) which is too + * large. + * @param typo + * Whether the typo search was exhaustive (`true`) or approximate (`false`). An approximation is done when the typo + * search query part takes more than 10% of the query budget (ie. 5ms by default) to be processed (this can happen + * when a lot of typo alternatives exist for the query). This field will not be included when typo-tolerance is + * entirely disabled. + */ +case class Exhaustive( + facetsCount: Option[Boolean] = scala.None, + facetValues: Option[Boolean] = scala.None, + nbHits: Option[Boolean] = scala.None, + rulesMatch: Option[Boolean] = scala.None, + typo: Option[Boolean] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/FacetFilters.scala b/src/main/scala/algoliasearch/composition/FacetFilters.scala new file mode 100644 index 00000000..f6d97847 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/FacetFilters.scala @@ -0,0 +1,52 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +/** Filter the search by facet values, so that only records with the same facet values are retrieved. **Prefer using the + * `filters` parameter, which supports all filter types and combinations with boolean operators.** - `[filter1, + * filter2]` is interpreted as `filter1 AND filter2`. - `[[filter1, filter2], filter3]` is interpreted as `filter1 OR + * filter2 AND filter3`. - `facet:-value` is interpreted as `NOT facet:value`. While it's best to avoid attributes that + * start with a `-`, you can still filter them by escaping with a backslash: `facet:\\-value`. + */ +sealed trait FacetFilters + +object FacetFilters { + + case class SeqOfFacetFilters(value: Seq[FacetFilters]) extends FacetFilters + case class StringValue(value: String) extends FacetFilters + + def apply(value: Seq[FacetFilters]): FacetFilters = { + FacetFilters.SeqOfFacetFilters(value) + } + def apply(value: String): FacetFilters = { + FacetFilters.StringValue(value) + } + +} + +object FacetFiltersSerializer extends Serializer[FacetFilters] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), FacetFilters] = { + + case (TypeInfo(clazz, _), json) if clazz == classOf[FacetFilters] => + json match { + case JArray(value) if value.forall(_.isInstanceOf[JArray]) => + FacetFilters.SeqOfFacetFilters(value.map(_.extract)) + case JString(value) => FacetFilters.StringValue(value) + case _ => throw new MappingException("Can't convert " + json + " to FacetFilters") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: FacetFilters => + value match { + case FacetFilters.SeqOfFacetFilters(value) => JArray(value.map(Extraction.decompose).toList) + case FacetFilters.StringValue(value) => JString(value) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/FacetHits.scala b/src/main/scala/algoliasearch/composition/FacetHits.scala new file mode 100644 index 00000000..e8673123 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/FacetHits.scala @@ -0,0 +1,24 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** FacetHits + * + * @param value + * Facet value. + * @param highlighted + * Highlighted attribute value, including HTML tags. + * @param count + * Number of records with this facet value. [The count may be + * approximated](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-). + */ +case class FacetHits( + value: String, + highlighted: String, + count: Int +) diff --git a/src/main/scala/algoliasearch/composition/FacetOrdering.scala b/src/main/scala/algoliasearch/composition/FacetOrdering.scala new file mode 100644 index 00000000..f8c18a84 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/FacetOrdering.scala @@ -0,0 +1,18 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Order of facet names and facet values in your UI. + * + * @param values + * Order of facet values. One object for each facet. + */ +case class FacetOrdering( + facets: Option[Facets] = scala.None, + values: Option[Map[String, Value]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/FacetStats.scala b/src/main/scala/algoliasearch/composition/FacetStats.scala new file mode 100644 index 00000000..0d348735 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/FacetStats.scala @@ -0,0 +1,26 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** FacetStats + * + * @param min + * Minimum value in the results. + * @param max + * Maximum value in the results. + * @param avg + * Average facet value in the results. + * @param sum + * Sum of all values in the results. + */ +case class FacetStats( + min: Option[Double] = scala.None, + max: Option[Double] = scala.None, + avg: Option[Double] = scala.None, + sum: Option[Double] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/Facets.scala b/src/main/scala/algoliasearch/composition/Facets.scala new file mode 100644 index 00000000..b18e191c --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Facets.scala @@ -0,0 +1,18 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Order of facet names. + * + * @param order + * Explicit order of facets or facet values. This setting lets you always show specific facets or facet values at the + * top of the list. + */ +case class Facets( + order: Option[Seq[String]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/HighlightResult.scala b/src/main/scala/algoliasearch/composition/HighlightResult.scala new file mode 100644 index 00000000..2bb8e3d0 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/HighlightResult.scala @@ -0,0 +1,54 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.MatchLevel._ + +import org.json4s._ + +/** HighlightResult + */ +sealed trait HighlightResult + +trait HighlightResultTrait extends HighlightResult + +object HighlightResult { + + case class MapOfStringHighlightResult(value: Map[String, HighlightResult]) extends HighlightResult + case class SeqOfHighlightResult(value: Seq[HighlightResult]) extends HighlightResult + + def apply(value: Map[String, HighlightResult]): HighlightResult = { + HighlightResult.MapOfStringHighlightResult(value) + } + def apply(value: Seq[HighlightResult]): HighlightResult = { + HighlightResult.SeqOfHighlightResult(value) + } + +} + +object HighlightResultSerializer extends Serializer[HighlightResult] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), 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 JArray(value) if value.forall(_.isInstanceOf[JArray]) => + HighlightResult.SeqOfHighlightResult(value.map(_.extract)) + case _ => throw new MappingException("Can't convert " + json + " to HighlightResult") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: HighlightResult => + value match { + case value: HighlightResultOption => Extraction.decompose(value)(format - this) + case HighlightResult.SeqOfHighlightResult(value) => JArray(value.map(Extraction.decompose).toList) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/HighlightResultOption.scala b/src/main/scala/algoliasearch/composition/HighlightResultOption.scala new file mode 100644 index 00000000..a5561463 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/HighlightResultOption.scala @@ -0,0 +1,26 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.MatchLevel._ + +/** Surround words that match the query with HTML tags for highlighting. + * + * @param value + * Highlighted attribute value, including HTML tags. + * @param matchedWords + * List of matched words from the search query. + * @param fullyHighlighted + * Whether the entire attribute value is highlighted. + */ +case class HighlightResultOption( + value: String, + matchLevel: MatchLevel, + matchedWords: Seq[String], + fullyHighlighted: Option[Boolean] = scala.None +) extends HighlightResultTrait diff --git a/src/main/scala/algoliasearch/composition/Hit.scala b/src/main/scala/algoliasearch/composition/Hit.scala new file mode 100644 index 00000000..e7cd47dc --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Hit.scala @@ -0,0 +1,62 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** Search result. A hit is a record from your index, augmented with special attributes for highlighting, snippeting, + * and ranking. + * + * @param objectID + * Unique record identifier. + * @param highlightResult + * Surround words that match the query with HTML tags for highlighting. + * @param snippetResult + * Snippets that show the context around a matching search query. + */ +case class Hit( + objectID: String, + highlightResult: Option[Map[String, HighlightResult]] = scala.None, + snippetResult: Option[Map[String, SnippetResult]] = scala.None, + rankingInfo: Option[HitRankingInfo] = scala.None, + distinctSeqID: Option[Int] = scala.None, + additionalProperties: Option[List[JField]] = None +) + +class HitSerializer extends Serializer[Hit] { + + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Hit] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[Hit] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[Hit] + val obj = Extraction.extract[Hit](jobject)(formats, mf) + + val fields = Set("objectID", "highlightResult", "snippetResult", "rankingInfo", "distinctSeqID") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as Hit") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: Hit => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/HitRankingInfo.scala b/src/main/scala/algoliasearch/composition/HitRankingInfo.scala new file mode 100644 index 00000000..561f09a3 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/HitRankingInfo.scala @@ -0,0 +1,51 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** HitRankingInfo + * + * @param filters + * Whether a filter matched the query. + * @param firstMatchedWord + * Position of the first matched word in the best matching attribute of the record. + * @param geoDistance + * Distance between the geo location in the search query and the best matching geo location in the record, divided by + * the geo precision (in meters). + * @param geoPrecision + * Precision used when computing the geo distance, in meters. + * @param nbExactWords + * Number of exactly matched words. + * @param nbTypos + * Number of typos encountered when matching the record. + * @param promoted + * Whether the record was promoted by a rule. + * @param proximityDistance + * Number of words between multiple matches in the query plus 1. For single word queries, `proximityDistance` is 0. + * @param userScore + * Overall ranking of the record, expressed as a single integer. This attribute is internal. + * @param words + * Number of matched words. + * @param promotedByReRanking + * Whether the record is re-ranked. + */ +case class HitRankingInfo( + filters: Option[Int] = scala.None, + firstMatchedWord: Int, + geoDistance: Int, + geoPrecision: Option[Int] = scala.None, + matchedGeoLocation: Option[MatchedGeoLocation] = scala.None, + personalization: Option[Personalization] = scala.None, + nbExactWords: Int, + nbTypos: Int, + promoted: Option[Boolean] = scala.None, + proximityDistance: Option[Int] = scala.None, + userScore: Int, + words: Option[Int] = scala.None, + promotedByReRanking: Option[Boolean] = scala.None, + composed: Option[Map[String, CompositionIdRankingInfo]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/InsideBoundingBox.scala b/src/main/scala/algoliasearch/composition/InsideBoundingBox.scala new file mode 100644 index 00000000..5f9108bb --- /dev/null +++ b/src/main/scala/algoliasearch/composition/InsideBoundingBox.scala @@ -0,0 +1,48 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +/** InsideBoundingBox + */ +sealed trait InsideBoundingBox + +object InsideBoundingBox { + + case class StringValue(value: String) extends InsideBoundingBox + case class SeqOfSeqOfDouble(value: Seq[Seq[Double]]) extends InsideBoundingBox + + def apply(value: String): InsideBoundingBox = { + InsideBoundingBox.StringValue(value) + } + def apply(value: Seq[Seq[Double]]): InsideBoundingBox = { + InsideBoundingBox.SeqOfSeqOfDouble(value) + } + +} + +object InsideBoundingBoxSerializer extends Serializer[InsideBoundingBox] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), InsideBoundingBox] = { + + case (TypeInfo(clazz, _), json) if clazz == classOf[InsideBoundingBox] => + json match { + case JString(value) => InsideBoundingBox.StringValue(value) + case JArray(value) if value.forall(_.isInstanceOf[JArray]) => + InsideBoundingBox.SeqOfSeqOfDouble(value.map(_.extract)) + case _ => throw new MappingException("Can't convert " + json + " to InsideBoundingBox") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: InsideBoundingBox => + value match { + case InsideBoundingBox.StringValue(value) => JString(value) + case InsideBoundingBox.SeqOfSeqOfDouble(value) => JArray(value.map(Extraction.decompose).toList) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/JsonSupport.scala b/src/main/scala/algoliasearch/composition/JsonSupport.scala new file mode 100644 index 00000000..1397555d --- /dev/null +++ b/src/main/scala/algoliasearch/composition/JsonSupport.scala @@ -0,0 +1,42 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +object JsonSupport { + private def enumSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+ + new AroundRadiusAllSerializer() :+ + new MatchLevelSerializer() :+ + new SortRemainingBySerializer() :+ + new SupportedLanguageSerializer() + + private def oneOfsSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+ + AroundPrecisionSerializer :+ + AroundRadiusSerializer :+ + FacetFiltersSerializer :+ + HighlightResultSerializer :+ + InsideBoundingBoxSerializer :+ + NumericFiltersSerializer :+ + OptionalFiltersSerializer :+ + SnippetResultSerializer + + private def classMapSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+ + new BaseSearchResponseSerializer() :+ + new CompositionBaseSearchResponseSerializer() :+ + new CompositionRunSearchResponseSerializer() :+ + new CompositionsSearchResponseSerializer() :+ + new ErrorBaseSerializer() :+ + new HitSerializer() :+ + new ResultsCompositionsResponseSerializer() :+ + new ResultsInjectedItemInfoResponseSerializer() :+ + new SearchHitsSerializer() + + implicit val format: Formats = DefaultFormats ++ enumSerializers ++ oneOfsSerializers ++ classMapSerializers + implicit val serialization: org.json4s.Serialization = org.json4s.native.Serialization +} diff --git a/src/main/scala/algoliasearch/composition/MatchLevel.scala b/src/main/scala/algoliasearch/composition/MatchLevel.scala new file mode 100644 index 00000000..0d30d603 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/MatchLevel.scala @@ -0,0 +1,44 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +sealed trait MatchLevel + +/** Whether the whole query string matches or only a part. + */ +object MatchLevel { + case object None extends MatchLevel { + override def toString = "none" + } + case object Partial extends MatchLevel { + override def toString = "partial" + } + case object Full extends MatchLevel { + override def toString = "full" + } + val values: Seq[MatchLevel] = Seq(None, Partial, Full) + + def withName(name: String): MatchLevel = MatchLevel.values + .find(_.toString == name) + .getOrElse(throw new MappingException(s"Unknown MatchLevel value: $name")) +} + +class MatchLevelSerializer + extends CustomSerializer[MatchLevel](_ => + ( + { + case JString(value) => MatchLevel.withName(value) + case JNull => null + }, + { case value: MatchLevel => + JString(value.toString) + } + ) + ) diff --git a/src/main/scala/algoliasearch/composition/MatchedGeoLocation.scala b/src/main/scala/algoliasearch/composition/MatchedGeoLocation.scala new file mode 100644 index 00000000..0a31924d --- /dev/null +++ b/src/main/scala/algoliasearch/composition/MatchedGeoLocation.scala @@ -0,0 +1,23 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** MatchedGeoLocation + * + * @param lat + * Latitude of the matched location. + * @param lng + * Longitude of the matched location. + * @param distance + * Distance between the matched location and the search location (in meters). + */ +case class MatchedGeoLocation( + lat: Option[Double] = scala.None, + lng: Option[Double] = scala.None, + distance: Option[Int] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/NumericFilters.scala b/src/main/scala/algoliasearch/composition/NumericFilters.scala new file mode 100644 index 00000000..53fa2752 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/NumericFilters.scala @@ -0,0 +1,51 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +/** Filter by numeric facets. **Prefer using the `filters` parameter, which supports all filter types and combinations + * with boolean operators.** You can use numeric comparison operators: `<`, `<=`, `=`, `!=`, `>`, `>=`. Comparisons are + * precise up to 3 decimals. You can also provide ranges: `facet: TO `. The range includes the lower and + * upper boundaries. The same combination rules apply as for `facetFilters`. + */ +sealed trait NumericFilters + +object NumericFilters { + + case class SeqOfNumericFilters(value: Seq[NumericFilters]) extends NumericFilters + case class StringValue(value: String) extends NumericFilters + + def apply(value: Seq[NumericFilters]): NumericFilters = { + NumericFilters.SeqOfNumericFilters(value) + } + def apply(value: String): NumericFilters = { + NumericFilters.StringValue(value) + } + +} + +object NumericFiltersSerializer extends Serializer[NumericFilters] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), NumericFilters] = { + + case (TypeInfo(clazz, _), json) if clazz == classOf[NumericFilters] => + json match { + case JArray(value) if value.forall(_.isInstanceOf[JArray]) => + NumericFilters.SeqOfNumericFilters(value.map(_.extract)) + case JString(value) => NumericFilters.StringValue(value) + case _ => throw new MappingException("Can't convert " + json + " to NumericFilters") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: NumericFilters => + value match { + case NumericFilters.SeqOfNumericFilters(value) => JArray(value.map(Extraction.decompose).toList) + case NumericFilters.StringValue(value) => JString(value) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/OptionalFilters.scala b/src/main/scala/algoliasearch/composition/OptionalFilters.scala new file mode 100644 index 00000000..3c009a4b --- /dev/null +++ b/src/main/scala/algoliasearch/composition/OptionalFilters.scala @@ -0,0 +1,54 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +/** Filters to promote or demote records in the search results. Optional filters work like facet filters, but they don't + * exclude records from the search results. Records that match the optional filter rank before records that don't + * match. If you're using a negative filter `facet:-value`, matching records rank after records that don't match. - + * Optional filters don't work on virtual replicas. - Optional filters are applied _after_ sort-by attributes. - + * Optional filters are applied _before_ custom ranking attributes (in the default + * [ranking](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/)). - + * Optional filters don't work with numeric attributes. + */ +sealed trait OptionalFilters + +object OptionalFilters { + + case class SeqOfOptionalFilters(value: Seq[OptionalFilters]) extends OptionalFilters + case class StringValue(value: String) extends OptionalFilters + + def apply(value: Seq[OptionalFilters]): OptionalFilters = { + OptionalFilters.SeqOfOptionalFilters(value) + } + def apply(value: String): OptionalFilters = { + OptionalFilters.StringValue(value) + } + +} + +object OptionalFiltersSerializer extends Serializer[OptionalFilters] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), OptionalFilters] = { + + case (TypeInfo(clazz, _), json) if clazz == classOf[OptionalFilters] => + json match { + case JArray(value) if value.forall(_.isInstanceOf[JArray]) => + OptionalFilters.SeqOfOptionalFilters(value.map(_.extract)) + case JString(value) => OptionalFilters.StringValue(value) + case _ => throw new MappingException("Can't convert " + json + " to OptionalFilters") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: OptionalFilters => + value match { + case OptionalFilters.SeqOfOptionalFilters(value) => JArray(value.map(Extraction.decompose).toList) + case OptionalFilters.StringValue(value) => JString(value) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/Params.scala b/src/main/scala/algoliasearch/composition/Params.scala new file mode 100644 index 00000000..8a832716 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Params.scala @@ -0,0 +1,118 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.SupportedLanguage._ + +/** Params + * + * @param query + * Search query. + * @param filters + * Filter expression to only include items that match the filter criteria in the response. You can use these filter + * expressions: - **Numeric filters.** ` `, where `` is one of `<`, `<=`, `=`, `!=`, `>`, + * `>=`. - **Ranges.** `: TO ` where `` and `` are the lower and upper limits of + * the range (inclusive). - **Facet filters.** `:` where `` is a facet attribute + * (case-sensitive) and `` a facet value. - **Tag filters.** `_tags:` or just `` + * (case-sensitive). - **Boolean filters.** `: true | false`. You can combine filters with `AND`, `OR`, and + * `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not + * supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** + * `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** + * `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or + * facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter + * matches if it matches at least one element of the array. For more information, see + * [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/). + * @param page + * Page of search results to retrieve. + * @param getRankingInfo + * Whether the search response should include detailed ranking information. + * @param hitsPerPage + * Number of hits per page. + * @param aroundLatLng + * Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only + * records included within a circle around this central location are included in the results. The radius of the + * circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you + * also specify `insidePolygon` or `insideBoundingBox`. + * @param aroundLatLngViaIP + * Whether to obtain the coordinates from the request's IP address. + * @param minimumAroundRadius + * Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. + * @param insidePolygon + * Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented + * by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering + * inside + * polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). + * This parameter is ignored if you also specify `insideBoundingBox`. + * @param queryLanguages + * Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection + * dictionaries. This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` + * settings. This setting also sets a dictionary for word detection in the logogram-based + * [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) + * languages. To support this, you must place the CJK language **first**. **You should always specify a query + * language.** If you don't specify an indexing language, the search engine uses all [supported + * languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), + * or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to + * unexpected search results. For more information, see [Language-specific + * configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/). + * @param naturalLanguages + * ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to + * keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets + * `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and + * `analyticsTags`. + * @param enableRules + * Whether to enable rules. + * @param ruleContexts + * Assigns a rule context to the search query. [Rule + * contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) + * are strings that you can use to trigger matching rules. + * @param userToken + * Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For + * more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/). + * @param clickAnalytics + * Whether to include a `queryID` attribute in the response. The query ID is a unique identifier for a search query + * and is required for tracking [click and conversion + * events](https://www.algolia.com/guides/sending-events/getting-started/). + * @param analytics + * Whether this search will be included in Analytics. + * @param analyticsTags + * Tags to apply to the query for [segmenting analytics + * data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/). + * @param enableABTest + * Whether to enable A/B testing for this search. + * @param enableReRanking + * Whether this search will use [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/). This + * setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard. + */ +case class Params( + query: Option[String] = scala.None, + filters: Option[String] = scala.None, + page: Option[Int] = scala.None, + getRankingInfo: Option[Boolean] = scala.None, + relevancyStrictness: Option[Int] = scala.None, + facetFilters: Option[FacetFilters] = scala.None, + optionalFilters: Option[OptionalFilters] = scala.None, + numericFilters: Option[NumericFilters] = scala.None, + hitsPerPage: Option[Int] = scala.None, + aroundLatLng: Option[String] = scala.None, + aroundLatLngViaIP: Option[Boolean] = scala.None, + aroundRadius: Option[AroundRadius] = scala.None, + aroundPrecision: Option[AroundPrecision] = scala.None, + minimumAroundRadius: Option[Int] = scala.None, + insideBoundingBox: Option[InsideBoundingBox] = scala.None, + insidePolygon: Option[Seq[Seq[Double]]] = scala.None, + queryLanguages: Option[Seq[SupportedLanguage]] = scala.None, + naturalLanguages: Option[Seq[SupportedLanguage]] = scala.None, + enableRules: Option[Boolean] = scala.None, + ruleContexts: Option[Seq[String]] = scala.None, + userToken: Option[String] = scala.None, + clickAnalytics: Option[Boolean] = scala.None, + analytics: Option[Boolean] = scala.None, + analyticsTags: Option[Seq[String]] = scala.None, + enableABTest: Option[Boolean] = scala.None, + enableReRanking: Option[Boolean] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/Personalization.scala b/src/main/scala/algoliasearch/composition/Personalization.scala new file mode 100644 index 00000000..88412702 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Personalization.scala @@ -0,0 +1,23 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Personalization + * + * @param filtersScore + * The score of the filters. + * @param rankingScore + * The score of the ranking. + * @param score + * The score of the event. + */ +case class Personalization( + filtersScore: Option[Int] = scala.None, + rankingScore: Option[Int] = scala.None, + score: Option[Int] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/Range.scala b/src/main/scala/algoliasearch/composition/Range.scala new file mode 100644 index 00000000..e4904602 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Range.scala @@ -0,0 +1,20 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Range object with lower and upper values in meters to define custom ranges. + * + * @param from + * Lower boundary of a range in meters. The Geo ranking criterion considers all records within the range to be equal. + * @param value + * Upper boundary of a range in meters. The Geo ranking criterion considers all records within the range to be equal. + */ +case class Range( + from: Option[Int] = scala.None, + value: Option[Int] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/RankingInfo.scala b/src/main/scala/algoliasearch/composition/RankingInfo.scala new file mode 100644 index 00000000..3b4e865a --- /dev/null +++ b/src/main/scala/algoliasearch/composition/RankingInfo.scala @@ -0,0 +1,50 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Object with detailed information about the record's ranking. + * + * @param filters + * Whether a filter matched the query. + * @param firstMatchedWord + * Position of the first matched word in the best matching attribute of the record. + * @param geoDistance + * Distance between the geo location in the search query and the best matching geo location in the record, divided by + * the geo precision (in meters). + * @param geoPrecision + * Precision used when computing the geo distance, in meters. + * @param nbExactWords + * Number of exactly matched words. + * @param nbTypos + * Number of typos encountered when matching the record. + * @param promoted + * Whether the record was promoted by a rule. + * @param proximityDistance + * Number of words between multiple matches in the query plus 1. For single word queries, `proximityDistance` is 0. + * @param userScore + * Overall ranking of the record, expressed as a single integer. This attribute is internal. + * @param words + * Number of matched words. + * @param promotedByReRanking + * Whether the record is re-ranked. + */ +case class RankingInfo( + filters: Option[Int] = scala.None, + firstMatchedWord: Int, + geoDistance: Int, + geoPrecision: Option[Int] = scala.None, + matchedGeoLocation: Option[MatchedGeoLocation] = scala.None, + personalization: Option[Personalization] = scala.None, + nbExactWords: Int, + nbTypos: Int, + promoted: Option[Boolean] = scala.None, + proximityDistance: Option[Int] = scala.None, + userScore: Int, + words: Option[Int] = scala.None, + promotedByReRanking: Option[Boolean] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/Redirect.scala b/src/main/scala/algoliasearch/composition/Redirect.scala new file mode 100644 index 00000000..93294d12 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Redirect.scala @@ -0,0 +1,16 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** [Redirect results to a + * URL](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/redirects/), this + * this parameter is for internal use only. + */ +case class Redirect( + index: Option[Seq[RedirectRuleIndexMetadata]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/RedirectRuleIndexData.scala b/src/main/scala/algoliasearch/composition/RedirectRuleIndexData.scala new file mode 100644 index 00000000..ef1127c0 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/RedirectRuleIndexData.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Redirect rule data. + */ +case class RedirectRuleIndexData( + ruleObjectID: String +) diff --git a/src/main/scala/algoliasearch/composition/RedirectRuleIndexMetadata.scala b/src/main/scala/algoliasearch/composition/RedirectRuleIndexMetadata.scala new file mode 100644 index 00000000..cea2c20e --- /dev/null +++ b/src/main/scala/algoliasearch/composition/RedirectRuleIndexMetadata.scala @@ -0,0 +1,27 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** RedirectRuleIndexMetadata + * + * @param source + * Source index for the redirect rule. + * @param dest + * Destination index for the redirect rule. + * @param reason + * Reason for the redirect rule. + * @param succeed + * Redirect rule status. + */ +case class RedirectRuleIndexMetadata( + source: String, + dest: String, + reason: String, + succeed: Boolean, + data: RedirectRuleIndexData +) diff --git a/src/main/scala/algoliasearch/composition/RedirectURL.scala b/src/main/scala/algoliasearch/composition/RedirectURL.scala new file mode 100644 index 00000000..1b29b217 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/RedirectURL.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** The redirect rule container. + */ +case class RedirectURL( + url: Option[String] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/RenderingContent.scala b/src/main/scala/algoliasearch/composition/RenderingContent.scala new file mode 100644 index 00000000..2363a284 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/RenderingContent.scala @@ -0,0 +1,17 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Extra data that can be used in the search UI. You can use this to control aspects of your search UI, such as the + * order of facet names and values without changing your frontend code. + */ +case class RenderingContent( + facetOrdering: Option[FacetOrdering] = scala.None, + redirect: Option[RedirectURL] = scala.None, + widgets: Option[Widgets] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/RequestBody.scala b/src/main/scala/algoliasearch/composition/RequestBody.scala new file mode 100644 index 00000000..f31ad3d3 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/RequestBody.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** RequestBody + */ +case class RequestBody( + params: Option[Params] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/ResultsCompositionInfoResponse.scala b/src/main/scala/algoliasearch/composition/ResultsCompositionInfoResponse.scala new file mode 100644 index 00000000..2ce702d1 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/ResultsCompositionInfoResponse.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** ResultsCompositionInfoResponse + */ +case class ResultsCompositionInfoResponse( + injectedItems: Seq[ResultsInjectedItemInfoResponse] +) diff --git a/src/main/scala/algoliasearch/composition/ResultsCompositionsResponse.scala b/src/main/scala/algoliasearch/composition/ResultsCompositionsResponse.scala new file mode 100644 index 00000000..7ef24022 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/ResultsCompositionsResponse.scala @@ -0,0 +1,54 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** ResultsCompositionsResponse + */ +case class ResultsCompositionsResponse( + compositions: Map[String, ResultsCompositionInfoResponse], + additionalProperties: Option[List[JField]] = None +) + +class ResultsCompositionsResponseSerializer extends Serializer[ResultsCompositionsResponse] { + + override def deserialize(implicit + format: Formats + ): PartialFunction[(TypeInfo, JValue), ResultsCompositionsResponse] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[ResultsCompositionsResponse] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[ResultsCompositionsResponse] + val obj = Extraction.extract[ResultsCompositionsResponse](jobject)(formats, mf) + + val fields = Set("compositions") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as ResultsCompositionsResponse") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case value: ResultsCompositionsResponse => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => + Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/ResultsInjectedItemAppliedRulesInfoResponse.scala b/src/main/scala/algoliasearch/composition/ResultsInjectedItemAppliedRulesInfoResponse.scala new file mode 100644 index 00000000..c1661376 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/ResultsInjectedItemAppliedRulesInfoResponse.scala @@ -0,0 +1,17 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** ResultsInjectedItemAppliedRulesInfoResponse + * + * @param objectID + * Unique record identifier. + */ +case class ResultsInjectedItemAppliedRulesInfoResponse( + objectID: String +) diff --git a/src/main/scala/algoliasearch/composition/ResultsInjectedItemInfoResponse.scala b/src/main/scala/algoliasearch/composition/ResultsInjectedItemInfoResponse.scala new file mode 100644 index 00000000..77ee7634 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/ResultsInjectedItemInfoResponse.scala @@ -0,0 +1,55 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** ResultsInjectedItemInfoResponse + */ +case class ResultsInjectedItemInfoResponse( + key: String, + appliedRules: Option[Seq[ResultsInjectedItemAppliedRulesInfoResponse]] = scala.None, + additionalProperties: Option[List[JField]] = None +) + +class ResultsInjectedItemInfoResponseSerializer extends Serializer[ResultsInjectedItemInfoResponse] { + + override def deserialize(implicit + format: Formats + ): PartialFunction[(TypeInfo, JValue), ResultsInjectedItemInfoResponse] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[ResultsInjectedItemInfoResponse] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[ResultsInjectedItemInfoResponse] + val obj = Extraction.extract[ResultsInjectedItemInfoResponse](jobject)(formats, mf) + + val fields = Set("key", "appliedRules") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as ResultsInjectedItemInfoResponse") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case value: ResultsInjectedItemInfoResponse => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => + Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/SearchForFacetValuesParams.scala b/src/main/scala/algoliasearch/composition/SearchForFacetValuesParams.scala new file mode 100644 index 00000000..f20fbd89 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchForFacetValuesParams.scala @@ -0,0 +1,22 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchForFacetValuesParams + * + * @param query + * Search query. + * @param maxFacetHits + * Maximum number of facet values to return when [searching for facet + * values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values). + */ +case class SearchForFacetValuesParams( + query: Option[String] = scala.None, + maxFacetHits: Option[Int] = scala.None, + searchQuery: Option[Params] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/SearchForFacetValuesRequest.scala b/src/main/scala/algoliasearch/composition/SearchForFacetValuesRequest.scala new file mode 100644 index 00000000..e19dc6a3 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchForFacetValuesRequest.scala @@ -0,0 +1,14 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchForFacetValuesRequest + */ +case class SearchForFacetValuesRequest( + params: Option[SearchForFacetValuesParams] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/SearchForFacetValuesResponse.scala b/src/main/scala/algoliasearch/composition/SearchForFacetValuesResponse.scala new file mode 100644 index 00000000..fc9018b1 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchForFacetValuesResponse.scala @@ -0,0 +1,17 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchForFacetValuesResponse + * + * @param results + * Search for facet values results. + */ +case class SearchForFacetValuesResponse( + results: Option[Seq[SearchForFacetValuesResults]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/SearchForFacetValuesResults.scala b/src/main/scala/algoliasearch/composition/SearchForFacetValuesResults.scala new file mode 100644 index 00000000..f4694349 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchForFacetValuesResults.scala @@ -0,0 +1,26 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchForFacetValuesResults + * + * @param facetHits + * Matching facet values. + * @param exhaustiveFacetsCount + * Whether the facet count is exhaustive (true) or approximate (false). For more information, see [Why are my facet + * and hit counts not + * accurate](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-). + * @param processingTimeMS + * Time the server took to process the request, in milliseconds. + */ +case class SearchForFacetValuesResults( + indexName: String, + facetHits: Seq[FacetHits], + exhaustiveFacetsCount: Boolean, + processingTimeMS: Option[Int] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/SearchHits.scala b/src/main/scala/algoliasearch/composition/SearchHits.scala new file mode 100644 index 00000000..e7855dec --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchHits.scala @@ -0,0 +1,60 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s.MonadicJValue.jvalueToMonadic +import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, TypeInfo} + +/** SearchHits + * + * @param hits + * Search results (hits). Hits are records from your index that match the search criteria, augmented with additional + * attributes, such as, for highlighting. + * @param query + * Search query. + * @param params + * URL-encoded string of all search parameters. + */ +case class SearchHits( + hits: Seq[Hit], + query: String, + params: String, + additionalProperties: Option[List[JField]] = None +) + +class SearchHitsSerializer extends Serializer[SearchHits] { + + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), SearchHits] = { + case (TypeInfo(clazz, _), json) if clazz == classOf[SearchHits] => + json match { + case jobject: JObject => + val formats = format - this + val mf = manifest[SearchHits] + val obj = Extraction.extract[SearchHits](jobject)(formats, mf) + + val fields = Set("hits", "query", "params") + val additionalProperties = jobject removeField { + case (name, _) if fields.contains(name) => true + case _ => false + } + additionalProperties.values match { + case JObject(fieldsList) => obj copy (additionalProperties = Some(fieldsList)) + case _ => obj + } + case _ => throw new IllegalArgumentException(s"Can't deserialize $json as SearchHits") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: SearchHits => + val formats = format - this // remove current serializer from formats to avoid stackoverflow + value.additionalProperties match { + case Some(fields) => Extraction.decompose(value.copy(additionalProperties = None))(formats) merge JObject(fields) + case None => Extraction.decompose(value)(formats) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/SearchPagination.scala b/src/main/scala/algoliasearch/composition/SearchPagination.scala new file mode 100644 index 00000000..0f9080e7 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchPagination.scala @@ -0,0 +1,26 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchPagination + * + * @param page + * Page of search results to retrieve. + * @param nbHits + * Number of results (hits). + * @param nbPages + * Number of pages of results. + * @param hitsPerPage + * Number of hits per page. + */ +case class SearchPagination( + page: Int, + nbHits: Int, + nbPages: Int, + hitsPerPage: Int +) diff --git a/src/main/scala/algoliasearch/composition/SearchResponse.scala b/src/main/scala/algoliasearch/composition/SearchResponse.scala new file mode 100644 index 00000000..4d4f8d4a --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchResponse.scala @@ -0,0 +1,18 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchResponse + * + * @param results + * Search results. + */ +case class SearchResponse( + compositions: Option[CompositionsSearchResponse] = scala.None, + results: Seq[SearchResultsItem] +) diff --git a/src/main/scala/algoliasearch/composition/SearchResults.scala b/src/main/scala/algoliasearch/composition/SearchResults.scala new file mode 100644 index 00000000..07256f7b --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchResults.scala @@ -0,0 +1,17 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchResults + * + * @param results + * Search results. + */ +case class SearchResults( + results: Seq[SearchResultsItem] +) diff --git a/src/main/scala/algoliasearch/composition/SearchResultsItem.scala b/src/main/scala/algoliasearch/composition/SearchResultsItem.scala new file mode 100644 index 00000000..f10f9d51 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SearchResultsItem.scala @@ -0,0 +1,112 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** SearchResultsItem + * + * @param abTestID + * A/B test ID. This is only included in the response for indices that are part of an A/B test. + * @param abTestVariantID + * Variant ID. This is only included in the response for indices that are part of an A/B test. + * @param aroundLatLng + * Computed geographical location. + * @param automaticRadius + * Distance from a central coordinate provided by `aroundLatLng`. + * @param appliedRules + * Rules applied to the query. + * @param exhaustiveFacetsCount + * See the `facetsCount` field of the `exhaustive` object in the response. + * @param exhaustiveNbHits + * See the `nbHits` field of the `exhaustive` object in the response. + * @param exhaustiveTypo + * See the `typo` field of the `exhaustive` object in the response. + * @param facets + * Facet counts. + * @param facetsStats + * Statistics for numerical facets. + * @param index + * Index name used for the query. + * @param indexUsed + * Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query. + * @param message + * Warnings about the query. + * @param nbSortedHits + * Number of hits selected and sorted by the relevant sort algorithm. + * @param parsedQuery + * Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) + * query string that will be searched. + * @param processingTimeMS + * Time the server took to process the request, in milliseconds. + * @param processingTimingsMS + * Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate + * performance issues. + * @param queryAfterRemoval + * Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set. + * @param serverTimeMS + * Time the server took to process the request, in milliseconds. + * @param serverUsed + * Host name of the server that processed the request. + * @param userData + * An object with custom data. You can store up to 32kB as custom data. + * @param queryID + * Unique identifier for the query. This is used for [click + * analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/). + * @param automaticInsights + * Whether automatic events collection is enabled for the application. + * @param page + * Page of search results to retrieve. + * @param nbHits + * Number of results (hits). + * @param nbPages + * Number of pages of results. + * @param hitsPerPage + * Number of hits per page. + * @param hits + * Search results (hits). Hits are records from your index that match the search criteria, augmented with additional + * attributes, such as, for highlighting. + * @param query + * Search query. + * @param params + * URL-encoded string of all search parameters. + */ +case class SearchResultsItem( + abTestID: Option[Int] = scala.None, + abTestVariantID: Option[Int] = scala.None, + aroundLatLng: Option[String] = scala.None, + automaticRadius: Option[String] = scala.None, + exhaustive: Option[Exhaustive] = scala.None, + appliedRules: Option[Seq[Any]] = scala.None, + exhaustiveFacetsCount: Option[Boolean] = scala.None, + exhaustiveNbHits: Option[Boolean] = scala.None, + exhaustiveTypo: Option[Boolean] = scala.None, + facets: Option[Map[String, Map[String, Int]]] = scala.None, + facetsStats: Option[Map[String, FacetStats]] = scala.None, + index: Option[String] = scala.None, + indexUsed: Option[String] = scala.None, + message: Option[String] = scala.None, + nbSortedHits: Option[Int] = scala.None, + parsedQuery: Option[String] = scala.None, + processingTimeMS: Int, + processingTimingsMS: Option[Any] = scala.None, + queryAfterRemoval: Option[String] = scala.None, + redirect: Option[Redirect] = scala.None, + renderingContent: Option[RenderingContent] = scala.None, + serverTimeMS: Option[Int] = scala.None, + serverUsed: Option[String] = scala.None, + userData: Option[Any] = scala.None, + queryID: Option[String] = scala.None, + automaticInsights: Option[Boolean] = scala.None, + page: Int, + nbHits: Int, + nbPages: Int, + hitsPerPage: Int, + hits: Seq[Hit], + query: String, + params: String, + compositions: Map[String, ResultsCompositionInfoResponse] +) diff --git a/src/main/scala/algoliasearch/composition/SnippetResult.scala b/src/main/scala/algoliasearch/composition/SnippetResult.scala new file mode 100644 index 00000000..77133310 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SnippetResult.scala @@ -0,0 +1,53 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.MatchLevel._ + +import org.json4s._ + +/** SnippetResult + */ +sealed trait SnippetResult + +trait SnippetResultTrait extends SnippetResult + +object SnippetResult { + + case class MapOfStringSnippetResult(value: Map[String, SnippetResult]) extends SnippetResult + case class SeqOfSnippetResult(value: Seq[SnippetResult]) extends SnippetResult + + def apply(value: Map[String, SnippetResult]): SnippetResult = { + SnippetResult.MapOfStringSnippetResult(value) + } + def apply(value: Seq[SnippetResult]): SnippetResult = { + SnippetResult.SeqOfSnippetResult(value) + } + +} + +object SnippetResultSerializer extends Serializer[SnippetResult] { + override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), 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 JArray(value) if value.forall(_.isInstanceOf[JArray]) => + SnippetResult.SeqOfSnippetResult(value.map(_.extract)) + case _ => throw new MappingException("Can't convert " + json + " to SnippetResult") + } + } + + override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: SnippetResult => + value match { + case value: SnippetResultOption => Extraction.decompose(value)(format - this) + case SnippetResult.SeqOfSnippetResult(value) => JArray(value.map(Extraction.decompose).toList) + } + } +} diff --git a/src/main/scala/algoliasearch/composition/SnippetResultOption.scala b/src/main/scala/algoliasearch/composition/SnippetResultOption.scala new file mode 100644 index 00000000..7dac06b7 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SnippetResultOption.scala @@ -0,0 +1,20 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.MatchLevel._ + +/** Snippets that show the context around a matching search query. + * + * @param value + * Highlighted attribute value, including HTML tags. + */ +case class SnippetResultOption( + value: String, + matchLevel: MatchLevel +) extends SnippetResultTrait diff --git a/src/main/scala/algoliasearch/composition/SortRemainingBy.scala b/src/main/scala/algoliasearch/composition/SortRemainingBy.scala new file mode 100644 index 00000000..ae6f7e20 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SortRemainingBy.scala @@ -0,0 +1,46 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +sealed trait SortRemainingBy + +/** Order of facet values that aren't explicitly positioned with the `order` setting. - `count`. Order remaining facet + * values by decreasing count. The count is the number of matching records containing this facet value. - `alpha`. Sort + * facet values alphabetically. - `hidden`. Don't show facet values that aren't explicitly positioned. + */ +object SortRemainingBy { + case object Count extends SortRemainingBy { + override def toString = "count" + } + case object Alpha extends SortRemainingBy { + override def toString = "alpha" + } + case object Hidden extends SortRemainingBy { + override def toString = "hidden" + } + val values: Seq[SortRemainingBy] = Seq(Count, Alpha, Hidden) + + def withName(name: String): SortRemainingBy = SortRemainingBy.values + .find(_.toString == name) + .getOrElse(throw new MappingException(s"Unknown SortRemainingBy value: $name")) +} + +class SortRemainingBySerializer + extends CustomSerializer[SortRemainingBy](_ => + ( + { + case JString(value) => SortRemainingBy.withName(value) + case JNull => null + }, + { case value: SortRemainingBy => + JString(value.toString) + } + ) + ) diff --git a/src/main/scala/algoliasearch/composition/SupportedLanguage.scala b/src/main/scala/algoliasearch/composition/SupportedLanguage.scala new file mode 100644 index 00000000..d0f3b745 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/SupportedLanguage.scala @@ -0,0 +1,308 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import org.json4s._ + +sealed trait SupportedLanguage + +/** ISO code for a supported language. + */ +object SupportedLanguage { + case object Af extends SupportedLanguage { + override def toString = "af" + } + case object Ar extends SupportedLanguage { + override def toString = "ar" + } + case object Az extends SupportedLanguage { + override def toString = "az" + } + case object Bg extends SupportedLanguage { + override def toString = "bg" + } + case object Bn extends SupportedLanguage { + override def toString = "bn" + } + case object Ca extends SupportedLanguage { + override def toString = "ca" + } + case object Cs extends SupportedLanguage { + override def toString = "cs" + } + case object Cy extends SupportedLanguage { + override def toString = "cy" + } + case object Da extends SupportedLanguage { + override def toString = "da" + } + case object De extends SupportedLanguage { + override def toString = "de" + } + case object El extends SupportedLanguage { + override def toString = "el" + } + case object En extends SupportedLanguage { + override def toString = "en" + } + case object Eo extends SupportedLanguage { + override def toString = "eo" + } + case object Es extends SupportedLanguage { + override def toString = "es" + } + case object Et extends SupportedLanguage { + override def toString = "et" + } + case object Eu extends SupportedLanguage { + override def toString = "eu" + } + case object Fa extends SupportedLanguage { + override def toString = "fa" + } + case object Fi extends SupportedLanguage { + override def toString = "fi" + } + case object Fo extends SupportedLanguage { + override def toString = "fo" + } + case object Fr extends SupportedLanguage { + override def toString = "fr" + } + case object Ga extends SupportedLanguage { + override def toString = "ga" + } + case object Gl extends SupportedLanguage { + override def toString = "gl" + } + case object He extends SupportedLanguage { + override def toString = "he" + } + case object Hi extends SupportedLanguage { + override def toString = "hi" + } + case object Hu extends SupportedLanguage { + override def toString = "hu" + } + case object Hy extends SupportedLanguage { + override def toString = "hy" + } + case object Id extends SupportedLanguage { + override def toString = "id" + } + case object Is extends SupportedLanguage { + override def toString = "is" + } + case object It extends SupportedLanguage { + override def toString = "it" + } + case object Ja extends SupportedLanguage { + override def toString = "ja" + } + case object Ka extends SupportedLanguage { + override def toString = "ka" + } + case object Kk extends SupportedLanguage { + override def toString = "kk" + } + case object Ko extends SupportedLanguage { + override def toString = "ko" + } + case object Ku extends SupportedLanguage { + override def toString = "ku" + } + case object Ky extends SupportedLanguage { + override def toString = "ky" + } + case object Lt extends SupportedLanguage { + override def toString = "lt" + } + case object Lv extends SupportedLanguage { + override def toString = "lv" + } + case object Mi extends SupportedLanguage { + override def toString = "mi" + } + case object Mn extends SupportedLanguage { + override def toString = "mn" + } + case object Mr extends SupportedLanguage { + override def toString = "mr" + } + case object Ms extends SupportedLanguage { + override def toString = "ms" + } + case object Mt extends SupportedLanguage { + override def toString = "mt" + } + case object Nb extends SupportedLanguage { + override def toString = "nb" + } + case object Nl extends SupportedLanguage { + override def toString = "nl" + } + case object No extends SupportedLanguage { + override def toString = "no" + } + case object Ns extends SupportedLanguage { + override def toString = "ns" + } + case object Pl extends SupportedLanguage { + override def toString = "pl" + } + case object Ps extends SupportedLanguage { + override def toString = "ps" + } + case object Pt extends SupportedLanguage { + override def toString = "pt" + } + case object PtBr extends SupportedLanguage { + override def toString = "pt-br" + } + case object Qu extends SupportedLanguage { + override def toString = "qu" + } + case object Ro extends SupportedLanguage { + override def toString = "ro" + } + case object Ru extends SupportedLanguage { + override def toString = "ru" + } + case object Sk extends SupportedLanguage { + override def toString = "sk" + } + case object Sq extends SupportedLanguage { + override def toString = "sq" + } + case object Sv extends SupportedLanguage { + override def toString = "sv" + } + case object Sw extends SupportedLanguage { + override def toString = "sw" + } + case object Ta extends SupportedLanguage { + override def toString = "ta" + } + case object Te extends SupportedLanguage { + override def toString = "te" + } + case object Th extends SupportedLanguage { + override def toString = "th" + } + case object Tl extends SupportedLanguage { + override def toString = "tl" + } + case object Tn extends SupportedLanguage { + override def toString = "tn" + } + case object Tr extends SupportedLanguage { + override def toString = "tr" + } + case object Tt extends SupportedLanguage { + override def toString = "tt" + } + case object Uk extends SupportedLanguage { + override def toString = "uk" + } + case object Ur extends SupportedLanguage { + override def toString = "ur" + } + case object Uz extends SupportedLanguage { + override def toString = "uz" + } + case object Zh extends SupportedLanguage { + override def toString = "zh" + } + val values: Seq[SupportedLanguage] = Seq( + Af, + Ar, + Az, + Bg, + Bn, + Ca, + Cs, + Cy, + Da, + De, + El, + En, + Eo, + Es, + Et, + Eu, + Fa, + Fi, + Fo, + Fr, + Ga, + Gl, + He, + Hi, + Hu, + Hy, + Id, + Is, + It, + Ja, + Ka, + Kk, + Ko, + Ku, + Ky, + Lt, + Lv, + Mi, + Mn, + Mr, + Ms, + Mt, + Nb, + Nl, + No, + Ns, + Pl, + Ps, + Pt, + PtBr, + Qu, + Ro, + Ru, + Sk, + Sq, + Sv, + Sw, + Ta, + Te, + Th, + Tl, + Tn, + Tr, + Tt, + Uk, + Ur, + Uz, + Zh + ) + + def withName(name: String): SupportedLanguage = SupportedLanguage.values + .find(_.toString == name) + .getOrElse(throw new MappingException(s"Unknown SupportedLanguage value: $name")) +} + +class SupportedLanguageSerializer + extends CustomSerializer[SupportedLanguage](_ => + ( + { + case JString(value) => SupportedLanguage.withName(value) + case JNull => null + }, + { case value: SupportedLanguage => + JString(value.toString) + } + ) + ) diff --git a/src/main/scala/algoliasearch/composition/Value.scala b/src/main/scala/algoliasearch/composition/Value.scala new file mode 100644 index 00000000..e9e2cc46 --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Value.scala @@ -0,0 +1,24 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +import algoliasearch.composition.SortRemainingBy._ + +/** Value + * + * @param order + * Explicit order of facets or facet values. This setting lets you always show specific facets or facet values at the + * top of the list. + * @param hide + * Hide facet values. + */ +case class Value( + order: Option[Seq[String]] = scala.None, + sortRemainingBy: Option[SortRemainingBy] = scala.None, + hide: Option[Seq[String]] = scala.None +) diff --git a/src/main/scala/algoliasearch/composition/Widgets.scala b/src/main/scala/algoliasearch/composition/Widgets.scala new file mode 100644 index 00000000..36d1529a --- /dev/null +++ b/src/main/scala/algoliasearch/composition/Widgets.scala @@ -0,0 +1,17 @@ +/** Composition API Composition API. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech Do not edit the class manually. + */ +package algoliasearch.composition + +/** Widgets returned from any rules that are applied to the current search. + * + * @param banners + * Banners defined in the Merchandising Studio for a given search. + */ +case class Widgets( + banners: Option[Seq[Banner]] = scala.None +)