/* 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 {
  CollectionCursorPage,
  CollectionDetailWithProducts,
} from '../models';

export interface ApiCollectionV1CollectionsListRequest {
    cursor?: string;
    pageSize?: number;
    sellerId?: string;
    category?: string;
    trending?: number;
    q?: string;
}

export interface ApiCollectionV1CollectionsReadRequest {
    id: string;
    cursor?: string;
    pageSize?: number;
}

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

    /**
     * Cursor-paginated list of public collections created by ADMIN only.  Filters: - `seller_id` (UUID): collections containing products by this seller - `category` (UUID): collections containing products in this category - `trending` (0/1): if 1, order by product_count desc, then updated_at desc - `q`: search in title/description
     * List public ADMIN collections only
     */
    async apiCollectionV1CollectionsListRaw(requestParameters: ApiCollectionV1CollectionsListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<CollectionCursorPage>> {
        const queryParameters: any = {};

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

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

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

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

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

        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/collection/v1/collections/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Cursor-paginated list of public collections created by ADMIN only.  Filters: - `seller_id` (UUID): collections containing products by this seller - `category` (UUID): collections containing products in this category - `trending` (0/1): if 1, order by product_count desc, then updated_at desc - `q`: search in title/description
     * List public ADMIN collections only
     */
    async apiCollectionV1CollectionsList(requestParameters: ApiCollectionV1CollectionsListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<CollectionCursorPage> {
        const response = await this.apiCollectionV1CollectionsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns a public collection plus a cursor-paginated list of its products and a list of unique sellers appearing in those products.
     * Get a public collection (with products)
     */
    async apiCollectionV1CollectionsReadRaw(requestParameters: ApiCollectionV1CollectionsReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<CollectionDetailWithProducts>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiCollectionV1CollectionsRead.');
        }

        const queryParameters: any = {};

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

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

        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/collection/v1/collections/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Returns a public collection plus a cursor-paginated list of its products and a list of unique sellers appearing in those products.
     * Get a public collection (with products)
     */
    async apiCollectionV1CollectionsRead(requestParameters: ApiCollectionV1CollectionsReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<CollectionDetailWithProducts> {
        const response = await this.apiCollectionV1CollectionsReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
