/* 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 {
  Discount,
  DiscountVerifyRequest,
  DiscountVerifyResponse,
} from '../models';

export interface ApiDiscountV1DiscountsCreateCreateRequest {
    data: Discount;
}

export interface ApiDiscountV1DiscountsDetailDeleteRequest {
    id: string;
}

export interface ApiDiscountV1DiscountsDetailListRequest {
    id: string;
}

export interface ApiDiscountV1DiscountsDetailPartialUpdateRequest {
    id: string;
    data: Discount;
}

export interface ApiDiscountV1DiscountsListRequest {
    ordering?: string;
    search?: string;
    type?: string;
}

export interface ApiDiscountV1DiscountsVerifyCreateRequest {
    data: DiscountVerifyRequest;
}

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

    /**
     * Create a discount
     */
    async apiDiscountV1DiscountsCreateCreateRaw(requestParameters: ApiDiscountV1DiscountsCreateCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Discount>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiDiscountV1DiscountsCreateCreate.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Create a discount
     */
    async apiDiscountV1DiscountsCreateCreate(requestParameters: ApiDiscountV1DiscountsCreateCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Discount> {
        const response = await this.apiDiscountV1DiscountsCreateCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Delete discount by query param
     */
    async apiDiscountV1DiscountsDetailDeleteRaw(requestParameters: ApiDiscountV1DiscountsDetailDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiDiscountV1DiscountsDetailDelete.');
        }

        const queryParameters: any = {};

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

        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/discount/v1/discounts/detail/`,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Delete discount by query param
     */
    async apiDiscountV1DiscountsDetailDelete(requestParameters: ApiDiscountV1DiscountsDetailDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiDiscountV1DiscountsDetailDeleteRaw(requestParameters, initOverrides);
    }

    /**
     * Retrieve discount detail by query param
     */
    async apiDiscountV1DiscountsDetailListRaw(requestParameters: ApiDiscountV1DiscountsDetailListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Discount>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiDiscountV1DiscountsDetailList.');
        }

        const queryParameters: any = {};

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

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Retrieve discount detail by query param
     */
    async apiDiscountV1DiscountsDetailList(requestParameters: ApiDiscountV1DiscountsDetailListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Discount> {
        const response = await this.apiDiscountV1DiscountsDetailListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update discount by query param
     */
    async apiDiscountV1DiscountsDetailPartialUpdateRaw(requestParameters: ApiDiscountV1DiscountsDetailPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Discount>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiDiscountV1DiscountsDetailPartialUpdate.');
        }

        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiDiscountV1DiscountsDetailPartialUpdate.');
        }

        const queryParameters: any = {};

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

        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/discount/v1/discounts/detail/`,
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Update discount by query param
     */
    async apiDiscountV1DiscountsDetailPartialUpdate(requestParameters: ApiDiscountV1DiscountsDetailPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Discount> {
        const response = await this.apiDiscountV1DiscountsDetailPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * List available discounts
     */
    async apiDiscountV1DiscountsListRaw(requestParameters: ApiDiscountV1DiscountsListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<Discount>>> {
        const queryParameters: any = {};

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

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

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

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * List available discounts
     */
    async apiDiscountV1DiscountsList(requestParameters: ApiDiscountV1DiscountsListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<Discount>> {
        const response = await this.apiDiscountV1DiscountsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Verify a discount code against a shopping cart
     */
    async apiDiscountV1DiscountsVerifyCreateRaw(requestParameters: ApiDiscountV1DiscountsVerifyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DiscountVerifyResponse>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiDiscountV1DiscountsVerifyCreate.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Verify a discount code against a shopping cart
     */
    async apiDiscountV1DiscountsVerifyCreate(requestParameters: ApiDiscountV1DiscountsVerifyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DiscountVerifyResponse> {
        const response = await this.apiDiscountV1DiscountsVerifyCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
