/* tslint:disable */
/* eslint-disable */
/**
 * CWMS Data API
 * CWMS REST API for Data Retrieval
 *
 * The version of the OpenAPI document: 2.4.0-2026.3.16
 * 
 *
 * 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 {
    CdaError,
    CdaErrorFromJSON,
    CdaErrorToJSON,
    WaterSupplyAccounting,
    WaterSupplyAccountingFromJSON,
    WaterSupplyAccountingToJSON,
} from '../models';

export interface GetProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRequest {
    office: string;
    projectId: string;
    waterUser: string;
    contractName: string;
    start: string;
    end: string;
    timezone?: string;
    unit?: string;
    startTimeInclusive?: boolean;
    endTimeInclusive?: boolean;
    ascending?: boolean;
    rowLimit?: number;
}

export interface PostProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRequest {
    office: string;
    projectId: string;
    waterUser: string;
    contractName: string;
    waterSupplyAccounting: WaterSupplyAccounting;
}

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

    /**
     * Get pump accounting entries associated with a water supply contract.
     * Get projects with office with projectId waterUser with waterUser contracts with contractName accounting
     */
    async getProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRaw(requestParameters: GetProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<WaterSupplyAccounting>>> {
        if (requestParameters.office === null || requestParameters.office === undefined) {
            throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccounting.');
        }

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

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

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

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

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

        const queryParameters: any = {};

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

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

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

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

        if (requestParameters.startTimeInclusive !== undefined) {
            queryParameters['start-time-inclusive'] = requestParameters.startTimeInclusive;
        }

        if (requestParameters.endTimeInclusive !== undefined) {
            queryParameters['end-time-inclusive'] = requestParameters.endTimeInclusive;
        }

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

        if (requestParameters.rowLimit !== undefined) {
            queryParameters['row-limit'] = requestParameters.rowLimit;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/projects/{office}/{project-id}/water-user/{water-user}/contracts/{contract-name}/accounting`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters.office))).replace(`{${"project-id"}}`, encodeURIComponent(String(requestParameters.projectId))).replace(`{${"water-user"}}`, encodeURIComponent(String(requestParameters.waterUser))).replace(`{${"contract-name"}}`, encodeURIComponent(String(requestParameters.contractName))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(WaterSupplyAccountingFromJSON));
    }

    /**
     * Get pump accounting entries associated with a water supply contract.
     * Get projects with office with projectId waterUser with waterUser contracts with contractName accounting
     */
    async getProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccounting(requestParameters: GetProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRequest, initOverrides?: RequestInit): Promise<Array<WaterSupplyAccounting>> {
        const response = await this.getProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Create a new pump accounting entry associated with a water supply contract.
     * Post projects with office with projectId waterUser with waterUser contracts with contractName accounting
     */
    async postProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRaw(requestParameters: PostProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.office === null || requestParameters.office === undefined) {
            throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling postProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccounting.');
        }

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

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

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

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/projects/{office}/{project-id}/water-user/{water-user}/contracts/{contract-name}/accounting`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters.office))).replace(`{${"project-id"}}`, encodeURIComponent(String(requestParameters.projectId))).replace(`{${"water-user"}}`, encodeURIComponent(String(requestParameters.waterUser))).replace(`{${"contract-name"}}`, encodeURIComponent(String(requestParameters.contractName))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: WaterSupplyAccountingToJSON(requestParameters.waterSupplyAccounting),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create a new pump accounting entry associated with a water supply contract.
     * Post projects with office with projectId waterUser with waterUser contracts with contractName accounting
     */
    async postProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccounting(requestParameters: PostProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRequest, initOverrides?: RequestInit): Promise<void> {
        await this.postProjectsWithOfficeWithProjectIdWaterUserWithWaterUserContractsWithContractNameAccountingRaw(requestParameters, initOverrides);
    }

}
