|
| 1 | +/** |
| 2 | + * MeMaS DP APIs |
| 3 | + * This is the Data Plane APIs for MeMaS (Memory Management Service). |
| 4 | + * |
| 5 | + * The version of the OpenAPI document: 0.1.0 |
| 6 | + * Contact: max.yu@memas.ai |
| 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 | + |
| 13 | + |
| 14 | +import localVarRequest from 'request'; |
| 15 | +import http from 'http'; |
| 16 | + |
| 17 | +/* tslint:disable:no-unused-locals */ |
| 18 | +import { CitedDocument } from '../model/citedDocument'; |
| 19 | +import { RecollectRequest } from '../model/recollectRequest'; |
| 20 | +import { Remember200Response } from '../model/remember200Response'; |
| 21 | + |
| 22 | +import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; |
| 23 | + |
| 24 | +import { HttpError, RequestFile } from './apis'; |
| 25 | + |
| 26 | +let defaultBasePath = 'http://localhost'; |
| 27 | + |
| 28 | +// =============================================== |
| 29 | +// This file is autogenerated - Please do not edit |
| 30 | +// =============================================== |
| 31 | + |
| 32 | +export enum DpApiApiKeys { |
| 33 | +} |
| 34 | + |
| 35 | +export class DpApi { |
| 36 | + protected _basePath = defaultBasePath; |
| 37 | + protected _defaultHeaders : any = {}; |
| 38 | + protected _useQuerystring : boolean = false; |
| 39 | + |
| 40 | + protected authentications = { |
| 41 | + 'default': <Authentication>new VoidAuth(), |
| 42 | + } |
| 43 | + |
| 44 | + protected interceptors: Interceptor[] = []; |
| 45 | + |
| 46 | + constructor(basePath?: string); |
| 47 | + constructor(basePathOrUsername: string, password?: string, basePath?: string) { |
| 48 | + if (password) { |
| 49 | + if (basePath) { |
| 50 | + this.basePath = basePath; |
| 51 | + } |
| 52 | + } else { |
| 53 | + if (basePathOrUsername) { |
| 54 | + this.basePath = basePathOrUsername |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + set useQuerystring(value: boolean) { |
| 60 | + this._useQuerystring = value; |
| 61 | + } |
| 62 | + |
| 63 | + set basePath(basePath: string) { |
| 64 | + this._basePath = basePath; |
| 65 | + } |
| 66 | + |
| 67 | + set defaultHeaders(defaultHeaders: any) { |
| 68 | + this._defaultHeaders = defaultHeaders; |
| 69 | + } |
| 70 | + |
| 71 | + get defaultHeaders() { |
| 72 | + return this._defaultHeaders; |
| 73 | + } |
| 74 | + |
| 75 | + get basePath() { |
| 76 | + return this._basePath; |
| 77 | + } |
| 78 | + |
| 79 | + public setDefaultAuthentication(auth: Authentication) { |
| 80 | + this.authentications.default = auth; |
| 81 | + } |
| 82 | + |
| 83 | + public setApiKey(key: DpApiApiKeys, value: string) { |
| 84 | + (this.authentications as any)[DpApiApiKeys[key]].apiKey = value; |
| 85 | + } |
| 86 | + |
| 87 | + public addInterceptor(interceptor: Interceptor) { |
| 88 | + this.interceptors.push(interceptor); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * |
| 93 | + * @summary Recollects |
| 94 | + * @param recollectRequest |
| 95 | + */ |
| 96 | + public async recollect (recollectRequest: RecollectRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<CitedDocument>; }> { |
| 97 | + const localVarPath = this.basePath + '/dp/recollect'; |
| 98 | + let localVarQueryParameters: any = {}; |
| 99 | + let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); |
| 100 | + const produces = ['application/json']; |
| 101 | + // give precedence to 'application/json' |
| 102 | + if (produces.indexOf('application/json') >= 0) { |
| 103 | + localVarHeaderParams.Accept = 'application/json'; |
| 104 | + } else { |
| 105 | + localVarHeaderParams.Accept = produces.join(','); |
| 106 | + } |
| 107 | + let localVarFormParams: any = {}; |
| 108 | + |
| 109 | + // verify required parameter 'recollectRequest' is not null or undefined |
| 110 | + if (recollectRequest === null || recollectRequest === undefined) { |
| 111 | + throw new Error('Required parameter recollectRequest was null or undefined when calling recollect.'); |
| 112 | + } |
| 113 | + |
| 114 | + (<any>Object).assign(localVarHeaderParams, options.headers); |
| 115 | + |
| 116 | + let localVarUseFormData = false; |
| 117 | + |
| 118 | + let localVarRequestOptions: localVarRequest.Options = { |
| 119 | + method: 'POST', |
| 120 | + qs: localVarQueryParameters, |
| 121 | + headers: localVarHeaderParams, |
| 122 | + uri: localVarPath, |
| 123 | + useQuerystring: this._useQuerystring, |
| 124 | + json: true, |
| 125 | + body: ObjectSerializer.serialize(recollectRequest, "RecollectRequest") |
| 126 | + }; |
| 127 | + |
| 128 | + let authenticationPromise = Promise.resolve(); |
| 129 | + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); |
| 130 | + |
| 131 | + let interceptorPromise = authenticationPromise; |
| 132 | + for (const interceptor of this.interceptors) { |
| 133 | + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); |
| 134 | + } |
| 135 | + |
| 136 | + return interceptorPromise.then(() => { |
| 137 | + if (Object.keys(localVarFormParams).length) { |
| 138 | + if (localVarUseFormData) { |
| 139 | + (<any>localVarRequestOptions).formData = localVarFormParams; |
| 140 | + } else { |
| 141 | + localVarRequestOptions.form = localVarFormParams; |
| 142 | + } |
| 143 | + } |
| 144 | + return new Promise<{ response: http.IncomingMessage; body: Array<CitedDocument>; }>((resolve, reject) => { |
| 145 | + localVarRequest(localVarRequestOptions, (error, response, body) => { |
| 146 | + if (error) { |
| 147 | + reject(error); |
| 148 | + } else { |
| 149 | + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { |
| 150 | + body = ObjectSerializer.deserialize(body, "Array<CitedDocument>"); |
| 151 | + resolve({ response: response, body: body }); |
| 152 | + } else { |
| 153 | + reject(new HttpError(response, body, response.statusCode)); |
| 154 | + } |
| 155 | + } |
| 156 | + }); |
| 157 | + }); |
| 158 | + }); |
| 159 | + } |
| 160 | + /** |
| 161 | + * Memorize information |
| 162 | + * @summary Memorize information |
| 163 | + * @param citedDocument Remember the following information |
| 164 | + */ |
| 165 | + public async remember (citedDocument: CitedDocument, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Remember200Response; }> { |
| 166 | + const localVarPath = this.basePath + '/dp/remember'; |
| 167 | + let localVarQueryParameters: any = {}; |
| 168 | + let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); |
| 169 | + const produces = ['application/json']; |
| 170 | + // give precedence to 'application/json' |
| 171 | + if (produces.indexOf('application/json') >= 0) { |
| 172 | + localVarHeaderParams.Accept = 'application/json'; |
| 173 | + } else { |
| 174 | + localVarHeaderParams.Accept = produces.join(','); |
| 175 | + } |
| 176 | + let localVarFormParams: any = {}; |
| 177 | + |
| 178 | + // verify required parameter 'citedDocument' is not null or undefined |
| 179 | + if (citedDocument === null || citedDocument === undefined) { |
| 180 | + throw new Error('Required parameter citedDocument was null or undefined when calling remember.'); |
| 181 | + } |
| 182 | + |
| 183 | + (<any>Object).assign(localVarHeaderParams, options.headers); |
| 184 | + |
| 185 | + let localVarUseFormData = false; |
| 186 | + |
| 187 | + let localVarRequestOptions: localVarRequest.Options = { |
| 188 | + method: 'POST', |
| 189 | + qs: localVarQueryParameters, |
| 190 | + headers: localVarHeaderParams, |
| 191 | + uri: localVarPath, |
| 192 | + useQuerystring: this._useQuerystring, |
| 193 | + json: true, |
| 194 | + body: ObjectSerializer.serialize(citedDocument, "CitedDocument") |
| 195 | + }; |
| 196 | + |
| 197 | + let authenticationPromise = Promise.resolve(); |
| 198 | + authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); |
| 199 | + |
| 200 | + let interceptorPromise = authenticationPromise; |
| 201 | + for (const interceptor of this.interceptors) { |
| 202 | + interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); |
| 203 | + } |
| 204 | + |
| 205 | + return interceptorPromise.then(() => { |
| 206 | + if (Object.keys(localVarFormParams).length) { |
| 207 | + if (localVarUseFormData) { |
| 208 | + (<any>localVarRequestOptions).formData = localVarFormParams; |
| 209 | + } else { |
| 210 | + localVarRequestOptions.form = localVarFormParams; |
| 211 | + } |
| 212 | + } |
| 213 | + return new Promise<{ response: http.IncomingMessage; body: Remember200Response; }>((resolve, reject) => { |
| 214 | + localVarRequest(localVarRequestOptions, (error, response, body) => { |
| 215 | + if (error) { |
| 216 | + reject(error); |
| 217 | + } else { |
| 218 | + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { |
| 219 | + body = ObjectSerializer.deserialize(body, "Remember200Response"); |
| 220 | + resolve({ response: response, body: body }); |
| 221 | + } else { |
| 222 | + reject(new HttpError(response, body, response.statusCode)); |
| 223 | + } |
| 224 | + } |
| 225 | + }); |
| 226 | + }); |
| 227 | + }); |
| 228 | + } |
| 229 | +} |
0 commit comments