UNPKG

cwmsjs

Version:

CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps

121 lines (98 loc) 3.77 kB
/* 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, Office, OfficeFromJSON, OfficeToJSON, OfficeFormatV1, OfficeFormatV1FromJSON, OfficeFormatV1ToJSON, } from '../models'; export interface GetOfficesRequest { format?: string; hasData?: boolean; } export interface GetOfficesWithOfficeRequest { office: string; format?: string; } /** * */ export class OfficesApi extends runtime.BaseAPI { /** * Get offices */ async getOfficesRaw(requestParameters: GetOfficesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<Office>>> { const queryParameters: any = {}; if (requestParameters.format !== undefined) { queryParameters['format'] = requestParameters.format; } if (requestParameters.hasData !== undefined) { queryParameters['has-data'] = requestParameters.hasData; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = await this.request({ path: `/offices`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OfficeFromJSON)); } /** * Get offices */ async getOffices(requestParameters: GetOfficesRequest = {}, initOverrides?: RequestInit): Promise<Array<Office>> { const response = await this.getOfficesRaw(requestParameters, initOverrides); return await response.value(); } /** * Get offices with office */ async getOfficesWithOfficeRaw(requestParameters: GetOfficesWithOfficeRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<OfficeFormatV1>> { if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getOfficesWithOffice.'); } const queryParameters: any = {}; if (requestParameters.format !== undefined) { queryParameters['format'] = requestParameters.format; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = await this.request({ path: `/offices/{office}`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters.office))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OfficeFormatV1FromJSON(jsonValue)); } /** * Get offices with office */ async getOfficesWithOffice(requestParameters: GetOfficesWithOfficeRequest, initOverrides?: RequestInit): Promise<OfficeFormatV1> { const response = await this.getOfficesWithOfficeRaw(requestParameters, initOverrides); return await response.value(); } }