| 1 | /**
|
|---|
| 2 | * GNUBoat Mapservice API
|
|---|
| 3 | * API to upload log files with water depth to GNUBoat server
|
|---|
| 4 | *
|
|---|
| 5 | * The version of the OpenAPI document: v1
|
|---|
| 6 | * Contact: info@engsas.de
|
|---|
| 7 | *
|
|---|
| 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|---|
| 9 | * https://openapi-generator.tech
|
|---|
| 10 | * Do not edit the class manually.
|
|---|
| 11 | */
|
|---|
| 12 | /* tslint:disable:no-unused-variable member-ordering */
|
|---|
| 13 |
|
|---|
| 14 | import { Inject, Injectable, Optional } from '@angular/core';
|
|---|
| 15 | import { HttpClient, HttpHeaders, HttpParams,
|
|---|
| 16 | HttpResponse, HttpEvent, HttpParameterCodec } from '@angular/common/http';
|
|---|
| 17 | import { CustomHttpParameterCodec } from '../encoder';
|
|---|
| 18 | import { Observable } from 'rxjs';
|
|---|
| 19 |
|
|---|
| 20 | import { Device } from '../model/models';
|
|---|
| 21 | import { DeviceCreation } from '../model/models';
|
|---|
| 22 | import { HttpError } from '../model/models';
|
|---|
| 23 |
|
|---|
| 24 | import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
|---|
| 25 | import { Configuration } from '../configuration';
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | @Injectable({
|
|---|
| 30 | providedIn: 'root'
|
|---|
| 31 | })
|
|---|
| 32 | export class DevicesService {
|
|---|
| 33 |
|
|---|
| 34 | protected basePath = 'https://gnuboat.engsas.com/mapservice/v1';
|
|---|
| 35 | public defaultHeaders = new HttpHeaders();
|
|---|
| 36 | public configuration = new Configuration();
|
|---|
| 37 | public encoder: HttpParameterCodec;
|
|---|
| 38 |
|
|---|
| 39 | constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
|---|
| 40 | if (configuration) {
|
|---|
| 41 | this.configuration = configuration;
|
|---|
| 42 | }
|
|---|
| 43 | if (typeof this.configuration.basePath !== 'string') {
|
|---|
| 44 | if (typeof basePath !== 'string') {
|
|---|
| 45 | basePath = this.basePath;
|
|---|
| 46 | }
|
|---|
| 47 | this.configuration.basePath = basePath;
|
|---|
| 48 | }
|
|---|
| 49 | this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
|
|---|
| 55 | if (typeof value === "object" && value instanceof Date === false) {
|
|---|
| 56 | httpParams = this.addToHttpParamsRecursive(httpParams, value);
|
|---|
| 57 | } else {
|
|---|
| 58 | httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
|
|---|
| 59 | }
|
|---|
| 60 | return httpParams;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
|
|---|
| 64 | if (value == null) {
|
|---|
| 65 | return httpParams;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | if (typeof value === "object") {
|
|---|
| 69 | if (Array.isArray(value)) {
|
|---|
| 70 | (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
|
|---|
| 71 | } else if (value instanceof Date) {
|
|---|
| 72 | if (key != null) {
|
|---|
| 73 | httpParams = httpParams.append(key,
|
|---|
| 74 | (value as Date).toISOString().substr(0, 10));
|
|---|
| 75 | } else {
|
|---|
| 76 | throw Error("key may not be null if value is Date");
|
|---|
| 77 | }
|
|---|
| 78 | } else {
|
|---|
| 79 | Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
|
|---|
| 80 | httpParams, value[k], key != null ? `${key}.${k}` : k));
|
|---|
| 81 | }
|
|---|
| 82 | } else if (key != null) {
|
|---|
| 83 | httpParams = httpParams.append(key, value);
|
|---|
| 84 | } else {
|
|---|
| 85 | throw Error("key may not be null if value is not object or array");
|
|---|
| 86 | }
|
|---|
| 87 | return httpParams;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | /**
|
|---|
| 91 | * Add a new device
|
|---|
| 92 | * Adds a new device to the database
|
|---|
| 93 | * @param deviceCreation
|
|---|
| 94 | * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
|---|
| 95 | * @param reportProgress flag to report request and response progress.
|
|---|
| 96 | */
|
|---|
| 97 | public devicesCreate(deviceCreation?: DeviceCreation, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<Device>;
|
|---|
| 98 | public devicesCreate(deviceCreation?: DeviceCreation, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpResponse<Device>>;
|
|---|
| 99 | public devicesCreate(deviceCreation?: DeviceCreation, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpEvent<Device>>;
|
|---|
| 100 | public devicesCreate(deviceCreation?: DeviceCreation, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<any> {
|
|---|
| 101 |
|
|---|
| 102 | let headers = this.defaultHeaders;
|
|---|
| 103 |
|
|---|
| 104 | // authentication (apiKeyAuth) required
|
|---|
| 105 | if (this.configuration.apiKeys) {
|
|---|
| 106 | const key: string | undefined = this.configuration.apiKeys["apiKeyAuth"] || this.configuration.apiKeys["X-API-KEY"];
|
|---|
| 107 | if (key) {
|
|---|
| 108 | headers = headers.set('X-API-KEY', key);
|
|---|
| 109 | }
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | // authentication (basicAuth) required
|
|---|
| 113 | if (this.configuration.username || this.configuration.password) {
|
|---|
| 114 | headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password));
|
|---|
| 115 | }
|
|---|
| 116 | let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
|---|
| 117 | if (httpHeaderAcceptSelected === undefined) {
|
|---|
| 118 | // to determine the Accept header
|
|---|
| 119 | const httpHeaderAccepts: string[] = [
|
|---|
| 120 | 'application/json',
|
|---|
| 121 | 'application/problem+json'
|
|---|
| 122 | ];
|
|---|
| 123 | httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
|---|
| 124 | }
|
|---|
| 125 | if (httpHeaderAcceptSelected !== undefined) {
|
|---|
| 126 | headers = headers.set('Accept', httpHeaderAcceptSelected);
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | // to determine the Content-Type header
|
|---|
| 131 | const consumes: string[] = [
|
|---|
| 132 | 'application/json'
|
|---|
| 133 | ];
|
|---|
| 134 | const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
|
|---|
| 135 | if (httpContentTypeSelected !== undefined) {
|
|---|
| 136 | headers = headers.set('Content-Type', httpContentTypeSelected);
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | let responseType: 'text' | 'json' = 'json';
|
|---|
| 140 | if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
|
|---|
| 141 | responseType = 'text';
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | return this.httpClient.post<Device>(`${this.configuration.basePath}/devices`,
|
|---|
| 145 | deviceCreation,
|
|---|
| 146 | {
|
|---|
| 147 | responseType: <any>responseType,
|
|---|
| 148 | withCredentials: this.configuration.withCredentials,
|
|---|
| 149 | headers: headers,
|
|---|
| 150 | observe: observe,
|
|---|
| 151 | reportProgress: reportProgress
|
|---|
| 152 | }
|
|---|
| 153 | );
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | /**
|
|---|
| 157 | * Deletes device
|
|---|
| 158 | * Deletes given device and returns remaining devices of the user
|
|---|
| 159 | * @param id Item id
|
|---|
| 160 | * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
|---|
| 161 | * @param reportProgress flag to report request and response progress.
|
|---|
| 162 | */
|
|---|
| 163 | public devicesDeviceDelete(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<Array<Device>>;
|
|---|
| 164 | public devicesDeviceDelete(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpResponse<Array<Device>>>;
|
|---|
| 165 | public devicesDeviceDelete(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpEvent<Array<Device>>>;
|
|---|
| 166 | public devicesDeviceDelete(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<any> {
|
|---|
| 167 | if (id === null || id === undefined) {
|
|---|
| 168 | throw new Error('Required parameter id was null or undefined when calling devicesDeviceDelete.');
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | let headers = this.defaultHeaders;
|
|---|
| 172 |
|
|---|
| 173 | // authentication (apiKeyAuth) required
|
|---|
| 174 | if (this.configuration.apiKeys) {
|
|---|
| 175 | const key: string | undefined = this.configuration.apiKeys["apiKeyAuth"] || this.configuration.apiKeys["X-API-KEY"];
|
|---|
| 176 | if (key) {
|
|---|
| 177 | headers = headers.set('X-API-KEY', key);
|
|---|
| 178 | }
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | // authentication (basicAuth) required
|
|---|
| 182 | if (this.configuration.username || this.configuration.password) {
|
|---|
| 183 | headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password));
|
|---|
| 184 | }
|
|---|
| 185 | let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
|---|
| 186 | if (httpHeaderAcceptSelected === undefined) {
|
|---|
| 187 | // to determine the Accept header
|
|---|
| 188 | const httpHeaderAccepts: string[] = [
|
|---|
| 189 | 'application/json',
|
|---|
| 190 | 'application/problem+json'
|
|---|
| 191 | ];
|
|---|
| 192 | httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
|---|
| 193 | }
|
|---|
| 194 | if (httpHeaderAcceptSelected !== undefined) {
|
|---|
| 195 | headers = headers.set('Accept', httpHeaderAcceptSelected);
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 | let responseType: 'text' | 'json' = 'json';
|
|---|
| 200 | if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
|
|---|
| 201 | responseType = 'text';
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | return this.httpClient.delete<Array<Device>>(`${this.configuration.basePath}/devices/${encodeURIComponent(String(id))}`,
|
|---|
| 205 | {
|
|---|
| 206 | responseType: <any>responseType,
|
|---|
| 207 | withCredentials: this.configuration.withCredentials,
|
|---|
| 208 | headers: headers,
|
|---|
| 209 | observe: observe,
|
|---|
| 210 | reportProgress: reportProgress
|
|---|
| 211 | }
|
|---|
| 212 | );
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | /**
|
|---|
| 216 | * Find devices by id
|
|---|
| 217 | * Returns all devices of user
|
|---|
| 218 | * @param name
|
|---|
| 219 | * @param orderBy Order by field: name
|
|---|
| 220 | * @param offset Skip over a number of elements by specifying an offset value for the query
|
|---|
| 221 | * @param limit Limit the number of elements on the response
|
|---|
| 222 | * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
|---|
| 223 | * @param reportProgress flag to report request and response progress.
|
|---|
| 224 | */
|
|---|
| 225 | public devicesGet(name?: string, orderBy?: string, offset?: number, limit?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<Array<Device>>;
|
|---|
| 226 | public devicesGet(name?: string, orderBy?: string, offset?: number, limit?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpResponse<Array<Device>>>;
|
|---|
| 227 | public devicesGet(name?: string, orderBy?: string, offset?: number, limit?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpEvent<Array<Device>>>;
|
|---|
| 228 | public devicesGet(name?: string, orderBy?: string, offset?: number, limit?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<any> {
|
|---|
| 229 |
|
|---|
| 230 | let queryParameters = new HttpParams({encoder: this.encoder});
|
|---|
| 231 | if (name !== undefined && name !== null) {
|
|---|
| 232 | queryParameters = this.addToHttpParams(queryParameters,
|
|---|
| 233 | <any>name, 'name');
|
|---|
| 234 | }
|
|---|
| 235 | if (orderBy !== undefined && orderBy !== null) {
|
|---|
| 236 | queryParameters = this.addToHttpParams(queryParameters,
|
|---|
| 237 | <any>orderBy, 'order_by');
|
|---|
| 238 | }
|
|---|
| 239 | if (offset !== undefined && offset !== null) {
|
|---|
| 240 | queryParameters = this.addToHttpParams(queryParameters,
|
|---|
| 241 | <any>offset, 'offset');
|
|---|
| 242 | }
|
|---|
| 243 | if (limit !== undefined && limit !== null) {
|
|---|
| 244 | queryParameters = this.addToHttpParams(queryParameters,
|
|---|
| 245 | <any>limit, 'limit');
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | let headers = this.defaultHeaders;
|
|---|
| 249 |
|
|---|
| 250 | // authentication (apiKeyAuth) required
|
|---|
| 251 | if (this.configuration.apiKeys) {
|
|---|
| 252 | const key: string | undefined = this.configuration.apiKeys["apiKeyAuth"] || this.configuration.apiKeys["X-API-KEY"];
|
|---|
| 253 | if (key) {
|
|---|
| 254 | headers = headers.set('X-API-KEY', key);
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | // authentication (basicAuth) required
|
|---|
| 259 | if (this.configuration.username || this.configuration.password) {
|
|---|
| 260 | headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password));
|
|---|
| 261 | }
|
|---|
| 262 | let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
|---|
| 263 | if (httpHeaderAcceptSelected === undefined) {
|
|---|
| 264 | // to determine the Accept header
|
|---|
| 265 | const httpHeaderAccepts: string[] = [
|
|---|
| 266 | 'application/json',
|
|---|
| 267 | 'application/problem+json'
|
|---|
| 268 | ];
|
|---|
| 269 | httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
|---|
| 270 | }
|
|---|
| 271 | if (httpHeaderAcceptSelected !== undefined) {
|
|---|
| 272 | headers = headers.set('Accept', httpHeaderAcceptSelected);
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 | let responseType: 'text' | 'json' = 'json';
|
|---|
| 277 | if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
|
|---|
| 278 | responseType = 'text';
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | return this.httpClient.get<Array<Device>>(`${this.configuration.basePath}/devices`,
|
|---|
| 282 | {
|
|---|
| 283 | params: queryParameters,
|
|---|
| 284 | responseType: <any>responseType,
|
|---|
| 285 | withCredentials: this.configuration.withCredentials,
|
|---|
| 286 | headers: headers,
|
|---|
| 287 | observe: observe,
|
|---|
| 288 | reportProgress: reportProgress
|
|---|
| 289 | }
|
|---|
| 290 | );
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | /**
|
|---|
| 294 | * Represents a device
|
|---|
| 295 | * Returns the device identified by id
|
|---|
| 296 | * @param id Item ID
|
|---|
| 297 | * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
|---|
| 298 | * @param reportProgress flag to report request and response progress.
|
|---|
| 299 | */
|
|---|
| 300 | public devicesGetById(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<Device>;
|
|---|
| 301 | public devicesGetById(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpResponse<Device>>;
|
|---|
| 302 | public devicesGetById(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<HttpEvent<Device>>;
|
|---|
| 303 | public devicesGetById(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json'}): Observable<any> {
|
|---|
| 304 | if (id === null || id === undefined) {
|
|---|
| 305 | throw new Error('Required parameter id was null or undefined when calling devicesGetById.');
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | let headers = this.defaultHeaders;
|
|---|
| 309 |
|
|---|
| 310 | // authentication (apiKeyAuth) required
|
|---|
| 311 | if (this.configuration.apiKeys) {
|
|---|
| 312 | const key: string | undefined = this.configuration.apiKeys["apiKeyAuth"] || this.configuration.apiKeys["X-API-KEY"];
|
|---|
| 313 | if (key) {
|
|---|
| 314 | headers = headers.set('X-API-KEY', key);
|
|---|
| 315 | }
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | // authentication (basicAuth) required
|
|---|
| 319 | if (this.configuration.username || this.configuration.password) {
|
|---|
| 320 | headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password));
|
|---|
| 321 | }
|
|---|
| 322 | let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
|---|
| 323 | if (httpHeaderAcceptSelected === undefined) {
|
|---|
| 324 | // to determine the Accept header
|
|---|
| 325 | const httpHeaderAccepts: string[] = [
|
|---|
| 326 | 'application/json',
|
|---|
| 327 | 'application/problem+json'
|
|---|
| 328 | ];
|
|---|
| 329 | httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
|---|
| 330 | }
|
|---|
| 331 | if (httpHeaderAcceptSelected !== undefined) {
|
|---|
| 332 | headers = headers.set('Accept', httpHeaderAcceptSelected);
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 | let responseType: 'text' | 'json' = 'json';
|
|---|
| 337 | if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
|
|---|
| 338 | responseType = 'text';
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | return this.httpClient.get<Device>(`${this.configuration.basePath}/devices/${encodeURIComponent(String(id))}`,
|
|---|
| 342 | {
|
|---|
| 343 | responseType: <any>responseType,
|
|---|
| 344 | withCredentials: this.configuration.withCredentials,
|
|---|
| 345 | headers: headers,
|
|---|
| 346 | observe: observe,
|
|---|
| 347 | reportProgress: reportProgress
|
|---|
| 348 | }
|
|---|
| 349 | );
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | }
|
|---|