/* 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 {
  ShippingInfoCreate,
  ShippingInfoDetail,
  ShippingInfoTrackingUpdate,
} from '../models';

export interface ApiOrderV1ShippingInfoCreateRequest {
    data: ShippingInfoCreate;
}

export interface ApiOrderV1ShippingInfoReadRequest {
    shippingInfoId: string;
}

export interface ApiOrderV1ShippingInfoSellerupdatePartialUpdateRequest {
    shippingInfoId: string;
    data: ShippingInfoTrackingUpdate;
}

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

    /**
     * Create shipping info using an address and seller courier. For **face-to-face (pickup)** couriers, the address must be omitted/null; otherwise address is required. Estimated delivery is auto-filled.
     * Create Shipping Info
     */
    async apiOrderV1ShippingInfoCreateRaw(requestParameters: ApiOrderV1ShippingInfoCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ShippingInfoCreate>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiOrderV1ShippingInfoCreate.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Create shipping info using an address and seller courier. For **face-to-face (pickup)** couriers, the address must be omitted/null; otherwise address is required. Estimated delivery is auto-filled.
     * Create Shipping Info
     */
    async apiOrderV1ShippingInfoCreate(requestParameters: ApiOrderV1ShippingInfoCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ShippingInfoCreate> {
        const response = await this.apiOrderV1ShippingInfoCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Accessible by the buyer (order owner), the seller (courier owner), or superadmin. Works for both delivery and face-to-face (pickup) shipments.
     * Retrieve shipping info details
     */
    async apiOrderV1ShippingInfoReadRaw(requestParameters: ApiOrderV1ShippingInfoReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ShippingInfoDetail>> {
        if (requestParameters.shippingInfoId === null || requestParameters.shippingInfoId === undefined) {
            throw new runtime.RequiredError('shippingInfoId','Required parameter requestParameters.shippingInfoId was null or undefined when calling apiOrderV1ShippingInfoRead.');
        }

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

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Accessible by the buyer (order owner), the seller (courier owner), or superadmin. Works for both delivery and face-to-face (pickup) shipments.
     * Retrieve shipping info details
     */
    async apiOrderV1ShippingInfoRead(requestParameters: ApiOrderV1ShippingInfoReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ShippingInfoDetail> {
        const response = await this.apiOrderV1ShippingInfoReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     *  Allows the seller of the selected courier to update the tracking code.  Automatically sets tracking_url and status to `in_transit`. **Not applicable to face-to-face (pickup) couriers.** 
     * Update tracking code (Seller only)
     */
    async apiOrderV1ShippingInfoSellerupdatePartialUpdateRaw(requestParameters: ApiOrderV1ShippingInfoSellerupdatePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.shippingInfoId === null || requestParameters.shippingInfoId === undefined) {
            throw new runtime.RequiredError('shippingInfoId','Required parameter requestParameters.shippingInfoId was null or undefined when calling apiOrderV1ShippingInfoSellerupdatePartialUpdate.');
        }

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     *  Allows the seller of the selected courier to update the tracking code.  Automatically sets tracking_url and status to `in_transit`. **Not applicable to face-to-face (pickup) couriers.** 
     * Update tracking code (Seller only)
     */
    async apiOrderV1ShippingInfoSellerupdatePartialUpdate(requestParameters: ApiOrderV1ShippingInfoSellerupdatePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiOrderV1ShippingInfoSellerupdatePartialUpdateRaw(requestParameters, initOverrides);
    }

}
