/* 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 {
  BookmarkCheckResponse,
  BookmarkCountResponse,
  BookmarkCreate,
  BookmarkDeleteResponse,
  BookmarkListPaginated,
} from '../models';

export interface ApiEngagementV1BookmarksCheckReadRequest {
    productId: string;
}

export interface ApiEngagementV1BookmarksCountReadRequest {
    productId: string;
}

export interface ApiEngagementV1BookmarksCreateRequest {
    data: BookmarkCreate;
}

export interface ApiEngagementV1BookmarksDeleteRequest {
    productId: string;
}

export interface ApiEngagementV1BookmarksListListRequest {
    page?: number;
    pageSize?: number;
}

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

    /**
     * Check if the authenticated user has bookmarked a specific product.
     * Check if product is bookmarked
     */
    async apiEngagementV1BookmarksCheckReadRaw(requestParameters: ApiEngagementV1BookmarksCheckReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BookmarkCheckResponse>> {
        if (requestParameters.productId === null || requestParameters.productId === undefined) {
            throw new runtime.RequiredError('productId','Required parameter requestParameters.productId was null or undefined when calling apiEngagementV1BookmarksCheckRead.');
        }

        const queryParameters: any = {};

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Check if the authenticated user has bookmarked a specific product.
     * Check if product is bookmarked
     */
    async apiEngagementV1BookmarksCheckRead(requestParameters: ApiEngagementV1BookmarksCheckReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BookmarkCheckResponse> {
        const response = await this.apiEngagementV1BookmarksCheckReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Return the number of users who have bookmarked a specific product.
     * Count bookmarks for a product
     */
    async apiEngagementV1BookmarksCountReadRaw(requestParameters: ApiEngagementV1BookmarksCountReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BookmarkCountResponse>> {
        if (requestParameters.productId === null || requestParameters.productId === undefined) {
            throw new runtime.RequiredError('productId','Required parameter requestParameters.productId was null or undefined when calling apiEngagementV1BookmarksCountRead.');
        }

        const queryParameters: any = {};

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Return the number of users who have bookmarked a specific product.
     * Count bookmarks for a product
     */
    async apiEngagementV1BookmarksCountRead(requestParameters: ApiEngagementV1BookmarksCountReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BookmarkCountResponse> {
        const response = await this.apiEngagementV1BookmarksCountReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Bookmark a product for the authenticated user. If already bookmarked, returns the existing one.
     * Bookmark a product
     */
    async apiEngagementV1BookmarksCreateRaw(requestParameters: ApiEngagementV1BookmarksCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BookmarkCreate>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiEngagementV1BookmarksCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        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/engagement/v1/bookmarks/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Bookmark a product for the authenticated user. If already bookmarked, returns the existing one.
     * Bookmark a product
     */
    async apiEngagementV1BookmarksCreate(requestParameters: ApiEngagementV1BookmarksCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BookmarkCreate> {
        const response = await this.apiEngagementV1BookmarksCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Remove a bookmarked product for the authenticated user.
     * Delete a bookmark
     */
    async apiEngagementV1BookmarksDeleteRaw(requestParameters: ApiEngagementV1BookmarksDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BookmarkDeleteResponse>> {
        if (requestParameters.productId === null || requestParameters.productId === undefined) {
            throw new runtime.RequiredError('productId','Required parameter requestParameters.productId was null or undefined when calling apiEngagementV1BookmarksDelete.');
        }

        const queryParameters: any = {};

        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/engagement/v1/bookmarks/{product_id}/`.replace(`{${"product_id"}}`, encodeURIComponent(String(requestParameters.productId))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Remove a bookmarked product for the authenticated user.
     * Delete a bookmark
     */
    async apiEngagementV1BookmarksDelete(requestParameters: ApiEngagementV1BookmarksDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BookmarkDeleteResponse> {
        const response = await this.apiEngagementV1BookmarksDeleteRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     *  Retrieve all products bookmarked by the authenticated user. Supports pagination using `page` and `pageSize` query parameters. 
     * List user\'s bookmarks with pagination
     */
    async apiEngagementV1BookmarksListListRaw(requestParameters: ApiEngagementV1BookmarksListListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BookmarkListPaginated>> {
        const queryParameters: any = {};

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

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     *  Retrieve all products bookmarked by the authenticated user. Supports pagination using `page` and `pageSize` query parameters. 
     * List user\'s bookmarks with pagination
     */
    async apiEngagementV1BookmarksListList(requestParameters: ApiEngagementV1BookmarksListListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BookmarkListPaginated> {
        const response = await this.apiEngagementV1BookmarksListListRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
