/* 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 {
  InstagramVerification,
  Seller,
  SellerApplication,
  SellerApplicationResponse,
  SellerCategory,
  SellerProductList200Response,
  SellerStatusUpdate,
  SellerUpdate,
  StateCity,
} from '../models';

export interface ApiSellerV1ApplyCreateRequest {
    data: SellerApplication;
}

export interface ApiSellerV1InstapplyCreateRequest {
    data: InstagramVerification;
}

export interface ApiSellerV1SellersPartialUpdateRequest {
    username: string;
    data: SellerUpdate;
}

export interface ApiSellerV1SellersReadRequest {
    username: string;
}

export interface ApiSellerV1VerifyCreateRequest {
    data: SellerStatusUpdate;
}

export interface SellerPartialUpdateRequest {
    username: string;
    data: SellerUpdate;
}

export interface SellerProductListRequest {
    username: string;
    page?: number;
    pageSize?: number;
    q?: string;
    category?: string;
    priceMin?: number;
    priceMax?: number;
    ordering?: string;
    sort?: string;
    useEs?: boolean;
}

export interface SellerReadRequest {
    username: string;
}

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

    /**
     * Submit an application to become a seller. You must include a unique username and basic store info. Use a URL for the `store_logo` field (uploaded via /api/media/v1/image/).
     * Apply to become a seller
     */
    async apiSellerV1ApplyCreateRaw(requestParameters: ApiSellerV1ApplyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SellerApplicationResponse>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiSellerV1ApplyCreate.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Submit an application to become a seller. You must include a unique username and basic store info. Use a URL for the `store_logo` field (uploaded via /api/media/v1/image/).
     * Apply to become a seller
     */
    async apiSellerV1ApplyCreate(requestParameters: ApiSellerV1ApplyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SellerApplicationResponse> {
        const response = await this.apiSellerV1ApplyCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * List all available categories.
     */
    async apiSellerV1CategoriesListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<SellerCategory>>> {
        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/seller/v1/categories/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * List all available categories.
     */
    async apiSellerV1CategoriesList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<SellerCategory>> {
        const response = await this.apiSellerV1CategoriesListRaw(initOverrides);
        return await response.value();
    }

    /**
     * Verify a seller\'s Instagram account by checking if their Vitron link is in their bio.
     * Verify Instagram account
     */
    async apiSellerV1InstapplyCreateRaw(requestParameters: ApiSellerV1InstapplyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<InstagramVerification>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiSellerV1InstapplyCreate.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Verify a seller\'s Instagram account by checking if their Vitron link is in their bio.
     * Verify Instagram account
     */
    async apiSellerV1InstapplyCreate(requestParameters: ApiSellerV1InstapplyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<InstagramVerification> {
        const response = await this.apiSellerV1InstapplyCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update seller profile fields (Only PATCH).
     */
    async apiSellerV1SellersPartialUpdateRaw(requestParameters: ApiSellerV1SellersPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SellerUpdate>> {
        if (requestParameters.username === null || requestParameters.username === undefined) {
            throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling apiSellerV1SellersPartialUpdate.');
        }

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

        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/seller/v1/sellers/{username}/`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Update seller profile fields (Only PATCH).
     */
    async apiSellerV1SellersPartialUpdate(requestParameters: ApiSellerV1SellersPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SellerUpdate> {
        const response = await this.apiSellerV1SellersPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Retrieve detailed seller profile by username.
     */
    async apiSellerV1SellersReadRaw(requestParameters: ApiSellerV1SellersReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Seller>> {
        if (requestParameters.username === null || requestParameters.username === undefined) {
            throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling apiSellerV1SellersRead.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Retrieve detailed seller profile by username.
     */
    async apiSellerV1SellersRead(requestParameters: ApiSellerV1SellersReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Seller> {
        const response = await this.apiSellerV1SellersReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * List all states along with their respective cities.
     */
    async apiSellerV1StateCityListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StateCity>>> {
        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/seller/v1/state-city/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * List all states along with their respective cities.
     */
    async apiSellerV1StateCityList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StateCity>> {
        const response = await this.apiSellerV1StateCityListRaw(initOverrides);
        return await response.value();
    }

    /**
     * Superadmin can approve or reject a seller application.
     * Approve or reject seller
     */
    async apiSellerV1VerifyCreateRaw(requestParameters: ApiSellerV1VerifyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiSellerV1VerifyCreate.');
        }

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Superadmin can approve or reject a seller application.
     * Approve or reject seller
     */
    async apiSellerV1VerifyCreate(requestParameters: ApiSellerV1VerifyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiSellerV1VerifyCreateRaw(requestParameters, initOverrides);
    }

    /**
     * Update seller profile fields (Only PATCH).
     */
    async sellerPartialUpdateRaw(requestParameters: SellerPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SellerUpdate>> {
        if (requestParameters.username === null || requestParameters.username === undefined) {
            throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling sellerPartialUpdate.');
        }

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

        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: `/seller/{username}/`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Update seller profile fields (Only PATCH).
     */
    async sellerPartialUpdate(requestParameters: SellerPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SellerUpdate> {
        const response = await this.sellerPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Public storefront list for a seller. Uses DB filters by default. If `use_es=1` or a search query `q` is provided, uses Elasticsearch for relevance ranking.
     * List products by seller username
     */
    async sellerProductListRaw(requestParameters: SellerProductListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SellerProductList200Response>> {
        if (requestParameters.username === null || requestParameters.username === undefined) {
            throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling sellerProductList.');
        }

        const queryParameters: any = {};

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

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

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

        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.ordering !== undefined) {
            queryParameters['ordering'] = requestParameters.ordering;
        }

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

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

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Public storefront list for a seller. Uses DB filters by default. If `use_es=1` or a search query `q` is provided, uses Elasticsearch for relevance ranking.
     * List products by seller username
     */
    async sellerProductList(requestParameters: SellerProductListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SellerProductList200Response> {
        const response = await this.sellerProductListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Retrieve detailed seller profile by username.
     */
    async sellerReadRaw(requestParameters: SellerReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Seller>> {
        if (requestParameters.username === null || requestParameters.username === undefined) {
            throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling sellerRead.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Retrieve detailed seller profile by username.
     */
    async sellerRead(requestParameters: SellerReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Seller> {
        const response = await this.sellerReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
