/* tslint:disable */
/* eslint-disable */
/**
 * Vitron API
 * API documentation for Vitron backend
 *
 * The version of the OpenAPI document: v1
 * Contact: support@yourcompany.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  AutocompleteResponse,
  SearchResponse,
} from '../models';

export interface ApiSearchV1AutocompleteListRequest {
    q: string;
}

export interface ApiSearchV1ListRequest {
    q?: string;
    type?: string;
    category?: string;
    priceMin?: number;
    priceMax?: number;
    sortBy?: string;
    page?: number;
    pageSize?: number;
    attributesColor?: string;
    attributesSize?: string;
    sellerId?: string;
}

/**
 * 
 */
export class SearchSystemApi extends runtime.BaseAPI {

    /**
     * Autocomplete suggestions for products, sellers, and categories
     */
    async apiSearchV1AutocompleteListRaw(requestParameters: ApiSearchV1AutocompleteListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AutocompleteResponse>> {
        if (requestParameters.q === null || requestParameters.q === undefined) {
            throw new runtime.RequiredError('q','Required parameter requestParameters.q was null or undefined when calling apiSearchV1AutocompleteList.');
        }

        const queryParameters: any = {};

        if (requestParameters.q !== undefined) {
            queryParameters['q'] = requestParameters.q;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/search/v1/autocomplete/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Autocomplete suggestions for products, sellers, and categories
     */
    async apiSearchV1AutocompleteList(requestParameters: ApiSearchV1AutocompleteListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AutocompleteResponse> {
        const response = await this.apiSearchV1AutocompleteListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Search products and sellers
     */
    async apiSearchV1ListRaw(requestParameters: ApiSearchV1ListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SearchResponse>> {
        const queryParameters: any = {};

        if (requestParameters.q !== undefined) {
            queryParameters['q'] = requestParameters.q;
        }

        if (requestParameters.type !== undefined) {
            queryParameters['type'] = requestParameters.type;
        }

        if (requestParameters.category !== undefined) {
            queryParameters['category'] = requestParameters.category;
        }

        if (requestParameters.priceMin !== undefined) {
            queryParameters['price_min'] = requestParameters.priceMin;
        }

        if (requestParameters.priceMax !== undefined) {
            queryParameters['price_max'] = requestParameters.priceMax;
        }

        if (requestParameters.sortBy !== undefined) {
            queryParameters['sort_by'] = requestParameters.sortBy;
        }

        if (requestParameters.page !== undefined) {
            queryParameters['page'] = requestParameters.page;
        }

        if (requestParameters.pageSize !== undefined) {
            queryParameters['page_size'] = requestParameters.pageSize;
        }

        if (requestParameters.attributesColor !== undefined) {
            queryParameters['attributes[Color]'] = requestParameters.attributesColor;
        }

        if (requestParameters.attributesSize !== undefined) {
            queryParameters['attributes[Size]'] = requestParameters.attributesSize;
        }

        if (requestParameters.sellerId !== undefined) {
            queryParameters['seller_id'] = requestParameters.sellerId;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/search/v1/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Search products and sellers
     */
    async apiSearchV1List(requestParameters: ApiSearchV1ListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SearchResponse> {
        const response = await this.apiSearchV1ListRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
