cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
126 lines (103 loc) • 3.98 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* CWMS Data API
* CWMS REST API for Data Retrieval
*
* The version of the OpenAPI document: 2.3.2-2025.03.19
*
*
* 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 {
CdaError,
Office,
OfficeFormatV1,
} from '../models/index';
import {
CdaErrorFromJSON,
CdaErrorToJSON,
OfficeFromJSON,
OfficeToJSON,
OfficeFormatV1FromJSON,
OfficeFormatV1ToJSON,
} from '../models/index';
export interface GetOfficesRequest {
format?: string;
hasData?: boolean;
}
export interface GetOfficesWithOfficeRequest {
office: string;
format?: string;
}
/**
*
*/
export class OfficesApi extends runtime.BaseAPI {
/**
* Get cwmsData offices
*/
async getOfficesRaw(requestParameters: GetOfficesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<Office>>> {
const queryParameters: any = {};
if (requestParameters['format'] != null) {
queryParameters['format'] = requestParameters['format'];
}
if (requestParameters['hasData'] != null) {
queryParameters['has-data'] = requestParameters['hasData'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await 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 cwmsData offices
*/
async getOffices(requestParameters: GetOfficesRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<Office>> {
const response = await this.getOfficesRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Get cwmsData offices with office
*/
async getOfficesWithOfficeRaw(requestParameters: GetOfficesWithOfficeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OfficeFormatV1>> {
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling getOfficesWithOffice().'
);
}
const queryParameters: any = {};
if (requestParameters['format'] != null) {
queryParameters['format'] = requestParameters['format'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await 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 cwmsData offices with office
*/
async getOfficesWithOffice(requestParameters: GetOfficesWithOfficeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OfficeFormatV1> {
const response = await this.getOfficesWithOfficeRaw(requestParameters, initOverrides);
return await response.value();
}
}