/* 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 {
  InvoiceAndShippingResponse,
  OrderDetail,
  SellerOrderList,
  SellerOrderUpdate,
} from '../models';

export interface ApiOrderV1InfoListRequest {
    invoiceNumber: string;
    shippingInfoId: string;
}

export interface ApiOrderV1OrderDetailListRequest {
    orderId: string;
}

export interface ApiOrderV1SellerordersDetailReadRequest {
    id: string;
}

export interface ApiOrderV1SellerordersPartialUpdateRequest {
    id: string;
    data: SellerOrderUpdate;
}

export interface ApiOrderV1VerifyListRequest {
    authority: string;
    status: string;
    authorityId: string;
}

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

    /**
     * Fetches invoice and shipping info details by providing invoice number and shipping_info_id as query parameters.
     * Get invoice and shipping info
     */
    async apiOrderV1InfoListRaw(requestParameters: ApiOrderV1InfoListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<InvoiceAndShippingResponse>> {
        if (requestParameters.invoiceNumber === null || requestParameters.invoiceNumber === undefined) {
            throw new runtime.RequiredError('invoiceNumber','Required parameter requestParameters.invoiceNumber was null or undefined when calling apiOrderV1InfoList.');
        }

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

        const queryParameters: any = {};

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

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

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Fetches invoice and shipping info details by providing invoice number and shipping_info_id as query parameters.
     * Get invoice and shipping info
     */
    async apiOrderV1InfoList(requestParameters: ApiOrderV1InfoListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<InvoiceAndShippingResponse> {
        const response = await this.apiOrderV1InfoListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     *  Returns full order information. Accessible only by: - Superadmin - The buyer (who owns the order) - The seller (who owns the items in the order) 
     * Get full order details
     */
    async apiOrderV1OrderDetailListRaw(requestParameters: ApiOrderV1OrderDetailListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrderDetail>> {
        if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
            throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling apiOrderV1OrderDetailList.');
        }

        const queryParameters: any = {};

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

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     *  Returns full order information. Accessible only by: - Superadmin - The buyer (who owns the order) - The seller (who owns the items in the order) 
     * Get full order details
     */
    async apiOrderV1OrderDetailList(requestParameters: ApiOrderV1OrderDetailListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrderDetail> {
        const response = await this.apiOrderV1OrderDetailListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns detailed order information for the seller who owns it. Only accessible by the seller that owns the order.
     * Get seller order detail
     */
    async apiOrderV1SellerordersDetailReadRaw(requestParameters: ApiOrderV1SellerordersDetailReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrderDetail>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiOrderV1SellerordersDetailRead.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Returns detailed order information for the seller who owns it. Only accessible by the seller that owns the order.
     * Get seller order detail
     */
    async apiOrderV1SellerordersDetailRead(requestParameters: ApiOrderV1SellerordersDetailReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrderDetail> {
        const response = await this.apiOrderV1SellerordersDetailReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns all orders where the logged-in user is a seller.
     * List orders for the seller
     */
    async apiOrderV1SellerordersListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<SellerOrderList>>> {
        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/order/v1/sellerorders/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Returns all orders where the logged-in user is a seller.
     * List orders for the seller
     */
    async apiOrderV1SellerordersList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<SellerOrderList>> {
        const response = await this.apiOrderV1SellerordersListRaw(initOverrides);
        return await response.value();
    }

    /**
     *  Allows the seller to update the order status and the associated shipping info. You can send one or more of the following fields in the body: - `status`: order status (`pending`, `confirmed`, `shipped`, `delivered`, `cancelled`) - `tracking_code`: courier tracking code - `shipping_status`: shipping status (`pending`, `shipped`, `in_transit`, `delivered`, `failed`) - `cancel_reason`, `cancel_description` (required/conditional when cancelling) 
     * Seller updates an order (status and shipping info)
     */
    async apiOrderV1SellerordersPartialUpdateRaw(requestParameters: ApiOrderV1SellerordersPartialUpdateRequest, 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 apiOrderV1SellerordersPartialUpdate.');
        }

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     *  Allows the seller to update the order status and the associated shipping info. You can send one or more of the following fields in the body: - `status`: order status (`pending`, `confirmed`, `shipped`, `delivered`, `cancelled`) - `tracking_code`: courier tracking code - `shipping_status`: shipping status (`pending`, `shipped`, `in_transit`, `delivered`, `failed`) - `cancel_reason`, `cancel_description` (required/conditional when cancelling) 
     * Seller updates an order (status and shipping info)
     */
    async apiOrderV1SellerordersPartialUpdate(requestParameters: ApiOrderV1SellerordersPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiOrderV1SellerordersPartialUpdateRaw(requestParameters, initOverrides);
    }

    /**
     *  Verifies payment after returning from Zarinpal gateway. This will redirect the user to either success or failure page on the frontend. 
     * Verify Zarinpal payment for order
     */
    async apiOrderV1VerifyListRaw(requestParameters: ApiOrderV1VerifyListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.authority === null || requestParameters.authority === undefined) {
            throw new runtime.RequiredError('authority','Required parameter requestParameters.authority was null or undefined when calling apiOrderV1VerifyList.');
        }

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

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

        const queryParameters: any = {};

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

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

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     *  Verifies payment after returning from Zarinpal gateway. This will redirect the user to either success or failure page on the frontend. 
     * Verify Zarinpal payment for order
     */
    async apiOrderV1VerifyList(requestParameters: ApiOrderV1VerifyListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiOrderV1VerifyListRaw(requestParameters, initOverrides);
    }

}
