diff --git a/algolia/composition/api_composition.go b/algolia/composition/api_composition.go new file mode 100644 index 000000000..ff6d13a85 --- /dev/null +++ b/algolia/composition/api_composition.go @@ -0,0 +1,366 @@ +// 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 composition + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + "time" + + "github.com/algolia/algoliasearch-client-go/v4/algolia/transport" + "github.com/algolia/algoliasearch-client-go/v4/algolia/utils" +) + +type config struct { + // -- Request options for API calls + context context.Context + queryParams url.Values + headerParams map[string]string + timeouts transport.RequestConfiguration +} + +type RequestOption interface { + apply(*config) +} + +type requestOption func(*config) + +func (r requestOption) apply(c *config) { + r(c) +} + +func WithContext(ctx context.Context) requestOption { + return requestOption(func(c *config) { + c.context = ctx + }) +} + +func WithHeaderParam(key string, value any) requestOption { + return requestOption(func(c *config) { + c.headerParams[key] = utils.ParameterToString(value) + }) +} + +func WithQueryParam(key string, value any) requestOption { + return requestOption(func(c *config) { + c.queryParams.Set(utils.QueryParameterToString(key), utils.QueryParameterToString(value)) + }) +} + +func WithReadTimeout(timeout time.Duration) requestOption { + return requestOption(func(c *config) { + c.timeouts.ReadTimeout = &timeout + }) +} + +func WithWriteTimeout(timeout time.Duration) requestOption { + return requestOption(func(c *config) { + c.timeouts.WriteTimeout = &timeout + }) +} + +func WithConnectTimeout(timeout time.Duration) requestOption { + return requestOption(func(c *config) { + c.timeouts.ConnectTimeout = &timeout + }) +} + +func (r *ApiSearchRequest) UnmarshalJSON(b []byte) error { + req := map[string]json.RawMessage{} + err := json.Unmarshal(b, &req) + if err != nil { + return fmt.Errorf("cannot unmarshal request: %w", err) + } + if v, ok := req["compositionID"]; ok { + err = json.Unmarshal(v, &r.compositionID) + if err != nil { + err = json.Unmarshal(b, &r.compositionID) + if err != nil { + return fmt.Errorf("cannot unmarshal compositionID: %w", err) + } + } + } + if v, ok := req["requestBody"]; ok { + err = json.Unmarshal(v, &r.requestBody) + if err != nil { + err = json.Unmarshal(b, &r.requestBody) + if err != nil { + return fmt.Errorf("cannot unmarshal requestBody: %w", err) + } + } + } else { + err = json.Unmarshal(b, &r.requestBody) + if err != nil { + return fmt.Errorf("cannot unmarshal body parameter requestBody: %w", err) + } + } + + return nil +} + +// ApiSearchRequest represents the request with all the parameters for the API call. +type ApiSearchRequest struct { + compositionID string + requestBody *RequestBody +} + +// NewApiSearchRequest creates an instance of the ApiSearchRequest to be used for the API call. +func (c *APIClient) NewApiSearchRequest(compositionID string, requestBody *RequestBody) ApiSearchRequest { + return ApiSearchRequest{ + compositionID: compositionID, + requestBody: requestBody, + } +} + +/* +Search calls the API and returns the raw response from it. + + Runs a query on a single composition and returns matching results. + + Required API Key ACLs: + - search + + Request can be constructed by NewApiSearchRequest with parameters below. + @param compositionID string - Unique Composition ObjectID. + @param requestBody RequestBody + @param opts ...RequestOption - Optional parameters for the API call + @return *http.Response - The raw response from the API + @return []byte - The raw response body from the API + @return error - An error if the API call fails +*/ +func (c *APIClient) SearchWithHTTPInfo(r ApiSearchRequest, opts ...RequestOption) (*http.Response, []byte, error) { + requestPath := "/1/compositions/{compositionID}/run" + requestPath = strings.ReplaceAll(requestPath, "{compositionID}", url.PathEscape(utils.ParameterToString(r.compositionID))) + + if r.compositionID == "" { + return nil, nil, reportError("Parameter `compositionID` is required when calling `Search`.") + } + + if r.requestBody == nil { + return nil, nil, reportError("Parameter `requestBody` is required when calling `Search`.") + } + + conf := config{ + context: context.Background(), + queryParams: url.Values{}, + headerParams: map[string]string{}, + } + + // optional params if any + for _, opt := range opts { + opt.apply(&conf) + } + + var postBody any + + // body params + postBody = r.requestBody + req, err := c.prepareRequest(conf.context, requestPath, http.MethodPost, postBody, conf.headerParams, conf.queryParams) + if err != nil { + return nil, nil, err + } + + return c.callAPI(req, true, conf.timeouts) +} + +/* +Search casts the HTTP response body to a defined struct. + +Runs a query on a single composition and returns matching results. + +Required API Key ACLs: + - search + +Request can be constructed by NewApiSearchRequest with parameters below. + + @param compositionID string - Unique Composition ObjectID. + @param requestBody RequestBody + @return SearchResponse +*/ +func (c *APIClient) Search(r ApiSearchRequest, opts ...RequestOption) (*SearchResponse, error) { + var returnValue *SearchResponse + + res, resBody, err := c.SearchWithHTTPInfo(r, opts...) + if err != nil { + return returnValue, err + } + if res == nil { + return returnValue, reportError("res is nil") + } + + if res.StatusCode >= 300 { + return returnValue, c.decodeError(res, resBody) + } + + err = c.decode(&returnValue, resBody) + if err != nil { + return returnValue, reportError("cannot decode result: %w", err) + } + + return returnValue, nil +} + +func (r *ApiSearchForFacetValuesRequest) UnmarshalJSON(b []byte) error { + req := map[string]json.RawMessage{} + err := json.Unmarshal(b, &req) + if err != nil { + return fmt.Errorf("cannot unmarshal request: %w", err) + } + if v, ok := req["compositionID"]; ok { + err = json.Unmarshal(v, &r.compositionID) + if err != nil { + err = json.Unmarshal(b, &r.compositionID) + if err != nil { + return fmt.Errorf("cannot unmarshal compositionID: %w", err) + } + } + } + if v, ok := req["facetName"]; ok { + err = json.Unmarshal(v, &r.facetName) + if err != nil { + err = json.Unmarshal(b, &r.facetName) + if err != nil { + return fmt.Errorf("cannot unmarshal facetName: %w", err) + } + } + } + if v, ok := req["searchForFacetValuesRequest"]; ok { + err = json.Unmarshal(v, &r.searchForFacetValuesRequest) + if err != nil { + err = json.Unmarshal(b, &r.searchForFacetValuesRequest) + if err != nil { + return fmt.Errorf("cannot unmarshal searchForFacetValuesRequest: %w", err) + } + } + } + + return nil +} + +// ApiSearchForFacetValuesRequest represents the request with all the parameters for the API call. +type ApiSearchForFacetValuesRequest struct { + compositionID string + facetName string + searchForFacetValuesRequest *SearchForFacetValuesRequest +} + +// NewApiSearchForFacetValuesRequest creates an instance of the ApiSearchForFacetValuesRequest to be used for the API call. +func (c *APIClient) NewApiSearchForFacetValuesRequest(compositionID string, facetName string) ApiSearchForFacetValuesRequest { + return ApiSearchForFacetValuesRequest{ + compositionID: compositionID, + facetName: facetName, + } +} + +// WithSearchForFacetValuesRequest adds the searchForFacetValuesRequest to the ApiSearchForFacetValuesRequest and returns the request for chaining. +func (r ApiSearchForFacetValuesRequest) WithSearchForFacetValuesRequest(searchForFacetValuesRequest *SearchForFacetValuesRequest) ApiSearchForFacetValuesRequest { + r.searchForFacetValuesRequest = searchForFacetValuesRequest + return r +} + +/* +SearchForFacetValues calls the API and returns the raw response from it. + + 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 + + Request can be constructed by NewApiSearchForFacetValuesRequest with parameters below. + @param compositionID string - Unique Composition ObjectID. + @param facetName string - Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier. + @param searchForFacetValuesRequest SearchForFacetValuesRequest + @param opts ...RequestOption - Optional parameters for the API call + @return *http.Response - The raw response from the API + @return []byte - The raw response body from the API + @return error - An error if the API call fails +*/ +func (c *APIClient) SearchForFacetValuesWithHTTPInfo(r ApiSearchForFacetValuesRequest, opts ...RequestOption) (*http.Response, []byte, error) { + requestPath := "/1/compositions/{compositionID}/facets/{facetName}/query" + requestPath = strings.ReplaceAll(requestPath, "{compositionID}", url.PathEscape(utils.ParameterToString(r.compositionID))) + requestPath = strings.ReplaceAll(requestPath, "{facetName}", url.PathEscape(utils.ParameterToString(r.facetName))) + + if r.compositionID == "" { + return nil, nil, reportError("Parameter `compositionID` is required when calling `SearchForFacetValues`.") + } + if r.facetName == "" { + return nil, nil, reportError("Parameter `facetName` is required when calling `SearchForFacetValues`.") + } + + conf := config{ + context: context.Background(), + queryParams: url.Values{}, + headerParams: map[string]string{}, + } + + // optional params if any + for _, opt := range opts { + opt.apply(&conf) + } + + var postBody any + + // body params + if utils.IsNilOrEmpty(r.searchForFacetValuesRequest) { + postBody = "{}" + } else { + postBody = r.searchForFacetValuesRequest + } + req, err := c.prepareRequest(conf.context, requestPath, http.MethodPost, postBody, conf.headerParams, conf.queryParams) + if err != nil { + return nil, nil, err + } + + return c.callAPI(req, true, conf.timeouts) +} + +/* +SearchForFacetValues casts the HTTP response body to a defined struct. + +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 + +Request can be constructed by NewApiSearchForFacetValuesRequest with parameters below. + + @param compositionID string - Unique Composition ObjectID. + @param facetName string - Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier. + @param searchForFacetValuesRequest SearchForFacetValuesRequest + @return SearchForFacetValuesResponse +*/ +func (c *APIClient) SearchForFacetValues(r ApiSearchForFacetValuesRequest, opts ...RequestOption) (*SearchForFacetValuesResponse, error) { + var returnValue *SearchForFacetValuesResponse + + res, resBody, err := c.SearchForFacetValuesWithHTTPInfo(r, opts...) + if err != nil { + return returnValue, err + } + if res == nil { + return returnValue, reportError("res is nil") + } + + if res.StatusCode >= 300 { + return returnValue, c.decodeError(res, resBody) + } + + err = c.decode(&returnValue, resBody) + if err != nil { + return returnValue, reportError("cannot decode result: %w", err) + } + + return returnValue, nil +} diff --git a/algolia/composition/client.go b/algolia/composition/client.go new file mode 100644 index 000000000..6ab08f009 --- /dev/null +++ b/algolia/composition/client.go @@ -0,0 +1,364 @@ +// 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 composition + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "runtime" + "strings" + "time" + + "github.com/go-playground/validator/v10" + + "github.com/algolia/algoliasearch-client-go/v4/algolia/call" + "github.com/algolia/algoliasearch-client-go/v4/algolia/compression" + "github.com/algolia/algoliasearch-client-go/v4/algolia/transport" +) + +// APIClient manages communication with the Composition API API v1.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + appID string + cfg *CompositionConfiguration + transport *transport.Transport +} + +// NewClient creates a new API client with appID and apiKey. +func NewClient(appID, apiKey string) (*APIClient, error) { + return NewClientWithConfig(CompositionConfiguration{ + Configuration: transport.Configuration{ + AppID: appID, + ApiKey: apiKey, + DefaultHeader: make(map[string]string), + UserAgent: getUserAgent(), + Requester: transport.NewDefaultRequester(nil), + }, + }) +} + +// NewClientWithConfig creates a new API client with the given configuration to fully customize the client behaviour. +func NewClientWithConfig(cfg CompositionConfiguration) (*APIClient, error) { + if cfg.AppID == "" { + return nil, errors.New("`appId` is missing.") + } + if cfg.ApiKey == "" { + return nil, errors.New("`apiKey` is missing.") + } + if len(cfg.Hosts) == 0 { + cfg.Hosts = getDefaultHosts(cfg.AppID) + } + if cfg.UserAgent == "" { + cfg.UserAgent = getUserAgent() + } + if cfg.ReadTimeout == 0 { + cfg.ReadTimeout = 5000 * time.Millisecond + } + if cfg.ConnectTimeout == 0 { + cfg.ConnectTimeout = 2000 * time.Millisecond + } + if cfg.WriteTimeout == 0 { + cfg.WriteTimeout = 30000 * time.Millisecond + } + + return &APIClient{ + appID: cfg.AppID, + cfg: &cfg, + transport: transport.New( + cfg.Configuration, + ), + }, nil +} + +func getDefaultHosts(appID string) []transport.StatefulHost { + hosts := []transport.StatefulHost{ + transport.NewStatefulHost("https", appID+"-dsn.algolia.net", call.IsRead), + transport.NewStatefulHost("https", appID+".algolia.net", call.IsWrite), + } + hosts = append(hosts, transport.Shuffle( + []transport.StatefulHost{ + transport.NewStatefulHost("https", fmt.Sprintf("%s-1.algolianet.com", appID), call.IsReadWrite), + transport.NewStatefulHost("https", fmt.Sprintf("%s-2.algolianet.com", appID), call.IsReadWrite), + transport.NewStatefulHost("https", fmt.Sprintf("%s-3.algolianet.com", appID), call.IsReadWrite), + }, + )...) + return hosts +} + +func getUserAgent() string { + return fmt.Sprintf("Algolia for Go (4.11.0); Go (%s); Composition (4.11.0)", runtime.Version()) +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request. +func (c *APIClient) AddDefaultHeader(key string, value string) { + c.cfg.DefaultHeader[key] = value +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request, useReadTransporter bool, requestConfiguration transport.RequestConfiguration) (*http.Response, []byte, error) { + callKind := call.Write + if useReadTransporter || request.Method == http.MethodGet { + callKind = call.Read + } + + resp, body, err := c.transport.Request(request.Context(), request, callKind, requestConfiguration) + if err != nil { + return nil, nil, fmt.Errorf("failed to do request: %w", err) + } + + return resp, body, nil +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior. +func (c *APIClient) GetConfiguration() *CompositionConfiguration { + return c.cfg +} + +// Allow update of stored API key used to authenticate requests. +func (c *APIClient) SetClientApiKey(apiKey string) error { + if c.cfg == nil { + return errors.New("client config is not set") + } + + c.cfg.ApiKey = apiKey + + return nil +} + +// prepareRequest build the request. +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody any, + headerParams map[string]string, + queryParams url.Values, +) (req *http.Request, err error) { + body, err := setBody(postBody, c.cfg.Compression) + if err != nil { + return nil, fmt.Errorf("failed to set the body: %w", err) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, fmt.Errorf("failed to parse the path: %w", err) + } + + var queryString []string + for k, v := range queryParams { + for _, value := range v { + queryString = append(queryString, k+"="+value) + } + } + + url.RawQuery = strings.Join(queryString, "&") + + // Generate a new request + + // weird nil typing + var bodyReader io.Reader + if body != nil { + bodyReader = body + } + req, err = http.NewRequest(method, url.String(), bodyReader) + if err != nil { + return nil, fmt.Errorf("failed to create http request: %w", err) + } + + // add header parameters, if any + if len(headerParams) > 0 { + for h, v := range headerParams { + req.Header.Add(h, v) + } + } + + contentType := "application/json" + + // Add the user agent to the request. + req.Header.Add("User-Agent", c.cfg.UserAgent) + req.Header.Add("X-Algolia-Application-Id", c.cfg.AppID) + req.Header.Add("X-Algolia-API-Key", c.cfg.ApiKey) + req.Header.Add("Content-Type", contentType) + req.Header.Add("Accept", contentType) + + if ctx != nil { + // add context to the request + req = req.WithContext(ctx) + } + + for header, value := range c.cfg.DefaultHeader { + req.Header.Add(header, value) + } + + return req, nil +} + +func (c *APIClient) decode(v any, b []byte) error { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + + if actualObj, ok := v.(interface{ GetActualInstance() any }); ok { // oneOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err := unmarshalObj.UnmarshalJSON(b); err != nil { + return fmt.Errorf("failed to unmarshal one of in response body: %w", err) + } + } else { + return errors.New("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err := json.Unmarshal(b, v); err != nil { // simple model + return fmt.Errorf("failed to unmarshal response body: %w", err) + } + + return nil +} + +func (c *APIClient) decodeError(res *http.Response, body []byte) error { + apiErr := &APIError{ + Message: string(body), // default to the full body if we cannot guess the type of the error. + Status: res.StatusCode, + } + + if strings.Contains(res.Header.Get("Content-Type"), "application/json") { + var errBase ErrorBase + + err := c.decode(&errBase, body) + if err != nil { + apiErr.Message = err.Error() + + return apiErr + } + if errBase.Message != nil { + apiErr.Message = *errBase.Message + } + + apiErr.AdditionalProperties = errBase.AdditionalProperties + } else if strings.Contains(res.Header.Get("Content-Type"), "text/html") { + apiErr.Message = http.StatusText(res.StatusCode) + } + + return apiErr +} + +// Prevent trying to import "fmt". +func reportError(format string, a ...any) error { + return fmt.Errorf(format, a...) +} + +// A wrapper for strict JSON decoding. +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// A wrapper for validating a struct, returns nil if value is not a struct. +func validateStruct(v any) error { + err := validator.New().Struct(v) + validationErrors, ok := err.(validator.ValidationErrors) + if ok && len(validationErrors) > 0 { + return validationErrors + } + + return nil +} + +// Set request body from an any. +func setBody(body any, c compression.Compression) (*bytes.Buffer, error) { + if body == nil { + return nil, nil + } + + bodyBuf := &bytes.Buffer{} + var err error + + switch c { + case compression.GZIP: + gzipWriter := gzip.NewWriter(bodyBuf) + defer gzipWriter.Close() + err = json.NewEncoder(gzipWriter).Encode(body) + default: + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else { + err = json.NewEncoder(bodyBuf).Encode(body) + } + } + + if err != nil { + return nil, fmt.Errorf("failed to encode body: %w", err) + } + + if bodyBuf.Len() == 0 { + return nil, errors.New("invalid body type, or empty body") + } + return bodyBuf, nil +} + +type APIError struct { + Message string + Status int + AdditionalProperties map[string]any +} + +func (e APIError) Error() string { + return fmt.Sprintf("API error [%d] %s", e.Status, e.Message) +} + +func (o APIError) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{ + "message": o.Message, + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal APIError: %w", err) + } + + return serialized, nil +} + +func (o *APIError) UnmarshalJSON(bytes []byte) error { + type _APIError APIError + apiErr := _APIError{} + + err := json.Unmarshal(bytes, &apiErr) + if err != nil { + return fmt.Errorf("failed to unmarshal APIError: %w", err) + } + + *o = APIError(apiErr) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in APIError: %w", err) + } + + delete(additionalProperties, "message") + o.AdditionalProperties = additionalProperties + + return nil +} diff --git a/algolia/composition/configuration.go b/algolia/composition/configuration.go new file mode 100644 index 000000000..56a694503 --- /dev/null +++ b/algolia/composition/configuration.go @@ -0,0 +1,11 @@ +// 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 composition + +import ( + "github.com/algolia/algoliasearch-client-go/v4/algolia/transport" +) + +// CompositionConfiguration stores the configuration of the API client. +type CompositionConfiguration struct { + transport.Configuration +} diff --git a/algolia/composition/model_around_precision.go b/algolia/composition/model_around_precision.go new file mode 100644 index 000000000..e8fe5794e --- /dev/null +++ b/algolia/composition/model_around_precision.go @@ -0,0 +1,85 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// AroundPrecision - 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. +type AroundPrecision struct { + ArrayOfModelRange *[]ModelRange + Int32 *int32 +} + +// int32AsAroundPrecision is a convenience function that returns int32 wrapped in AroundPrecision. +func Int32AsAroundPrecision(v int32) *AroundPrecision { + return &AroundPrecision{ + Int32: &v, + } +} + +// []ModelRangeAsAroundPrecision is a convenience function that returns []ModelRange wrapped in AroundPrecision. +func ArrayOfModelRangeAsAroundPrecision(v []ModelRange) *AroundPrecision { + return &AroundPrecision{ + ArrayOfModelRange: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *AroundPrecision) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal data into Int32 + err = newStrictDecoder(data).Decode(&dst.Int32) + if err == nil && validateStruct(dst.Int32) == nil { + return nil // found the correct type + } else { + dst.Int32 = nil + } + // try to unmarshal data into ArrayOfModelRange + err = newStrictDecoder(data).Decode(&dst.ArrayOfModelRange) + if err == nil && validateStruct(dst.ArrayOfModelRange) == nil { + return nil // found the correct type + } else { + dst.ArrayOfModelRange = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(AroundPrecision)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src AroundPrecision) MarshalJSON() ([]byte, error) { + if src.ArrayOfModelRange != nil { + serialized, err := json.Marshal(&src.ArrayOfModelRange) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfModelRange of AroundPrecision: %w", err) + } + + return serialized, nil + } + + if src.Int32 != nil { + serialized, err := json.Marshal(&src.Int32) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of Int32 of AroundPrecision: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj AroundPrecision) GetActualInstance() any { + if obj.ArrayOfModelRange != nil { + return *obj.ArrayOfModelRange + } + + if obj.Int32 != nil { + return *obj.Int32 + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_around_radius.go b/algolia/composition/model_around_radius.go new file mode 100644 index 000000000..114dd8e4c --- /dev/null +++ b/algolia/composition/model_around_radius.go @@ -0,0 +1,85 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// AroundRadius - 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. +type AroundRadius struct { + AroundRadiusAll *AroundRadiusAll + Int32 *int32 +} + +// int32AsAroundRadius is a convenience function that returns int32 wrapped in AroundRadius. +func Int32AsAroundRadius(v int32) *AroundRadius { + return &AroundRadius{ + Int32: &v, + } +} + +// AroundRadiusAllAsAroundRadius is a convenience function that returns AroundRadiusAll wrapped in AroundRadius. +func AroundRadiusAllAsAroundRadius(v AroundRadiusAll) *AroundRadius { + return &AroundRadius{ + AroundRadiusAll: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *AroundRadius) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal data into Int32 + err = newStrictDecoder(data).Decode(&dst.Int32) + if err == nil && validateStruct(dst.Int32) == nil { + return nil // found the correct type + } else { + dst.Int32 = nil + } + // try to unmarshal data into AroundRadiusAll + err = newStrictDecoder(data).Decode(&dst.AroundRadiusAll) + if err == nil && validateStruct(dst.AroundRadiusAll) == nil { + return nil // found the correct type + } else { + dst.AroundRadiusAll = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(AroundRadius)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src AroundRadius) MarshalJSON() ([]byte, error) { + if src.AroundRadiusAll != nil { + serialized, err := json.Marshal(&src.AroundRadiusAll) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of AroundRadiusAll of AroundRadius: %w", err) + } + + return serialized, nil + } + + if src.Int32 != nil { + serialized, err := json.Marshal(&src.Int32) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of Int32 of AroundRadius: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj AroundRadius) GetActualInstance() any { + if obj.AroundRadiusAll != nil { + return *obj.AroundRadiusAll + } + + if obj.Int32 != nil { + return *obj.Int32 + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_around_radius_all.go b/algolia/composition/model_around_radius_all.go new file mode 100644 index 000000000..2e9b07b47 --- /dev/null +++ b/algolia/composition/model_around_radius_all.go @@ -0,0 +1,63 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// AroundRadiusAll Return all records with a valid `_geoloc` attribute. Don't filter by distance. +type AroundRadiusAll string + +// List of aroundRadiusAll. +const ( + AROUND_RADIUS_ALL_ALL AroundRadiusAll = "all" +) + +// All allowed values of AroundRadiusAll enum. +var AllowedAroundRadiusAllEnumValues = []AroundRadiusAll{ + "all", +} + +func (v *AroundRadiusAll) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return fmt.Errorf("failed to unmarshal value '%s' for enum 'AroundRadiusAll': %w", string(src), err) + } + enumTypeValue := AroundRadiusAll(value) + for _, existing := range AllowedAroundRadiusAllEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid AroundRadiusAll", value) +} + +// NewAroundRadiusAllFromValue returns a pointer to a valid AroundRadiusAll +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAroundRadiusAllFromValue(v string) (*AroundRadiusAll, error) { + ev := AroundRadiusAll(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for AroundRadiusAll: valid values are %v", v, AllowedAroundRadiusAllEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AroundRadiusAll) IsValid() bool { + for _, existing := range AllowedAroundRadiusAllEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to aroundRadiusAll value. +func (v AroundRadiusAll) Ptr() *AroundRadiusAll { + return &v +} diff --git a/algolia/composition/model_banner.go b/algolia/composition/model_banner.go new file mode 100644 index 000000000..971004177 --- /dev/null +++ b/algolia/composition/model_banner.go @@ -0,0 +1,133 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Banner Banner with image and link to redirect users. +type Banner struct { + Image *BannerImage `json:"image,omitempty"` + Link *BannerLink `json:"link,omitempty"` +} + +type BannerOption func(f *Banner) + +func WithBannerImage(val BannerImage) BannerOption { + return func(f *Banner) { + f.Image = &val + } +} + +func WithBannerLink(val BannerLink) BannerOption { + return func(f *Banner) { + f.Link = &val + } +} + +// NewBanner instantiates a new Banner object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewBanner(opts ...BannerOption) *Banner { + this := &Banner{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyBanner return a pointer to an empty Banner object. +func NewEmptyBanner() *Banner { + return &Banner{} +} + +// GetImage returns the Image field value if set, zero value otherwise. +func (o *Banner) GetImage() BannerImage { + if o == nil || o.Image == nil { + var ret BannerImage + return ret + } + return *o.Image +} + +// GetImageOk returns a tuple with the Image field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Banner) GetImageOk() (*BannerImage, bool) { + if o == nil || o.Image == nil { + return nil, false + } + return o.Image, true +} + +// HasImage returns a boolean if a field has been set. +func (o *Banner) HasImage() bool { + if o != nil && o.Image != nil { + return true + } + + return false +} + +// SetImage gets a reference to the given BannerImage and assigns it to the Image field. +func (o *Banner) SetImage(v *BannerImage) *Banner { + o.Image = v + return o +} + +// GetLink returns the Link field value if set, zero value otherwise. +func (o *Banner) GetLink() BannerLink { + if o == nil || o.Link == nil { + var ret BannerLink + return ret + } + return *o.Link +} + +// GetLinkOk returns a tuple with the Link field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Banner) GetLinkOk() (*BannerLink, bool) { + if o == nil || o.Link == nil { + return nil, false + } + return o.Link, true +} + +// HasLink returns a boolean if a field has been set. +func (o *Banner) HasLink() bool { + if o != nil && o.Link != nil { + return true + } + + return false +} + +// SetLink gets a reference to the given BannerLink and assigns it to the Link field. +func (o *Banner) SetLink(v *BannerLink) *Banner { + o.Link = v + return o +} + +func (o Banner) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Image != nil { + toSerialize["image"] = o.Image + } + if o.Link != nil { + toSerialize["link"] = o.Link + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Banner: %w", err) + } + + return serialized, nil +} + +func (o Banner) String() string { + out := "" + out += fmt.Sprintf(" image=%v\n", o.Image) + out += fmt.Sprintf(" link=%v\n", o.Link) + return fmt.Sprintf("Banner {\n%s}", out) +} diff --git a/algolia/composition/model_banner_image.go b/algolia/composition/model_banner_image.go new file mode 100644 index 000000000..65dced129 --- /dev/null +++ b/algolia/composition/model_banner_image.go @@ -0,0 +1,133 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// BannerImage Image to show inside a banner. +type BannerImage struct { + Urls []BannerImageUrl `json:"urls,omitempty"` + Title *string `json:"title,omitempty"` +} + +type BannerImageOption func(f *BannerImage) + +func WithBannerImageUrls(val []BannerImageUrl) BannerImageOption { + return func(f *BannerImage) { + f.Urls = val + } +} + +func WithBannerImageTitle(val string) BannerImageOption { + return func(f *BannerImage) { + f.Title = &val + } +} + +// NewBannerImage instantiates a new BannerImage object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewBannerImage(opts ...BannerImageOption) *BannerImage { + this := &BannerImage{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyBannerImage return a pointer to an empty BannerImage object. +func NewEmptyBannerImage() *BannerImage { + return &BannerImage{} +} + +// GetUrls returns the Urls field value if set, zero value otherwise. +func (o *BannerImage) GetUrls() []BannerImageUrl { + if o == nil || o.Urls == nil { + var ret []BannerImageUrl + return ret + } + return o.Urls +} + +// GetUrlsOk returns a tuple with the Urls field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BannerImage) GetUrlsOk() ([]BannerImageUrl, bool) { + if o == nil || o.Urls == nil { + return nil, false + } + return o.Urls, true +} + +// HasUrls returns a boolean if a field has been set. +func (o *BannerImage) HasUrls() bool { + if o != nil && o.Urls != nil { + return true + } + + return false +} + +// SetUrls gets a reference to the given []BannerImageUrl and assigns it to the Urls field. +func (o *BannerImage) SetUrls(v []BannerImageUrl) *BannerImage { + o.Urls = v + return o +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *BannerImage) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BannerImage) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *BannerImage) HasTitle() bool { + if o != nil && o.Title != nil { + return true + } + + return false +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *BannerImage) SetTitle(v string) *BannerImage { + o.Title = &v + return o +} + +func (o BannerImage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Urls != nil { + toSerialize["urls"] = o.Urls + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal BannerImage: %w", err) + } + + return serialized, nil +} + +func (o BannerImage) String() string { + out := "" + out += fmt.Sprintf(" urls=%v\n", o.Urls) + out += fmt.Sprintf(" title=%v\n", o.Title) + return fmt.Sprintf("BannerImage {\n%s}", out) +} diff --git a/algolia/composition/model_banner_image_url.go b/algolia/composition/model_banner_image_url.go new file mode 100644 index 000000000..ddfbd6775 --- /dev/null +++ b/algolia/composition/model_banner_image_url.go @@ -0,0 +1,89 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// BannerImageUrl URL for an image to show inside a banner. +type BannerImageUrl struct { + Url *string `json:"url,omitempty"` +} + +type BannerImageUrlOption func(f *BannerImageUrl) + +func WithBannerImageUrlUrl(val string) BannerImageUrlOption { + return func(f *BannerImageUrl) { + f.Url = &val + } +} + +// NewBannerImageUrl instantiates a new BannerImageUrl object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewBannerImageUrl(opts ...BannerImageUrlOption) *BannerImageUrl { + this := &BannerImageUrl{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyBannerImageUrl return a pointer to an empty BannerImageUrl object. +func NewEmptyBannerImageUrl() *BannerImageUrl { + return &BannerImageUrl{} +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *BannerImageUrl) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BannerImageUrl) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *BannerImageUrl) HasUrl() bool { + if o != nil && o.Url != nil { + return true + } + + return false +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *BannerImageUrl) SetUrl(v string) *BannerImageUrl { + o.Url = &v + return o +} + +func (o BannerImageUrl) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Url != nil { + toSerialize["url"] = o.Url + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal BannerImageUrl: %w", err) + } + + return serialized, nil +} + +func (o BannerImageUrl) String() string { + out := "" + out += fmt.Sprintf(" url=%v\n", o.Url) + return fmt.Sprintf("BannerImageUrl {\n%s}", out) +} diff --git a/algolia/composition/model_banner_link.go b/algolia/composition/model_banner_link.go new file mode 100644 index 000000000..12537dee6 --- /dev/null +++ b/algolia/composition/model_banner_link.go @@ -0,0 +1,89 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// BannerLink Link for a banner defined in the Merchandising Studio. +type BannerLink struct { + Url *string `json:"url,omitempty"` +} + +type BannerLinkOption func(f *BannerLink) + +func WithBannerLinkUrl(val string) BannerLinkOption { + return func(f *BannerLink) { + f.Url = &val + } +} + +// NewBannerLink instantiates a new BannerLink object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewBannerLink(opts ...BannerLinkOption) *BannerLink { + this := &BannerLink{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyBannerLink return a pointer to an empty BannerLink object. +func NewEmptyBannerLink() *BannerLink { + return &BannerLink{} +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *BannerLink) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BannerLink) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *BannerLink) HasUrl() bool { + if o != nil && o.Url != nil { + return true + } + + return false +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *BannerLink) SetUrl(v string) *BannerLink { + o.Url = &v + return o +} + +func (o BannerLink) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Url != nil { + toSerialize["url"] = o.Url + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal BannerLink: %w", err) + } + + return serialized, nil +} + +func (o BannerLink) String() string { + out := "" + out += fmt.Sprintf(" url=%v\n", o.Url) + return fmt.Sprintf("BannerLink {\n%s}", out) +} diff --git a/algolia/composition/model_composition_id_ranking_info.go b/algolia/composition/model_composition_id_ranking_info.go new file mode 100644 index 000000000..8d9d0baaf --- /dev/null +++ b/algolia/composition/model_composition_id_ranking_info.go @@ -0,0 +1,102 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// CompositionIdRankingInfo struct for CompositionIdRankingInfo. +type CompositionIdRankingInfo struct { + Index string `json:"index"` + InjectedItemKey string `json:"injectedItemKey"` +} + +// NewCompositionIdRankingInfo instantiates a new CompositionIdRankingInfo object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCompositionIdRankingInfo(index string, injectedItemKey string) *CompositionIdRankingInfo { + this := &CompositionIdRankingInfo{} + this.Index = index + this.InjectedItemKey = injectedItemKey + return this +} + +// NewEmptyCompositionIdRankingInfo return a pointer to an empty CompositionIdRankingInfo object. +func NewEmptyCompositionIdRankingInfo() *CompositionIdRankingInfo { + return &CompositionIdRankingInfo{} +} + +// GetIndex returns the Index field value. +func (o *CompositionIdRankingInfo) GetIndex() string { + if o == nil { + var ret string + return ret + } + + return o.Index +} + +// GetIndexOk returns a tuple with the Index field value +// and a boolean to check if the value has been set. +func (o *CompositionIdRankingInfo) GetIndexOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Index, true +} + +// SetIndex sets field value. +func (o *CompositionIdRankingInfo) SetIndex(v string) *CompositionIdRankingInfo { + o.Index = v + return o +} + +// GetInjectedItemKey returns the InjectedItemKey field value. +func (o *CompositionIdRankingInfo) GetInjectedItemKey() string { + if o == nil { + var ret string + return ret + } + + return o.InjectedItemKey +} + +// GetInjectedItemKeyOk returns a tuple with the InjectedItemKey field value +// and a boolean to check if the value has been set. +func (o *CompositionIdRankingInfo) GetInjectedItemKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InjectedItemKey, true +} + +// SetInjectedItemKey sets field value. +func (o *CompositionIdRankingInfo) SetInjectedItemKey(v string) *CompositionIdRankingInfo { + o.InjectedItemKey = v + return o +} + +func (o CompositionIdRankingInfo) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["index"] = o.Index + } + if true { + toSerialize["injectedItemKey"] = o.InjectedItemKey + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal CompositionIdRankingInfo: %w", err) + } + + return serialized, nil +} + +func (o CompositionIdRankingInfo) String() string { + out := "" + out += fmt.Sprintf(" index=%v\n", o.Index) + out += fmt.Sprintf(" injectedItemKey=%v\n", o.InjectedItemKey) + return fmt.Sprintf("CompositionIdRankingInfo {\n%s}", out) +} diff --git a/algolia/composition/model_composition_run_applied_rules.go b/algolia/composition/model_composition_run_applied_rules.go new file mode 100644 index 000000000..29a6bf352 --- /dev/null +++ b/algolia/composition/model_composition_run_applied_rules.go @@ -0,0 +1,72 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// CompositionRunAppliedRules struct for CompositionRunAppliedRules. +type CompositionRunAppliedRules struct { + // Unique record identifier. + ObjectID string `json:"objectID"` +} + +// NewCompositionRunAppliedRules instantiates a new CompositionRunAppliedRules object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCompositionRunAppliedRules(objectID string) *CompositionRunAppliedRules { + this := &CompositionRunAppliedRules{} + this.ObjectID = objectID + return this +} + +// NewEmptyCompositionRunAppliedRules return a pointer to an empty CompositionRunAppliedRules object. +func NewEmptyCompositionRunAppliedRules() *CompositionRunAppliedRules { + return &CompositionRunAppliedRules{} +} + +// GetObjectID returns the ObjectID field value. +func (o *CompositionRunAppliedRules) GetObjectID() string { + if o == nil { + var ret string + return ret + } + + return o.ObjectID +} + +// GetObjectIDOk returns a tuple with the ObjectID field value +// and a boolean to check if the value has been set. +func (o *CompositionRunAppliedRules) GetObjectIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ObjectID, true +} + +// SetObjectID sets field value. +func (o *CompositionRunAppliedRules) SetObjectID(v string) *CompositionRunAppliedRules { + o.ObjectID = v + return o +} + +func (o CompositionRunAppliedRules) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["objectID"] = o.ObjectID + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal CompositionRunAppliedRules: %w", err) + } + + return serialized, nil +} + +func (o CompositionRunAppliedRules) String() string { + out := "" + out += fmt.Sprintf(" objectID=%v\n", o.ObjectID) + return fmt.Sprintf("CompositionRunAppliedRules {\n%s}", out) +} diff --git a/algolia/composition/model_composition_run_search_response.go b/algolia/composition/model_composition_run_search_response.go new file mode 100644 index 000000000..299d6eb5b --- /dev/null +++ b/algolia/composition/model_composition_run_search_response.go @@ -0,0 +1,166 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// CompositionRunSearchResponse struct for CompositionRunSearchResponse. +type CompositionRunSearchResponse struct { + // Unique record identifier. + ObjectID string `json:"objectID"` + AppliedRules []CompositionRunAppliedRules `json:"appliedRules,omitempty"` + AdditionalProperties map[string]any +} + +type _CompositionRunSearchResponse CompositionRunSearchResponse + +type CompositionRunSearchResponseOption func(f *CompositionRunSearchResponse) + +func WithCompositionRunSearchResponseAppliedRules(val []CompositionRunAppliedRules) CompositionRunSearchResponseOption { + return func(f *CompositionRunSearchResponse) { + f.AppliedRules = val + } +} + +// NewCompositionRunSearchResponse instantiates a new CompositionRunSearchResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCompositionRunSearchResponse(objectID string, opts ...CompositionRunSearchResponseOption) *CompositionRunSearchResponse { + this := &CompositionRunSearchResponse{} + this.ObjectID = objectID + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyCompositionRunSearchResponse return a pointer to an empty CompositionRunSearchResponse object. +func NewEmptyCompositionRunSearchResponse() *CompositionRunSearchResponse { + return &CompositionRunSearchResponse{} +} + +// GetObjectID returns the ObjectID field value. +func (o *CompositionRunSearchResponse) GetObjectID() string { + if o == nil { + var ret string + return ret + } + + return o.ObjectID +} + +// GetObjectIDOk returns a tuple with the ObjectID field value +// and a boolean to check if the value has been set. +func (o *CompositionRunSearchResponse) GetObjectIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ObjectID, true +} + +// SetObjectID sets field value. +func (o *CompositionRunSearchResponse) SetObjectID(v string) *CompositionRunSearchResponse { + o.ObjectID = v + return o +} + +// GetAppliedRules returns the AppliedRules field value if set, zero value otherwise. +func (o *CompositionRunSearchResponse) GetAppliedRules() []CompositionRunAppliedRules { + if o == nil || o.AppliedRules == nil { + var ret []CompositionRunAppliedRules + return ret + } + return o.AppliedRules +} + +// GetAppliedRulesOk returns a tuple with the AppliedRules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CompositionRunSearchResponse) GetAppliedRulesOk() ([]CompositionRunAppliedRules, bool) { + if o == nil || o.AppliedRules == nil { + return nil, false + } + return o.AppliedRules, true +} + +// HasAppliedRules returns a boolean if a field has been set. +func (o *CompositionRunSearchResponse) HasAppliedRules() bool { + if o != nil && o.AppliedRules != nil { + return true + } + + return false +} + +// SetAppliedRules gets a reference to the given []CompositionRunAppliedRules and assigns it to the AppliedRules field. +func (o *CompositionRunSearchResponse) SetAppliedRules(v []CompositionRunAppliedRules) *CompositionRunSearchResponse { + o.AppliedRules = v + return o +} + +func (o *CompositionRunSearchResponse) SetAdditionalProperty(key string, value any) *CompositionRunSearchResponse { + if o.AdditionalProperties == nil { + o.AdditionalProperties = make(map[string]any) + } + + o.AdditionalProperties[key] = value + + return o +} + +func (o CompositionRunSearchResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["objectID"] = o.ObjectID + } + if o.AppliedRules != nil { + toSerialize["appliedRules"] = o.AppliedRules + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal CompositionRunSearchResponse: %w", err) + } + + return serialized, nil +} + +func (o *CompositionRunSearchResponse) UnmarshalJSON(bytes []byte) error { + varCompositionRunSearchResponse := _CompositionRunSearchResponse{} + + err := json.Unmarshal(bytes, &varCompositionRunSearchResponse) + if err != nil { + return fmt.Errorf("failed to unmarshal CompositionRunSearchResponse: %w", err) + } + + *o = CompositionRunSearchResponse(varCompositionRunSearchResponse) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in CompositionRunSearchResponse: %w", err) + } + + delete(additionalProperties, "objectID") + delete(additionalProperties, "appliedRules") + o.AdditionalProperties = additionalProperties + + return nil +} + +func (o CompositionRunSearchResponse) String() string { + out := "" + out += fmt.Sprintf(" objectID=%v\n", o.ObjectID) + out += fmt.Sprintf(" appliedRules=%v\n", o.AppliedRules) + for key, value := range o.AdditionalProperties { + out += fmt.Sprintf(" %s=%v\n", key, value) + } + return fmt.Sprintf("CompositionRunSearchResponse {\n%s}", out) +} diff --git a/algolia/composition/model_compositions_search_response.go b/algolia/composition/model_compositions_search_response.go new file mode 100644 index 000000000..3d3b3aa07 --- /dev/null +++ b/algolia/composition/model_compositions_search_response.go @@ -0,0 +1,115 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// CompositionsSearchResponse struct for CompositionsSearchResponse. +type CompositionsSearchResponse struct { + Run []CompositionRunSearchResponse `json:"run"` + AdditionalProperties map[string]any +} + +type _CompositionsSearchResponse CompositionsSearchResponse + +// NewCompositionsSearchResponse instantiates a new CompositionsSearchResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCompositionsSearchResponse(run []CompositionRunSearchResponse) *CompositionsSearchResponse { + this := &CompositionsSearchResponse{} + this.Run = run + return this +} + +// NewEmptyCompositionsSearchResponse return a pointer to an empty CompositionsSearchResponse object. +func NewEmptyCompositionsSearchResponse() *CompositionsSearchResponse { + return &CompositionsSearchResponse{} +} + +// GetRun returns the Run field value. +func (o *CompositionsSearchResponse) GetRun() []CompositionRunSearchResponse { + if o == nil { + var ret []CompositionRunSearchResponse + return ret + } + + return o.Run +} + +// GetRunOk returns a tuple with the Run field value +// and a boolean to check if the value has been set. +func (o *CompositionsSearchResponse) GetRunOk() ([]CompositionRunSearchResponse, bool) { + if o == nil { + return nil, false + } + return o.Run, true +} + +// SetRun sets field value. +func (o *CompositionsSearchResponse) SetRun(v []CompositionRunSearchResponse) *CompositionsSearchResponse { + o.Run = v + return o +} + +func (o *CompositionsSearchResponse) SetAdditionalProperty(key string, value any) *CompositionsSearchResponse { + if o.AdditionalProperties == nil { + o.AdditionalProperties = make(map[string]any) + } + + o.AdditionalProperties[key] = value + + return o +} + +func (o CompositionsSearchResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["run"] = o.Run + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal CompositionsSearchResponse: %w", err) + } + + return serialized, nil +} + +func (o *CompositionsSearchResponse) UnmarshalJSON(bytes []byte) error { + varCompositionsSearchResponse := _CompositionsSearchResponse{} + + err := json.Unmarshal(bytes, &varCompositionsSearchResponse) + if err != nil { + return fmt.Errorf("failed to unmarshal CompositionsSearchResponse: %w", err) + } + + *o = CompositionsSearchResponse(varCompositionsSearchResponse) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in CompositionsSearchResponse: %w", err) + } + + delete(additionalProperties, "run") + o.AdditionalProperties = additionalProperties + + return nil +} + +func (o CompositionsSearchResponse) String() string { + out := "" + out += fmt.Sprintf(" run=%v\n", o.Run) + for key, value := range o.AdditionalProperties { + out += fmt.Sprintf(" %s=%v\n", key, value) + } + return fmt.Sprintf("CompositionsSearchResponse {\n%s}", out) +} diff --git a/algolia/composition/model_error_base.go b/algolia/composition/model_error_base.go new file mode 100644 index 000000000..d696e0ccc --- /dev/null +++ b/algolia/composition/model_error_base.go @@ -0,0 +1,133 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// ErrorBase Error. +type ErrorBase struct { + Message *string `json:"message,omitempty"` + AdditionalProperties map[string]any +} + +type _ErrorBase ErrorBase + +type ErrorBaseOption func(f *ErrorBase) + +func WithErrorBaseMessage(val string) ErrorBaseOption { + return func(f *ErrorBase) { + f.Message = &val + } +} + +// NewErrorBase instantiates a new ErrorBase object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewErrorBase(opts ...ErrorBaseOption) *ErrorBase { + this := &ErrorBase{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyErrorBase return a pointer to an empty ErrorBase object. +func NewEmptyErrorBase() *ErrorBase { + return &ErrorBase{} +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *ErrorBase) GetMessage() string { + if o == nil || o.Message == nil { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorBase) GetMessageOk() (*string, bool) { + if o == nil || o.Message == nil { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *ErrorBase) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *ErrorBase) SetMessage(v string) *ErrorBase { + o.Message = &v + return o +} + +func (o *ErrorBase) SetAdditionalProperty(key string, value any) *ErrorBase { + if o.AdditionalProperties == nil { + o.AdditionalProperties = make(map[string]any) + } + + o.AdditionalProperties[key] = value + + return o +} + +func (o ErrorBase) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Message != nil { + toSerialize["message"] = o.Message + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal ErrorBase: %w", err) + } + + return serialized, nil +} + +func (o *ErrorBase) UnmarshalJSON(bytes []byte) error { + varErrorBase := _ErrorBase{} + + err := json.Unmarshal(bytes, &varErrorBase) + if err != nil { + return fmt.Errorf("failed to unmarshal ErrorBase: %w", err) + } + + *o = ErrorBase(varErrorBase) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in ErrorBase: %w", err) + } + + delete(additionalProperties, "message") + o.AdditionalProperties = additionalProperties + + return nil +} + +func (o ErrorBase) String() string { + out := "" + out += fmt.Sprintf(" message=%v\n", o.Message) + for key, value := range o.AdditionalProperties { + out += fmt.Sprintf(" %s=%v\n", key, value) + } + return fmt.Sprintf("ErrorBase {\n%s}", out) +} diff --git a/algolia/composition/model_exhaustive.go b/algolia/composition/model_exhaustive.go new file mode 100644 index 000000000..f8112f076 --- /dev/null +++ b/algolia/composition/model_exhaustive.go @@ -0,0 +1,270 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Exhaustive Whether certain properties of the search response are calculated exhaustive (exact) or approximated. +type Exhaustive struct { + // 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-). + FacetsCount *bool `json:"facetsCount,omitempty"` + // The value is `false` if not all facet values are retrieved. + FacetValues *bool `json:"facetValues,omitempty"` + // 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. + NbHits *bool `json:"nbHits,omitempty"` + // 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. + RulesMatch *bool `json:"rulesMatch,omitempty"` + // 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. + Typo *bool `json:"typo,omitempty"` +} + +type ExhaustiveOption func(f *Exhaustive) + +func WithExhaustiveFacetsCount(val bool) ExhaustiveOption { + return func(f *Exhaustive) { + f.FacetsCount = &val + } +} + +func WithExhaustiveFacetValues(val bool) ExhaustiveOption { + return func(f *Exhaustive) { + f.FacetValues = &val + } +} + +func WithExhaustiveNbHits(val bool) ExhaustiveOption { + return func(f *Exhaustive) { + f.NbHits = &val + } +} + +func WithExhaustiveRulesMatch(val bool) ExhaustiveOption { + return func(f *Exhaustive) { + f.RulesMatch = &val + } +} + +func WithExhaustiveTypo(val bool) ExhaustiveOption { + return func(f *Exhaustive) { + f.Typo = &val + } +} + +// NewExhaustive instantiates a new Exhaustive object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewExhaustive(opts ...ExhaustiveOption) *Exhaustive { + this := &Exhaustive{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyExhaustive return a pointer to an empty Exhaustive object. +func NewEmptyExhaustive() *Exhaustive { + return &Exhaustive{} +} + +// GetFacetsCount returns the FacetsCount field value if set, zero value otherwise. +func (o *Exhaustive) GetFacetsCount() bool { + if o == nil || o.FacetsCount == nil { + var ret bool + return ret + } + return *o.FacetsCount +} + +// GetFacetsCountOk returns a tuple with the FacetsCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Exhaustive) GetFacetsCountOk() (*bool, bool) { + if o == nil || o.FacetsCount == nil { + return nil, false + } + return o.FacetsCount, true +} + +// HasFacetsCount returns a boolean if a field has been set. +func (o *Exhaustive) HasFacetsCount() bool { + if o != nil && o.FacetsCount != nil { + return true + } + + return false +} + +// SetFacetsCount gets a reference to the given bool and assigns it to the FacetsCount field. +func (o *Exhaustive) SetFacetsCount(v bool) *Exhaustive { + o.FacetsCount = &v + return o +} + +// GetFacetValues returns the FacetValues field value if set, zero value otherwise. +func (o *Exhaustive) GetFacetValues() bool { + if o == nil || o.FacetValues == nil { + var ret bool + return ret + } + return *o.FacetValues +} + +// GetFacetValuesOk returns a tuple with the FacetValues field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Exhaustive) GetFacetValuesOk() (*bool, bool) { + if o == nil || o.FacetValues == nil { + return nil, false + } + return o.FacetValues, true +} + +// HasFacetValues returns a boolean if a field has been set. +func (o *Exhaustive) HasFacetValues() bool { + if o != nil && o.FacetValues != nil { + return true + } + + return false +} + +// SetFacetValues gets a reference to the given bool and assigns it to the FacetValues field. +func (o *Exhaustive) SetFacetValues(v bool) *Exhaustive { + o.FacetValues = &v + return o +} + +// GetNbHits returns the NbHits field value if set, zero value otherwise. +func (o *Exhaustive) GetNbHits() bool { + if o == nil || o.NbHits == nil { + var ret bool + return ret + } + return *o.NbHits +} + +// GetNbHitsOk returns a tuple with the NbHits field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Exhaustive) GetNbHitsOk() (*bool, bool) { + if o == nil || o.NbHits == nil { + return nil, false + } + return o.NbHits, true +} + +// HasNbHits returns a boolean if a field has been set. +func (o *Exhaustive) HasNbHits() bool { + if o != nil && o.NbHits != nil { + return true + } + + return false +} + +// SetNbHits gets a reference to the given bool and assigns it to the NbHits field. +func (o *Exhaustive) SetNbHits(v bool) *Exhaustive { + o.NbHits = &v + return o +} + +// GetRulesMatch returns the RulesMatch field value if set, zero value otherwise. +func (o *Exhaustive) GetRulesMatch() bool { + if o == nil || o.RulesMatch == nil { + var ret bool + return ret + } + return *o.RulesMatch +} + +// GetRulesMatchOk returns a tuple with the RulesMatch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Exhaustive) GetRulesMatchOk() (*bool, bool) { + if o == nil || o.RulesMatch == nil { + return nil, false + } + return o.RulesMatch, true +} + +// HasRulesMatch returns a boolean if a field has been set. +func (o *Exhaustive) HasRulesMatch() bool { + if o != nil && o.RulesMatch != nil { + return true + } + + return false +} + +// SetRulesMatch gets a reference to the given bool and assigns it to the RulesMatch field. +func (o *Exhaustive) SetRulesMatch(v bool) *Exhaustive { + o.RulesMatch = &v + return o +} + +// GetTypo returns the Typo field value if set, zero value otherwise. +func (o *Exhaustive) GetTypo() bool { + if o == nil || o.Typo == nil { + var ret bool + return ret + } + return *o.Typo +} + +// GetTypoOk returns a tuple with the Typo field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Exhaustive) GetTypoOk() (*bool, bool) { + if o == nil || o.Typo == nil { + return nil, false + } + return o.Typo, true +} + +// HasTypo returns a boolean if a field has been set. +func (o *Exhaustive) HasTypo() bool { + if o != nil && o.Typo != nil { + return true + } + + return false +} + +// SetTypo gets a reference to the given bool and assigns it to the Typo field. +func (o *Exhaustive) SetTypo(v bool) *Exhaustive { + o.Typo = &v + return o +} + +func (o Exhaustive) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.FacetsCount != nil { + toSerialize["facetsCount"] = o.FacetsCount + } + if o.FacetValues != nil { + toSerialize["facetValues"] = o.FacetValues + } + if o.NbHits != nil { + toSerialize["nbHits"] = o.NbHits + } + if o.RulesMatch != nil { + toSerialize["rulesMatch"] = o.RulesMatch + } + if o.Typo != nil { + toSerialize["typo"] = o.Typo + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Exhaustive: %w", err) + } + + return serialized, nil +} + +func (o Exhaustive) String() string { + out := "" + out += fmt.Sprintf(" facetsCount=%v\n", o.FacetsCount) + out += fmt.Sprintf(" facetValues=%v\n", o.FacetValues) + out += fmt.Sprintf(" nbHits=%v\n", o.NbHits) + out += fmt.Sprintf(" rulesMatch=%v\n", o.RulesMatch) + out += fmt.Sprintf(" typo=%v\n", o.Typo) + return fmt.Sprintf("Exhaustive {\n%s}", out) +} diff --git a/algolia/composition/model_facet_filters.go b/algolia/composition/model_facet_filters.go new file mode 100644 index 000000000..f102fa680 --- /dev/null +++ b/algolia/composition/model_facet_filters.go @@ -0,0 +1,85 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// FacetFilters - 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`. +type FacetFilters struct { + ArrayOfFacetFilters *[]FacetFilters + String *string +} + +// []FacetFiltersAsFacetFilters is a convenience function that returns []FacetFilters wrapped in FacetFilters. +func ArrayOfFacetFiltersAsFacetFilters(v []FacetFilters) *FacetFilters { + return &FacetFilters{ + ArrayOfFacetFilters: &v, + } +} + +// stringAsFacetFilters is a convenience function that returns string wrapped in FacetFilters. +func StringAsFacetFilters(v string) *FacetFilters { + return &FacetFilters{ + String: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *FacetFilters) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal data into ArrayOfFacetFilters + err = newStrictDecoder(data).Decode(&dst.ArrayOfFacetFilters) + if err == nil && validateStruct(dst.ArrayOfFacetFilters) == nil { + return nil // found the correct type + } else { + dst.ArrayOfFacetFilters = nil + } + // try to unmarshal data into String + err = newStrictDecoder(data).Decode(&dst.String) + if err == nil && validateStruct(dst.String) == nil { + return nil // found the correct type + } else { + dst.String = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(FacetFilters)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src FacetFilters) MarshalJSON() ([]byte, error) { + if src.ArrayOfFacetFilters != nil { + serialized, err := json.Marshal(&src.ArrayOfFacetFilters) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfFacetFilters of FacetFilters: %w", err) + } + + return serialized, nil + } + + if src.String != nil { + serialized, err := json.Marshal(&src.String) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of String of FacetFilters: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj FacetFilters) GetActualInstance() any { + if obj.ArrayOfFacetFilters != nil { + return *obj.ArrayOfFacetFilters + } + + if obj.String != nil { + return *obj.String + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_facet_hits.go b/algolia/composition/model_facet_hits.go new file mode 100644 index 000000000..647c779b3 --- /dev/null +++ b/algolia/composition/model_facet_hits.go @@ -0,0 +1,136 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// FacetHits struct for FacetHits. +type FacetHits struct { + // Facet value. + Value string `json:"value"` + // Highlighted attribute value, including HTML tags. + Highlighted string `json:"highlighted"` + // 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-). + Count int32 `json:"count"` +} + +// NewFacetHits instantiates a new FacetHits object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFacetHits(value string, highlighted string, count int32) *FacetHits { + this := &FacetHits{} + this.Value = value + this.Highlighted = highlighted + this.Count = count + return this +} + +// NewEmptyFacetHits return a pointer to an empty FacetHits object. +func NewEmptyFacetHits() *FacetHits { + return &FacetHits{} +} + +// GetValue returns the Value field value. +func (o *FacetHits) GetValue() string { + if o == nil { + var ret string + return ret + } + + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *FacetHits) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *FacetHits) SetValue(v string) *FacetHits { + o.Value = v + return o +} + +// GetHighlighted returns the Highlighted field value. +func (o *FacetHits) GetHighlighted() string { + if o == nil { + var ret string + return ret + } + + return o.Highlighted +} + +// GetHighlightedOk returns a tuple with the Highlighted field value +// and a boolean to check if the value has been set. +func (o *FacetHits) GetHighlightedOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Highlighted, true +} + +// SetHighlighted sets field value. +func (o *FacetHits) SetHighlighted(v string) *FacetHits { + o.Highlighted = v + return o +} + +// GetCount returns the Count field value. +func (o *FacetHits) GetCount() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Count +} + +// GetCountOk returns a tuple with the Count field value +// and a boolean to check if the value has been set. +func (o *FacetHits) GetCountOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Count, true +} + +// SetCount sets field value. +func (o *FacetHits) SetCount(v int32) *FacetHits { + o.Count = v + return o +} + +func (o FacetHits) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["value"] = o.Value + } + if true { + toSerialize["highlighted"] = o.Highlighted + } + if true { + toSerialize["count"] = o.Count + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal FacetHits: %w", err) + } + + return serialized, nil +} + +func (o FacetHits) String() string { + out := "" + out += fmt.Sprintf(" value=%v\n", o.Value) + out += fmt.Sprintf(" highlighted=%v\n", o.Highlighted) + out += fmt.Sprintf(" count=%v\n", o.Count) + return fmt.Sprintf("FacetHits {\n%s}", out) +} diff --git a/algolia/composition/model_facet_ordering.go b/algolia/composition/model_facet_ordering.go new file mode 100644 index 000000000..e4d11286f --- /dev/null +++ b/algolia/composition/model_facet_ordering.go @@ -0,0 +1,134 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// FacetOrdering Order of facet names and facet values in your UI. +type FacetOrdering struct { + Facets *Facets `json:"facets,omitempty"` + // Order of facet values. One object for each facet. + Values *map[string]Value `json:"values,omitempty"` +} + +type FacetOrderingOption func(f *FacetOrdering) + +func WithFacetOrderingFacets(val Facets) FacetOrderingOption { + return func(f *FacetOrdering) { + f.Facets = &val + } +} + +func WithFacetOrderingValues(val map[string]Value) FacetOrderingOption { + return func(f *FacetOrdering) { + f.Values = &val + } +} + +// NewFacetOrdering instantiates a new FacetOrdering object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFacetOrdering(opts ...FacetOrderingOption) *FacetOrdering { + this := &FacetOrdering{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyFacetOrdering return a pointer to an empty FacetOrdering object. +func NewEmptyFacetOrdering() *FacetOrdering { + return &FacetOrdering{} +} + +// GetFacets returns the Facets field value if set, zero value otherwise. +func (o *FacetOrdering) GetFacets() Facets { + if o == nil || o.Facets == nil { + var ret Facets + return ret + } + return *o.Facets +} + +// GetFacetsOk returns a tuple with the Facets field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FacetOrdering) GetFacetsOk() (*Facets, bool) { + if o == nil || o.Facets == nil { + return nil, false + } + return o.Facets, true +} + +// HasFacets returns a boolean if a field has been set. +func (o *FacetOrdering) HasFacets() bool { + if o != nil && o.Facets != nil { + return true + } + + return false +} + +// SetFacets gets a reference to the given Facets and assigns it to the Facets field. +func (o *FacetOrdering) SetFacets(v *Facets) *FacetOrdering { + o.Facets = v + return o +} + +// GetValues returns the Values field value if set, zero value otherwise. +func (o *FacetOrdering) GetValues() map[string]Value { + if o == nil || o.Values == nil { + var ret map[string]Value + return ret + } + return *o.Values +} + +// GetValuesOk returns a tuple with the Values field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FacetOrdering) GetValuesOk() (*map[string]Value, bool) { + if o == nil || o.Values == nil { + return nil, false + } + return o.Values, true +} + +// HasValues returns a boolean if a field has been set. +func (o *FacetOrdering) HasValues() bool { + if o != nil && o.Values != nil { + return true + } + + return false +} + +// SetValues gets a reference to the given map[string]Value and assigns it to the Values field. +func (o *FacetOrdering) SetValues(v map[string]Value) *FacetOrdering { + o.Values = &v + return o +} + +func (o FacetOrdering) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Facets != nil { + toSerialize["facets"] = o.Facets + } + if o.Values != nil { + toSerialize["values"] = o.Values + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal FacetOrdering: %w", err) + } + + return serialized, nil +} + +func (o FacetOrdering) String() string { + out := "" + out += fmt.Sprintf(" facets=%v\n", o.Facets) + out += fmt.Sprintf(" values=%v\n", o.Values) + return fmt.Sprintf("FacetOrdering {\n%s}", out) +} diff --git a/algolia/composition/model_facet_stats.go b/algolia/composition/model_facet_stats.go new file mode 100644 index 000000000..1937390d8 --- /dev/null +++ b/algolia/composition/model_facet_stats.go @@ -0,0 +1,225 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// FacetStats struct for FacetStats. +type FacetStats struct { + // Minimum value in the results. + Min *float64 `json:"min,omitempty"` + // Maximum value in the results. + Max *float64 `json:"max,omitempty"` + // Average facet value in the results. + Avg *float64 `json:"avg,omitempty"` + // Sum of all values in the results. + Sum *float64 `json:"sum,omitempty"` +} + +type FacetStatsOption func(f *FacetStats) + +func WithFacetStatsMin(val float64) FacetStatsOption { + return func(f *FacetStats) { + f.Min = &val + } +} + +func WithFacetStatsMax(val float64) FacetStatsOption { + return func(f *FacetStats) { + f.Max = &val + } +} + +func WithFacetStatsAvg(val float64) FacetStatsOption { + return func(f *FacetStats) { + f.Avg = &val + } +} + +func WithFacetStatsSum(val float64) FacetStatsOption { + return func(f *FacetStats) { + f.Sum = &val + } +} + +// NewFacetStats instantiates a new FacetStats object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFacetStats(opts ...FacetStatsOption) *FacetStats { + this := &FacetStats{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyFacetStats return a pointer to an empty FacetStats object. +func NewEmptyFacetStats() *FacetStats { + return &FacetStats{} +} + +// GetMin returns the Min field value if set, zero value otherwise. +func (o *FacetStats) GetMin() float64 { + if o == nil || o.Min == nil { + var ret float64 + return ret + } + return *o.Min +} + +// GetMinOk returns a tuple with the Min field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FacetStats) GetMinOk() (*float64, bool) { + if o == nil || o.Min == nil { + return nil, false + } + return o.Min, true +} + +// HasMin returns a boolean if a field has been set. +func (o *FacetStats) HasMin() bool { + if o != nil && o.Min != nil { + return true + } + + return false +} + +// SetMin gets a reference to the given float64 and assigns it to the Min field. +func (o *FacetStats) SetMin(v float64) *FacetStats { + o.Min = &v + return o +} + +// GetMax returns the Max field value if set, zero value otherwise. +func (o *FacetStats) GetMax() float64 { + if o == nil || o.Max == nil { + var ret float64 + return ret + } + return *o.Max +} + +// GetMaxOk returns a tuple with the Max field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FacetStats) GetMaxOk() (*float64, bool) { + if o == nil || o.Max == nil { + return nil, false + } + return o.Max, true +} + +// HasMax returns a boolean if a field has been set. +func (o *FacetStats) HasMax() bool { + if o != nil && o.Max != nil { + return true + } + + return false +} + +// SetMax gets a reference to the given float64 and assigns it to the Max field. +func (o *FacetStats) SetMax(v float64) *FacetStats { + o.Max = &v + return o +} + +// GetAvg returns the Avg field value if set, zero value otherwise. +func (o *FacetStats) GetAvg() float64 { + if o == nil || o.Avg == nil { + var ret float64 + return ret + } + return *o.Avg +} + +// GetAvgOk returns a tuple with the Avg field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FacetStats) GetAvgOk() (*float64, bool) { + if o == nil || o.Avg == nil { + return nil, false + } + return o.Avg, true +} + +// HasAvg returns a boolean if a field has been set. +func (o *FacetStats) HasAvg() bool { + if o != nil && o.Avg != nil { + return true + } + + return false +} + +// SetAvg gets a reference to the given float64 and assigns it to the Avg field. +func (o *FacetStats) SetAvg(v float64) *FacetStats { + o.Avg = &v + return o +} + +// GetSum returns the Sum field value if set, zero value otherwise. +func (o *FacetStats) GetSum() float64 { + if o == nil || o.Sum == nil { + var ret float64 + return ret + } + return *o.Sum +} + +// GetSumOk returns a tuple with the Sum field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FacetStats) GetSumOk() (*float64, bool) { + if o == nil || o.Sum == nil { + return nil, false + } + return o.Sum, true +} + +// HasSum returns a boolean if a field has been set. +func (o *FacetStats) HasSum() bool { + if o != nil && o.Sum != nil { + return true + } + + return false +} + +// SetSum gets a reference to the given float64 and assigns it to the Sum field. +func (o *FacetStats) SetSum(v float64) *FacetStats { + o.Sum = &v + return o +} + +func (o FacetStats) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Min != nil { + toSerialize["min"] = o.Min + } + if o.Max != nil { + toSerialize["max"] = o.Max + } + if o.Avg != nil { + toSerialize["avg"] = o.Avg + } + if o.Sum != nil { + toSerialize["sum"] = o.Sum + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal FacetStats: %w", err) + } + + return serialized, nil +} + +func (o FacetStats) String() string { + out := "" + out += fmt.Sprintf(" min=%v\n", o.Min) + out += fmt.Sprintf(" max=%v\n", o.Max) + out += fmt.Sprintf(" avg=%v\n", o.Avg) + out += fmt.Sprintf(" sum=%v\n", o.Sum) + return fmt.Sprintf("FacetStats {\n%s}", out) +} diff --git a/algolia/composition/model_facets.go b/algolia/composition/model_facets.go new file mode 100644 index 000000000..61104dd1a --- /dev/null +++ b/algolia/composition/model_facets.go @@ -0,0 +1,90 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Facets Order of facet names. +type Facets struct { + // Explicit order of facets or facet values. This setting lets you always show specific facets or facet values at the top of the list. + Order []string `json:"order,omitempty"` +} + +type FacetsOption func(f *Facets) + +func WithFacetsOrder(val []string) FacetsOption { + return func(f *Facets) { + f.Order = val + } +} + +// NewFacets instantiates a new Facets object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFacets(opts ...FacetsOption) *Facets { + this := &Facets{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyFacets return a pointer to an empty Facets object. +func NewEmptyFacets() *Facets { + return &Facets{} +} + +// GetOrder returns the Order field value if set, zero value otherwise. +func (o *Facets) GetOrder() []string { + if o == nil || o.Order == nil { + var ret []string + return ret + } + return o.Order +} + +// GetOrderOk returns a tuple with the Order field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Facets) GetOrderOk() ([]string, bool) { + if o == nil || o.Order == nil { + return nil, false + } + return o.Order, true +} + +// HasOrder returns a boolean if a field has been set. +func (o *Facets) HasOrder() bool { + if o != nil && o.Order != nil { + return true + } + + return false +} + +// SetOrder gets a reference to the given []string and assigns it to the Order field. +func (o *Facets) SetOrder(v []string) *Facets { + o.Order = v + return o +} + +func (o Facets) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Order != nil { + toSerialize["order"] = o.Order + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Facets: %w", err) + } + + return serialized, nil +} + +func (o Facets) String() string { + out := "" + out += fmt.Sprintf(" order=%v\n", o.Order) + return fmt.Sprintf("Facets {\n%s}", out) +} diff --git a/algolia/composition/model_highlight_result.go b/algolia/composition/model_highlight_result.go new file mode 100644 index 000000000..db565bbec --- /dev/null +++ b/algolia/composition/model_highlight_result.go @@ -0,0 +1,120 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" + + "github.com/algolia/algoliasearch-client-go/v4/algolia/utils" +) + +// HighlightResult - struct for HighlightResult. +type HighlightResult struct { + HighlightResultOption *HighlightResultOption + ArrayOfHighlightResult *[]HighlightResult + MapmapOfStringHighlightResult *map[string]HighlightResult +} + +// HighlightResultOptionAsHighlightResult is a convenience function that returns HighlightResultOption wrapped in HighlightResult. +func HighlightResultOptionAsHighlightResult(v *HighlightResultOption) *HighlightResult { + return &HighlightResult{ + HighlightResultOption: v, + } +} + +// map[string]HighlightResultAsHighlightResult is a convenience function that returns map[string]HighlightResult wrapped in HighlightResult. +func MapmapOfStringHighlightResultAsHighlightResult(v map[string]HighlightResult) *HighlightResult { + return &HighlightResult{ + MapmapOfStringHighlightResult: &v, + } +} + +// []HighlightResultAsHighlightResult is a convenience function that returns []HighlightResult wrapped in HighlightResult. +func ArrayOfHighlightResultAsHighlightResult(v []HighlightResult) *HighlightResult { + return &HighlightResult{ + ArrayOfHighlightResult: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *HighlightResult) UnmarshalJSON(data []byte) error { + var err error + // use discriminator value to speed up the lookup if possible, if not we will try every possibility + var jsonDict map[string]any + _ = newStrictDecoder(data).Decode(&jsonDict) + if utils.HasKey(jsonDict, "matchLevel") && utils.HasKey(jsonDict, "matchedWords") { + // try to unmarshal data into HighlightResultOption + err = newStrictDecoder(data).Decode(&dst.HighlightResultOption) + if err == nil && validateStruct(dst.HighlightResultOption) == nil { + return nil // found the correct type + } else { + dst.HighlightResultOption = nil + } + } + // try to unmarshal data into MapmapOfStringHighlightResult + err = newStrictDecoder(data).Decode(&dst.MapmapOfStringHighlightResult) + if err == nil && validateStruct(dst.MapmapOfStringHighlightResult) == nil { + return nil // found the correct type + } else { + dst.MapmapOfStringHighlightResult = nil + } + // try to unmarshal data into ArrayOfHighlightResult + err = newStrictDecoder(data).Decode(&dst.ArrayOfHighlightResult) + if err == nil && validateStruct(dst.ArrayOfHighlightResult) == nil { + return nil // found the correct type + } else { + dst.ArrayOfHighlightResult = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(HighlightResult)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src HighlightResult) MarshalJSON() ([]byte, error) { + if src.HighlightResultOption != nil { + serialized, err := json.Marshal(&src.HighlightResultOption) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of HighlightResultOption of HighlightResult: %w", err) + } + + return serialized, nil + } + + if src.ArrayOfHighlightResult != nil { + serialized, err := json.Marshal(&src.ArrayOfHighlightResult) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfHighlightResult of HighlightResult: %w", err) + } + + return serialized, nil + } + + if src.MapmapOfStringHighlightResult != nil { + serialized, err := json.Marshal(&src.MapmapOfStringHighlightResult) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of MapmapOfStringHighlightResult of HighlightResult: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj HighlightResult) GetActualInstance() any { + if obj.HighlightResultOption != nil { + return *obj.HighlightResultOption + } + + if obj.ArrayOfHighlightResult != nil { + return *obj.ArrayOfHighlightResult + } + + if obj.MapmapOfStringHighlightResult != nil { + return *obj.MapmapOfStringHighlightResult + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_highlight_result_option.go b/algolia/composition/model_highlight_result_option.go new file mode 100644 index 000000000..cbad7313d --- /dev/null +++ b/algolia/composition/model_highlight_result_option.go @@ -0,0 +1,185 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// HighlightResultOption Surround words that match the query with HTML tags for highlighting. +type HighlightResultOption struct { + // Highlighted attribute value, including HTML tags. + Value string `json:"value"` + MatchLevel MatchLevel `json:"matchLevel"` + // List of matched words from the search query. + MatchedWords []string `json:"matchedWords"` + // Whether the entire attribute value is highlighted. + FullyHighlighted *bool `json:"fullyHighlighted,omitempty"` +} + +type HighlightResultOptionOption func(f *HighlightResultOption) + +func WithHighlightResultOptionFullyHighlighted(val bool) HighlightResultOptionOption { + return func(f *HighlightResultOption) { + f.FullyHighlighted = &val + } +} + +// NewHighlightResultOption instantiates a new HighlightResultOption object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewHighlightResultOption(value string, matchLevel MatchLevel, matchedWords []string, opts ...HighlightResultOptionOption) *HighlightResultOption { + this := &HighlightResultOption{} + this.Value = value + this.MatchLevel = matchLevel + this.MatchedWords = matchedWords + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyHighlightResultOption return a pointer to an empty HighlightResultOption object. +func NewEmptyHighlightResultOption() *HighlightResultOption { + return &HighlightResultOption{} +} + +// GetValue returns the Value field value. +func (o *HighlightResultOption) GetValue() string { + if o == nil { + var ret string + return ret + } + + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *HighlightResultOption) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *HighlightResultOption) SetValue(v string) *HighlightResultOption { + o.Value = v + return o +} + +// GetMatchLevel returns the MatchLevel field value. +func (o *HighlightResultOption) GetMatchLevel() MatchLevel { + if o == nil { + var ret MatchLevel + return ret + } + + return o.MatchLevel +} + +// GetMatchLevelOk returns a tuple with the MatchLevel field value +// and a boolean to check if the value has been set. +func (o *HighlightResultOption) GetMatchLevelOk() (*MatchLevel, bool) { + if o == nil { + return nil, false + } + return &o.MatchLevel, true +} + +// SetMatchLevel sets field value. +func (o *HighlightResultOption) SetMatchLevel(v MatchLevel) *HighlightResultOption { + o.MatchLevel = v + return o +} + +// GetMatchedWords returns the MatchedWords field value. +func (o *HighlightResultOption) GetMatchedWords() []string { + if o == nil { + var ret []string + return ret + } + + return o.MatchedWords +} + +// GetMatchedWordsOk returns a tuple with the MatchedWords field value +// and a boolean to check if the value has been set. +func (o *HighlightResultOption) GetMatchedWordsOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.MatchedWords, true +} + +// SetMatchedWords sets field value. +func (o *HighlightResultOption) SetMatchedWords(v []string) *HighlightResultOption { + o.MatchedWords = v + return o +} + +// GetFullyHighlighted returns the FullyHighlighted field value if set, zero value otherwise. +func (o *HighlightResultOption) GetFullyHighlighted() bool { + if o == nil || o.FullyHighlighted == nil { + var ret bool + return ret + } + return *o.FullyHighlighted +} + +// GetFullyHighlightedOk returns a tuple with the FullyHighlighted field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HighlightResultOption) GetFullyHighlightedOk() (*bool, bool) { + if o == nil || o.FullyHighlighted == nil { + return nil, false + } + return o.FullyHighlighted, true +} + +// HasFullyHighlighted returns a boolean if a field has been set. +func (o *HighlightResultOption) HasFullyHighlighted() bool { + if o != nil && o.FullyHighlighted != nil { + return true + } + + return false +} + +// SetFullyHighlighted gets a reference to the given bool and assigns it to the FullyHighlighted field. +func (o *HighlightResultOption) SetFullyHighlighted(v bool) *HighlightResultOption { + o.FullyHighlighted = &v + return o +} + +func (o HighlightResultOption) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["value"] = o.Value + } + if true { + toSerialize["matchLevel"] = o.MatchLevel + } + if true { + toSerialize["matchedWords"] = o.MatchedWords + } + if o.FullyHighlighted != nil { + toSerialize["fullyHighlighted"] = o.FullyHighlighted + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal HighlightResultOption: %w", err) + } + + return serialized, nil +} + +func (o HighlightResultOption) String() string { + out := "" + out += fmt.Sprintf(" value=%v\n", o.Value) + out += fmt.Sprintf(" matchLevel=%v\n", o.MatchLevel) + out += fmt.Sprintf(" matchedWords=%v\n", o.MatchedWords) + out += fmt.Sprintf(" fullyHighlighted=%v\n", o.FullyHighlighted) + return fmt.Sprintf("HighlightResultOption {\n%s}", out) +} diff --git a/algolia/composition/model_hit.go b/algolia/composition/model_hit.go new file mode 100644 index 000000000..152775034 --- /dev/null +++ b/algolia/composition/model_hit.go @@ -0,0 +1,303 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Hit Search result. A hit is a record from your index, augmented with special attributes for highlighting, snippeting, and ranking. +type Hit struct { + // Unique record identifier. + ObjectID string `json:"objectID"` + // Surround words that match the query with HTML tags for highlighting. + HighlightResult *map[string]HighlightResult `json:"_highlightResult,omitempty"` + // Snippets that show the context around a matching search query. + SnippetResult *map[string]SnippetResult `json:"_snippetResult,omitempty"` + RankingInfo *HitRankingInfo `json:"_rankingInfo,omitempty"` + DistinctSeqID *int32 `json:"_distinctSeqID,omitempty"` + AdditionalProperties map[string]any +} + +type _Hit Hit + +type HitOption func(f *Hit) + +func WithHitHighlightResult(val map[string]HighlightResult) HitOption { + return func(f *Hit) { + f.HighlightResult = &val + } +} + +func WithHitSnippetResult(val map[string]SnippetResult) HitOption { + return func(f *Hit) { + f.SnippetResult = &val + } +} + +func WithHitRankingInfo(val HitRankingInfo) HitOption { + return func(f *Hit) { + f.RankingInfo = &val + } +} + +func WithHitDistinctSeqID(val int32) HitOption { + return func(f *Hit) { + f.DistinctSeqID = &val + } +} + +// NewHit instantiates a new Hit object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewHit(objectID string, opts ...HitOption) *Hit { + this := &Hit{} + this.ObjectID = objectID + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyHit return a pointer to an empty Hit object. +func NewEmptyHit() *Hit { + return &Hit{} +} + +// GetObjectID returns the ObjectID field value. +func (o *Hit) GetObjectID() string { + if o == nil { + var ret string + return ret + } + + return o.ObjectID +} + +// GetObjectIDOk returns a tuple with the ObjectID field value +// and a boolean to check if the value has been set. +func (o *Hit) GetObjectIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ObjectID, true +} + +// SetObjectID sets field value. +func (o *Hit) SetObjectID(v string) *Hit { + o.ObjectID = v + return o +} + +// GetHighlightResult returns the HighlightResult field value if set, zero value otherwise. +func (o *Hit) GetHighlightResult() map[string]HighlightResult { + if o == nil || o.HighlightResult == nil { + var ret map[string]HighlightResult + return ret + } + return *o.HighlightResult +} + +// GetHighlightResultOk returns a tuple with the HighlightResult field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Hit) GetHighlightResultOk() (*map[string]HighlightResult, bool) { + if o == nil || o.HighlightResult == nil { + return nil, false + } + return o.HighlightResult, true +} + +// HasHighlightResult returns a boolean if a field has been set. +func (o *Hit) HasHighlightResult() bool { + if o != nil && o.HighlightResult != nil { + return true + } + + return false +} + +// SetHighlightResult gets a reference to the given map[string]HighlightResult and assigns it to the HighlightResult field. +func (o *Hit) SetHighlightResult(v map[string]HighlightResult) *Hit { + o.HighlightResult = &v + return o +} + +// GetSnippetResult returns the SnippetResult field value if set, zero value otherwise. +func (o *Hit) GetSnippetResult() map[string]SnippetResult { + if o == nil || o.SnippetResult == nil { + var ret map[string]SnippetResult + return ret + } + return *o.SnippetResult +} + +// GetSnippetResultOk returns a tuple with the SnippetResult field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Hit) GetSnippetResultOk() (*map[string]SnippetResult, bool) { + if o == nil || o.SnippetResult == nil { + return nil, false + } + return o.SnippetResult, true +} + +// HasSnippetResult returns a boolean if a field has been set. +func (o *Hit) HasSnippetResult() bool { + if o != nil && o.SnippetResult != nil { + return true + } + + return false +} + +// SetSnippetResult gets a reference to the given map[string]SnippetResult and assigns it to the SnippetResult field. +func (o *Hit) SetSnippetResult(v map[string]SnippetResult) *Hit { + o.SnippetResult = &v + return o +} + +// GetRankingInfo returns the RankingInfo field value if set, zero value otherwise. +func (o *Hit) GetRankingInfo() HitRankingInfo { + if o == nil || o.RankingInfo == nil { + var ret HitRankingInfo + return ret + } + return *o.RankingInfo +} + +// GetRankingInfoOk returns a tuple with the RankingInfo field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Hit) GetRankingInfoOk() (*HitRankingInfo, bool) { + if o == nil || o.RankingInfo == nil { + return nil, false + } + return o.RankingInfo, true +} + +// HasRankingInfo returns a boolean if a field has been set. +func (o *Hit) HasRankingInfo() bool { + if o != nil && o.RankingInfo != nil { + return true + } + + return false +} + +// SetRankingInfo gets a reference to the given HitRankingInfo and assigns it to the RankingInfo field. +func (o *Hit) SetRankingInfo(v *HitRankingInfo) *Hit { + o.RankingInfo = v + return o +} + +// GetDistinctSeqID returns the DistinctSeqID field value if set, zero value otherwise. +func (o *Hit) GetDistinctSeqID() int32 { + if o == nil || o.DistinctSeqID == nil { + var ret int32 + return ret + } + return *o.DistinctSeqID +} + +// GetDistinctSeqIDOk returns a tuple with the DistinctSeqID field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Hit) GetDistinctSeqIDOk() (*int32, bool) { + if o == nil || o.DistinctSeqID == nil { + return nil, false + } + return o.DistinctSeqID, true +} + +// HasDistinctSeqID returns a boolean if a field has been set. +func (o *Hit) HasDistinctSeqID() bool { + if o != nil && o.DistinctSeqID != nil { + return true + } + + return false +} + +// SetDistinctSeqID gets a reference to the given int32 and assigns it to the DistinctSeqID field. +func (o *Hit) SetDistinctSeqID(v int32) *Hit { + o.DistinctSeqID = &v + return o +} + +func (o *Hit) SetAdditionalProperty(key string, value any) *Hit { + if o.AdditionalProperties == nil { + o.AdditionalProperties = make(map[string]any) + } + + o.AdditionalProperties[key] = value + + return o +} + +func (o Hit) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["objectID"] = o.ObjectID + } + if o.HighlightResult != nil { + toSerialize["_highlightResult"] = o.HighlightResult + } + if o.SnippetResult != nil { + toSerialize["_snippetResult"] = o.SnippetResult + } + if o.RankingInfo != nil { + toSerialize["_rankingInfo"] = o.RankingInfo + } + if o.DistinctSeqID != nil { + toSerialize["_distinctSeqID"] = o.DistinctSeqID + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Hit: %w", err) + } + + return serialized, nil +} + +func (o *Hit) UnmarshalJSON(bytes []byte) error { + varHit := _Hit{} + + err := json.Unmarshal(bytes, &varHit) + if err != nil { + return fmt.Errorf("failed to unmarshal Hit: %w", err) + } + + *o = Hit(varHit) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in Hit: %w", err) + } + + delete(additionalProperties, "objectID") + delete(additionalProperties, "_highlightResult") + delete(additionalProperties, "_snippetResult") + delete(additionalProperties, "_rankingInfo") + delete(additionalProperties, "_distinctSeqID") + o.AdditionalProperties = additionalProperties + + return nil +} + +func (o Hit) String() string { + out := "" + out += fmt.Sprintf(" objectID=%v\n", o.ObjectID) + out += fmt.Sprintf(" _highlightResult=%v\n", o.HighlightResult) + out += fmt.Sprintf(" _snippetResult=%v\n", o.SnippetResult) + out += fmt.Sprintf(" _rankingInfo=%v\n", o.RankingInfo) + out += fmt.Sprintf(" _distinctSeqID=%v\n", o.DistinctSeqID) + for key, value := range o.AdditionalProperties { + out += fmt.Sprintf(" %s=%v\n", key, value) + } + return fmt.Sprintf("Hit {\n%s}", out) +} diff --git a/algolia/composition/model_hit_ranking_info.go b/algolia/composition/model_hit_ranking_info.go new file mode 100644 index 000000000..856b2c6fd --- /dev/null +++ b/algolia/composition/model_hit_ranking_info.go @@ -0,0 +1,607 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// HitRankingInfo struct for HitRankingInfo. +type HitRankingInfo struct { + // Whether a filter matched the query. + Filters *int32 `json:"filters,omitempty"` + // Position of the first matched word in the best matching attribute of the record. + FirstMatchedWord int32 `json:"firstMatchedWord"` + // 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). + GeoDistance int32 `json:"geoDistance"` + // Precision used when computing the geo distance, in meters. + GeoPrecision *int32 `json:"geoPrecision,omitempty"` + MatchedGeoLocation *MatchedGeoLocation `json:"matchedGeoLocation,omitempty"` + Personalization *Personalization `json:"personalization,omitempty"` + // Number of exactly matched words. + NbExactWords int32 `json:"nbExactWords"` + // Number of typos encountered when matching the record. + NbTypos int32 `json:"nbTypos"` + // Whether the record was promoted by a rule. + Promoted *bool `json:"promoted,omitempty"` + // Number of words between multiple matches in the query plus 1. For single word queries, `proximityDistance` is 0. + ProximityDistance *int32 `json:"proximityDistance,omitempty"` + // Overall ranking of the record, expressed as a single integer. This attribute is internal. + UserScore int32 `json:"userScore"` + // Number of matched words. + Words *int32 `json:"words,omitempty"` + // Whether the record is re-ranked. + PromotedByReRanking *bool `json:"promotedByReRanking,omitempty"` + Composed *map[string]CompositionIdRankingInfo `json:"composed,omitempty"` +} + +type HitRankingInfoOption func(f *HitRankingInfo) + +func WithHitRankingInfoFilters(val int32) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.Filters = &val + } +} + +func WithHitRankingInfoGeoPrecision(val int32) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.GeoPrecision = &val + } +} + +func WithHitRankingInfoMatchedGeoLocation(val MatchedGeoLocation) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.MatchedGeoLocation = &val + } +} + +func WithHitRankingInfoPersonalization(val Personalization) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.Personalization = &val + } +} + +func WithHitRankingInfoPromoted(val bool) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.Promoted = &val + } +} + +func WithHitRankingInfoProximityDistance(val int32) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.ProximityDistance = &val + } +} + +func WithHitRankingInfoWords(val int32) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.Words = &val + } +} + +func WithHitRankingInfoPromotedByReRanking(val bool) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.PromotedByReRanking = &val + } +} + +func WithHitRankingInfoComposed(val map[string]CompositionIdRankingInfo) HitRankingInfoOption { + return func(f *HitRankingInfo) { + f.Composed = &val + } +} + +// NewHitRankingInfo instantiates a new HitRankingInfo object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewHitRankingInfo(firstMatchedWord int32, geoDistance int32, nbExactWords int32, nbTypos int32, userScore int32, opts ...HitRankingInfoOption) *HitRankingInfo { + this := &HitRankingInfo{} + this.FirstMatchedWord = firstMatchedWord + this.GeoDistance = geoDistance + this.NbExactWords = nbExactWords + this.NbTypos = nbTypos + this.UserScore = userScore + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyHitRankingInfo return a pointer to an empty HitRankingInfo object. +func NewEmptyHitRankingInfo() *HitRankingInfo { + return &HitRankingInfo{} +} + +// GetFilters returns the Filters field value if set, zero value otherwise. +func (o *HitRankingInfo) GetFilters() int32 { + if o == nil || o.Filters == nil { + var ret int32 + return ret + } + return *o.Filters +} + +// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetFiltersOk() (*int32, bool) { + if o == nil || o.Filters == nil { + return nil, false + } + return o.Filters, true +} + +// HasFilters returns a boolean if a field has been set. +func (o *HitRankingInfo) HasFilters() bool { + if o != nil && o.Filters != nil { + return true + } + + return false +} + +// SetFilters gets a reference to the given int32 and assigns it to the Filters field. +func (o *HitRankingInfo) SetFilters(v int32) *HitRankingInfo { + o.Filters = &v + return o +} + +// GetFirstMatchedWord returns the FirstMatchedWord field value. +func (o *HitRankingInfo) GetFirstMatchedWord() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.FirstMatchedWord +} + +// GetFirstMatchedWordOk returns a tuple with the FirstMatchedWord field value +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetFirstMatchedWordOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.FirstMatchedWord, true +} + +// SetFirstMatchedWord sets field value. +func (o *HitRankingInfo) SetFirstMatchedWord(v int32) *HitRankingInfo { + o.FirstMatchedWord = v + return o +} + +// GetGeoDistance returns the GeoDistance field value. +func (o *HitRankingInfo) GetGeoDistance() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.GeoDistance +} + +// GetGeoDistanceOk returns a tuple with the GeoDistance field value +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetGeoDistanceOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.GeoDistance, true +} + +// SetGeoDistance sets field value. +func (o *HitRankingInfo) SetGeoDistance(v int32) *HitRankingInfo { + o.GeoDistance = v + return o +} + +// GetGeoPrecision returns the GeoPrecision field value if set, zero value otherwise. +func (o *HitRankingInfo) GetGeoPrecision() int32 { + if o == nil || o.GeoPrecision == nil { + var ret int32 + return ret + } + return *o.GeoPrecision +} + +// GetGeoPrecisionOk returns a tuple with the GeoPrecision field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetGeoPrecisionOk() (*int32, bool) { + if o == nil || o.GeoPrecision == nil { + return nil, false + } + return o.GeoPrecision, true +} + +// HasGeoPrecision returns a boolean if a field has been set. +func (o *HitRankingInfo) HasGeoPrecision() bool { + if o != nil && o.GeoPrecision != nil { + return true + } + + return false +} + +// SetGeoPrecision gets a reference to the given int32 and assigns it to the GeoPrecision field. +func (o *HitRankingInfo) SetGeoPrecision(v int32) *HitRankingInfo { + o.GeoPrecision = &v + return o +} + +// GetMatchedGeoLocation returns the MatchedGeoLocation field value if set, zero value otherwise. +func (o *HitRankingInfo) GetMatchedGeoLocation() MatchedGeoLocation { + if o == nil || o.MatchedGeoLocation == nil { + var ret MatchedGeoLocation + return ret + } + return *o.MatchedGeoLocation +} + +// GetMatchedGeoLocationOk returns a tuple with the MatchedGeoLocation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetMatchedGeoLocationOk() (*MatchedGeoLocation, bool) { + if o == nil || o.MatchedGeoLocation == nil { + return nil, false + } + return o.MatchedGeoLocation, true +} + +// HasMatchedGeoLocation returns a boolean if a field has been set. +func (o *HitRankingInfo) HasMatchedGeoLocation() bool { + if o != nil && o.MatchedGeoLocation != nil { + return true + } + + return false +} + +// SetMatchedGeoLocation gets a reference to the given MatchedGeoLocation and assigns it to the MatchedGeoLocation field. +func (o *HitRankingInfo) SetMatchedGeoLocation(v *MatchedGeoLocation) *HitRankingInfo { + o.MatchedGeoLocation = v + return o +} + +// GetPersonalization returns the Personalization field value if set, zero value otherwise. +func (o *HitRankingInfo) GetPersonalization() Personalization { + if o == nil || o.Personalization == nil { + var ret Personalization + return ret + } + return *o.Personalization +} + +// GetPersonalizationOk returns a tuple with the Personalization field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetPersonalizationOk() (*Personalization, bool) { + if o == nil || o.Personalization == nil { + return nil, false + } + return o.Personalization, true +} + +// HasPersonalization returns a boolean if a field has been set. +func (o *HitRankingInfo) HasPersonalization() bool { + if o != nil && o.Personalization != nil { + return true + } + + return false +} + +// SetPersonalization gets a reference to the given Personalization and assigns it to the Personalization field. +func (o *HitRankingInfo) SetPersonalization(v *Personalization) *HitRankingInfo { + o.Personalization = v + return o +} + +// GetNbExactWords returns the NbExactWords field value. +func (o *HitRankingInfo) GetNbExactWords() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.NbExactWords +} + +// GetNbExactWordsOk returns a tuple with the NbExactWords field value +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetNbExactWordsOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.NbExactWords, true +} + +// SetNbExactWords sets field value. +func (o *HitRankingInfo) SetNbExactWords(v int32) *HitRankingInfo { + o.NbExactWords = v + return o +} + +// GetNbTypos returns the NbTypos field value. +func (o *HitRankingInfo) GetNbTypos() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.NbTypos +} + +// GetNbTyposOk returns a tuple with the NbTypos field value +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetNbTyposOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.NbTypos, true +} + +// SetNbTypos sets field value. +func (o *HitRankingInfo) SetNbTypos(v int32) *HitRankingInfo { + o.NbTypos = v + return o +} + +// GetPromoted returns the Promoted field value if set, zero value otherwise. +func (o *HitRankingInfo) GetPromoted() bool { + if o == nil || o.Promoted == nil { + var ret bool + return ret + } + return *o.Promoted +} + +// GetPromotedOk returns a tuple with the Promoted field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetPromotedOk() (*bool, bool) { + if o == nil || o.Promoted == nil { + return nil, false + } + return o.Promoted, true +} + +// HasPromoted returns a boolean if a field has been set. +func (o *HitRankingInfo) HasPromoted() bool { + if o != nil && o.Promoted != nil { + return true + } + + return false +} + +// SetPromoted gets a reference to the given bool and assigns it to the Promoted field. +func (o *HitRankingInfo) SetPromoted(v bool) *HitRankingInfo { + o.Promoted = &v + return o +} + +// GetProximityDistance returns the ProximityDistance field value if set, zero value otherwise. +func (o *HitRankingInfo) GetProximityDistance() int32 { + if o == nil || o.ProximityDistance == nil { + var ret int32 + return ret + } + return *o.ProximityDistance +} + +// GetProximityDistanceOk returns a tuple with the ProximityDistance field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetProximityDistanceOk() (*int32, bool) { + if o == nil || o.ProximityDistance == nil { + return nil, false + } + return o.ProximityDistance, true +} + +// HasProximityDistance returns a boolean if a field has been set. +func (o *HitRankingInfo) HasProximityDistance() bool { + if o != nil && o.ProximityDistance != nil { + return true + } + + return false +} + +// SetProximityDistance gets a reference to the given int32 and assigns it to the ProximityDistance field. +func (o *HitRankingInfo) SetProximityDistance(v int32) *HitRankingInfo { + o.ProximityDistance = &v + return o +} + +// GetUserScore returns the UserScore field value. +func (o *HitRankingInfo) GetUserScore() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.UserScore +} + +// GetUserScoreOk returns a tuple with the UserScore field value +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetUserScoreOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.UserScore, true +} + +// SetUserScore sets field value. +func (o *HitRankingInfo) SetUserScore(v int32) *HitRankingInfo { + o.UserScore = v + return o +} + +// GetWords returns the Words field value if set, zero value otherwise. +func (o *HitRankingInfo) GetWords() int32 { + if o == nil || o.Words == nil { + var ret int32 + return ret + } + return *o.Words +} + +// GetWordsOk returns a tuple with the Words field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetWordsOk() (*int32, bool) { + if o == nil || o.Words == nil { + return nil, false + } + return o.Words, true +} + +// HasWords returns a boolean if a field has been set. +func (o *HitRankingInfo) HasWords() bool { + if o != nil && o.Words != nil { + return true + } + + return false +} + +// SetWords gets a reference to the given int32 and assigns it to the Words field. +func (o *HitRankingInfo) SetWords(v int32) *HitRankingInfo { + o.Words = &v + return o +} + +// GetPromotedByReRanking returns the PromotedByReRanking field value if set, zero value otherwise. +func (o *HitRankingInfo) GetPromotedByReRanking() bool { + if o == nil || o.PromotedByReRanking == nil { + var ret bool + return ret + } + return *o.PromotedByReRanking +} + +// GetPromotedByReRankingOk returns a tuple with the PromotedByReRanking field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetPromotedByReRankingOk() (*bool, bool) { + if o == nil || o.PromotedByReRanking == nil { + return nil, false + } + return o.PromotedByReRanking, true +} + +// HasPromotedByReRanking returns a boolean if a field has been set. +func (o *HitRankingInfo) HasPromotedByReRanking() bool { + if o != nil && o.PromotedByReRanking != nil { + return true + } + + return false +} + +// SetPromotedByReRanking gets a reference to the given bool and assigns it to the PromotedByReRanking field. +func (o *HitRankingInfo) SetPromotedByReRanking(v bool) *HitRankingInfo { + o.PromotedByReRanking = &v + return o +} + +// GetComposed returns the Composed field value if set, zero value otherwise. +func (o *HitRankingInfo) GetComposed() map[string]CompositionIdRankingInfo { + if o == nil || o.Composed == nil { + var ret map[string]CompositionIdRankingInfo + return ret + } + return *o.Composed +} + +// GetComposedOk returns a tuple with the Composed field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HitRankingInfo) GetComposedOk() (*map[string]CompositionIdRankingInfo, bool) { + if o == nil || o.Composed == nil { + return nil, false + } + return o.Composed, true +} + +// HasComposed returns a boolean if a field has been set. +func (o *HitRankingInfo) HasComposed() bool { + if o != nil && o.Composed != nil { + return true + } + + return false +} + +// SetComposed gets a reference to the given map[string]CompositionIdRankingInfo and assigns it to the Composed field. +func (o *HitRankingInfo) SetComposed(v map[string]CompositionIdRankingInfo) *HitRankingInfo { + o.Composed = &v + return o +} + +func (o HitRankingInfo) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Filters != nil { + toSerialize["filters"] = o.Filters + } + if true { + toSerialize["firstMatchedWord"] = o.FirstMatchedWord + } + if true { + toSerialize["geoDistance"] = o.GeoDistance + } + if o.GeoPrecision != nil { + toSerialize["geoPrecision"] = o.GeoPrecision + } + if o.MatchedGeoLocation != nil { + toSerialize["matchedGeoLocation"] = o.MatchedGeoLocation + } + if o.Personalization != nil { + toSerialize["personalization"] = o.Personalization + } + if true { + toSerialize["nbExactWords"] = o.NbExactWords + } + if true { + toSerialize["nbTypos"] = o.NbTypos + } + if o.Promoted != nil { + toSerialize["promoted"] = o.Promoted + } + if o.ProximityDistance != nil { + toSerialize["proximityDistance"] = o.ProximityDistance + } + if true { + toSerialize["userScore"] = o.UserScore + } + if o.Words != nil { + toSerialize["words"] = o.Words + } + if o.PromotedByReRanking != nil { + toSerialize["promotedByReRanking"] = o.PromotedByReRanking + } + if o.Composed != nil { + toSerialize["composed"] = o.Composed + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal HitRankingInfo: %w", err) + } + + return serialized, nil +} + +func (o HitRankingInfo) String() string { + out := "" + out += fmt.Sprintf(" filters=%v\n", o.Filters) + out += fmt.Sprintf(" firstMatchedWord=%v\n", o.FirstMatchedWord) + out += fmt.Sprintf(" geoDistance=%v\n", o.GeoDistance) + out += fmt.Sprintf(" geoPrecision=%v\n", o.GeoPrecision) + out += fmt.Sprintf(" matchedGeoLocation=%v\n", o.MatchedGeoLocation) + out += fmt.Sprintf(" personalization=%v\n", o.Personalization) + out += fmt.Sprintf(" nbExactWords=%v\n", o.NbExactWords) + out += fmt.Sprintf(" nbTypos=%v\n", o.NbTypos) + out += fmt.Sprintf(" promoted=%v\n", o.Promoted) + out += fmt.Sprintf(" proximityDistance=%v\n", o.ProximityDistance) + out += fmt.Sprintf(" userScore=%v\n", o.UserScore) + out += fmt.Sprintf(" words=%v\n", o.Words) + out += fmt.Sprintf(" promotedByReRanking=%v\n", o.PromotedByReRanking) + out += fmt.Sprintf(" composed=%v\n", o.Composed) + return fmt.Sprintf("HitRankingInfo {\n%s}", out) +} diff --git a/algolia/composition/model_inside_bounding_box.go b/algolia/composition/model_inside_bounding_box.go new file mode 100644 index 000000000..b6a88a9e2 --- /dev/null +++ b/algolia/composition/model_inside_bounding_box.go @@ -0,0 +1,90 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// InsideBoundingBox - struct for InsideBoundingBox. +type InsideBoundingBox struct { + ArrayOfArrayOfFloat64 *[][]float64 + String *string +} + +// stringAsInsideBoundingBox is a convenience function that returns string wrapped in InsideBoundingBox. +func StringAsInsideBoundingBox(v string) *InsideBoundingBox { + return &InsideBoundingBox{ + String: &v, + } +} + +// [][]float64AsInsideBoundingBox is a convenience function that returns [][]float64 wrapped in InsideBoundingBox. +func ArrayOfArrayOfFloat64AsInsideBoundingBox(v [][]float64) *InsideBoundingBox { + return &InsideBoundingBox{ + ArrayOfArrayOfFloat64: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *InsideBoundingBox) UnmarshalJSON(data []byte) error { + var err error + // this object is nullable so check if the payload is null or empty string + if string(data) == "" || string(data) == "{}" { + return nil + } + + // try to unmarshal data into String + err = newStrictDecoder(data).Decode(&dst.String) + if err == nil && validateStruct(dst.String) == nil { + return nil // found the correct type + } else { + dst.String = nil + } + // try to unmarshal data into ArrayOfArrayOfFloat64 + err = newStrictDecoder(data).Decode(&dst.ArrayOfArrayOfFloat64) + if err == nil && validateStruct(dst.ArrayOfArrayOfFloat64) == nil { + return nil // found the correct type + } else { + dst.ArrayOfArrayOfFloat64 = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(InsideBoundingBox)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src InsideBoundingBox) MarshalJSON() ([]byte, error) { + if src.ArrayOfArrayOfFloat64 != nil { + serialized, err := json.Marshal(&src.ArrayOfArrayOfFloat64) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfArrayOfFloat64 of InsideBoundingBox: %w", err) + } + + return serialized, nil + } + + if src.String != nil { + serialized, err := json.Marshal(&src.String) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of String of InsideBoundingBox: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj InsideBoundingBox) GetActualInstance() any { + if obj.ArrayOfArrayOfFloat64 != nil { + return *obj.ArrayOfArrayOfFloat64 + } + + if obj.String != nil { + return *obj.String + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_match_level.go b/algolia/composition/model_match_level.go new file mode 100644 index 000000000..99c05970a --- /dev/null +++ b/algolia/composition/model_match_level.go @@ -0,0 +1,67 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// MatchLevel Whether the whole query string matches or only a part. +type MatchLevel string + +// List of matchLevel. +const ( + MATCH_LEVEL_NONE MatchLevel = "none" + MATCH_LEVEL_PARTIAL MatchLevel = "partial" + MATCH_LEVEL_FULL MatchLevel = "full" +) + +// All allowed values of MatchLevel enum. +var AllowedMatchLevelEnumValues = []MatchLevel{ + "none", + "partial", + "full", +} + +func (v *MatchLevel) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return fmt.Errorf("failed to unmarshal value '%s' for enum 'MatchLevel': %w", string(src), err) + } + enumTypeValue := MatchLevel(value) + for _, existing := range AllowedMatchLevelEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid MatchLevel", value) +} + +// NewMatchLevelFromValue returns a pointer to a valid MatchLevel +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMatchLevelFromValue(v string) (*MatchLevel, error) { + ev := MatchLevel(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for MatchLevel: valid values are %v", v, AllowedMatchLevelEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v MatchLevel) IsValid() bool { + for _, existing := range AllowedMatchLevelEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to matchLevel value. +func (v MatchLevel) Ptr() *MatchLevel { + return &v +} diff --git a/algolia/composition/model_matched_geo_location.go b/algolia/composition/model_matched_geo_location.go new file mode 100644 index 000000000..49a52ca4f --- /dev/null +++ b/algolia/composition/model_matched_geo_location.go @@ -0,0 +1,180 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// MatchedGeoLocation struct for MatchedGeoLocation. +type MatchedGeoLocation struct { + // Latitude of the matched location. + Lat *float64 `json:"lat,omitempty"` + // Longitude of the matched location. + Lng *float64 `json:"lng,omitempty"` + // Distance between the matched location and the search location (in meters). + Distance *int32 `json:"distance,omitempty"` +} + +type MatchedGeoLocationOption func(f *MatchedGeoLocation) + +func WithMatchedGeoLocationLat(val float64) MatchedGeoLocationOption { + return func(f *MatchedGeoLocation) { + f.Lat = &val + } +} + +func WithMatchedGeoLocationLng(val float64) MatchedGeoLocationOption { + return func(f *MatchedGeoLocation) { + f.Lng = &val + } +} + +func WithMatchedGeoLocationDistance(val int32) MatchedGeoLocationOption { + return func(f *MatchedGeoLocation) { + f.Distance = &val + } +} + +// NewMatchedGeoLocation instantiates a new MatchedGeoLocation object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewMatchedGeoLocation(opts ...MatchedGeoLocationOption) *MatchedGeoLocation { + this := &MatchedGeoLocation{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyMatchedGeoLocation return a pointer to an empty MatchedGeoLocation object. +func NewEmptyMatchedGeoLocation() *MatchedGeoLocation { + return &MatchedGeoLocation{} +} + +// GetLat returns the Lat field value if set, zero value otherwise. +func (o *MatchedGeoLocation) GetLat() float64 { + if o == nil || o.Lat == nil { + var ret float64 + return ret + } + return *o.Lat +} + +// GetLatOk returns a tuple with the Lat field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MatchedGeoLocation) GetLatOk() (*float64, bool) { + if o == nil || o.Lat == nil { + return nil, false + } + return o.Lat, true +} + +// HasLat returns a boolean if a field has been set. +func (o *MatchedGeoLocation) HasLat() bool { + if o != nil && o.Lat != nil { + return true + } + + return false +} + +// SetLat gets a reference to the given float64 and assigns it to the Lat field. +func (o *MatchedGeoLocation) SetLat(v float64) *MatchedGeoLocation { + o.Lat = &v + return o +} + +// GetLng returns the Lng field value if set, zero value otherwise. +func (o *MatchedGeoLocation) GetLng() float64 { + if o == nil || o.Lng == nil { + var ret float64 + return ret + } + return *o.Lng +} + +// GetLngOk returns a tuple with the Lng field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MatchedGeoLocation) GetLngOk() (*float64, bool) { + if o == nil || o.Lng == nil { + return nil, false + } + return o.Lng, true +} + +// HasLng returns a boolean if a field has been set. +func (o *MatchedGeoLocation) HasLng() bool { + if o != nil && o.Lng != nil { + return true + } + + return false +} + +// SetLng gets a reference to the given float64 and assigns it to the Lng field. +func (o *MatchedGeoLocation) SetLng(v float64) *MatchedGeoLocation { + o.Lng = &v + return o +} + +// GetDistance returns the Distance field value if set, zero value otherwise. +func (o *MatchedGeoLocation) GetDistance() int32 { + if o == nil || o.Distance == nil { + var ret int32 + return ret + } + return *o.Distance +} + +// GetDistanceOk returns a tuple with the Distance field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MatchedGeoLocation) GetDistanceOk() (*int32, bool) { + if o == nil || o.Distance == nil { + return nil, false + } + return o.Distance, true +} + +// HasDistance returns a boolean if a field has been set. +func (o *MatchedGeoLocation) HasDistance() bool { + if o != nil && o.Distance != nil { + return true + } + + return false +} + +// SetDistance gets a reference to the given int32 and assigns it to the Distance field. +func (o *MatchedGeoLocation) SetDistance(v int32) *MatchedGeoLocation { + o.Distance = &v + return o +} + +func (o MatchedGeoLocation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Lat != nil { + toSerialize["lat"] = o.Lat + } + if o.Lng != nil { + toSerialize["lng"] = o.Lng + } + if o.Distance != nil { + toSerialize["distance"] = o.Distance + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal MatchedGeoLocation: %w", err) + } + + return serialized, nil +} + +func (o MatchedGeoLocation) String() string { + out := "" + out += fmt.Sprintf(" lat=%v\n", o.Lat) + out += fmt.Sprintf(" lng=%v\n", o.Lng) + out += fmt.Sprintf(" distance=%v\n", o.Distance) + return fmt.Sprintf("MatchedGeoLocation {\n%s}", out) +} diff --git a/algolia/composition/model_model_range.go b/algolia/composition/model_model_range.go new file mode 100644 index 000000000..ca6d14896 --- /dev/null +++ b/algolia/composition/model_model_range.go @@ -0,0 +1,135 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// ModelRange Range object with lower and upper values in meters to define custom ranges. +type ModelRange struct { + // Lower boundary of a range in meters. The Geo ranking criterion considers all records within the range to be equal. + From *int32 `json:"from,omitempty"` + // Upper boundary of a range in meters. The Geo ranking criterion considers all records within the range to be equal. + Value *int32 `json:"value,omitempty"` +} + +type ModelRangeOption func(f *ModelRange) + +func WithModelRangeFrom(val int32) ModelRangeOption { + return func(f *ModelRange) { + f.From = &val + } +} + +func WithModelRangeValue(val int32) ModelRangeOption { + return func(f *ModelRange) { + f.Value = &val + } +} + +// NewModelRange instantiates a new ModelRange object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewModelRange(opts ...ModelRangeOption) *ModelRange { + this := &ModelRange{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyModelRange return a pointer to an empty ModelRange object. +func NewEmptyModelRange() *ModelRange { + return &ModelRange{} +} + +// GetFrom returns the From field value if set, zero value otherwise. +func (o *ModelRange) GetFrom() int32 { + if o == nil || o.From == nil { + var ret int32 + return ret + } + return *o.From +} + +// GetFromOk returns a tuple with the From field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelRange) GetFromOk() (*int32, bool) { + if o == nil || o.From == nil { + return nil, false + } + return o.From, true +} + +// HasFrom returns a boolean if a field has been set. +func (o *ModelRange) HasFrom() bool { + if o != nil && o.From != nil { + return true + } + + return false +} + +// SetFrom gets a reference to the given int32 and assigns it to the From field. +func (o *ModelRange) SetFrom(v int32) *ModelRange { + o.From = &v + return o +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *ModelRange) GetValue() int32 { + if o == nil || o.Value == nil { + var ret int32 + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelRange) GetValueOk() (*int32, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *ModelRange) HasValue() bool { + if o != nil && o.Value != nil { + return true + } + + return false +} + +// SetValue gets a reference to the given int32 and assigns it to the Value field. +func (o *ModelRange) SetValue(v int32) *ModelRange { + o.Value = &v + return o +} + +func (o ModelRange) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.From != nil { + toSerialize["from"] = o.From + } + if o.Value != nil { + toSerialize["value"] = o.Value + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal ModelRange: %w", err) + } + + return serialized, nil +} + +func (o ModelRange) String() string { + out := "" + out += fmt.Sprintf(" from=%v\n", o.From) + out += fmt.Sprintf(" value=%v\n", o.Value) + return fmt.Sprintf("ModelRange {\n%s}", out) +} diff --git a/algolia/composition/model_numeric_filters.go b/algolia/composition/model_numeric_filters.go new file mode 100644 index 000000000..ec57fdf17 --- /dev/null +++ b/algolia/composition/model_numeric_filters.go @@ -0,0 +1,85 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// NumericFilters - 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`. +type NumericFilters struct { + ArrayOfNumericFilters *[]NumericFilters + String *string +} + +// []NumericFiltersAsNumericFilters is a convenience function that returns []NumericFilters wrapped in NumericFilters. +func ArrayOfNumericFiltersAsNumericFilters(v []NumericFilters) *NumericFilters { + return &NumericFilters{ + ArrayOfNumericFilters: &v, + } +} + +// stringAsNumericFilters is a convenience function that returns string wrapped in NumericFilters. +func StringAsNumericFilters(v string) *NumericFilters { + return &NumericFilters{ + String: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *NumericFilters) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal data into ArrayOfNumericFilters + err = newStrictDecoder(data).Decode(&dst.ArrayOfNumericFilters) + if err == nil && validateStruct(dst.ArrayOfNumericFilters) == nil { + return nil // found the correct type + } else { + dst.ArrayOfNumericFilters = nil + } + // try to unmarshal data into String + err = newStrictDecoder(data).Decode(&dst.String) + if err == nil && validateStruct(dst.String) == nil { + return nil // found the correct type + } else { + dst.String = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(NumericFilters)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src NumericFilters) MarshalJSON() ([]byte, error) { + if src.ArrayOfNumericFilters != nil { + serialized, err := json.Marshal(&src.ArrayOfNumericFilters) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfNumericFilters of NumericFilters: %w", err) + } + + return serialized, nil + } + + if src.String != nil { + serialized, err := json.Marshal(&src.String) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of String of NumericFilters: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj NumericFilters) GetActualInstance() any { + if obj.ArrayOfNumericFilters != nil { + return *obj.ArrayOfNumericFilters + } + + if obj.String != nil { + return *obj.String + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_optional_filters.go b/algolia/composition/model_optional_filters.go new file mode 100644 index 000000000..e869a7fca --- /dev/null +++ b/algolia/composition/model_optional_filters.go @@ -0,0 +1,85 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// OptionalFilters - 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. +type OptionalFilters struct { + ArrayOfOptionalFilters *[]OptionalFilters + String *string +} + +// []OptionalFiltersAsOptionalFilters is a convenience function that returns []OptionalFilters wrapped in OptionalFilters. +func ArrayOfOptionalFiltersAsOptionalFilters(v []OptionalFilters) *OptionalFilters { + return &OptionalFilters{ + ArrayOfOptionalFilters: &v, + } +} + +// stringAsOptionalFilters is a convenience function that returns string wrapped in OptionalFilters. +func StringAsOptionalFilters(v string) *OptionalFilters { + return &OptionalFilters{ + String: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *OptionalFilters) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal data into ArrayOfOptionalFilters + err = newStrictDecoder(data).Decode(&dst.ArrayOfOptionalFilters) + if err == nil && validateStruct(dst.ArrayOfOptionalFilters) == nil { + return nil // found the correct type + } else { + dst.ArrayOfOptionalFilters = nil + } + // try to unmarshal data into String + err = newStrictDecoder(data).Decode(&dst.String) + if err == nil && validateStruct(dst.String) == nil { + return nil // found the correct type + } else { + dst.String = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(OptionalFilters)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src OptionalFilters) MarshalJSON() ([]byte, error) { + if src.ArrayOfOptionalFilters != nil { + serialized, err := json.Marshal(&src.ArrayOfOptionalFilters) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfOptionalFilters of OptionalFilters: %w", err) + } + + return serialized, nil + } + + if src.String != nil { + serialized, err := json.Marshal(&src.String) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of String of OptionalFilters: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj OptionalFilters) GetActualInstance() any { + if obj.ArrayOfOptionalFilters != nil { + return *obj.ArrayOfOptionalFilters + } + + if obj.String != nil { + return *obj.String + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_params.go b/algolia/composition/model_params.go new file mode 100644 index 000000000..1021e23b4 --- /dev/null +++ b/algolia/composition/model_params.go @@ -0,0 +1,1221 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" + + "github.com/algolia/algoliasearch-client-go/v4/algolia/utils" +) + +// Params struct for Params. +type Params struct { + // Search query. + Query *string `json:"query,omitempty"` + // 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/). + Filters *string `json:"filters,omitempty"` + // Page of search results to retrieve. + Page *int32 `json:"page,omitempty"` + // Whether the search response should include detailed ranking information. + GetRankingInfo *bool `json:"getRankingInfo,omitempty"` + RelevancyStrictness *int32 `json:"relevancyStrictness,omitempty"` + FacetFilters *FacetFilters `json:"facetFilters,omitempty"` + OptionalFilters *OptionalFilters `json:"optionalFilters,omitempty"` + NumericFilters *NumericFilters `json:"numericFilters,omitempty"` + // Number of hits per page. + HitsPerPage *int32 `json:"hitsPerPage,omitempty"` + // 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`. + AroundLatLng *string `json:"aroundLatLng,omitempty"` + // Whether to obtain the coordinates from the request's IP address. + AroundLatLngViaIP *bool `json:"aroundLatLngViaIP,omitempty"` + AroundRadius *AroundRadius `json:"aroundRadius,omitempty"` + AroundPrecision *AroundPrecision `json:"aroundPrecision,omitempty"` + // Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. + MinimumAroundRadius *int32 `json:"minimumAroundRadius,omitempty"` + InsideBoundingBox utils.Nullable[InsideBoundingBox] `json:"insideBoundingBox,omitempty"` + // 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`. + InsidePolygon [][]float64 `json:"insidePolygon,omitempty"` + // 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/). + QueryLanguages []SupportedLanguage `json:"queryLanguages,omitempty"` + // 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`. + NaturalLanguages []SupportedLanguage `json:"naturalLanguages,omitempty"` + // Whether to enable rules. + EnableRules *bool `json:"enableRules,omitempty"` + // 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. + RuleContexts []string `json:"ruleContexts,omitempty"` + // 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/). + UserToken *string `json:"userToken,omitempty"` + // 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/). + ClickAnalytics *bool `json:"clickAnalytics,omitempty"` + // Whether this search will be included in Analytics. + Analytics *bool `json:"analytics,omitempty"` + // Tags to apply to the query for [segmenting analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/). + AnalyticsTags []string `json:"analyticsTags,omitempty"` + // Whether to enable A/B testing for this search. + EnableABTest *bool `json:"enableABTest,omitempty"` + // 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. + EnableReRanking *bool `json:"enableReRanking,omitempty"` +} + +type ParamsOption func(f *Params) + +func WithParamsQuery(val string) ParamsOption { + return func(f *Params) { + f.Query = &val + } +} + +func WithParamsFilters(val string) ParamsOption { + return func(f *Params) { + f.Filters = &val + } +} + +func WithParamsPage(val int32) ParamsOption { + return func(f *Params) { + f.Page = &val + } +} + +func WithParamsGetRankingInfo(val bool) ParamsOption { + return func(f *Params) { + f.GetRankingInfo = &val + } +} + +func WithParamsRelevancyStrictness(val int32) ParamsOption { + return func(f *Params) { + f.RelevancyStrictness = &val + } +} + +func WithParamsFacetFilters(val FacetFilters) ParamsOption { + return func(f *Params) { + f.FacetFilters = &val + } +} + +func WithParamsOptionalFilters(val OptionalFilters) ParamsOption { + return func(f *Params) { + f.OptionalFilters = &val + } +} + +func WithParamsNumericFilters(val NumericFilters) ParamsOption { + return func(f *Params) { + f.NumericFilters = &val + } +} + +func WithParamsHitsPerPage(val int32) ParamsOption { + return func(f *Params) { + f.HitsPerPage = &val + } +} + +func WithParamsAroundLatLng(val string) ParamsOption { + return func(f *Params) { + f.AroundLatLng = &val + } +} + +func WithParamsAroundLatLngViaIP(val bool) ParamsOption { + return func(f *Params) { + f.AroundLatLngViaIP = &val + } +} + +func WithParamsAroundRadius(val AroundRadius) ParamsOption { + return func(f *Params) { + f.AroundRadius = &val + } +} + +func WithParamsAroundPrecision(val AroundPrecision) ParamsOption { + return func(f *Params) { + f.AroundPrecision = &val + } +} + +func WithParamsMinimumAroundRadius(val int32) ParamsOption { + return func(f *Params) { + f.MinimumAroundRadius = &val + } +} + +func WithParamsInsideBoundingBox(val utils.Nullable[InsideBoundingBox]) ParamsOption { + return func(f *Params) { + f.InsideBoundingBox = val + } +} + +func WithParamsInsidePolygon(val [][]float64) ParamsOption { + return func(f *Params) { + f.InsidePolygon = val + } +} + +func WithParamsQueryLanguages(val []SupportedLanguage) ParamsOption { + return func(f *Params) { + f.QueryLanguages = val + } +} + +func WithParamsNaturalLanguages(val []SupportedLanguage) ParamsOption { + return func(f *Params) { + f.NaturalLanguages = val + } +} + +func WithParamsEnableRules(val bool) ParamsOption { + return func(f *Params) { + f.EnableRules = &val + } +} + +func WithParamsRuleContexts(val []string) ParamsOption { + return func(f *Params) { + f.RuleContexts = val + } +} + +func WithParamsUserToken(val string) ParamsOption { + return func(f *Params) { + f.UserToken = &val + } +} + +func WithParamsClickAnalytics(val bool) ParamsOption { + return func(f *Params) { + f.ClickAnalytics = &val + } +} + +func WithParamsAnalytics(val bool) ParamsOption { + return func(f *Params) { + f.Analytics = &val + } +} + +func WithParamsAnalyticsTags(val []string) ParamsOption { + return func(f *Params) { + f.AnalyticsTags = val + } +} + +func WithParamsEnableABTest(val bool) ParamsOption { + return func(f *Params) { + f.EnableABTest = &val + } +} + +func WithParamsEnableReRanking(val bool) ParamsOption { + return func(f *Params) { + f.EnableReRanking = &val + } +} + +// NewParams instantiates a new Params object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewParams(opts ...ParamsOption) *Params { + this := &Params{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyParams return a pointer to an empty Params object. +func NewEmptyParams() *Params { + return &Params{} +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *Params) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *Params) HasQuery() bool { + if o != nil && o.Query != nil { + return true + } + + return false +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *Params) SetQuery(v string) *Params { + o.Query = &v + return o +} + +// GetFilters returns the Filters field value if set, zero value otherwise. +func (o *Params) GetFilters() string { + if o == nil || o.Filters == nil { + var ret string + return ret + } + return *o.Filters +} + +// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetFiltersOk() (*string, bool) { + if o == nil || o.Filters == nil { + return nil, false + } + return o.Filters, true +} + +// HasFilters returns a boolean if a field has been set. +func (o *Params) HasFilters() bool { + if o != nil && o.Filters != nil { + return true + } + + return false +} + +// SetFilters gets a reference to the given string and assigns it to the Filters field. +func (o *Params) SetFilters(v string) *Params { + o.Filters = &v + return o +} + +// GetPage returns the Page field value if set, zero value otherwise. +func (o *Params) GetPage() int32 { + if o == nil || o.Page == nil { + var ret int32 + return ret + } + return *o.Page +} + +// GetPageOk returns a tuple with the Page field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetPageOk() (*int32, bool) { + if o == nil || o.Page == nil { + return nil, false + } + return o.Page, true +} + +// HasPage returns a boolean if a field has been set. +func (o *Params) HasPage() bool { + if o != nil && o.Page != nil { + return true + } + + return false +} + +// SetPage gets a reference to the given int32 and assigns it to the Page field. +func (o *Params) SetPage(v int32) *Params { + o.Page = &v + return o +} + +// GetGetRankingInfo returns the GetRankingInfo field value if set, zero value otherwise. +func (o *Params) GetGetRankingInfo() bool { + if o == nil || o.GetRankingInfo == nil { + var ret bool + return ret + } + return *o.GetRankingInfo +} + +// GetGetRankingInfoOk returns a tuple with the GetRankingInfo field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetGetRankingInfoOk() (*bool, bool) { + if o == nil || o.GetRankingInfo == nil { + return nil, false + } + return o.GetRankingInfo, true +} + +// HasGetRankingInfo returns a boolean if a field has been set. +func (o *Params) HasGetRankingInfo() bool { + if o != nil && o.GetRankingInfo != nil { + return true + } + + return false +} + +// SetGetRankingInfo gets a reference to the given bool and assigns it to the GetRankingInfo field. +func (o *Params) SetGetRankingInfo(v bool) *Params { + o.GetRankingInfo = &v + return o +} + +// GetRelevancyStrictness returns the RelevancyStrictness field value if set, zero value otherwise. +func (o *Params) GetRelevancyStrictness() int32 { + if o == nil || o.RelevancyStrictness == nil { + var ret int32 + return ret + } + return *o.RelevancyStrictness +} + +// GetRelevancyStrictnessOk returns a tuple with the RelevancyStrictness field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetRelevancyStrictnessOk() (*int32, bool) { + if o == nil || o.RelevancyStrictness == nil { + return nil, false + } + return o.RelevancyStrictness, true +} + +// HasRelevancyStrictness returns a boolean if a field has been set. +func (o *Params) HasRelevancyStrictness() bool { + if o != nil && o.RelevancyStrictness != nil { + return true + } + + return false +} + +// SetRelevancyStrictness gets a reference to the given int32 and assigns it to the RelevancyStrictness field. +func (o *Params) SetRelevancyStrictness(v int32) *Params { + o.RelevancyStrictness = &v + return o +} + +// GetFacetFilters returns the FacetFilters field value if set, zero value otherwise. +func (o *Params) GetFacetFilters() FacetFilters { + if o == nil || o.FacetFilters == nil { + var ret FacetFilters + return ret + } + return *o.FacetFilters +} + +// GetFacetFiltersOk returns a tuple with the FacetFilters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetFacetFiltersOk() (*FacetFilters, bool) { + if o == nil || o.FacetFilters == nil { + return nil, false + } + return o.FacetFilters, true +} + +// HasFacetFilters returns a boolean if a field has been set. +func (o *Params) HasFacetFilters() bool { + if o != nil && o.FacetFilters != nil { + return true + } + + return false +} + +// SetFacetFilters gets a reference to the given FacetFilters and assigns it to the FacetFilters field. +func (o *Params) SetFacetFilters(v *FacetFilters) *Params { + o.FacetFilters = v + return o +} + +// GetOptionalFilters returns the OptionalFilters field value if set, zero value otherwise. +func (o *Params) GetOptionalFilters() OptionalFilters { + if o == nil || o.OptionalFilters == nil { + var ret OptionalFilters + return ret + } + return *o.OptionalFilters +} + +// GetOptionalFiltersOk returns a tuple with the OptionalFilters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetOptionalFiltersOk() (*OptionalFilters, bool) { + if o == nil || o.OptionalFilters == nil { + return nil, false + } + return o.OptionalFilters, true +} + +// HasOptionalFilters returns a boolean if a field has been set. +func (o *Params) HasOptionalFilters() bool { + if o != nil && o.OptionalFilters != nil { + return true + } + + return false +} + +// SetOptionalFilters gets a reference to the given OptionalFilters and assigns it to the OptionalFilters field. +func (o *Params) SetOptionalFilters(v *OptionalFilters) *Params { + o.OptionalFilters = v + return o +} + +// GetNumericFilters returns the NumericFilters field value if set, zero value otherwise. +func (o *Params) GetNumericFilters() NumericFilters { + if o == nil || o.NumericFilters == nil { + var ret NumericFilters + return ret + } + return *o.NumericFilters +} + +// GetNumericFiltersOk returns a tuple with the NumericFilters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetNumericFiltersOk() (*NumericFilters, bool) { + if o == nil || o.NumericFilters == nil { + return nil, false + } + return o.NumericFilters, true +} + +// HasNumericFilters returns a boolean if a field has been set. +func (o *Params) HasNumericFilters() bool { + if o != nil && o.NumericFilters != nil { + return true + } + + return false +} + +// SetNumericFilters gets a reference to the given NumericFilters and assigns it to the NumericFilters field. +func (o *Params) SetNumericFilters(v *NumericFilters) *Params { + o.NumericFilters = v + return o +} + +// GetHitsPerPage returns the HitsPerPage field value if set, zero value otherwise. +func (o *Params) GetHitsPerPage() int32 { + if o == nil || o.HitsPerPage == nil { + var ret int32 + return ret + } + return *o.HitsPerPage +} + +// GetHitsPerPageOk returns a tuple with the HitsPerPage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetHitsPerPageOk() (*int32, bool) { + if o == nil || o.HitsPerPage == nil { + return nil, false + } + return o.HitsPerPage, true +} + +// HasHitsPerPage returns a boolean if a field has been set. +func (o *Params) HasHitsPerPage() bool { + if o != nil && o.HitsPerPage != nil { + return true + } + + return false +} + +// SetHitsPerPage gets a reference to the given int32 and assigns it to the HitsPerPage field. +func (o *Params) SetHitsPerPage(v int32) *Params { + o.HitsPerPage = &v + return o +} + +// GetAroundLatLng returns the AroundLatLng field value if set, zero value otherwise. +func (o *Params) GetAroundLatLng() string { + if o == nil || o.AroundLatLng == nil { + var ret string + return ret + } + return *o.AroundLatLng +} + +// GetAroundLatLngOk returns a tuple with the AroundLatLng field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetAroundLatLngOk() (*string, bool) { + if o == nil || o.AroundLatLng == nil { + return nil, false + } + return o.AroundLatLng, true +} + +// HasAroundLatLng returns a boolean if a field has been set. +func (o *Params) HasAroundLatLng() bool { + if o != nil && o.AroundLatLng != nil { + return true + } + + return false +} + +// SetAroundLatLng gets a reference to the given string and assigns it to the AroundLatLng field. +func (o *Params) SetAroundLatLng(v string) *Params { + o.AroundLatLng = &v + return o +} + +// GetAroundLatLngViaIP returns the AroundLatLngViaIP field value if set, zero value otherwise. +func (o *Params) GetAroundLatLngViaIP() bool { + if o == nil || o.AroundLatLngViaIP == nil { + var ret bool + return ret + } + return *o.AroundLatLngViaIP +} + +// GetAroundLatLngViaIPOk returns a tuple with the AroundLatLngViaIP field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetAroundLatLngViaIPOk() (*bool, bool) { + if o == nil || o.AroundLatLngViaIP == nil { + return nil, false + } + return o.AroundLatLngViaIP, true +} + +// HasAroundLatLngViaIP returns a boolean if a field has been set. +func (o *Params) HasAroundLatLngViaIP() bool { + if o != nil && o.AroundLatLngViaIP != nil { + return true + } + + return false +} + +// SetAroundLatLngViaIP gets a reference to the given bool and assigns it to the AroundLatLngViaIP field. +func (o *Params) SetAroundLatLngViaIP(v bool) *Params { + o.AroundLatLngViaIP = &v + return o +} + +// GetAroundRadius returns the AroundRadius field value if set, zero value otherwise. +func (o *Params) GetAroundRadius() AroundRadius { + if o == nil || o.AroundRadius == nil { + var ret AroundRadius + return ret + } + return *o.AroundRadius +} + +// GetAroundRadiusOk returns a tuple with the AroundRadius field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetAroundRadiusOk() (*AroundRadius, bool) { + if o == nil || o.AroundRadius == nil { + return nil, false + } + return o.AroundRadius, true +} + +// HasAroundRadius returns a boolean if a field has been set. +func (o *Params) HasAroundRadius() bool { + if o != nil && o.AroundRadius != nil { + return true + } + + return false +} + +// SetAroundRadius gets a reference to the given AroundRadius and assigns it to the AroundRadius field. +func (o *Params) SetAroundRadius(v *AroundRadius) *Params { + o.AroundRadius = v + return o +} + +// GetAroundPrecision returns the AroundPrecision field value if set, zero value otherwise. +func (o *Params) GetAroundPrecision() AroundPrecision { + if o == nil || o.AroundPrecision == nil { + var ret AroundPrecision + return ret + } + return *o.AroundPrecision +} + +// GetAroundPrecisionOk returns a tuple with the AroundPrecision field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetAroundPrecisionOk() (*AroundPrecision, bool) { + if o == nil || o.AroundPrecision == nil { + return nil, false + } + return o.AroundPrecision, true +} + +// HasAroundPrecision returns a boolean if a field has been set. +func (o *Params) HasAroundPrecision() bool { + if o != nil && o.AroundPrecision != nil { + return true + } + + return false +} + +// SetAroundPrecision gets a reference to the given AroundPrecision and assigns it to the AroundPrecision field. +func (o *Params) SetAroundPrecision(v *AroundPrecision) *Params { + o.AroundPrecision = v + return o +} + +// GetMinimumAroundRadius returns the MinimumAroundRadius field value if set, zero value otherwise. +func (o *Params) GetMinimumAroundRadius() int32 { + if o == nil || o.MinimumAroundRadius == nil { + var ret int32 + return ret + } + return *o.MinimumAroundRadius +} + +// GetMinimumAroundRadiusOk returns a tuple with the MinimumAroundRadius field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetMinimumAroundRadiusOk() (*int32, bool) { + if o == nil || o.MinimumAroundRadius == nil { + return nil, false + } + return o.MinimumAroundRadius, true +} + +// HasMinimumAroundRadius returns a boolean if a field has been set. +func (o *Params) HasMinimumAroundRadius() bool { + if o != nil && o.MinimumAroundRadius != nil { + return true + } + + return false +} + +// SetMinimumAroundRadius gets a reference to the given int32 and assigns it to the MinimumAroundRadius field. +func (o *Params) SetMinimumAroundRadius(v int32) *Params { + o.MinimumAroundRadius = &v + return o +} + +// GetInsideBoundingBox returns the InsideBoundingBox field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Params) GetInsideBoundingBox() InsideBoundingBox { + if o == nil || o.InsideBoundingBox.Get() == nil { + var ret InsideBoundingBox + return ret + } + return *o.InsideBoundingBox.Get() +} + +// GetInsideBoundingBoxOk returns a tuple with the InsideBoundingBox field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *Params) GetInsideBoundingBoxOk() (*InsideBoundingBox, bool) { + if o == nil { + return nil, false + } + return o.InsideBoundingBox.Get(), o.InsideBoundingBox.IsSet() +} + +// HasInsideBoundingBox returns a boolean if a field has been set. +func (o *Params) HasInsideBoundingBox() bool { + if o != nil && o.InsideBoundingBox.IsSet() { + return true + } + + return false +} + +// SetInsideBoundingBox gets a reference to the given utils.Nullable[InsideBoundingBox] and assigns it to the InsideBoundingBox field. +func (o *Params) SetInsideBoundingBox(v *InsideBoundingBox) *Params { + o.InsideBoundingBox.Set(v) + return o +} + +// SetInsideBoundingBoxNil sets the value for InsideBoundingBox to be an explicit nil. +func (o *Params) SetInsideBoundingBoxNil() { + o.InsideBoundingBox.Set(nil) +} + +// UnsetInsideBoundingBox ensures that no value is present for InsideBoundingBox, not even an explicit nil. +func (o *Params) UnsetInsideBoundingBox() { + o.InsideBoundingBox.Unset() +} + +// GetInsidePolygon returns the InsidePolygon field value if set, zero value otherwise. +func (o *Params) GetInsidePolygon() [][]float64 { + if o == nil || o.InsidePolygon == nil { + var ret [][]float64 + return ret + } + return o.InsidePolygon +} + +// GetInsidePolygonOk returns a tuple with the InsidePolygon field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetInsidePolygonOk() ([][]float64, bool) { + if o == nil || o.InsidePolygon == nil { + return nil, false + } + return o.InsidePolygon, true +} + +// HasInsidePolygon returns a boolean if a field has been set. +func (o *Params) HasInsidePolygon() bool { + if o != nil && o.InsidePolygon != nil { + return true + } + + return false +} + +// SetInsidePolygon gets a reference to the given [][]float64 and assigns it to the InsidePolygon field. +func (o *Params) SetInsidePolygon(v [][]float64) *Params { + o.InsidePolygon = v + return o +} + +// GetQueryLanguages returns the QueryLanguages field value if set, zero value otherwise. +func (o *Params) GetQueryLanguages() []SupportedLanguage { + if o == nil || o.QueryLanguages == nil { + var ret []SupportedLanguage + return ret + } + return o.QueryLanguages +} + +// GetQueryLanguagesOk returns a tuple with the QueryLanguages field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetQueryLanguagesOk() ([]SupportedLanguage, bool) { + if o == nil || o.QueryLanguages == nil { + return nil, false + } + return o.QueryLanguages, true +} + +// HasQueryLanguages returns a boolean if a field has been set. +func (o *Params) HasQueryLanguages() bool { + if o != nil && o.QueryLanguages != nil { + return true + } + + return false +} + +// SetQueryLanguages gets a reference to the given []SupportedLanguage and assigns it to the QueryLanguages field. +func (o *Params) SetQueryLanguages(v []SupportedLanguage) *Params { + o.QueryLanguages = v + return o +} + +// GetNaturalLanguages returns the NaturalLanguages field value if set, zero value otherwise. +func (o *Params) GetNaturalLanguages() []SupportedLanguage { + if o == nil || o.NaturalLanguages == nil { + var ret []SupportedLanguage + return ret + } + return o.NaturalLanguages +} + +// GetNaturalLanguagesOk returns a tuple with the NaturalLanguages field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetNaturalLanguagesOk() ([]SupportedLanguage, bool) { + if o == nil || o.NaturalLanguages == nil { + return nil, false + } + return o.NaturalLanguages, true +} + +// HasNaturalLanguages returns a boolean if a field has been set. +func (o *Params) HasNaturalLanguages() bool { + if o != nil && o.NaturalLanguages != nil { + return true + } + + return false +} + +// SetNaturalLanguages gets a reference to the given []SupportedLanguage and assigns it to the NaturalLanguages field. +func (o *Params) SetNaturalLanguages(v []SupportedLanguage) *Params { + o.NaturalLanguages = v + return o +} + +// GetEnableRules returns the EnableRules field value if set, zero value otherwise. +func (o *Params) GetEnableRules() bool { + if o == nil || o.EnableRules == nil { + var ret bool + return ret + } + return *o.EnableRules +} + +// GetEnableRulesOk returns a tuple with the EnableRules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetEnableRulesOk() (*bool, bool) { + if o == nil || o.EnableRules == nil { + return nil, false + } + return o.EnableRules, true +} + +// HasEnableRules returns a boolean if a field has been set. +func (o *Params) HasEnableRules() bool { + if o != nil && o.EnableRules != nil { + return true + } + + return false +} + +// SetEnableRules gets a reference to the given bool and assigns it to the EnableRules field. +func (o *Params) SetEnableRules(v bool) *Params { + o.EnableRules = &v + return o +} + +// GetRuleContexts returns the RuleContexts field value if set, zero value otherwise. +func (o *Params) GetRuleContexts() []string { + if o == nil || o.RuleContexts == nil { + var ret []string + return ret + } + return o.RuleContexts +} + +// GetRuleContextsOk returns a tuple with the RuleContexts field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetRuleContextsOk() ([]string, bool) { + if o == nil || o.RuleContexts == nil { + return nil, false + } + return o.RuleContexts, true +} + +// HasRuleContexts returns a boolean if a field has been set. +func (o *Params) HasRuleContexts() bool { + if o != nil && o.RuleContexts != nil { + return true + } + + return false +} + +// SetRuleContexts gets a reference to the given []string and assigns it to the RuleContexts field. +func (o *Params) SetRuleContexts(v []string) *Params { + o.RuleContexts = v + return o +} + +// GetUserToken returns the UserToken field value if set, zero value otherwise. +func (o *Params) GetUserToken() string { + if o == nil || o.UserToken == nil { + var ret string + return ret + } + return *o.UserToken +} + +// GetUserTokenOk returns a tuple with the UserToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetUserTokenOk() (*string, bool) { + if o == nil || o.UserToken == nil { + return nil, false + } + return o.UserToken, true +} + +// HasUserToken returns a boolean if a field has been set. +func (o *Params) HasUserToken() bool { + if o != nil && o.UserToken != nil { + return true + } + + return false +} + +// SetUserToken gets a reference to the given string and assigns it to the UserToken field. +func (o *Params) SetUserToken(v string) *Params { + o.UserToken = &v + return o +} + +// GetClickAnalytics returns the ClickAnalytics field value if set, zero value otherwise. +func (o *Params) GetClickAnalytics() bool { + if o == nil || o.ClickAnalytics == nil { + var ret bool + return ret + } + return *o.ClickAnalytics +} + +// GetClickAnalyticsOk returns a tuple with the ClickAnalytics field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetClickAnalyticsOk() (*bool, bool) { + if o == nil || o.ClickAnalytics == nil { + return nil, false + } + return o.ClickAnalytics, true +} + +// HasClickAnalytics returns a boolean if a field has been set. +func (o *Params) HasClickAnalytics() bool { + if o != nil && o.ClickAnalytics != nil { + return true + } + + return false +} + +// SetClickAnalytics gets a reference to the given bool and assigns it to the ClickAnalytics field. +func (o *Params) SetClickAnalytics(v bool) *Params { + o.ClickAnalytics = &v + return o +} + +// GetAnalytics returns the Analytics field value if set, zero value otherwise. +func (o *Params) GetAnalytics() bool { + if o == nil || o.Analytics == nil { + var ret bool + return ret + } + return *o.Analytics +} + +// GetAnalyticsOk returns a tuple with the Analytics field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetAnalyticsOk() (*bool, bool) { + if o == nil || o.Analytics == nil { + return nil, false + } + return o.Analytics, true +} + +// HasAnalytics returns a boolean if a field has been set. +func (o *Params) HasAnalytics() bool { + if o != nil && o.Analytics != nil { + return true + } + + return false +} + +// SetAnalytics gets a reference to the given bool and assigns it to the Analytics field. +func (o *Params) SetAnalytics(v bool) *Params { + o.Analytics = &v + return o +} + +// GetAnalyticsTags returns the AnalyticsTags field value if set, zero value otherwise. +func (o *Params) GetAnalyticsTags() []string { + if o == nil || o.AnalyticsTags == nil { + var ret []string + return ret + } + return o.AnalyticsTags +} + +// GetAnalyticsTagsOk returns a tuple with the AnalyticsTags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetAnalyticsTagsOk() ([]string, bool) { + if o == nil || o.AnalyticsTags == nil { + return nil, false + } + return o.AnalyticsTags, true +} + +// HasAnalyticsTags returns a boolean if a field has been set. +func (o *Params) HasAnalyticsTags() bool { + if o != nil && o.AnalyticsTags != nil { + return true + } + + return false +} + +// SetAnalyticsTags gets a reference to the given []string and assigns it to the AnalyticsTags field. +func (o *Params) SetAnalyticsTags(v []string) *Params { + o.AnalyticsTags = v + return o +} + +// GetEnableABTest returns the EnableABTest field value if set, zero value otherwise. +func (o *Params) GetEnableABTest() bool { + if o == nil || o.EnableABTest == nil { + var ret bool + return ret + } + return *o.EnableABTest +} + +// GetEnableABTestOk returns a tuple with the EnableABTest field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetEnableABTestOk() (*bool, bool) { + if o == nil || o.EnableABTest == nil { + return nil, false + } + return o.EnableABTest, true +} + +// HasEnableABTest returns a boolean if a field has been set. +func (o *Params) HasEnableABTest() bool { + if o != nil && o.EnableABTest != nil { + return true + } + + return false +} + +// SetEnableABTest gets a reference to the given bool and assigns it to the EnableABTest field. +func (o *Params) SetEnableABTest(v bool) *Params { + o.EnableABTest = &v + return o +} + +// GetEnableReRanking returns the EnableReRanking field value if set, zero value otherwise. +func (o *Params) GetEnableReRanking() bool { + if o == nil || o.EnableReRanking == nil { + var ret bool + return ret + } + return *o.EnableReRanking +} + +// GetEnableReRankingOk returns a tuple with the EnableReRanking field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Params) GetEnableReRankingOk() (*bool, bool) { + if o == nil || o.EnableReRanking == nil { + return nil, false + } + return o.EnableReRanking, true +} + +// HasEnableReRanking returns a boolean if a field has been set. +func (o *Params) HasEnableReRanking() bool { + if o != nil && o.EnableReRanking != nil { + return true + } + + return false +} + +// SetEnableReRanking gets a reference to the given bool and assigns it to the EnableReRanking field. +func (o *Params) SetEnableReRanking(v bool) *Params { + o.EnableReRanking = &v + return o +} + +func (o Params) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Query != nil { + toSerialize["query"] = o.Query + } + if o.Filters != nil { + toSerialize["filters"] = o.Filters + } + if o.Page != nil { + toSerialize["page"] = o.Page + } + if o.GetRankingInfo != nil { + toSerialize["getRankingInfo"] = o.GetRankingInfo + } + if o.RelevancyStrictness != nil { + toSerialize["relevancyStrictness"] = o.RelevancyStrictness + } + if o.FacetFilters != nil { + toSerialize["facetFilters"] = o.FacetFilters + } + if o.OptionalFilters != nil { + toSerialize["optionalFilters"] = o.OptionalFilters + } + if o.NumericFilters != nil { + toSerialize["numericFilters"] = o.NumericFilters + } + if o.HitsPerPage != nil { + toSerialize["hitsPerPage"] = o.HitsPerPage + } + if o.AroundLatLng != nil { + toSerialize["aroundLatLng"] = o.AroundLatLng + } + if o.AroundLatLngViaIP != nil { + toSerialize["aroundLatLngViaIP"] = o.AroundLatLngViaIP + } + if o.AroundRadius != nil { + toSerialize["aroundRadius"] = o.AroundRadius + } + if o.AroundPrecision != nil { + toSerialize["aroundPrecision"] = o.AroundPrecision + } + if o.MinimumAroundRadius != nil { + toSerialize["minimumAroundRadius"] = o.MinimumAroundRadius + } + if o.InsideBoundingBox.IsSet() { + toSerialize["insideBoundingBox"] = o.InsideBoundingBox.Get() + } + if o.InsidePolygon != nil { + toSerialize["insidePolygon"] = o.InsidePolygon + } + if o.QueryLanguages != nil { + toSerialize["queryLanguages"] = o.QueryLanguages + } + if o.NaturalLanguages != nil { + toSerialize["naturalLanguages"] = o.NaturalLanguages + } + if o.EnableRules != nil { + toSerialize["enableRules"] = o.EnableRules + } + if o.RuleContexts != nil { + toSerialize["ruleContexts"] = o.RuleContexts + } + if o.UserToken != nil { + toSerialize["userToken"] = o.UserToken + } + if o.ClickAnalytics != nil { + toSerialize["clickAnalytics"] = o.ClickAnalytics + } + if o.Analytics != nil { + toSerialize["analytics"] = o.Analytics + } + if o.AnalyticsTags != nil { + toSerialize["analyticsTags"] = o.AnalyticsTags + } + if o.EnableABTest != nil { + toSerialize["enableABTest"] = o.EnableABTest + } + if o.EnableReRanking != nil { + toSerialize["enableReRanking"] = o.EnableReRanking + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Params: %w", err) + } + + return serialized, nil +} + +func (o Params) String() string { + out := "" + out += fmt.Sprintf(" query=%v\n", o.Query) + out += fmt.Sprintf(" filters=%v\n", o.Filters) + out += fmt.Sprintf(" page=%v\n", o.Page) + out += fmt.Sprintf(" getRankingInfo=%v\n", o.GetRankingInfo) + out += fmt.Sprintf(" relevancyStrictness=%v\n", o.RelevancyStrictness) + out += fmt.Sprintf(" facetFilters=%v\n", o.FacetFilters) + out += fmt.Sprintf(" optionalFilters=%v\n", o.OptionalFilters) + out += fmt.Sprintf(" numericFilters=%v\n", o.NumericFilters) + out += fmt.Sprintf(" hitsPerPage=%v\n", o.HitsPerPage) + out += fmt.Sprintf(" aroundLatLng=%v\n", o.AroundLatLng) + out += fmt.Sprintf(" aroundLatLngViaIP=%v\n", o.AroundLatLngViaIP) + out += fmt.Sprintf(" aroundRadius=%v\n", o.AroundRadius) + out += fmt.Sprintf(" aroundPrecision=%v\n", o.AroundPrecision) + out += fmt.Sprintf(" minimumAroundRadius=%v\n", o.MinimumAroundRadius) + out += fmt.Sprintf(" insideBoundingBox=%v\n", o.InsideBoundingBox) + out += fmt.Sprintf(" insidePolygon=%v\n", o.InsidePolygon) + out += fmt.Sprintf(" queryLanguages=%v\n", o.QueryLanguages) + out += fmt.Sprintf(" naturalLanguages=%v\n", o.NaturalLanguages) + out += fmt.Sprintf(" enableRules=%v\n", o.EnableRules) + out += fmt.Sprintf(" ruleContexts=%v\n", o.RuleContexts) + out += fmt.Sprintf(" userToken=%v\n", o.UserToken) + out += fmt.Sprintf(" clickAnalytics=%v\n", o.ClickAnalytics) + out += fmt.Sprintf(" analytics=%v\n", o.Analytics) + out += fmt.Sprintf(" analyticsTags=%v\n", o.AnalyticsTags) + out += fmt.Sprintf(" enableABTest=%v\n", o.EnableABTest) + out += fmt.Sprintf(" enableReRanking=%v\n", o.EnableReRanking) + return fmt.Sprintf("Params {\n%s}", out) +} diff --git a/algolia/composition/model_personalization.go b/algolia/composition/model_personalization.go new file mode 100644 index 000000000..31c5c9403 --- /dev/null +++ b/algolia/composition/model_personalization.go @@ -0,0 +1,180 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Personalization struct for Personalization. +type Personalization struct { + // The score of the filters. + FiltersScore *int32 `json:"filtersScore,omitempty"` + // The score of the ranking. + RankingScore *int32 `json:"rankingScore,omitempty"` + // The score of the event. + Score *int32 `json:"score,omitempty"` +} + +type PersonalizationOption func(f *Personalization) + +func WithPersonalizationFiltersScore(val int32) PersonalizationOption { + return func(f *Personalization) { + f.FiltersScore = &val + } +} + +func WithPersonalizationRankingScore(val int32) PersonalizationOption { + return func(f *Personalization) { + f.RankingScore = &val + } +} + +func WithPersonalizationScore(val int32) PersonalizationOption { + return func(f *Personalization) { + f.Score = &val + } +} + +// NewPersonalization instantiates a new Personalization object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewPersonalization(opts ...PersonalizationOption) *Personalization { + this := &Personalization{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyPersonalization return a pointer to an empty Personalization object. +func NewEmptyPersonalization() *Personalization { + return &Personalization{} +} + +// GetFiltersScore returns the FiltersScore field value if set, zero value otherwise. +func (o *Personalization) GetFiltersScore() int32 { + if o == nil || o.FiltersScore == nil { + var ret int32 + return ret + } + return *o.FiltersScore +} + +// GetFiltersScoreOk returns a tuple with the FiltersScore field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Personalization) GetFiltersScoreOk() (*int32, bool) { + if o == nil || o.FiltersScore == nil { + return nil, false + } + return o.FiltersScore, true +} + +// HasFiltersScore returns a boolean if a field has been set. +func (o *Personalization) HasFiltersScore() bool { + if o != nil && o.FiltersScore != nil { + return true + } + + return false +} + +// SetFiltersScore gets a reference to the given int32 and assigns it to the FiltersScore field. +func (o *Personalization) SetFiltersScore(v int32) *Personalization { + o.FiltersScore = &v + return o +} + +// GetRankingScore returns the RankingScore field value if set, zero value otherwise. +func (o *Personalization) GetRankingScore() int32 { + if o == nil || o.RankingScore == nil { + var ret int32 + return ret + } + return *o.RankingScore +} + +// GetRankingScoreOk returns a tuple with the RankingScore field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Personalization) GetRankingScoreOk() (*int32, bool) { + if o == nil || o.RankingScore == nil { + return nil, false + } + return o.RankingScore, true +} + +// HasRankingScore returns a boolean if a field has been set. +func (o *Personalization) HasRankingScore() bool { + if o != nil && o.RankingScore != nil { + return true + } + + return false +} + +// SetRankingScore gets a reference to the given int32 and assigns it to the RankingScore field. +func (o *Personalization) SetRankingScore(v int32) *Personalization { + o.RankingScore = &v + return o +} + +// GetScore returns the Score field value if set, zero value otherwise. +func (o *Personalization) GetScore() int32 { + if o == nil || o.Score == nil { + var ret int32 + return ret + } + return *o.Score +} + +// GetScoreOk returns a tuple with the Score field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Personalization) GetScoreOk() (*int32, bool) { + if o == nil || o.Score == nil { + return nil, false + } + return o.Score, true +} + +// HasScore returns a boolean if a field has been set. +func (o *Personalization) HasScore() bool { + if o != nil && o.Score != nil { + return true + } + + return false +} + +// SetScore gets a reference to the given int32 and assigns it to the Score field. +func (o *Personalization) SetScore(v int32) *Personalization { + o.Score = &v + return o +} + +func (o Personalization) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.FiltersScore != nil { + toSerialize["filtersScore"] = o.FiltersScore + } + if o.RankingScore != nil { + toSerialize["rankingScore"] = o.RankingScore + } + if o.Score != nil { + toSerialize["score"] = o.Score + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Personalization: %w", err) + } + + return serialized, nil +} + +func (o Personalization) String() string { + out := "" + out += fmt.Sprintf(" filtersScore=%v\n", o.FiltersScore) + out += fmt.Sprintf(" rankingScore=%v\n", o.RankingScore) + out += fmt.Sprintf(" score=%v\n", o.Score) + return fmt.Sprintf("Personalization {\n%s}", out) +} diff --git a/algolia/composition/model_redirect.go b/algolia/composition/model_redirect.go new file mode 100644 index 000000000..f5abf0a5e --- /dev/null +++ b/algolia/composition/model_redirect.go @@ -0,0 +1,89 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Redirect [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. +type Redirect struct { + Index []RedirectRuleIndexMetadata `json:"index,omitempty"` +} + +type RedirectOption func(f *Redirect) + +func WithRedirectIndex(val []RedirectRuleIndexMetadata) RedirectOption { + return func(f *Redirect) { + f.Index = val + } +} + +// NewRedirect instantiates a new Redirect object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRedirect(opts ...RedirectOption) *Redirect { + this := &Redirect{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyRedirect return a pointer to an empty Redirect object. +func NewEmptyRedirect() *Redirect { + return &Redirect{} +} + +// GetIndex returns the Index field value if set, zero value otherwise. +func (o *Redirect) GetIndex() []RedirectRuleIndexMetadata { + if o == nil || o.Index == nil { + var ret []RedirectRuleIndexMetadata + return ret + } + return o.Index +} + +// GetIndexOk returns a tuple with the Index field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Redirect) GetIndexOk() ([]RedirectRuleIndexMetadata, bool) { + if o == nil || o.Index == nil { + return nil, false + } + return o.Index, true +} + +// HasIndex returns a boolean if a field has been set. +func (o *Redirect) HasIndex() bool { + if o != nil && o.Index != nil { + return true + } + + return false +} + +// SetIndex gets a reference to the given []RedirectRuleIndexMetadata and assigns it to the Index field. +func (o *Redirect) SetIndex(v []RedirectRuleIndexMetadata) *Redirect { + o.Index = v + return o +} + +func (o Redirect) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Index != nil { + toSerialize["index"] = o.Index + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Redirect: %w", err) + } + + return serialized, nil +} + +func (o Redirect) String() string { + out := "" + out += fmt.Sprintf(" index=%v\n", o.Index) + return fmt.Sprintf("Redirect {\n%s}", out) +} diff --git a/algolia/composition/model_redirect_rule_index_data.go b/algolia/composition/model_redirect_rule_index_data.go new file mode 100644 index 000000000..789b012c5 --- /dev/null +++ b/algolia/composition/model_redirect_rule_index_data.go @@ -0,0 +1,71 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// RedirectRuleIndexData Redirect rule data. +type RedirectRuleIndexData struct { + RuleObjectID string `json:"ruleObjectID"` +} + +// NewRedirectRuleIndexData instantiates a new RedirectRuleIndexData object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRedirectRuleIndexData(ruleObjectID string) *RedirectRuleIndexData { + this := &RedirectRuleIndexData{} + this.RuleObjectID = ruleObjectID + return this +} + +// NewEmptyRedirectRuleIndexData return a pointer to an empty RedirectRuleIndexData object. +func NewEmptyRedirectRuleIndexData() *RedirectRuleIndexData { + return &RedirectRuleIndexData{} +} + +// GetRuleObjectID returns the RuleObjectID field value. +func (o *RedirectRuleIndexData) GetRuleObjectID() string { + if o == nil { + var ret string + return ret + } + + return o.RuleObjectID +} + +// GetRuleObjectIDOk returns a tuple with the RuleObjectID field value +// and a boolean to check if the value has been set. +func (o *RedirectRuleIndexData) GetRuleObjectIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RuleObjectID, true +} + +// SetRuleObjectID sets field value. +func (o *RedirectRuleIndexData) SetRuleObjectID(v string) *RedirectRuleIndexData { + o.RuleObjectID = v + return o +} + +func (o RedirectRuleIndexData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["ruleObjectID"] = o.RuleObjectID + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal RedirectRuleIndexData: %w", err) + } + + return serialized, nil +} + +func (o RedirectRuleIndexData) String() string { + out := "" + out += fmt.Sprintf(" ruleObjectID=%v\n", o.RuleObjectID) + return fmt.Sprintf("RedirectRuleIndexData {\n%s}", out) +} diff --git a/algolia/composition/model_redirect_rule_index_metadata.go b/algolia/composition/model_redirect_rule_index_metadata.go new file mode 100644 index 000000000..67418bf6a --- /dev/null +++ b/algolia/composition/model_redirect_rule_index_metadata.go @@ -0,0 +1,199 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// RedirectRuleIndexMetadata struct for RedirectRuleIndexMetadata. +type RedirectRuleIndexMetadata struct { + // Source index for the redirect rule. + Source string `json:"source"` + // Destination index for the redirect rule. + Dest string `json:"dest"` + // Reason for the redirect rule. + Reason string `json:"reason"` + // Redirect rule status. + Succeed bool `json:"succeed"` + Data RedirectRuleIndexData `json:"data"` +} + +// NewRedirectRuleIndexMetadata instantiates a new RedirectRuleIndexMetadata object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRedirectRuleIndexMetadata(source string, dest string, reason string, succeed bool, data RedirectRuleIndexData) *RedirectRuleIndexMetadata { + this := &RedirectRuleIndexMetadata{} + this.Source = source + this.Dest = dest + this.Reason = reason + this.Succeed = succeed + this.Data = data + return this +} + +// NewEmptyRedirectRuleIndexMetadata return a pointer to an empty RedirectRuleIndexMetadata object. +func NewEmptyRedirectRuleIndexMetadata() *RedirectRuleIndexMetadata { + return &RedirectRuleIndexMetadata{} +} + +// GetSource returns the Source field value. +func (o *RedirectRuleIndexMetadata) GetSource() string { + if o == nil { + var ret string + return ret + } + + return o.Source +} + +// GetSourceOk returns a tuple with the Source field value +// and a boolean to check if the value has been set. +func (o *RedirectRuleIndexMetadata) GetSourceOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Source, true +} + +// SetSource sets field value. +func (o *RedirectRuleIndexMetadata) SetSource(v string) *RedirectRuleIndexMetadata { + o.Source = v + return o +} + +// GetDest returns the Dest field value. +func (o *RedirectRuleIndexMetadata) GetDest() string { + if o == nil { + var ret string + return ret + } + + return o.Dest +} + +// GetDestOk returns a tuple with the Dest field value +// and a boolean to check if the value has been set. +func (o *RedirectRuleIndexMetadata) GetDestOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Dest, true +} + +// SetDest sets field value. +func (o *RedirectRuleIndexMetadata) SetDest(v string) *RedirectRuleIndexMetadata { + o.Dest = v + return o +} + +// GetReason returns the Reason field value. +func (o *RedirectRuleIndexMetadata) GetReason() string { + if o == nil { + var ret string + return ret + } + + return o.Reason +} + +// GetReasonOk returns a tuple with the Reason field value +// and a boolean to check if the value has been set. +func (o *RedirectRuleIndexMetadata) GetReasonOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Reason, true +} + +// SetReason sets field value. +func (o *RedirectRuleIndexMetadata) SetReason(v string) *RedirectRuleIndexMetadata { + o.Reason = v + return o +} + +// GetSucceed returns the Succeed field value. +func (o *RedirectRuleIndexMetadata) GetSucceed() bool { + if o == nil { + var ret bool + return ret + } + + return o.Succeed +} + +// GetSucceedOk returns a tuple with the Succeed field value +// and a boolean to check if the value has been set. +func (o *RedirectRuleIndexMetadata) GetSucceedOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Succeed, true +} + +// SetSucceed sets field value. +func (o *RedirectRuleIndexMetadata) SetSucceed(v bool) *RedirectRuleIndexMetadata { + o.Succeed = v + return o +} + +// GetData returns the Data field value. +func (o *RedirectRuleIndexMetadata) GetData() RedirectRuleIndexData { + if o == nil { + var ret RedirectRuleIndexData + return ret + } + + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *RedirectRuleIndexMetadata) GetDataOk() (*RedirectRuleIndexData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *RedirectRuleIndexMetadata) SetData(v *RedirectRuleIndexData) *RedirectRuleIndexMetadata { + o.Data = *v + return o +} + +func (o RedirectRuleIndexMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["source"] = o.Source + } + if true { + toSerialize["dest"] = o.Dest + } + if true { + toSerialize["reason"] = o.Reason + } + if true { + toSerialize["succeed"] = o.Succeed + } + if true { + toSerialize["data"] = o.Data + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal RedirectRuleIndexMetadata: %w", err) + } + + return serialized, nil +} + +func (o RedirectRuleIndexMetadata) String() string { + out := "" + out += fmt.Sprintf(" source=%v\n", o.Source) + out += fmt.Sprintf(" dest=%v\n", o.Dest) + out += fmt.Sprintf(" reason=%v\n", o.Reason) + out += fmt.Sprintf(" succeed=%v\n", o.Succeed) + out += fmt.Sprintf(" data=%v\n", o.Data) + return fmt.Sprintf("RedirectRuleIndexMetadata {\n%s}", out) +} diff --git a/algolia/composition/model_redirect_url.go b/algolia/composition/model_redirect_url.go new file mode 100644 index 000000000..bc4209955 --- /dev/null +++ b/algolia/composition/model_redirect_url.go @@ -0,0 +1,89 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// RedirectURL The redirect rule container. +type RedirectURL struct { + Url *string `json:"url,omitempty"` +} + +type RedirectURLOption func(f *RedirectURL) + +func WithRedirectURLUrl(val string) RedirectURLOption { + return func(f *RedirectURL) { + f.Url = &val + } +} + +// NewRedirectURL instantiates a new RedirectURL object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRedirectURL(opts ...RedirectURLOption) *RedirectURL { + this := &RedirectURL{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyRedirectURL return a pointer to an empty RedirectURL object. +func NewEmptyRedirectURL() *RedirectURL { + return &RedirectURL{} +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *RedirectURL) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RedirectURL) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *RedirectURL) HasUrl() bool { + if o != nil && o.Url != nil { + return true + } + + return false +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *RedirectURL) SetUrl(v string) *RedirectURL { + o.Url = &v + return o +} + +func (o RedirectURL) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Url != nil { + toSerialize["url"] = o.Url + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal RedirectURL: %w", err) + } + + return serialized, nil +} + +func (o RedirectURL) String() string { + out := "" + out += fmt.Sprintf(" url=%v\n", o.Url) + return fmt.Sprintf("RedirectURL {\n%s}", out) +} diff --git a/algolia/composition/model_rendering_content.go b/algolia/composition/model_rendering_content.go new file mode 100644 index 000000000..bbccd24d7 --- /dev/null +++ b/algolia/composition/model_rendering_content.go @@ -0,0 +1,177 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// RenderingContent 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. +type RenderingContent struct { + FacetOrdering *FacetOrdering `json:"facetOrdering,omitempty"` + Redirect *RedirectURL `json:"redirect,omitempty"` + Widgets *Widgets `json:"widgets,omitempty"` +} + +type RenderingContentOption func(f *RenderingContent) + +func WithRenderingContentFacetOrdering(val FacetOrdering) RenderingContentOption { + return func(f *RenderingContent) { + f.FacetOrdering = &val + } +} + +func WithRenderingContentRedirect(val RedirectURL) RenderingContentOption { + return func(f *RenderingContent) { + f.Redirect = &val + } +} + +func WithRenderingContentWidgets(val Widgets) RenderingContentOption { + return func(f *RenderingContent) { + f.Widgets = &val + } +} + +// NewRenderingContent instantiates a new RenderingContent object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRenderingContent(opts ...RenderingContentOption) *RenderingContent { + this := &RenderingContent{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyRenderingContent return a pointer to an empty RenderingContent object. +func NewEmptyRenderingContent() *RenderingContent { + return &RenderingContent{} +} + +// GetFacetOrdering returns the FacetOrdering field value if set, zero value otherwise. +func (o *RenderingContent) GetFacetOrdering() FacetOrdering { + if o == nil || o.FacetOrdering == nil { + var ret FacetOrdering + return ret + } + return *o.FacetOrdering +} + +// GetFacetOrderingOk returns a tuple with the FacetOrdering field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RenderingContent) GetFacetOrderingOk() (*FacetOrdering, bool) { + if o == nil || o.FacetOrdering == nil { + return nil, false + } + return o.FacetOrdering, true +} + +// HasFacetOrdering returns a boolean if a field has been set. +func (o *RenderingContent) HasFacetOrdering() bool { + if o != nil && o.FacetOrdering != nil { + return true + } + + return false +} + +// SetFacetOrdering gets a reference to the given FacetOrdering and assigns it to the FacetOrdering field. +func (o *RenderingContent) SetFacetOrdering(v *FacetOrdering) *RenderingContent { + o.FacetOrdering = v + return o +} + +// GetRedirect returns the Redirect field value if set, zero value otherwise. +func (o *RenderingContent) GetRedirect() RedirectURL { + if o == nil || o.Redirect == nil { + var ret RedirectURL + return ret + } + return *o.Redirect +} + +// GetRedirectOk returns a tuple with the Redirect field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RenderingContent) GetRedirectOk() (*RedirectURL, bool) { + if o == nil || o.Redirect == nil { + return nil, false + } + return o.Redirect, true +} + +// HasRedirect returns a boolean if a field has been set. +func (o *RenderingContent) HasRedirect() bool { + if o != nil && o.Redirect != nil { + return true + } + + return false +} + +// SetRedirect gets a reference to the given RedirectURL and assigns it to the Redirect field. +func (o *RenderingContent) SetRedirect(v *RedirectURL) *RenderingContent { + o.Redirect = v + return o +} + +// GetWidgets returns the Widgets field value if set, zero value otherwise. +func (o *RenderingContent) GetWidgets() Widgets { + if o == nil || o.Widgets == nil { + var ret Widgets + return ret + } + return *o.Widgets +} + +// GetWidgetsOk returns a tuple with the Widgets field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RenderingContent) GetWidgetsOk() (*Widgets, bool) { + if o == nil || o.Widgets == nil { + return nil, false + } + return o.Widgets, true +} + +// HasWidgets returns a boolean if a field has been set. +func (o *RenderingContent) HasWidgets() bool { + if o != nil && o.Widgets != nil { + return true + } + + return false +} + +// SetWidgets gets a reference to the given Widgets and assigns it to the Widgets field. +func (o *RenderingContent) SetWidgets(v *Widgets) *RenderingContent { + o.Widgets = v + return o +} + +func (o RenderingContent) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.FacetOrdering != nil { + toSerialize["facetOrdering"] = o.FacetOrdering + } + if o.Redirect != nil { + toSerialize["redirect"] = o.Redirect + } + if o.Widgets != nil { + toSerialize["widgets"] = o.Widgets + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal RenderingContent: %w", err) + } + + return serialized, nil +} + +func (o RenderingContent) String() string { + out := "" + out += fmt.Sprintf(" facetOrdering=%v\n", o.FacetOrdering) + out += fmt.Sprintf(" redirect=%v\n", o.Redirect) + out += fmt.Sprintf(" widgets=%v\n", o.Widgets) + return fmt.Sprintf("RenderingContent {\n%s}", out) +} diff --git a/algolia/composition/model_request_body.go b/algolia/composition/model_request_body.go new file mode 100644 index 000000000..edaa23220 --- /dev/null +++ b/algolia/composition/model_request_body.go @@ -0,0 +1,89 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// RequestBody struct for RequestBody. +type RequestBody struct { + Params *Params `json:"params,omitempty"` +} + +type RequestBodyOption func(f *RequestBody) + +func WithRequestBodyParams(val Params) RequestBodyOption { + return func(f *RequestBody) { + f.Params = &val + } +} + +// NewRequestBody instantiates a new RequestBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRequestBody(opts ...RequestBodyOption) *RequestBody { + this := &RequestBody{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyRequestBody return a pointer to an empty RequestBody object. +func NewEmptyRequestBody() *RequestBody { + return &RequestBody{} +} + +// GetParams returns the Params field value if set, zero value otherwise. +func (o *RequestBody) GetParams() Params { + if o == nil || o.Params == nil { + var ret Params + return ret + } + return *o.Params +} + +// GetParamsOk returns a tuple with the Params field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RequestBody) GetParamsOk() (*Params, bool) { + if o == nil || o.Params == nil { + return nil, false + } + return o.Params, true +} + +// HasParams returns a boolean if a field has been set. +func (o *RequestBody) HasParams() bool { + if o != nil && o.Params != nil { + return true + } + + return false +} + +// SetParams gets a reference to the given Params and assigns it to the Params field. +func (o *RequestBody) SetParams(v *Params) *RequestBody { + o.Params = v + return o +} + +func (o RequestBody) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Params != nil { + toSerialize["params"] = o.Params + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal RequestBody: %w", err) + } + + return serialized, nil +} + +func (o RequestBody) String() string { + out := "" + out += fmt.Sprintf(" params=%v\n", o.Params) + return fmt.Sprintf("RequestBody {\n%s}", out) +} diff --git a/algolia/composition/model_results_composition_info_response.go b/algolia/composition/model_results_composition_info_response.go new file mode 100644 index 000000000..5ccd8dc0e --- /dev/null +++ b/algolia/composition/model_results_composition_info_response.go @@ -0,0 +1,71 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// ResultsCompositionInfoResponse struct for ResultsCompositionInfoResponse. +type ResultsCompositionInfoResponse struct { + InjectedItems []ResultsInjectedItemInfoResponse `json:"injectedItems"` +} + +// NewResultsCompositionInfoResponse instantiates a new ResultsCompositionInfoResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewResultsCompositionInfoResponse(injectedItems []ResultsInjectedItemInfoResponse) *ResultsCompositionInfoResponse { + this := &ResultsCompositionInfoResponse{} + this.InjectedItems = injectedItems + return this +} + +// NewEmptyResultsCompositionInfoResponse return a pointer to an empty ResultsCompositionInfoResponse object. +func NewEmptyResultsCompositionInfoResponse() *ResultsCompositionInfoResponse { + return &ResultsCompositionInfoResponse{} +} + +// GetInjectedItems returns the InjectedItems field value. +func (o *ResultsCompositionInfoResponse) GetInjectedItems() []ResultsInjectedItemInfoResponse { + if o == nil { + var ret []ResultsInjectedItemInfoResponse + return ret + } + + return o.InjectedItems +} + +// GetInjectedItemsOk returns a tuple with the InjectedItems field value +// and a boolean to check if the value has been set. +func (o *ResultsCompositionInfoResponse) GetInjectedItemsOk() ([]ResultsInjectedItemInfoResponse, bool) { + if o == nil { + return nil, false + } + return o.InjectedItems, true +} + +// SetInjectedItems sets field value. +func (o *ResultsCompositionInfoResponse) SetInjectedItems(v []ResultsInjectedItemInfoResponse) *ResultsCompositionInfoResponse { + o.InjectedItems = v + return o +} + +func (o ResultsCompositionInfoResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["injectedItems"] = o.InjectedItems + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal ResultsCompositionInfoResponse: %w", err) + } + + return serialized, nil +} + +func (o ResultsCompositionInfoResponse) String() string { + out := "" + out += fmt.Sprintf(" injectedItems=%v\n", o.InjectedItems) + return fmt.Sprintf("ResultsCompositionInfoResponse {\n%s}", out) +} diff --git a/algolia/composition/model_results_injected_item_applied_rules_info_response.go b/algolia/composition/model_results_injected_item_applied_rules_info_response.go new file mode 100644 index 000000000..a82fb424c --- /dev/null +++ b/algolia/composition/model_results_injected_item_applied_rules_info_response.go @@ -0,0 +1,72 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// ResultsInjectedItemAppliedRulesInfoResponse struct for ResultsInjectedItemAppliedRulesInfoResponse. +type ResultsInjectedItemAppliedRulesInfoResponse struct { + // Unique record identifier. + ObjectID string `json:"objectID"` +} + +// NewResultsInjectedItemAppliedRulesInfoResponse instantiates a new ResultsInjectedItemAppliedRulesInfoResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewResultsInjectedItemAppliedRulesInfoResponse(objectID string) *ResultsInjectedItemAppliedRulesInfoResponse { + this := &ResultsInjectedItemAppliedRulesInfoResponse{} + this.ObjectID = objectID + return this +} + +// NewEmptyResultsInjectedItemAppliedRulesInfoResponse return a pointer to an empty ResultsInjectedItemAppliedRulesInfoResponse object. +func NewEmptyResultsInjectedItemAppliedRulesInfoResponse() *ResultsInjectedItemAppliedRulesInfoResponse { + return &ResultsInjectedItemAppliedRulesInfoResponse{} +} + +// GetObjectID returns the ObjectID field value. +func (o *ResultsInjectedItemAppliedRulesInfoResponse) GetObjectID() string { + if o == nil { + var ret string + return ret + } + + return o.ObjectID +} + +// GetObjectIDOk returns a tuple with the ObjectID field value +// and a boolean to check if the value has been set. +func (o *ResultsInjectedItemAppliedRulesInfoResponse) GetObjectIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ObjectID, true +} + +// SetObjectID sets field value. +func (o *ResultsInjectedItemAppliedRulesInfoResponse) SetObjectID(v string) *ResultsInjectedItemAppliedRulesInfoResponse { + o.ObjectID = v + return o +} + +func (o ResultsInjectedItemAppliedRulesInfoResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["objectID"] = o.ObjectID + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal ResultsInjectedItemAppliedRulesInfoResponse: %w", err) + } + + return serialized, nil +} + +func (o ResultsInjectedItemAppliedRulesInfoResponse) String() string { + out := "" + out += fmt.Sprintf(" objectID=%v\n", o.ObjectID) + return fmt.Sprintf("ResultsInjectedItemAppliedRulesInfoResponse {\n%s}", out) +} diff --git a/algolia/composition/model_results_injected_item_info_response.go b/algolia/composition/model_results_injected_item_info_response.go new file mode 100644 index 000000000..f397e1271 --- /dev/null +++ b/algolia/composition/model_results_injected_item_info_response.go @@ -0,0 +1,165 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// ResultsInjectedItemInfoResponse struct for ResultsInjectedItemInfoResponse. +type ResultsInjectedItemInfoResponse struct { + Key string `json:"key"` + AppliedRules []ResultsInjectedItemAppliedRulesInfoResponse `json:"appliedRules,omitempty"` + AdditionalProperties map[string]any +} + +type _ResultsInjectedItemInfoResponse ResultsInjectedItemInfoResponse + +type ResultsInjectedItemInfoResponseOption func(f *ResultsInjectedItemInfoResponse) + +func WithResultsInjectedItemInfoResponseAppliedRules(val []ResultsInjectedItemAppliedRulesInfoResponse) ResultsInjectedItemInfoResponseOption { + return func(f *ResultsInjectedItemInfoResponse) { + f.AppliedRules = val + } +} + +// NewResultsInjectedItemInfoResponse instantiates a new ResultsInjectedItemInfoResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewResultsInjectedItemInfoResponse(key string, opts ...ResultsInjectedItemInfoResponseOption) *ResultsInjectedItemInfoResponse { + this := &ResultsInjectedItemInfoResponse{} + this.Key = key + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyResultsInjectedItemInfoResponse return a pointer to an empty ResultsInjectedItemInfoResponse object. +func NewEmptyResultsInjectedItemInfoResponse() *ResultsInjectedItemInfoResponse { + return &ResultsInjectedItemInfoResponse{} +} + +// GetKey returns the Key field value. +func (o *ResultsInjectedItemInfoResponse) GetKey() string { + if o == nil { + var ret string + return ret + } + + return o.Key +} + +// GetKeyOk returns a tuple with the Key field value +// and a boolean to check if the value has been set. +func (o *ResultsInjectedItemInfoResponse) GetKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Key, true +} + +// SetKey sets field value. +func (o *ResultsInjectedItemInfoResponse) SetKey(v string) *ResultsInjectedItemInfoResponse { + o.Key = v + return o +} + +// GetAppliedRules returns the AppliedRules field value if set, zero value otherwise. +func (o *ResultsInjectedItemInfoResponse) GetAppliedRules() []ResultsInjectedItemAppliedRulesInfoResponse { + if o == nil || o.AppliedRules == nil { + var ret []ResultsInjectedItemAppliedRulesInfoResponse + return ret + } + return o.AppliedRules +} + +// GetAppliedRulesOk returns a tuple with the AppliedRules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResultsInjectedItemInfoResponse) GetAppliedRulesOk() ([]ResultsInjectedItemAppliedRulesInfoResponse, bool) { + if o == nil || o.AppliedRules == nil { + return nil, false + } + return o.AppliedRules, true +} + +// HasAppliedRules returns a boolean if a field has been set. +func (o *ResultsInjectedItemInfoResponse) HasAppliedRules() bool { + if o != nil && o.AppliedRules != nil { + return true + } + + return false +} + +// SetAppliedRules gets a reference to the given []ResultsInjectedItemAppliedRulesInfoResponse and assigns it to the AppliedRules field. +func (o *ResultsInjectedItemInfoResponse) SetAppliedRules(v []ResultsInjectedItemAppliedRulesInfoResponse) *ResultsInjectedItemInfoResponse { + o.AppliedRules = v + return o +} + +func (o *ResultsInjectedItemInfoResponse) SetAdditionalProperty(key string, value any) *ResultsInjectedItemInfoResponse { + if o.AdditionalProperties == nil { + o.AdditionalProperties = make(map[string]any) + } + + o.AdditionalProperties[key] = value + + return o +} + +func (o ResultsInjectedItemInfoResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["key"] = o.Key + } + if o.AppliedRules != nil { + toSerialize["appliedRules"] = o.AppliedRules + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal ResultsInjectedItemInfoResponse: %w", err) + } + + return serialized, nil +} + +func (o *ResultsInjectedItemInfoResponse) UnmarshalJSON(bytes []byte) error { + varResultsInjectedItemInfoResponse := _ResultsInjectedItemInfoResponse{} + + err := json.Unmarshal(bytes, &varResultsInjectedItemInfoResponse) + if err != nil { + return fmt.Errorf("failed to unmarshal ResultsInjectedItemInfoResponse: %w", err) + } + + *o = ResultsInjectedItemInfoResponse(varResultsInjectedItemInfoResponse) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in ResultsInjectedItemInfoResponse: %w", err) + } + + delete(additionalProperties, "key") + delete(additionalProperties, "appliedRules") + o.AdditionalProperties = additionalProperties + + return nil +} + +func (o ResultsInjectedItemInfoResponse) String() string { + out := "" + out += fmt.Sprintf(" key=%v\n", o.Key) + out += fmt.Sprintf(" appliedRules=%v\n", o.AppliedRules) + for key, value := range o.AdditionalProperties { + out += fmt.Sprintf(" %s=%v\n", key, value) + } + return fmt.Sprintf("ResultsInjectedItemInfoResponse {\n%s}", out) +} diff --git a/algolia/composition/model_search_for_facet_values_params.go b/algolia/composition/model_search_for_facet_values_params.go new file mode 100644 index 000000000..425d1ddb5 --- /dev/null +++ b/algolia/composition/model_search_for_facet_values_params.go @@ -0,0 +1,179 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SearchForFacetValuesParams struct for SearchForFacetValuesParams. +type SearchForFacetValuesParams struct { + // Search query. + Query *string `json:"query,omitempty"` + // 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). + MaxFacetHits *int32 `json:"maxFacetHits,omitempty"` + SearchQuery *Params `json:"searchQuery,omitempty"` +} + +type SearchForFacetValuesParamsOption func(f *SearchForFacetValuesParams) + +func WithSearchForFacetValuesParamsQuery(val string) SearchForFacetValuesParamsOption { + return func(f *SearchForFacetValuesParams) { + f.Query = &val + } +} + +func WithSearchForFacetValuesParamsMaxFacetHits(val int32) SearchForFacetValuesParamsOption { + return func(f *SearchForFacetValuesParams) { + f.MaxFacetHits = &val + } +} + +func WithSearchForFacetValuesParamsSearchQuery(val Params) SearchForFacetValuesParamsOption { + return func(f *SearchForFacetValuesParams) { + f.SearchQuery = &val + } +} + +// NewSearchForFacetValuesParams instantiates a new SearchForFacetValuesParams object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSearchForFacetValuesParams(opts ...SearchForFacetValuesParamsOption) *SearchForFacetValuesParams { + this := &SearchForFacetValuesParams{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptySearchForFacetValuesParams return a pointer to an empty SearchForFacetValuesParams object. +func NewEmptySearchForFacetValuesParams() *SearchForFacetValuesParams { + return &SearchForFacetValuesParams{} +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *SearchForFacetValuesParams) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesParams) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *SearchForFacetValuesParams) HasQuery() bool { + if o != nil && o.Query != nil { + return true + } + + return false +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *SearchForFacetValuesParams) SetQuery(v string) *SearchForFacetValuesParams { + o.Query = &v + return o +} + +// GetMaxFacetHits returns the MaxFacetHits field value if set, zero value otherwise. +func (o *SearchForFacetValuesParams) GetMaxFacetHits() int32 { + if o == nil || o.MaxFacetHits == nil { + var ret int32 + return ret + } + return *o.MaxFacetHits +} + +// GetMaxFacetHitsOk returns a tuple with the MaxFacetHits field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesParams) GetMaxFacetHitsOk() (*int32, bool) { + if o == nil || o.MaxFacetHits == nil { + return nil, false + } + return o.MaxFacetHits, true +} + +// HasMaxFacetHits returns a boolean if a field has been set. +func (o *SearchForFacetValuesParams) HasMaxFacetHits() bool { + if o != nil && o.MaxFacetHits != nil { + return true + } + + return false +} + +// SetMaxFacetHits gets a reference to the given int32 and assigns it to the MaxFacetHits field. +func (o *SearchForFacetValuesParams) SetMaxFacetHits(v int32) *SearchForFacetValuesParams { + o.MaxFacetHits = &v + return o +} + +// GetSearchQuery returns the SearchQuery field value if set, zero value otherwise. +func (o *SearchForFacetValuesParams) GetSearchQuery() Params { + if o == nil || o.SearchQuery == nil { + var ret Params + return ret + } + return *o.SearchQuery +} + +// GetSearchQueryOk returns a tuple with the SearchQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesParams) GetSearchQueryOk() (*Params, bool) { + if o == nil || o.SearchQuery == nil { + return nil, false + } + return o.SearchQuery, true +} + +// HasSearchQuery returns a boolean if a field has been set. +func (o *SearchForFacetValuesParams) HasSearchQuery() bool { + if o != nil && o.SearchQuery != nil { + return true + } + + return false +} + +// SetSearchQuery gets a reference to the given Params and assigns it to the SearchQuery field. +func (o *SearchForFacetValuesParams) SetSearchQuery(v *Params) *SearchForFacetValuesParams { + o.SearchQuery = v + return o +} + +func (o SearchForFacetValuesParams) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Query != nil { + toSerialize["query"] = o.Query + } + if o.MaxFacetHits != nil { + toSerialize["maxFacetHits"] = o.MaxFacetHits + } + if o.SearchQuery != nil { + toSerialize["searchQuery"] = o.SearchQuery + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SearchForFacetValuesParams: %w", err) + } + + return serialized, nil +} + +func (o SearchForFacetValuesParams) String() string { + out := "" + out += fmt.Sprintf(" query=%v\n", o.Query) + out += fmt.Sprintf(" maxFacetHits=%v\n", o.MaxFacetHits) + out += fmt.Sprintf(" searchQuery=%v\n", o.SearchQuery) + return fmt.Sprintf("SearchForFacetValuesParams {\n%s}", out) +} diff --git a/algolia/composition/model_search_for_facet_values_request.go b/algolia/composition/model_search_for_facet_values_request.go new file mode 100644 index 000000000..089444b4c --- /dev/null +++ b/algolia/composition/model_search_for_facet_values_request.go @@ -0,0 +1,89 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SearchForFacetValuesRequest struct for SearchForFacetValuesRequest. +type SearchForFacetValuesRequest struct { + Params *SearchForFacetValuesParams `json:"params,omitempty"` +} + +type SearchForFacetValuesRequestOption func(f *SearchForFacetValuesRequest) + +func WithSearchForFacetValuesRequestParams(val SearchForFacetValuesParams) SearchForFacetValuesRequestOption { + return func(f *SearchForFacetValuesRequest) { + f.Params = &val + } +} + +// NewSearchForFacetValuesRequest instantiates a new SearchForFacetValuesRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSearchForFacetValuesRequest(opts ...SearchForFacetValuesRequestOption) *SearchForFacetValuesRequest { + this := &SearchForFacetValuesRequest{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptySearchForFacetValuesRequest return a pointer to an empty SearchForFacetValuesRequest object. +func NewEmptySearchForFacetValuesRequest() *SearchForFacetValuesRequest { + return &SearchForFacetValuesRequest{} +} + +// GetParams returns the Params field value if set, zero value otherwise. +func (o *SearchForFacetValuesRequest) GetParams() SearchForFacetValuesParams { + if o == nil || o.Params == nil { + var ret SearchForFacetValuesParams + return ret + } + return *o.Params +} + +// GetParamsOk returns a tuple with the Params field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesRequest) GetParamsOk() (*SearchForFacetValuesParams, bool) { + if o == nil || o.Params == nil { + return nil, false + } + return o.Params, true +} + +// HasParams returns a boolean if a field has been set. +func (o *SearchForFacetValuesRequest) HasParams() bool { + if o != nil && o.Params != nil { + return true + } + + return false +} + +// SetParams gets a reference to the given SearchForFacetValuesParams and assigns it to the Params field. +func (o *SearchForFacetValuesRequest) SetParams(v *SearchForFacetValuesParams) *SearchForFacetValuesRequest { + o.Params = v + return o +} + +func (o SearchForFacetValuesRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Params != nil { + toSerialize["params"] = o.Params + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SearchForFacetValuesRequest: %w", err) + } + + return serialized, nil +} + +func (o SearchForFacetValuesRequest) String() string { + out := "" + out += fmt.Sprintf(" params=%v\n", o.Params) + return fmt.Sprintf("SearchForFacetValuesRequest {\n%s}", out) +} diff --git a/algolia/composition/model_search_for_facet_values_response.go b/algolia/composition/model_search_for_facet_values_response.go new file mode 100644 index 000000000..92e2a14d6 --- /dev/null +++ b/algolia/composition/model_search_for_facet_values_response.go @@ -0,0 +1,90 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SearchForFacetValuesResponse struct for SearchForFacetValuesResponse. +type SearchForFacetValuesResponse struct { + // Search for facet values results. + Results []SearchForFacetValuesResults `json:"results,omitempty"` +} + +type SearchForFacetValuesResponseOption func(f *SearchForFacetValuesResponse) + +func WithSearchForFacetValuesResponseResults(val []SearchForFacetValuesResults) SearchForFacetValuesResponseOption { + return func(f *SearchForFacetValuesResponse) { + f.Results = val + } +} + +// NewSearchForFacetValuesResponse instantiates a new SearchForFacetValuesResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSearchForFacetValuesResponse(opts ...SearchForFacetValuesResponseOption) *SearchForFacetValuesResponse { + this := &SearchForFacetValuesResponse{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptySearchForFacetValuesResponse return a pointer to an empty SearchForFacetValuesResponse object. +func NewEmptySearchForFacetValuesResponse() *SearchForFacetValuesResponse { + return &SearchForFacetValuesResponse{} +} + +// GetResults returns the Results field value if set, zero value otherwise. +func (o *SearchForFacetValuesResponse) GetResults() []SearchForFacetValuesResults { + if o == nil || o.Results == nil { + var ret []SearchForFacetValuesResults + return ret + } + return o.Results +} + +// GetResultsOk returns a tuple with the Results field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesResponse) GetResultsOk() ([]SearchForFacetValuesResults, bool) { + if o == nil || o.Results == nil { + return nil, false + } + return o.Results, true +} + +// HasResults returns a boolean if a field has been set. +func (o *SearchForFacetValuesResponse) HasResults() bool { + if o != nil && o.Results != nil { + return true + } + + return false +} + +// SetResults gets a reference to the given []SearchForFacetValuesResults and assigns it to the Results field. +func (o *SearchForFacetValuesResponse) SetResults(v []SearchForFacetValuesResults) *SearchForFacetValuesResponse { + o.Results = v + return o +} + +func (o SearchForFacetValuesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Results != nil { + toSerialize["results"] = o.Results + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SearchForFacetValuesResponse: %w", err) + } + + return serialized, nil +} + +func (o SearchForFacetValuesResponse) String() string { + out := "" + out += fmt.Sprintf(" results=%v\n", o.Results) + return fmt.Sprintf("SearchForFacetValuesResponse {\n%s}", out) +} diff --git a/algolia/composition/model_search_for_facet_values_results.go b/algolia/composition/model_search_for_facet_values_results.go new file mode 100644 index 000000000..748ef4fc5 --- /dev/null +++ b/algolia/composition/model_search_for_facet_values_results.go @@ -0,0 +1,185 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SearchForFacetValuesResults struct for SearchForFacetValuesResults. +type SearchForFacetValuesResults struct { + IndexName string `json:"indexName"` + // Matching facet values. + FacetHits []FacetHits `json:"facetHits"` + // 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-). + ExhaustiveFacetsCount bool `json:"exhaustiveFacetsCount"` + // Time the server took to process the request, in milliseconds. + ProcessingTimeMS *int32 `json:"processingTimeMS,omitempty"` +} + +type SearchForFacetValuesResultsOption func(f *SearchForFacetValuesResults) + +func WithSearchForFacetValuesResultsProcessingTimeMS(val int32) SearchForFacetValuesResultsOption { + return func(f *SearchForFacetValuesResults) { + f.ProcessingTimeMS = &val + } +} + +// NewSearchForFacetValuesResults instantiates a new SearchForFacetValuesResults object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSearchForFacetValuesResults(indexName string, facetHits []FacetHits, exhaustiveFacetsCount bool, opts ...SearchForFacetValuesResultsOption) *SearchForFacetValuesResults { + this := &SearchForFacetValuesResults{} + this.IndexName = indexName + this.FacetHits = facetHits + this.ExhaustiveFacetsCount = exhaustiveFacetsCount + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptySearchForFacetValuesResults return a pointer to an empty SearchForFacetValuesResults object. +func NewEmptySearchForFacetValuesResults() *SearchForFacetValuesResults { + return &SearchForFacetValuesResults{} +} + +// GetIndexName returns the IndexName field value. +func (o *SearchForFacetValuesResults) GetIndexName() string { + if o == nil { + var ret string + return ret + } + + return o.IndexName +} + +// GetIndexNameOk returns a tuple with the IndexName field value +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesResults) GetIndexNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.IndexName, true +} + +// SetIndexName sets field value. +func (o *SearchForFacetValuesResults) SetIndexName(v string) *SearchForFacetValuesResults { + o.IndexName = v + return o +} + +// GetFacetHits returns the FacetHits field value. +func (o *SearchForFacetValuesResults) GetFacetHits() []FacetHits { + if o == nil { + var ret []FacetHits + return ret + } + + return o.FacetHits +} + +// GetFacetHitsOk returns a tuple with the FacetHits field value +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesResults) GetFacetHitsOk() ([]FacetHits, bool) { + if o == nil { + return nil, false + } + return o.FacetHits, true +} + +// SetFacetHits sets field value. +func (o *SearchForFacetValuesResults) SetFacetHits(v []FacetHits) *SearchForFacetValuesResults { + o.FacetHits = v + return o +} + +// GetExhaustiveFacetsCount returns the ExhaustiveFacetsCount field value. +func (o *SearchForFacetValuesResults) GetExhaustiveFacetsCount() bool { + if o == nil { + var ret bool + return ret + } + + return o.ExhaustiveFacetsCount +} + +// GetExhaustiveFacetsCountOk returns a tuple with the ExhaustiveFacetsCount field value +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesResults) GetExhaustiveFacetsCountOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.ExhaustiveFacetsCount, true +} + +// SetExhaustiveFacetsCount sets field value. +func (o *SearchForFacetValuesResults) SetExhaustiveFacetsCount(v bool) *SearchForFacetValuesResults { + o.ExhaustiveFacetsCount = v + return o +} + +// GetProcessingTimeMS returns the ProcessingTimeMS field value if set, zero value otherwise. +func (o *SearchForFacetValuesResults) GetProcessingTimeMS() int32 { + if o == nil || o.ProcessingTimeMS == nil { + var ret int32 + return ret + } + return *o.ProcessingTimeMS +} + +// GetProcessingTimeMSOk returns a tuple with the ProcessingTimeMS field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchForFacetValuesResults) GetProcessingTimeMSOk() (*int32, bool) { + if o == nil || o.ProcessingTimeMS == nil { + return nil, false + } + return o.ProcessingTimeMS, true +} + +// HasProcessingTimeMS returns a boolean if a field has been set. +func (o *SearchForFacetValuesResults) HasProcessingTimeMS() bool { + if o != nil && o.ProcessingTimeMS != nil { + return true + } + + return false +} + +// SetProcessingTimeMS gets a reference to the given int32 and assigns it to the ProcessingTimeMS field. +func (o *SearchForFacetValuesResults) SetProcessingTimeMS(v int32) *SearchForFacetValuesResults { + o.ProcessingTimeMS = &v + return o +} + +func (o SearchForFacetValuesResults) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["indexName"] = o.IndexName + } + if true { + toSerialize["facetHits"] = o.FacetHits + } + if true { + toSerialize["exhaustiveFacetsCount"] = o.ExhaustiveFacetsCount + } + if o.ProcessingTimeMS != nil { + toSerialize["processingTimeMS"] = o.ProcessingTimeMS + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SearchForFacetValuesResults: %w", err) + } + + return serialized, nil +} + +func (o SearchForFacetValuesResults) String() string { + out := "" + out += fmt.Sprintf(" indexName=%v\n", o.IndexName) + out += fmt.Sprintf(" facetHits=%v\n", o.FacetHits) + out += fmt.Sprintf(" exhaustiveFacetsCount=%v\n", o.ExhaustiveFacetsCount) + out += fmt.Sprintf(" processingTimeMS=%v\n", o.ProcessingTimeMS) + return fmt.Sprintf("SearchForFacetValuesResults {\n%s}", out) +} diff --git a/algolia/composition/model_search_response.go b/algolia/composition/model_search_response.go new file mode 100644 index 000000000..fa46a1058 --- /dev/null +++ b/algolia/composition/model_search_response.go @@ -0,0 +1,166 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SearchResponse struct for SearchResponse. +type SearchResponse struct { + Compositions *CompositionsSearchResponse `json:"compositions,omitempty"` + // Search results. + Results []SearchResultsItem `json:"results"` + AdditionalProperties map[string]any +} + +type _SearchResponse SearchResponse + +type SearchResponseOption func(f *SearchResponse) + +func WithSearchResponseCompositions(val CompositionsSearchResponse) SearchResponseOption { + return func(f *SearchResponse) { + f.Compositions = &val + } +} + +// NewSearchResponse instantiates a new SearchResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSearchResponse(results []SearchResultsItem, opts ...SearchResponseOption) *SearchResponse { + this := &SearchResponse{} + this.Results = results + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptySearchResponse return a pointer to an empty SearchResponse object. +func NewEmptySearchResponse() *SearchResponse { + return &SearchResponse{} +} + +// GetCompositions returns the Compositions field value if set, zero value otherwise. +func (o *SearchResponse) GetCompositions() CompositionsSearchResponse { + if o == nil || o.Compositions == nil { + var ret CompositionsSearchResponse + return ret + } + return *o.Compositions +} + +// GetCompositionsOk returns a tuple with the Compositions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResponse) GetCompositionsOk() (*CompositionsSearchResponse, bool) { + if o == nil || o.Compositions == nil { + return nil, false + } + return o.Compositions, true +} + +// HasCompositions returns a boolean if a field has been set. +func (o *SearchResponse) HasCompositions() bool { + if o != nil && o.Compositions != nil { + return true + } + + return false +} + +// SetCompositions gets a reference to the given CompositionsSearchResponse and assigns it to the Compositions field. +func (o *SearchResponse) SetCompositions(v *CompositionsSearchResponse) *SearchResponse { + o.Compositions = v + return o +} + +// GetResults returns the Results field value. +func (o *SearchResponse) GetResults() []SearchResultsItem { + if o == nil { + var ret []SearchResultsItem + return ret + } + + return o.Results +} + +// GetResultsOk returns a tuple with the Results field value +// and a boolean to check if the value has been set. +func (o *SearchResponse) GetResultsOk() ([]SearchResultsItem, bool) { + if o == nil { + return nil, false + } + return o.Results, true +} + +// SetResults sets field value. +func (o *SearchResponse) SetResults(v []SearchResultsItem) *SearchResponse { + o.Results = v + return o +} + +func (o *SearchResponse) SetAdditionalProperty(key string, value any) *SearchResponse { + if o.AdditionalProperties == nil { + o.AdditionalProperties = make(map[string]any) + } + + o.AdditionalProperties[key] = value + + return o +} + +func (o SearchResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Compositions != nil { + toSerialize["compositions"] = o.Compositions + } + if true { + toSerialize["results"] = o.Results + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SearchResponse: %w", err) + } + + return serialized, nil +} + +func (o *SearchResponse) UnmarshalJSON(bytes []byte) error { + varSearchResponse := _SearchResponse{} + + err := json.Unmarshal(bytes, &varSearchResponse) + if err != nil { + return fmt.Errorf("failed to unmarshal SearchResponse: %w", err) + } + + *o = SearchResponse(varSearchResponse) + + additionalProperties := make(map[string]any) + + err = json.Unmarshal(bytes, &additionalProperties) + if err != nil { + return fmt.Errorf("failed to unmarshal additionalProperties in SearchResponse: %w", err) + } + + delete(additionalProperties, "compositions") + delete(additionalProperties, "results") + o.AdditionalProperties = additionalProperties + + return nil +} + +func (o SearchResponse) String() string { + out := "" + out += fmt.Sprintf(" compositions=%v\n", o.Compositions) + out += fmt.Sprintf(" results=%v\n", o.Results) + for key, value := range o.AdditionalProperties { + out += fmt.Sprintf(" %s=%v\n", key, value) + } + return fmt.Sprintf("SearchResponse {\n%s}", out) +} diff --git a/algolia/composition/model_search_results_item.go b/algolia/composition/model_search_results_item.go new file mode 100644 index 000000000..4d885025f --- /dev/null +++ b/algolia/composition/model_search_results_item.go @@ -0,0 +1,1466 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SearchResultsItem struct for SearchResultsItem. +type SearchResultsItem struct { + // A/B test ID. This is only included in the response for indices that are part of an A/B test. + AbTestID *int32 `json:"abTestID,omitempty"` + // Variant ID. This is only included in the response for indices that are part of an A/B test. + AbTestVariantID *int32 `json:"abTestVariantID,omitempty"` + // Computed geographical location. + AroundLatLng *string `json:"aroundLatLng,omitempty"` + // Distance from a central coordinate provided by `aroundLatLng`. + AutomaticRadius *string `json:"automaticRadius,omitempty"` + Exhaustive *Exhaustive `json:"exhaustive,omitempty"` + // Rules applied to the query. + AppliedRules []map[string]any `json:"appliedRules,omitempty"` + // See the `facetsCount` field of the `exhaustive` object in the response. + // Deprecated + ExhaustiveFacetsCount *bool `json:"exhaustiveFacetsCount,omitempty"` + // See the `nbHits` field of the `exhaustive` object in the response. + // Deprecated + ExhaustiveNbHits *bool `json:"exhaustiveNbHits,omitempty"` + // See the `typo` field of the `exhaustive` object in the response. + // Deprecated + ExhaustiveTypo *bool `json:"exhaustiveTypo,omitempty"` + // Facet counts. + Facets *map[string]map[string]int32 `json:"facets,omitempty"` + // Statistics for numerical facets. + FacetsStats *map[string]FacetStats `json:"facets_stats,omitempty"` + // Index name used for the query. + Index *string `json:"index,omitempty"` + // Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query. + IndexUsed *string `json:"indexUsed,omitempty"` + // Warnings about the query. + Message *string `json:"message,omitempty"` + // Number of hits selected and sorted by the relevant sort algorithm. + NbSortedHits *int32 `json:"nbSortedHits,omitempty"` + // 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. + ParsedQuery *string `json:"parsedQuery,omitempty"` + // Time the server took to process the request, in milliseconds. + ProcessingTimeMS int32 `json:"processingTimeMS"` + // Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate performance issues. + ProcessingTimingsMS map[string]any `json:"processingTimingsMS,omitempty"` + // Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set. + QueryAfterRemoval *string `json:"queryAfterRemoval,omitempty"` + Redirect *Redirect `json:"redirect,omitempty"` + RenderingContent *RenderingContent `json:"renderingContent,omitempty"` + // Time the server took to process the request, in milliseconds. + ServerTimeMS *int32 `json:"serverTimeMS,omitempty"` + // Host name of the server that processed the request. + ServerUsed *string `json:"serverUsed,omitempty"` + // An object with custom data. You can store up to 32kB as custom data. + UserData map[string]any `json:"userData,omitempty"` + // Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/). + QueryID *string `json:"queryID,omitempty"` + // Whether automatic events collection is enabled for the application. + AutomaticInsights *bool `json:"_automaticInsights,omitempty"` + // Page of search results to retrieve. + Page int32 `json:"page"` + // Number of results (hits). + NbHits int32 `json:"nbHits"` + // Number of pages of results. + NbPages int32 `json:"nbPages"` + // Number of hits per page. + HitsPerPage int32 `json:"hitsPerPage"` + // Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. + Hits []Hit `json:"hits"` + // Search query. + Query string `json:"query"` + // URL-encoded string of all search parameters. + Params string `json:"params"` + Compositions map[string]ResultsCompositionInfoResponse `json:"compositions"` +} + +type SearchResultsItemOption func(f *SearchResultsItem) + +func WithSearchResultsItemAbTestID(val int32) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.AbTestID = &val + } +} + +func WithSearchResultsItemAbTestVariantID(val int32) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.AbTestVariantID = &val + } +} + +func WithSearchResultsItemAroundLatLng(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.AroundLatLng = &val + } +} + +func WithSearchResultsItemAutomaticRadius(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.AutomaticRadius = &val + } +} + +func WithSearchResultsItemExhaustive(val Exhaustive) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.Exhaustive = &val + } +} + +func WithSearchResultsItemAppliedRules(val []map[string]any) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.AppliedRules = val + } +} + +func WithSearchResultsItemExhaustiveFacetsCount(val bool) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ExhaustiveFacetsCount = &val + } +} + +func WithSearchResultsItemExhaustiveNbHits(val bool) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ExhaustiveNbHits = &val + } +} + +func WithSearchResultsItemExhaustiveTypo(val bool) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ExhaustiveTypo = &val + } +} + +func WithSearchResultsItemFacets(val map[string]map[string]int32) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.Facets = &val + } +} + +func WithSearchResultsItemFacetsStats(val map[string]FacetStats) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.FacetsStats = &val + } +} + +func WithSearchResultsItemIndex(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.Index = &val + } +} + +func WithSearchResultsItemIndexUsed(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.IndexUsed = &val + } +} + +func WithSearchResultsItemMessage(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.Message = &val + } +} + +func WithSearchResultsItemNbSortedHits(val int32) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.NbSortedHits = &val + } +} + +func WithSearchResultsItemParsedQuery(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ParsedQuery = &val + } +} + +func WithSearchResultsItemProcessingTimingsMS(val map[string]any) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ProcessingTimingsMS = val + } +} + +func WithSearchResultsItemQueryAfterRemoval(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.QueryAfterRemoval = &val + } +} + +func WithSearchResultsItemRedirect(val Redirect) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.Redirect = &val + } +} + +func WithSearchResultsItemRenderingContent(val RenderingContent) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.RenderingContent = &val + } +} + +func WithSearchResultsItemServerTimeMS(val int32) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ServerTimeMS = &val + } +} + +func WithSearchResultsItemServerUsed(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.ServerUsed = &val + } +} + +func WithSearchResultsItemUserData(val map[string]any) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.UserData = val + } +} + +func WithSearchResultsItemQueryID(val string) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.QueryID = &val + } +} + +func WithSearchResultsItemAutomaticInsights(val bool) SearchResultsItemOption { + return func(f *SearchResultsItem) { + f.AutomaticInsights = &val + } +} + +// NewSearchResultsItem instantiates a new SearchResultsItem object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSearchResultsItem(processingTimeMS int32, page int32, nbHits int32, nbPages int32, hitsPerPage int32, hits []Hit, query string, params string, compositions map[string]ResultsCompositionInfoResponse, opts ...SearchResultsItemOption) *SearchResultsItem { + this := &SearchResultsItem{} + this.ProcessingTimeMS = processingTimeMS + this.Page = page + this.NbHits = nbHits + this.NbPages = nbPages + this.HitsPerPage = hitsPerPage + this.Hits = hits + this.Query = query + this.Params = params + this.Compositions = compositions + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptySearchResultsItem return a pointer to an empty SearchResultsItem object. +func NewEmptySearchResultsItem() *SearchResultsItem { + return &SearchResultsItem{} +} + +// GetAbTestID returns the AbTestID field value if set, zero value otherwise. +func (o *SearchResultsItem) GetAbTestID() int32 { + if o == nil || o.AbTestID == nil { + var ret int32 + return ret + } + return *o.AbTestID +} + +// GetAbTestIDOk returns a tuple with the AbTestID field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetAbTestIDOk() (*int32, bool) { + if o == nil || o.AbTestID == nil { + return nil, false + } + return o.AbTestID, true +} + +// HasAbTestID returns a boolean if a field has been set. +func (o *SearchResultsItem) HasAbTestID() bool { + if o != nil && o.AbTestID != nil { + return true + } + + return false +} + +// SetAbTestID gets a reference to the given int32 and assigns it to the AbTestID field. +func (o *SearchResultsItem) SetAbTestID(v int32) *SearchResultsItem { + o.AbTestID = &v + return o +} + +// GetAbTestVariantID returns the AbTestVariantID field value if set, zero value otherwise. +func (o *SearchResultsItem) GetAbTestVariantID() int32 { + if o == nil || o.AbTestVariantID == nil { + var ret int32 + return ret + } + return *o.AbTestVariantID +} + +// GetAbTestVariantIDOk returns a tuple with the AbTestVariantID field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetAbTestVariantIDOk() (*int32, bool) { + if o == nil || o.AbTestVariantID == nil { + return nil, false + } + return o.AbTestVariantID, true +} + +// HasAbTestVariantID returns a boolean if a field has been set. +func (o *SearchResultsItem) HasAbTestVariantID() bool { + if o != nil && o.AbTestVariantID != nil { + return true + } + + return false +} + +// SetAbTestVariantID gets a reference to the given int32 and assigns it to the AbTestVariantID field. +func (o *SearchResultsItem) SetAbTestVariantID(v int32) *SearchResultsItem { + o.AbTestVariantID = &v + return o +} + +// GetAroundLatLng returns the AroundLatLng field value if set, zero value otherwise. +func (o *SearchResultsItem) GetAroundLatLng() string { + if o == nil || o.AroundLatLng == nil { + var ret string + return ret + } + return *o.AroundLatLng +} + +// GetAroundLatLngOk returns a tuple with the AroundLatLng field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetAroundLatLngOk() (*string, bool) { + if o == nil || o.AroundLatLng == nil { + return nil, false + } + return o.AroundLatLng, true +} + +// HasAroundLatLng returns a boolean if a field has been set. +func (o *SearchResultsItem) HasAroundLatLng() bool { + if o != nil && o.AroundLatLng != nil { + return true + } + + return false +} + +// SetAroundLatLng gets a reference to the given string and assigns it to the AroundLatLng field. +func (o *SearchResultsItem) SetAroundLatLng(v string) *SearchResultsItem { + o.AroundLatLng = &v + return o +} + +// GetAutomaticRadius returns the AutomaticRadius field value if set, zero value otherwise. +func (o *SearchResultsItem) GetAutomaticRadius() string { + if o == nil || o.AutomaticRadius == nil { + var ret string + return ret + } + return *o.AutomaticRadius +} + +// GetAutomaticRadiusOk returns a tuple with the AutomaticRadius field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetAutomaticRadiusOk() (*string, bool) { + if o == nil || o.AutomaticRadius == nil { + return nil, false + } + return o.AutomaticRadius, true +} + +// HasAutomaticRadius returns a boolean if a field has been set. +func (o *SearchResultsItem) HasAutomaticRadius() bool { + if o != nil && o.AutomaticRadius != nil { + return true + } + + return false +} + +// SetAutomaticRadius gets a reference to the given string and assigns it to the AutomaticRadius field. +func (o *SearchResultsItem) SetAutomaticRadius(v string) *SearchResultsItem { + o.AutomaticRadius = &v + return o +} + +// GetExhaustive returns the Exhaustive field value if set, zero value otherwise. +func (o *SearchResultsItem) GetExhaustive() Exhaustive { + if o == nil || o.Exhaustive == nil { + var ret Exhaustive + return ret + } + return *o.Exhaustive +} + +// GetExhaustiveOk returns a tuple with the Exhaustive field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetExhaustiveOk() (*Exhaustive, bool) { + if o == nil || o.Exhaustive == nil { + return nil, false + } + return o.Exhaustive, true +} + +// HasExhaustive returns a boolean if a field has been set. +func (o *SearchResultsItem) HasExhaustive() bool { + if o != nil && o.Exhaustive != nil { + return true + } + + return false +} + +// SetExhaustive gets a reference to the given Exhaustive and assigns it to the Exhaustive field. +func (o *SearchResultsItem) SetExhaustive(v *Exhaustive) *SearchResultsItem { + o.Exhaustive = v + return o +} + +// GetAppliedRules returns the AppliedRules field value if set, zero value otherwise. +func (o *SearchResultsItem) GetAppliedRules() []map[string]any { + if o == nil || o.AppliedRules == nil { + var ret []map[string]any + return ret + } + return o.AppliedRules +} + +// GetAppliedRulesOk returns a tuple with the AppliedRules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetAppliedRulesOk() ([]map[string]any, bool) { + if o == nil || o.AppliedRules == nil { + return nil, false + } + return o.AppliedRules, true +} + +// HasAppliedRules returns a boolean if a field has been set. +func (o *SearchResultsItem) HasAppliedRules() bool { + if o != nil && o.AppliedRules != nil { + return true + } + + return false +} + +// SetAppliedRules gets a reference to the given []map[string]any and assigns it to the AppliedRules field. +func (o *SearchResultsItem) SetAppliedRules(v []map[string]any) *SearchResultsItem { + o.AppliedRules = v + return o +} + +// GetExhaustiveFacetsCount returns the ExhaustiveFacetsCount field value if set, zero value otherwise. +// Deprecated. +func (o *SearchResultsItem) GetExhaustiveFacetsCount() bool { + if o == nil || o.ExhaustiveFacetsCount == nil { + var ret bool + return ret + } + return *o.ExhaustiveFacetsCount +} + +// GetExhaustiveFacetsCountOk returns a tuple with the ExhaustiveFacetsCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +// Deprecated. +func (o *SearchResultsItem) GetExhaustiveFacetsCountOk() (*bool, bool) { + if o == nil || o.ExhaustiveFacetsCount == nil { + return nil, false + } + return o.ExhaustiveFacetsCount, true +} + +// HasExhaustiveFacetsCount returns a boolean if a field has been set. +func (o *SearchResultsItem) HasExhaustiveFacetsCount() bool { + if o != nil && o.ExhaustiveFacetsCount != nil { + return true + } + + return false +} + +// SetExhaustiveFacetsCount gets a reference to the given bool and assigns it to the ExhaustiveFacetsCount field. +// Deprecated. +func (o *SearchResultsItem) SetExhaustiveFacetsCount(v bool) *SearchResultsItem { + o.ExhaustiveFacetsCount = &v + return o +} + +// GetExhaustiveNbHits returns the ExhaustiveNbHits field value if set, zero value otherwise. +// Deprecated. +func (o *SearchResultsItem) GetExhaustiveNbHits() bool { + if o == nil || o.ExhaustiveNbHits == nil { + var ret bool + return ret + } + return *o.ExhaustiveNbHits +} + +// GetExhaustiveNbHitsOk returns a tuple with the ExhaustiveNbHits field value if set, nil otherwise +// and a boolean to check if the value has been set. +// Deprecated. +func (o *SearchResultsItem) GetExhaustiveNbHitsOk() (*bool, bool) { + if o == nil || o.ExhaustiveNbHits == nil { + return nil, false + } + return o.ExhaustiveNbHits, true +} + +// HasExhaustiveNbHits returns a boolean if a field has been set. +func (o *SearchResultsItem) HasExhaustiveNbHits() bool { + if o != nil && o.ExhaustiveNbHits != nil { + return true + } + + return false +} + +// SetExhaustiveNbHits gets a reference to the given bool and assigns it to the ExhaustiveNbHits field. +// Deprecated. +func (o *SearchResultsItem) SetExhaustiveNbHits(v bool) *SearchResultsItem { + o.ExhaustiveNbHits = &v + return o +} + +// GetExhaustiveTypo returns the ExhaustiveTypo field value if set, zero value otherwise. +// Deprecated. +func (o *SearchResultsItem) GetExhaustiveTypo() bool { + if o == nil || o.ExhaustiveTypo == nil { + var ret bool + return ret + } + return *o.ExhaustiveTypo +} + +// GetExhaustiveTypoOk returns a tuple with the ExhaustiveTypo field value if set, nil otherwise +// and a boolean to check if the value has been set. +// Deprecated. +func (o *SearchResultsItem) GetExhaustiveTypoOk() (*bool, bool) { + if o == nil || o.ExhaustiveTypo == nil { + return nil, false + } + return o.ExhaustiveTypo, true +} + +// HasExhaustiveTypo returns a boolean if a field has been set. +func (o *SearchResultsItem) HasExhaustiveTypo() bool { + if o != nil && o.ExhaustiveTypo != nil { + return true + } + + return false +} + +// SetExhaustiveTypo gets a reference to the given bool and assigns it to the ExhaustiveTypo field. +// Deprecated. +func (o *SearchResultsItem) SetExhaustiveTypo(v bool) *SearchResultsItem { + o.ExhaustiveTypo = &v + return o +} + +// GetFacets returns the Facets field value if set, zero value otherwise. +func (o *SearchResultsItem) GetFacets() map[string]map[string]int32 { + if o == nil || o.Facets == nil { + var ret map[string]map[string]int32 + return ret + } + return *o.Facets +} + +// GetFacetsOk returns a tuple with the Facets field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetFacetsOk() (*map[string]map[string]int32, bool) { + if o == nil || o.Facets == nil { + return nil, false + } + return o.Facets, true +} + +// HasFacets returns a boolean if a field has been set. +func (o *SearchResultsItem) HasFacets() bool { + if o != nil && o.Facets != nil { + return true + } + + return false +} + +// SetFacets gets a reference to the given map[string]map[string]int32 and assigns it to the Facets field. +func (o *SearchResultsItem) SetFacets(v map[string]map[string]int32) *SearchResultsItem { + o.Facets = &v + return o +} + +// GetFacetsStats returns the FacetsStats field value if set, zero value otherwise. +func (o *SearchResultsItem) GetFacetsStats() map[string]FacetStats { + if o == nil || o.FacetsStats == nil { + var ret map[string]FacetStats + return ret + } + return *o.FacetsStats +} + +// GetFacetsStatsOk returns a tuple with the FacetsStats field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetFacetsStatsOk() (*map[string]FacetStats, bool) { + if o == nil || o.FacetsStats == nil { + return nil, false + } + return o.FacetsStats, true +} + +// HasFacetsStats returns a boolean if a field has been set. +func (o *SearchResultsItem) HasFacetsStats() bool { + if o != nil && o.FacetsStats != nil { + return true + } + + return false +} + +// SetFacetsStats gets a reference to the given map[string]FacetStats and assigns it to the FacetsStats field. +func (o *SearchResultsItem) SetFacetsStats(v map[string]FacetStats) *SearchResultsItem { + o.FacetsStats = &v + return o +} + +// GetIndex returns the Index field value if set, zero value otherwise. +func (o *SearchResultsItem) GetIndex() string { + if o == nil || o.Index == nil { + var ret string + return ret + } + return *o.Index +} + +// GetIndexOk returns a tuple with the Index field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetIndexOk() (*string, bool) { + if o == nil || o.Index == nil { + return nil, false + } + return o.Index, true +} + +// HasIndex returns a boolean if a field has been set. +func (o *SearchResultsItem) HasIndex() bool { + if o != nil && o.Index != nil { + return true + } + + return false +} + +// SetIndex gets a reference to the given string and assigns it to the Index field. +func (o *SearchResultsItem) SetIndex(v string) *SearchResultsItem { + o.Index = &v + return o +} + +// GetIndexUsed returns the IndexUsed field value if set, zero value otherwise. +func (o *SearchResultsItem) GetIndexUsed() string { + if o == nil || o.IndexUsed == nil { + var ret string + return ret + } + return *o.IndexUsed +} + +// GetIndexUsedOk returns a tuple with the IndexUsed field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetIndexUsedOk() (*string, bool) { + if o == nil || o.IndexUsed == nil { + return nil, false + } + return o.IndexUsed, true +} + +// HasIndexUsed returns a boolean if a field has been set. +func (o *SearchResultsItem) HasIndexUsed() bool { + if o != nil && o.IndexUsed != nil { + return true + } + + return false +} + +// SetIndexUsed gets a reference to the given string and assigns it to the IndexUsed field. +func (o *SearchResultsItem) SetIndexUsed(v string) *SearchResultsItem { + o.IndexUsed = &v + return o +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *SearchResultsItem) GetMessage() string { + if o == nil || o.Message == nil { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetMessageOk() (*string, bool) { + if o == nil || o.Message == nil { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *SearchResultsItem) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *SearchResultsItem) SetMessage(v string) *SearchResultsItem { + o.Message = &v + return o +} + +// GetNbSortedHits returns the NbSortedHits field value if set, zero value otherwise. +func (o *SearchResultsItem) GetNbSortedHits() int32 { + if o == nil || o.NbSortedHits == nil { + var ret int32 + return ret + } + return *o.NbSortedHits +} + +// GetNbSortedHitsOk returns a tuple with the NbSortedHits field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetNbSortedHitsOk() (*int32, bool) { + if o == nil || o.NbSortedHits == nil { + return nil, false + } + return o.NbSortedHits, true +} + +// HasNbSortedHits returns a boolean if a field has been set. +func (o *SearchResultsItem) HasNbSortedHits() bool { + if o != nil && o.NbSortedHits != nil { + return true + } + + return false +} + +// SetNbSortedHits gets a reference to the given int32 and assigns it to the NbSortedHits field. +func (o *SearchResultsItem) SetNbSortedHits(v int32) *SearchResultsItem { + o.NbSortedHits = &v + return o +} + +// GetParsedQuery returns the ParsedQuery field value if set, zero value otherwise. +func (o *SearchResultsItem) GetParsedQuery() string { + if o == nil || o.ParsedQuery == nil { + var ret string + return ret + } + return *o.ParsedQuery +} + +// GetParsedQueryOk returns a tuple with the ParsedQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetParsedQueryOk() (*string, bool) { + if o == nil || o.ParsedQuery == nil { + return nil, false + } + return o.ParsedQuery, true +} + +// HasParsedQuery returns a boolean if a field has been set. +func (o *SearchResultsItem) HasParsedQuery() bool { + if o != nil && o.ParsedQuery != nil { + return true + } + + return false +} + +// SetParsedQuery gets a reference to the given string and assigns it to the ParsedQuery field. +func (o *SearchResultsItem) SetParsedQuery(v string) *SearchResultsItem { + o.ParsedQuery = &v + return o +} + +// GetProcessingTimeMS returns the ProcessingTimeMS field value. +func (o *SearchResultsItem) GetProcessingTimeMS() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.ProcessingTimeMS +} + +// GetProcessingTimeMSOk returns a tuple with the ProcessingTimeMS field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetProcessingTimeMSOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.ProcessingTimeMS, true +} + +// SetProcessingTimeMS sets field value. +func (o *SearchResultsItem) SetProcessingTimeMS(v int32) *SearchResultsItem { + o.ProcessingTimeMS = v + return o +} + +// GetProcessingTimingsMS returns the ProcessingTimingsMS field value if set, zero value otherwise. +func (o *SearchResultsItem) GetProcessingTimingsMS() map[string]any { + if o == nil || o.ProcessingTimingsMS == nil { + var ret map[string]any + return ret + } + return o.ProcessingTimingsMS +} + +// GetProcessingTimingsMSOk returns a tuple with the ProcessingTimingsMS field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetProcessingTimingsMSOk() (map[string]any, bool) { + if o == nil || o.ProcessingTimingsMS == nil { + return nil, false + } + return o.ProcessingTimingsMS, true +} + +// HasProcessingTimingsMS returns a boolean if a field has been set. +func (o *SearchResultsItem) HasProcessingTimingsMS() bool { + if o != nil && o.ProcessingTimingsMS != nil { + return true + } + + return false +} + +// SetProcessingTimingsMS gets a reference to the given map[string]any and assigns it to the ProcessingTimingsMS field. +func (o *SearchResultsItem) SetProcessingTimingsMS(v map[string]any) *SearchResultsItem { + o.ProcessingTimingsMS = v + return o +} + +// GetQueryAfterRemoval returns the QueryAfterRemoval field value if set, zero value otherwise. +func (o *SearchResultsItem) GetQueryAfterRemoval() string { + if o == nil || o.QueryAfterRemoval == nil { + var ret string + return ret + } + return *o.QueryAfterRemoval +} + +// GetQueryAfterRemovalOk returns a tuple with the QueryAfterRemoval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetQueryAfterRemovalOk() (*string, bool) { + if o == nil || o.QueryAfterRemoval == nil { + return nil, false + } + return o.QueryAfterRemoval, true +} + +// HasQueryAfterRemoval returns a boolean if a field has been set. +func (o *SearchResultsItem) HasQueryAfterRemoval() bool { + if o != nil && o.QueryAfterRemoval != nil { + return true + } + + return false +} + +// SetQueryAfterRemoval gets a reference to the given string and assigns it to the QueryAfterRemoval field. +func (o *SearchResultsItem) SetQueryAfterRemoval(v string) *SearchResultsItem { + o.QueryAfterRemoval = &v + return o +} + +// GetRedirect returns the Redirect field value if set, zero value otherwise. +func (o *SearchResultsItem) GetRedirect() Redirect { + if o == nil || o.Redirect == nil { + var ret Redirect + return ret + } + return *o.Redirect +} + +// GetRedirectOk returns a tuple with the Redirect field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetRedirectOk() (*Redirect, bool) { + if o == nil || o.Redirect == nil { + return nil, false + } + return o.Redirect, true +} + +// HasRedirect returns a boolean if a field has been set. +func (o *SearchResultsItem) HasRedirect() bool { + if o != nil && o.Redirect != nil { + return true + } + + return false +} + +// SetRedirect gets a reference to the given Redirect and assigns it to the Redirect field. +func (o *SearchResultsItem) SetRedirect(v *Redirect) *SearchResultsItem { + o.Redirect = v + return o +} + +// GetRenderingContent returns the RenderingContent field value if set, zero value otherwise. +func (o *SearchResultsItem) GetRenderingContent() RenderingContent { + if o == nil || o.RenderingContent == nil { + var ret RenderingContent + return ret + } + return *o.RenderingContent +} + +// GetRenderingContentOk returns a tuple with the RenderingContent field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetRenderingContentOk() (*RenderingContent, bool) { + if o == nil || o.RenderingContent == nil { + return nil, false + } + return o.RenderingContent, true +} + +// HasRenderingContent returns a boolean if a field has been set. +func (o *SearchResultsItem) HasRenderingContent() bool { + if o != nil && o.RenderingContent != nil { + return true + } + + return false +} + +// SetRenderingContent gets a reference to the given RenderingContent and assigns it to the RenderingContent field. +func (o *SearchResultsItem) SetRenderingContent(v *RenderingContent) *SearchResultsItem { + o.RenderingContent = v + return o +} + +// GetServerTimeMS returns the ServerTimeMS field value if set, zero value otherwise. +func (o *SearchResultsItem) GetServerTimeMS() int32 { + if o == nil || o.ServerTimeMS == nil { + var ret int32 + return ret + } + return *o.ServerTimeMS +} + +// GetServerTimeMSOk returns a tuple with the ServerTimeMS field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetServerTimeMSOk() (*int32, bool) { + if o == nil || o.ServerTimeMS == nil { + return nil, false + } + return o.ServerTimeMS, true +} + +// HasServerTimeMS returns a boolean if a field has been set. +func (o *SearchResultsItem) HasServerTimeMS() bool { + if o != nil && o.ServerTimeMS != nil { + return true + } + + return false +} + +// SetServerTimeMS gets a reference to the given int32 and assigns it to the ServerTimeMS field. +func (o *SearchResultsItem) SetServerTimeMS(v int32) *SearchResultsItem { + o.ServerTimeMS = &v + return o +} + +// GetServerUsed returns the ServerUsed field value if set, zero value otherwise. +func (o *SearchResultsItem) GetServerUsed() string { + if o == nil || o.ServerUsed == nil { + var ret string + return ret + } + return *o.ServerUsed +} + +// GetServerUsedOk returns a tuple with the ServerUsed field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetServerUsedOk() (*string, bool) { + if o == nil || o.ServerUsed == nil { + return nil, false + } + return o.ServerUsed, true +} + +// HasServerUsed returns a boolean if a field has been set. +func (o *SearchResultsItem) HasServerUsed() bool { + if o != nil && o.ServerUsed != nil { + return true + } + + return false +} + +// SetServerUsed gets a reference to the given string and assigns it to the ServerUsed field. +func (o *SearchResultsItem) SetServerUsed(v string) *SearchResultsItem { + o.ServerUsed = &v + return o +} + +// GetUserData returns the UserData field value if set, zero value otherwise. +func (o *SearchResultsItem) GetUserData() map[string]any { + if o == nil || o.UserData == nil { + var ret map[string]any + return ret + } + return o.UserData +} + +// GetUserDataOk returns a tuple with the UserData field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetUserDataOk() (map[string]any, bool) { + if o == nil || o.UserData == nil { + return nil, false + } + return o.UserData, true +} + +// HasUserData returns a boolean if a field has been set. +func (o *SearchResultsItem) HasUserData() bool { + if o != nil && o.UserData != nil { + return true + } + + return false +} + +// SetUserData gets a reference to the given map[string]any and assigns it to the UserData field. +func (o *SearchResultsItem) SetUserData(v map[string]any) *SearchResultsItem { + o.UserData = v + return o +} + +// GetQueryID returns the QueryID field value if set, zero value otherwise. +func (o *SearchResultsItem) GetQueryID() string { + if o == nil || o.QueryID == nil { + var ret string + return ret + } + return *o.QueryID +} + +// GetQueryIDOk returns a tuple with the QueryID field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetQueryIDOk() (*string, bool) { + if o == nil || o.QueryID == nil { + return nil, false + } + return o.QueryID, true +} + +// HasQueryID returns a boolean if a field has been set. +func (o *SearchResultsItem) HasQueryID() bool { + if o != nil && o.QueryID != nil { + return true + } + + return false +} + +// SetQueryID gets a reference to the given string and assigns it to the QueryID field. +func (o *SearchResultsItem) SetQueryID(v string) *SearchResultsItem { + o.QueryID = &v + return o +} + +// GetAutomaticInsights returns the AutomaticInsights field value if set, zero value otherwise. +func (o *SearchResultsItem) GetAutomaticInsights() bool { + if o == nil || o.AutomaticInsights == nil { + var ret bool + return ret + } + return *o.AutomaticInsights +} + +// GetAutomaticInsightsOk returns a tuple with the AutomaticInsights field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetAutomaticInsightsOk() (*bool, bool) { + if o == nil || o.AutomaticInsights == nil { + return nil, false + } + return o.AutomaticInsights, true +} + +// HasAutomaticInsights returns a boolean if a field has been set. +func (o *SearchResultsItem) HasAutomaticInsights() bool { + if o != nil && o.AutomaticInsights != nil { + return true + } + + return false +} + +// SetAutomaticInsights gets a reference to the given bool and assigns it to the AutomaticInsights field. +func (o *SearchResultsItem) SetAutomaticInsights(v bool) *SearchResultsItem { + o.AutomaticInsights = &v + return o +} + +// GetPage returns the Page field value. +func (o *SearchResultsItem) GetPage() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Page +} + +// GetPageOk returns a tuple with the Page field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetPageOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Page, true +} + +// SetPage sets field value. +func (o *SearchResultsItem) SetPage(v int32) *SearchResultsItem { + o.Page = v + return o +} + +// GetNbHits returns the NbHits field value. +func (o *SearchResultsItem) GetNbHits() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.NbHits +} + +// GetNbHitsOk returns a tuple with the NbHits field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetNbHitsOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.NbHits, true +} + +// SetNbHits sets field value. +func (o *SearchResultsItem) SetNbHits(v int32) *SearchResultsItem { + o.NbHits = v + return o +} + +// GetNbPages returns the NbPages field value. +func (o *SearchResultsItem) GetNbPages() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.NbPages +} + +// GetNbPagesOk returns a tuple with the NbPages field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetNbPagesOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.NbPages, true +} + +// SetNbPages sets field value. +func (o *SearchResultsItem) SetNbPages(v int32) *SearchResultsItem { + o.NbPages = v + return o +} + +// GetHitsPerPage returns the HitsPerPage field value. +func (o *SearchResultsItem) GetHitsPerPage() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.HitsPerPage +} + +// GetHitsPerPageOk returns a tuple with the HitsPerPage field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetHitsPerPageOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.HitsPerPage, true +} + +// SetHitsPerPage sets field value. +func (o *SearchResultsItem) SetHitsPerPage(v int32) *SearchResultsItem { + o.HitsPerPage = v + return o +} + +// GetHits returns the Hits field value. +func (o *SearchResultsItem) GetHits() []Hit { + if o == nil { + var ret []Hit + return ret + } + + return o.Hits +} + +// GetHitsOk returns a tuple with the Hits field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetHitsOk() ([]Hit, bool) { + if o == nil { + return nil, false + } + return o.Hits, true +} + +// SetHits sets field value. +func (o *SearchResultsItem) SetHits(v []Hit) *SearchResultsItem { + o.Hits = v + return o +} + +// GetQuery returns the Query field value. +func (o *SearchResultsItem) GetQuery() string { + if o == nil { + var ret string + return ret + } + + return o.Query +} + +// GetQueryOk returns a tuple with the Query field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Query, true +} + +// SetQuery sets field value. +func (o *SearchResultsItem) SetQuery(v string) *SearchResultsItem { + o.Query = v + return o +} + +// GetParams returns the Params field value. +func (o *SearchResultsItem) GetParams() string { + if o == nil { + var ret string + return ret + } + + return o.Params +} + +// GetParamsOk returns a tuple with the Params field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetParamsOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Params, true +} + +// SetParams sets field value. +func (o *SearchResultsItem) SetParams(v string) *SearchResultsItem { + o.Params = v + return o +} + +// GetCompositions returns the Compositions field value. +func (o *SearchResultsItem) GetCompositions() map[string]ResultsCompositionInfoResponse { + if o == nil { + var ret map[string]ResultsCompositionInfoResponse + return ret + } + + return o.Compositions +} + +// GetCompositionsOk returns a tuple with the Compositions field value +// and a boolean to check if the value has been set. +func (o *SearchResultsItem) GetCompositionsOk() (*map[string]ResultsCompositionInfoResponse, bool) { + if o == nil { + return nil, false + } + return &o.Compositions, true +} + +// SetCompositions sets field value. +func (o *SearchResultsItem) SetCompositions(v map[string]ResultsCompositionInfoResponse) *SearchResultsItem { + o.Compositions = v + return o +} + +func (o SearchResultsItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.AbTestID != nil { + toSerialize["abTestID"] = o.AbTestID + } + if o.AbTestVariantID != nil { + toSerialize["abTestVariantID"] = o.AbTestVariantID + } + if o.AroundLatLng != nil { + toSerialize["aroundLatLng"] = o.AroundLatLng + } + if o.AutomaticRadius != nil { + toSerialize["automaticRadius"] = o.AutomaticRadius + } + if o.Exhaustive != nil { + toSerialize["exhaustive"] = o.Exhaustive + } + if o.AppliedRules != nil { + toSerialize["appliedRules"] = o.AppliedRules + } + if o.ExhaustiveFacetsCount != nil { + toSerialize["exhaustiveFacetsCount"] = o.ExhaustiveFacetsCount + } + if o.ExhaustiveNbHits != nil { + toSerialize["exhaustiveNbHits"] = o.ExhaustiveNbHits + } + if o.ExhaustiveTypo != nil { + toSerialize["exhaustiveTypo"] = o.ExhaustiveTypo + } + if o.Facets != nil { + toSerialize["facets"] = o.Facets + } + if o.FacetsStats != nil { + toSerialize["facets_stats"] = o.FacetsStats + } + if o.Index != nil { + toSerialize["index"] = o.Index + } + if o.IndexUsed != nil { + toSerialize["indexUsed"] = o.IndexUsed + } + if o.Message != nil { + toSerialize["message"] = o.Message + } + if o.NbSortedHits != nil { + toSerialize["nbSortedHits"] = o.NbSortedHits + } + if o.ParsedQuery != nil { + toSerialize["parsedQuery"] = o.ParsedQuery + } + if true { + toSerialize["processingTimeMS"] = o.ProcessingTimeMS + } + if o.ProcessingTimingsMS != nil { + toSerialize["processingTimingsMS"] = o.ProcessingTimingsMS + } + if o.QueryAfterRemoval != nil { + toSerialize["queryAfterRemoval"] = o.QueryAfterRemoval + } + if o.Redirect != nil { + toSerialize["redirect"] = o.Redirect + } + if o.RenderingContent != nil { + toSerialize["renderingContent"] = o.RenderingContent + } + if o.ServerTimeMS != nil { + toSerialize["serverTimeMS"] = o.ServerTimeMS + } + if o.ServerUsed != nil { + toSerialize["serverUsed"] = o.ServerUsed + } + if o.UserData != nil { + toSerialize["userData"] = o.UserData + } + if o.QueryID != nil { + toSerialize["queryID"] = o.QueryID + } + if o.AutomaticInsights != nil { + toSerialize["_automaticInsights"] = o.AutomaticInsights + } + if true { + toSerialize["page"] = o.Page + } + if true { + toSerialize["nbHits"] = o.NbHits + } + if true { + toSerialize["nbPages"] = o.NbPages + } + if true { + toSerialize["hitsPerPage"] = o.HitsPerPage + } + if true { + toSerialize["hits"] = o.Hits + } + if true { + toSerialize["query"] = o.Query + } + if true { + toSerialize["params"] = o.Params + } + if true { + toSerialize["compositions"] = o.Compositions + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SearchResultsItem: %w", err) + } + + return serialized, nil +} + +func (o SearchResultsItem) String() string { + out := "" + out += fmt.Sprintf(" abTestID=%v\n", o.AbTestID) + out += fmt.Sprintf(" abTestVariantID=%v\n", o.AbTestVariantID) + out += fmt.Sprintf(" aroundLatLng=%v\n", o.AroundLatLng) + out += fmt.Sprintf(" automaticRadius=%v\n", o.AutomaticRadius) + out += fmt.Sprintf(" exhaustive=%v\n", o.Exhaustive) + out += fmt.Sprintf(" appliedRules=%v\n", o.AppliedRules) + out += fmt.Sprintf(" exhaustiveFacetsCount=%v\n", o.ExhaustiveFacetsCount) + out += fmt.Sprintf(" exhaustiveNbHits=%v\n", o.ExhaustiveNbHits) + out += fmt.Sprintf(" exhaustiveTypo=%v\n", o.ExhaustiveTypo) + out += fmt.Sprintf(" facets=%v\n", o.Facets) + out += fmt.Sprintf(" facets_stats=%v\n", o.FacetsStats) + out += fmt.Sprintf(" index=%v\n", o.Index) + out += fmt.Sprintf(" indexUsed=%v\n", o.IndexUsed) + out += fmt.Sprintf(" message=%v\n", o.Message) + out += fmt.Sprintf(" nbSortedHits=%v\n", o.NbSortedHits) + out += fmt.Sprintf(" parsedQuery=%v\n", o.ParsedQuery) + out += fmt.Sprintf(" processingTimeMS=%v\n", o.ProcessingTimeMS) + out += fmt.Sprintf(" processingTimingsMS=%v\n", o.ProcessingTimingsMS) + out += fmt.Sprintf(" queryAfterRemoval=%v\n", o.QueryAfterRemoval) + out += fmt.Sprintf(" redirect=%v\n", o.Redirect) + out += fmt.Sprintf(" renderingContent=%v\n", o.RenderingContent) + out += fmt.Sprintf(" serverTimeMS=%v\n", o.ServerTimeMS) + out += fmt.Sprintf(" serverUsed=%v\n", o.ServerUsed) + out += fmt.Sprintf(" userData=%v\n", o.UserData) + out += fmt.Sprintf(" queryID=%v\n", o.QueryID) + out += fmt.Sprintf(" _automaticInsights=%v\n", o.AutomaticInsights) + out += fmt.Sprintf(" page=%v\n", o.Page) + out += fmt.Sprintf(" nbHits=%v\n", o.NbHits) + out += fmt.Sprintf(" nbPages=%v\n", o.NbPages) + out += fmt.Sprintf(" hitsPerPage=%v\n", o.HitsPerPage) + out += fmt.Sprintf(" hits=%v\n", o.Hits) + out += fmt.Sprintf(" query=%v\n", o.Query) + out += fmt.Sprintf(" params=%v\n", o.Params) + out += fmt.Sprintf(" compositions=%v\n", o.Compositions) + return fmt.Sprintf("SearchResultsItem {\n%s}", out) +} diff --git a/algolia/composition/model_snippet_result.go b/algolia/composition/model_snippet_result.go new file mode 100644 index 000000000..cc6230a67 --- /dev/null +++ b/algolia/composition/model_snippet_result.go @@ -0,0 +1,120 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" + + "github.com/algolia/algoliasearch-client-go/v4/algolia/utils" +) + +// SnippetResult - struct for SnippetResult. +type SnippetResult struct { + SnippetResultOption *SnippetResultOption + ArrayOfSnippetResult *[]SnippetResult + MapmapOfStringSnippetResult *map[string]SnippetResult +} + +// SnippetResultOptionAsSnippetResult is a convenience function that returns SnippetResultOption wrapped in SnippetResult. +func SnippetResultOptionAsSnippetResult(v *SnippetResultOption) *SnippetResult { + return &SnippetResult{ + SnippetResultOption: v, + } +} + +// map[string]SnippetResultAsSnippetResult is a convenience function that returns map[string]SnippetResult wrapped in SnippetResult. +func MapmapOfStringSnippetResultAsSnippetResult(v map[string]SnippetResult) *SnippetResult { + return &SnippetResult{ + MapmapOfStringSnippetResult: &v, + } +} + +// []SnippetResultAsSnippetResult is a convenience function that returns []SnippetResult wrapped in SnippetResult. +func ArrayOfSnippetResultAsSnippetResult(v []SnippetResult) *SnippetResult { + return &SnippetResult{ + ArrayOfSnippetResult: &v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct. +func (dst *SnippetResult) UnmarshalJSON(data []byte) error { + var err error + // use discriminator value to speed up the lookup if possible, if not we will try every possibility + var jsonDict map[string]any + _ = newStrictDecoder(data).Decode(&jsonDict) + if utils.HasKey(jsonDict, "matchLevel") { + // try to unmarshal data into SnippetResultOption + err = newStrictDecoder(data).Decode(&dst.SnippetResultOption) + if err == nil && validateStruct(dst.SnippetResultOption) == nil { + return nil // found the correct type + } else { + dst.SnippetResultOption = nil + } + } + // try to unmarshal data into MapmapOfStringSnippetResult + err = newStrictDecoder(data).Decode(&dst.MapmapOfStringSnippetResult) + if err == nil && validateStruct(dst.MapmapOfStringSnippetResult) == nil { + return nil // found the correct type + } else { + dst.MapmapOfStringSnippetResult = nil + } + // try to unmarshal data into ArrayOfSnippetResult + err = newStrictDecoder(data).Decode(&dst.ArrayOfSnippetResult) + if err == nil && validateStruct(dst.ArrayOfSnippetResult) == nil { + return nil // found the correct type + } else { + dst.ArrayOfSnippetResult = nil + } + + return fmt.Errorf("Data failed to match schemas in oneOf(SnippetResult)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON. +func (src SnippetResult) MarshalJSON() ([]byte, error) { + if src.SnippetResultOption != nil { + serialized, err := json.Marshal(&src.SnippetResultOption) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of SnippetResultOption of SnippetResult: %w", err) + } + + return serialized, nil + } + + if src.ArrayOfSnippetResult != nil { + serialized, err := json.Marshal(&src.ArrayOfSnippetResult) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfSnippetResult of SnippetResult: %w", err) + } + + return serialized, nil + } + + if src.MapmapOfStringSnippetResult != nil { + serialized, err := json.Marshal(&src.MapmapOfStringSnippetResult) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal one of MapmapOfStringSnippetResult of SnippetResult: %w", err) + } + + return serialized, nil + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance. +func (obj SnippetResult) GetActualInstance() any { + if obj.SnippetResultOption != nil { + return *obj.SnippetResultOption + } + + if obj.ArrayOfSnippetResult != nil { + return *obj.ArrayOfSnippetResult + } + + if obj.MapmapOfStringSnippetResult != nil { + return *obj.MapmapOfStringSnippetResult + } + + // all schemas are nil + return nil +} diff --git a/algolia/composition/model_snippet_result_option.go b/algolia/composition/model_snippet_result_option.go new file mode 100644 index 000000000..0963e8494 --- /dev/null +++ b/algolia/composition/model_snippet_result_option.go @@ -0,0 +1,103 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SnippetResultOption Snippets that show the context around a matching search query. +type SnippetResultOption struct { + // Highlighted attribute value, including HTML tags. + Value string `json:"value"` + MatchLevel MatchLevel `json:"matchLevel"` +} + +// NewSnippetResultOption instantiates a new SnippetResultOption object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSnippetResultOption(value string, matchLevel MatchLevel) *SnippetResultOption { + this := &SnippetResultOption{} + this.Value = value + this.MatchLevel = matchLevel + return this +} + +// NewEmptySnippetResultOption return a pointer to an empty SnippetResultOption object. +func NewEmptySnippetResultOption() *SnippetResultOption { + return &SnippetResultOption{} +} + +// GetValue returns the Value field value. +func (o *SnippetResultOption) GetValue() string { + if o == nil { + var ret string + return ret + } + + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *SnippetResultOption) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *SnippetResultOption) SetValue(v string) *SnippetResultOption { + o.Value = v + return o +} + +// GetMatchLevel returns the MatchLevel field value. +func (o *SnippetResultOption) GetMatchLevel() MatchLevel { + if o == nil { + var ret MatchLevel + return ret + } + + return o.MatchLevel +} + +// GetMatchLevelOk returns a tuple with the MatchLevel field value +// and a boolean to check if the value has been set. +func (o *SnippetResultOption) GetMatchLevelOk() (*MatchLevel, bool) { + if o == nil { + return nil, false + } + return &o.MatchLevel, true +} + +// SetMatchLevel sets field value. +func (o *SnippetResultOption) SetMatchLevel(v MatchLevel) *SnippetResultOption { + o.MatchLevel = v + return o +} + +func (o SnippetResultOption) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if true { + toSerialize["value"] = o.Value + } + if true { + toSerialize["matchLevel"] = o.MatchLevel + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal SnippetResultOption: %w", err) + } + + return serialized, nil +} + +func (o SnippetResultOption) String() string { + out := "" + out += fmt.Sprintf(" value=%v\n", o.Value) + out += fmt.Sprintf(" matchLevel=%v\n", o.MatchLevel) + return fmt.Sprintf("SnippetResultOption {\n%s}", out) +} diff --git a/algolia/composition/model_sort_remaining_by.go b/algolia/composition/model_sort_remaining_by.go new file mode 100644 index 000000000..843f8e0cb --- /dev/null +++ b/algolia/composition/model_sort_remaining_by.go @@ -0,0 +1,67 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// 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. +type SortRemainingBy string + +// List of sortRemainingBy. +const ( + SORT_REMAINING_BY_COUNT SortRemainingBy = "count" + SORT_REMAINING_BY_ALPHA SortRemainingBy = "alpha" + SORT_REMAINING_BY_HIDDEN SortRemainingBy = "hidden" +) + +// All allowed values of SortRemainingBy enum. +var AllowedSortRemainingByEnumValues = []SortRemainingBy{ + "count", + "alpha", + "hidden", +} + +func (v *SortRemainingBy) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return fmt.Errorf("failed to unmarshal value '%s' for enum 'SortRemainingBy': %w", string(src), err) + } + enumTypeValue := SortRemainingBy(value) + for _, existing := range AllowedSortRemainingByEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid SortRemainingBy", value) +} + +// NewSortRemainingByFromValue returns a pointer to a valid SortRemainingBy +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSortRemainingByFromValue(v string) (*SortRemainingBy, error) { + ev := SortRemainingBy(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for SortRemainingBy: valid values are %v", v, AllowedSortRemainingByEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SortRemainingBy) IsValid() bool { + for _, existing := range AllowedSortRemainingByEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to sortRemainingBy value. +func (v SortRemainingBy) Ptr() *SortRemainingBy { + return &v +} diff --git a/algolia/composition/model_supported_language.go b/algolia/composition/model_supported_language.go new file mode 100644 index 000000000..f1c4b9234 --- /dev/null +++ b/algolia/composition/model_supported_language.go @@ -0,0 +1,197 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// SupportedLanguage ISO code for a supported language. +type SupportedLanguage string + +// List of supportedLanguage. +const ( + SUPPORTED_LANGUAGE_AF SupportedLanguage = "af" + SUPPORTED_LANGUAGE_AR SupportedLanguage = "ar" + SUPPORTED_LANGUAGE_AZ SupportedLanguage = "az" + SUPPORTED_LANGUAGE_BG SupportedLanguage = "bg" + SUPPORTED_LANGUAGE_BN SupportedLanguage = "bn" + SUPPORTED_LANGUAGE_CA SupportedLanguage = "ca" + SUPPORTED_LANGUAGE_CS SupportedLanguage = "cs" + SUPPORTED_LANGUAGE_CY SupportedLanguage = "cy" + SUPPORTED_LANGUAGE_DA SupportedLanguage = "da" + SUPPORTED_LANGUAGE_DE SupportedLanguage = "de" + SUPPORTED_LANGUAGE_EL SupportedLanguage = "el" + SUPPORTED_LANGUAGE_EN SupportedLanguage = "en" + SUPPORTED_LANGUAGE_EO SupportedLanguage = "eo" + SUPPORTED_LANGUAGE_ES SupportedLanguage = "es" + SUPPORTED_LANGUAGE_ET SupportedLanguage = "et" + SUPPORTED_LANGUAGE_EU SupportedLanguage = "eu" + SUPPORTED_LANGUAGE_FA SupportedLanguage = "fa" + SUPPORTED_LANGUAGE_FI SupportedLanguage = "fi" + SUPPORTED_LANGUAGE_FO SupportedLanguage = "fo" + SUPPORTED_LANGUAGE_FR SupportedLanguage = "fr" + SUPPORTED_LANGUAGE_GA SupportedLanguage = "ga" + SUPPORTED_LANGUAGE_GL SupportedLanguage = "gl" + SUPPORTED_LANGUAGE_HE SupportedLanguage = "he" + SUPPORTED_LANGUAGE_HI SupportedLanguage = "hi" + SUPPORTED_LANGUAGE_HU SupportedLanguage = "hu" + SUPPORTED_LANGUAGE_HY SupportedLanguage = "hy" + SUPPORTED_LANGUAGE_ID SupportedLanguage = "id" + SUPPORTED_LANGUAGE_IS SupportedLanguage = "is" + SUPPORTED_LANGUAGE_IT SupportedLanguage = "it" + SUPPORTED_LANGUAGE_JA SupportedLanguage = "ja" + SUPPORTED_LANGUAGE_KA SupportedLanguage = "ka" + SUPPORTED_LANGUAGE_KK SupportedLanguage = "kk" + SUPPORTED_LANGUAGE_KO SupportedLanguage = "ko" + SUPPORTED_LANGUAGE_KU SupportedLanguage = "ku" + SUPPORTED_LANGUAGE_KY SupportedLanguage = "ky" + SUPPORTED_LANGUAGE_LT SupportedLanguage = "lt" + SUPPORTED_LANGUAGE_LV SupportedLanguage = "lv" + SUPPORTED_LANGUAGE_MI SupportedLanguage = "mi" + SUPPORTED_LANGUAGE_MN SupportedLanguage = "mn" + SUPPORTED_LANGUAGE_MR SupportedLanguage = "mr" + SUPPORTED_LANGUAGE_MS SupportedLanguage = "ms" + SUPPORTED_LANGUAGE_MT SupportedLanguage = "mt" + SUPPORTED_LANGUAGE_NB SupportedLanguage = "nb" + SUPPORTED_LANGUAGE_NL SupportedLanguage = "nl" + SUPPORTED_LANGUAGE_NO SupportedLanguage = "no" + SUPPORTED_LANGUAGE_NS SupportedLanguage = "ns" + SUPPORTED_LANGUAGE_PL SupportedLanguage = "pl" + SUPPORTED_LANGUAGE_PS SupportedLanguage = "ps" + SUPPORTED_LANGUAGE_PT SupportedLanguage = "pt" + SUPPORTED_LANGUAGE_PT_BR SupportedLanguage = "pt-br" + SUPPORTED_LANGUAGE_QU SupportedLanguage = "qu" + SUPPORTED_LANGUAGE_RO SupportedLanguage = "ro" + SUPPORTED_LANGUAGE_RU SupportedLanguage = "ru" + SUPPORTED_LANGUAGE_SK SupportedLanguage = "sk" + SUPPORTED_LANGUAGE_SQ SupportedLanguage = "sq" + SUPPORTED_LANGUAGE_SV SupportedLanguage = "sv" + SUPPORTED_LANGUAGE_SW SupportedLanguage = "sw" + SUPPORTED_LANGUAGE_TA SupportedLanguage = "ta" + SUPPORTED_LANGUAGE_TE SupportedLanguage = "te" + SUPPORTED_LANGUAGE_TH SupportedLanguage = "th" + SUPPORTED_LANGUAGE_TL SupportedLanguage = "tl" + SUPPORTED_LANGUAGE_TN SupportedLanguage = "tn" + SUPPORTED_LANGUAGE_TR SupportedLanguage = "tr" + SUPPORTED_LANGUAGE_TT SupportedLanguage = "tt" + SUPPORTED_LANGUAGE_UK SupportedLanguage = "uk" + SUPPORTED_LANGUAGE_UR SupportedLanguage = "ur" + SUPPORTED_LANGUAGE_UZ SupportedLanguage = "uz" + SUPPORTED_LANGUAGE_ZH SupportedLanguage = "zh" +) + +// All allowed values of SupportedLanguage enum. +var AllowedSupportedLanguageEnumValues = []SupportedLanguage{ + "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", + "pt-br", + "qu", + "ro", + "ru", + "sk", + "sq", + "sv", + "sw", + "ta", + "te", + "th", + "tl", + "tn", + "tr", + "tt", + "uk", + "ur", + "uz", + "zh", +} + +func (v *SupportedLanguage) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return fmt.Errorf("failed to unmarshal value '%s' for enum 'SupportedLanguage': %w", string(src), err) + } + enumTypeValue := SupportedLanguage(value) + for _, existing := range AllowedSupportedLanguageEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid SupportedLanguage", value) +} + +// NewSupportedLanguageFromValue returns a pointer to a valid SupportedLanguage +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSupportedLanguageFromValue(v string) (*SupportedLanguage, error) { + ev := SupportedLanguage(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for SupportedLanguage: valid values are %v", v, AllowedSupportedLanguageEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SupportedLanguage) IsValid() bool { + for _, existing := range AllowedSupportedLanguageEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to supportedLanguage value. +func (v SupportedLanguage) Ptr() *SupportedLanguage { + return &v +} diff --git a/algolia/composition/model_value.go b/algolia/composition/model_value.go new file mode 100644 index 000000000..9f3241fa9 --- /dev/null +++ b/algolia/composition/model_value.go @@ -0,0 +1,179 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Value struct for Value. +type Value struct { + // Explicit order of facets or facet values. This setting lets you always show specific facets or facet values at the top of the list. + Order []string `json:"order,omitempty"` + SortRemainingBy *SortRemainingBy `json:"sortRemainingBy,omitempty"` + // Hide facet values. + Hide []string `json:"hide,omitempty"` +} + +type ValueOption func(f *Value) + +func WithValueOrder(val []string) ValueOption { + return func(f *Value) { + f.Order = val + } +} + +func WithValueSortRemainingBy(val SortRemainingBy) ValueOption { + return func(f *Value) { + f.SortRemainingBy = &val + } +} + +func WithValueHide(val []string) ValueOption { + return func(f *Value) { + f.Hide = val + } +} + +// NewValue instantiates a new Value object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewValue(opts ...ValueOption) *Value { + this := &Value{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyValue return a pointer to an empty Value object. +func NewEmptyValue() *Value { + return &Value{} +} + +// GetOrder returns the Order field value if set, zero value otherwise. +func (o *Value) GetOrder() []string { + if o == nil || o.Order == nil { + var ret []string + return ret + } + return o.Order +} + +// GetOrderOk returns a tuple with the Order field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Value) GetOrderOk() ([]string, bool) { + if o == nil || o.Order == nil { + return nil, false + } + return o.Order, true +} + +// HasOrder returns a boolean if a field has been set. +func (o *Value) HasOrder() bool { + if o != nil && o.Order != nil { + return true + } + + return false +} + +// SetOrder gets a reference to the given []string and assigns it to the Order field. +func (o *Value) SetOrder(v []string) *Value { + o.Order = v + return o +} + +// GetSortRemainingBy returns the SortRemainingBy field value if set, zero value otherwise. +func (o *Value) GetSortRemainingBy() SortRemainingBy { + if o == nil || o.SortRemainingBy == nil { + var ret SortRemainingBy + return ret + } + return *o.SortRemainingBy +} + +// GetSortRemainingByOk returns a tuple with the SortRemainingBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Value) GetSortRemainingByOk() (*SortRemainingBy, bool) { + if o == nil || o.SortRemainingBy == nil { + return nil, false + } + return o.SortRemainingBy, true +} + +// HasSortRemainingBy returns a boolean if a field has been set. +func (o *Value) HasSortRemainingBy() bool { + if o != nil && o.SortRemainingBy != nil { + return true + } + + return false +} + +// SetSortRemainingBy gets a reference to the given SortRemainingBy and assigns it to the SortRemainingBy field. +func (o *Value) SetSortRemainingBy(v SortRemainingBy) *Value { + o.SortRemainingBy = &v + return o +} + +// GetHide returns the Hide field value if set, zero value otherwise. +func (o *Value) GetHide() []string { + if o == nil || o.Hide == nil { + var ret []string + return ret + } + return o.Hide +} + +// GetHideOk returns a tuple with the Hide field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Value) GetHideOk() ([]string, bool) { + if o == nil || o.Hide == nil { + return nil, false + } + return o.Hide, true +} + +// HasHide returns a boolean if a field has been set. +func (o *Value) HasHide() bool { + if o != nil && o.Hide != nil { + return true + } + + return false +} + +// SetHide gets a reference to the given []string and assigns it to the Hide field. +func (o *Value) SetHide(v []string) *Value { + o.Hide = v + return o +} + +func (o Value) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Order != nil { + toSerialize["order"] = o.Order + } + if o.SortRemainingBy != nil { + toSerialize["sortRemainingBy"] = o.SortRemainingBy + } + if o.Hide != nil { + toSerialize["hide"] = o.Hide + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Value: %w", err) + } + + return serialized, nil +} + +func (o Value) String() string { + out := "" + out += fmt.Sprintf(" order=%v\n", o.Order) + out += fmt.Sprintf(" sortRemainingBy=%v\n", o.SortRemainingBy) + out += fmt.Sprintf(" hide=%v\n", o.Hide) + return fmt.Sprintf("Value {\n%s}", out) +} diff --git a/algolia/composition/model_widgets.go b/algolia/composition/model_widgets.go new file mode 100644 index 000000000..f3d6c7f80 --- /dev/null +++ b/algolia/composition/model_widgets.go @@ -0,0 +1,90 @@ +// 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 composition + +import ( + "encoding/json" + "fmt" +) + +// Widgets Widgets returned from any rules that are applied to the current search. +type Widgets struct { + // Banners defined in the Merchandising Studio for a given search. + Banners []Banner `json:"banners,omitempty"` +} + +type WidgetsOption func(f *Widgets) + +func WithWidgetsBanners(val []Banner) WidgetsOption { + return func(f *Widgets) { + f.Banners = val + } +} + +// NewWidgets instantiates a new Widgets object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewWidgets(opts ...WidgetsOption) *Widgets { + this := &Widgets{} + for _, opt := range opts { + opt(this) + } + return this +} + +// NewEmptyWidgets return a pointer to an empty Widgets object. +func NewEmptyWidgets() *Widgets { + return &Widgets{} +} + +// GetBanners returns the Banners field value if set, zero value otherwise. +func (o *Widgets) GetBanners() []Banner { + if o == nil || o.Banners == nil { + var ret []Banner + return ret + } + return o.Banners +} + +// GetBannersOk returns a tuple with the Banners field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Widgets) GetBannersOk() ([]Banner, bool) { + if o == nil || o.Banners == nil { + return nil, false + } + return o.Banners, true +} + +// HasBanners returns a boolean if a field has been set. +func (o *Widgets) HasBanners() bool { + if o != nil && o.Banners != nil { + return true + } + + return false +} + +// SetBanners gets a reference to the given []Banner and assigns it to the Banners field. +func (o *Widgets) SetBanners(v []Banner) *Widgets { + o.Banners = v + return o +} + +func (o Widgets) MarshalJSON() ([]byte, error) { + toSerialize := map[string]any{} + if o.Banners != nil { + toSerialize["banners"] = o.Banners + } + serialized, err := json.Marshal(toSerialize) + if err != nil { + return nil, fmt.Errorf("failed to marshal Widgets: %w", err) + } + + return serialized, nil +} + +func (o Widgets) String() string { + out := "" + out += fmt.Sprintf(" banners=%v\n", o.Banners) + return fmt.Sprintf("Widgets {\n%s}", out) +}