|
| 1 | +// TODO: better import syntax? |
| 2 | +import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi'; |
| 3 | +import {Configuration} from '../configuration'; |
| 4 | +import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http'; |
| 5 | +import {ObjectSerializer} from '../models/ObjectSerializer'; |
| 6 | +import {ApiException} from './exception'; |
| 7 | +import {canConsumeForm, isCodeInRange} from '../util'; |
| 8 | +import {SecurityAuthentication} from '../auth/auth'; |
| 9 | + |
| 10 | + |
| 11 | +import { Response } from '../models/Response'; |
| 12 | + |
| 13 | +/** |
| 14 | + * no description |
| 15 | + */ |
| 16 | +export class DefaultApiRequestFactory extends BaseAPIRequestFactory { |
| 17 | + |
| 18 | + /** |
| 19 | + */ |
| 20 | + public async uniqueItems(_options?: Configuration): Promise<RequestContext> { |
| 21 | + let _config = _options || this.configuration; |
| 22 | + |
| 23 | + // Path Params |
| 24 | + const localVarPath = '/unique-items'; |
| 25 | + |
| 26 | + // Make Request Context |
| 27 | + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); |
| 28 | + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default |
| 33 | + if (defaultAuth?.applySecurityAuthentication) { |
| 34 | + await defaultAuth?.applySecurityAuthentication(requestContext); |
| 35 | + } |
| 36 | + |
| 37 | + return requestContext; |
| 38 | + } |
| 39 | + |
| 40 | +} |
| 41 | + |
| 42 | +export class DefaultApiResponseProcessor { |
| 43 | + |
| 44 | + /** |
| 45 | + * Unwraps the actual response sent by the server from the response context and deserializes the response content |
| 46 | + * to the expected objects |
| 47 | + * |
| 48 | + * @params response Response returned by the server for a request to uniqueItems |
| 49 | + * @throws ApiException if the response code was not in [200, 299] |
| 50 | + */ |
| 51 | + public async uniqueItemsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Response >> { |
| 52 | + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); |
| 53 | + if (isCodeInRange("200", response.httpStatusCode)) { |
| 54 | + const body: Response = ObjectSerializer.deserialize( |
| 55 | + ObjectSerializer.parse(await response.body.text(), contentType), |
| 56 | + "Response", "" |
| 57 | + ) as Response; |
| 58 | + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); |
| 59 | + } |
| 60 | + |
| 61 | + // Work around for missing responses in specification, e.g. for petstore.yaml |
| 62 | + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { |
| 63 | + const body: Response = ObjectSerializer.deserialize( |
| 64 | + ObjectSerializer.parse(await response.body.text(), contentType), |
| 65 | + "Response", "" |
| 66 | + ) as Response; |
| 67 | + return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); |
| 68 | + } |
| 69 | + |
| 70 | + throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments