1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import type { RequestStatus, SwaggerFetchPathOptions } from '../../../utility/Fetch';
|
12 | import { SwaggerFetch } from '../../../utility/Fetch';
|
13 | import t from 'flow-runtime';
|
14 |
|
15 | import type {
|
16 | TrovCommonModelProfileProfile,
|
17 | UnexpectedErrorException,
|
18 | TrovCommonModelProfileCustomerProfile,
|
19 | CustomerAddressNotSupportedException,
|
20 | CustomerAgeNotSupportedException,
|
21 | CustomerProfileInformationMissingException,
|
22 | StateOfResidenceNotSupportedException,
|
23 | ArgumentException,
|
24 | UnsupportedImageException,
|
25 | DocumentAccessException,
|
26 | } from '../../types_gen/V4';
|
27 | import Validators from '../../validators_gen/V4';
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | export type getApiProfileHeader = {|
|
42 | 'Trov-Tenant': string,
|
43 | 'Trov-Market': string,
|
44 | 'Trov-Client': string,
|
45 | 'Accept-Language': string,
|
46 | Authorization: string
|
47 | |};
|
48 |
|
49 | export type GetApiProfileResponseBody = TrovCommonModelProfileProfile | UnexpectedErrorException;
|
50 |
|
51 | export type GetApiProfileInit = {
|
52 | header: getApiProfileHeader,
|
53 | } & RequestOptions;
|
54 |
|
55 | export type GetApiProfileOptions = SwaggerFetchPathOptions;
|
56 |
|
57 | export class GetApiProfile extends SwaggerFetch {
|
58 | constructor(init: GetApiProfileInit, options: GetApiProfileOptions) {
|
59 | const finalInit = {
|
60 | ...init,
|
61 | method: 'GET',
|
62 | };
|
63 | super(finalInit, options);
|
64 |
|
65 | this.endpoint = '/api/v4.0/profile';
|
66 | }
|
67 |
|
68 | handleResponseStatus(response: Response, parsedBody: GetApiProfileResponseBody): ({
|
69 | response: Response,
|
70 | body: ?GetApiProfileResponseBody,
|
71 | status: RequestStatus,
|
72 | }) {
|
73 | const body = (parsedBody && typeof parsedBody === 'object') ? parsedBody : null;
|
74 | let status = 'MISTAKE';
|
75 |
|
76 | switch (response.status) {
|
77 |
|
78 | case 200:
|
79 | status = 'SUCCESS';
|
80 |
|
81 | if (process.env.DEV_TOOLS) {
|
82 | const TrovCommonModelProfileProfileValidation = Validators.TrovCommonModelProfileProfile.validate(parsedBody);
|
83 | if (TrovCommonModelProfileProfileValidation.hasErrors()) {
|
84 | console.error(JSON.stringify(t.makeJSONError(TrovCommonModelProfileProfileValidation), null, 2));
|
85 | }
|
86 | }
|
87 | break;
|
88 |
|
89 |
|
90 | case 500:
|
91 | status = 'FAILURE';
|
92 |
|
93 | if (process.env.DEV_TOOLS) {
|
94 | const UnexpectedErrorExceptionValidation = Validators.UnexpectedErrorException.validate(parsedBody);
|
95 | if (UnexpectedErrorExceptionValidation.hasErrors()) {
|
96 | console.error(JSON.stringify(t.makeJSONError(UnexpectedErrorExceptionValidation), null, 2));
|
97 | }
|
98 | }
|
99 | break;
|
100 |
|
101 |
|
102 | default:
|
103 | return super.handleResponseStatus(response, parsedBody, true);
|
104 | }
|
105 |
|
106 | return { response, body, status };
|
107 | }
|
108 | }
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | export type putApiProfileCustomerBody = TrovCommonModelProfileCustomerProfile;
|
124 |
|
125 | export type putApiProfileCustomerHeader = {|
|
126 | 'Trov-Tenant': string,
|
127 | 'Trov-Market': string,
|
128 | 'Trov-Client': string,
|
129 | 'Accept-Language': string,
|
130 | Authorization: string
|
131 | |};
|
132 |
|
133 | export type PutApiProfileCustomerResponseBody =
|
134 | | TrovCommonModelProfileProfile
|
135 | | CustomerAddressNotSupportedException
|
136 | | CustomerAgeNotSupportedException
|
137 | | CustomerProfileInformationMissingException
|
138 | | StateOfResidenceNotSupportedException
|
139 | | UnexpectedErrorException;
|
140 |
|
141 | export type PutApiProfileCustomerInit = {
|
142 | header: putApiProfileCustomerHeader,
|
143 | } & RequestOptions;
|
144 |
|
145 | export type PutApiProfileCustomerOptions = {
|
146 | body: putApiProfileCustomerBody,
|
147 | } & SwaggerFetchPathOptions;
|
148 |
|
149 | export class PutApiProfileCustomer extends SwaggerFetch {
|
150 | constructor(init: PutApiProfileCustomerInit, options: PutApiProfileCustomerOptions) {
|
151 | const finalInit = {
|
152 | ...init,
|
153 | method: 'PUT',
|
154 | body: typeof options.body === 'string' ? options.body : JSON.stringify(options.body),
|
155 | };
|
156 | super(finalInit, options);
|
157 |
|
158 | this.endpoint = '/api/v4.0/profile/customer';
|
159 | }
|
160 |
|
161 | handleResponseStatus(response: Response, parsedBody: PutApiProfileCustomerResponseBody): ({
|
162 | response: Response,
|
163 | body: ?PutApiProfileCustomerResponseBody,
|
164 | status: RequestStatus,
|
165 | }) {
|
166 | const body = (parsedBody && typeof parsedBody === 'object') ? parsedBody : null;
|
167 | let status = 'MISTAKE';
|
168 |
|
169 | switch (response.status) {
|
170 |
|
171 | case 200:
|
172 | status = 'SUCCESS';
|
173 |
|
174 | if (process.env.DEV_TOOLS) {
|
175 | const TrovCommonModelProfileProfileValidation = Validators.TrovCommonModelProfileProfile.validate(parsedBody);
|
176 | if (TrovCommonModelProfileProfileValidation.hasErrors()) {
|
177 | console.error(JSON.stringify(t.makeJSONError(TrovCommonModelProfileProfileValidation), null, 2));
|
178 | }
|
179 | }
|
180 | break;
|
181 |
|
182 |
|
183 | case 400:
|
184 | status = 'FAILURE';
|
185 |
|
186 | if (process.env.DEV_TOOLS && parsedBody && typeof parsedBody === 'object' && parsedBody.ExceptionType) {
|
187 | switch (parsedBody.ExceptionType) {
|
188 | case 'CustomerAddressNotSupportedException':
|
189 |
|
190 |
|
191 | if (process.env.DEV_TOOLS) {
|
192 | Validators.CustomerAddressNotSupportedException.assert(parsedBody);
|
193 | }
|
194 | break;
|
195 |
|
196 | case 'CustomerAgeNotSupportedException':
|
197 |
|
198 | if (process.env.DEV_TOOLS) {
|
199 | Validators.CustomerAgeNotSupportedException.assert(parsedBody);
|
200 | }
|
201 | break;
|
202 |
|
203 | case 'CustomerProfileInformationMissingException':
|
204 |
|
205 | if (process.env.DEV_TOOLS) {
|
206 | Validators.CustomerProfileInformationMissingException.assert(parsedBody);
|
207 | }
|
208 | break;
|
209 |
|
210 | default:
|
211 | console.warn(`${this.constructor.name} has no case for a "${response.status}" status and a differentiating key "ExceptionType" of ${JSON.stringify(parsedBody.ExceptionType)}.`);
|
212 | break;
|
213 | }
|
214 | }
|
215 |
|
216 | break;
|
217 |
|
218 |
|
219 | case 500:
|
220 | status = 'FAILURE';
|
221 |
|
222 | if (process.env.DEV_TOOLS && parsedBody && typeof parsedBody === 'object' && parsedBody.ExceptionType) {
|
223 | switch (parsedBody.ExceptionType) {
|
224 | case 'StateOfResidenceNotSupportedException':
|
225 |
|
226 | if (process.env.DEV_TOOLS) {
|
227 | Validators.StateOfResidenceNotSupportedException.assert(parsedBody);
|
228 | }
|
229 | break;
|
230 |
|
231 | case 'UnexpectedErrorException':
|
232 |
|
233 | if (process.env.DEV_TOOLS) {
|
234 | Validators.UnexpectedErrorException.assert(parsedBody);
|
235 | }
|
236 | break;
|
237 |
|
238 | default:
|
239 | console.warn(`${this.constructor.name} has no case for a "${response.status}" status and a differentiating key "ExceptionType" of ${JSON.stringify(parsedBody.ExceptionType)}.`);
|
240 | break;
|
241 | }
|
242 | }
|
243 |
|
244 | break;
|
245 |
|
246 |
|
247 | default:
|
248 | return super.handleResponseStatus(response, parsedBody, true);
|
249 | }
|
250 |
|
251 | return { response, body, status };
|
252 | }
|
253 | }
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 | export type postApiProfilePhotosProfileHeader = {|
|
272 | 'Trov-Tenant': string,
|
273 | 'Trov-Market': string,
|
274 | 'Trov-Client': string,
|
275 | 'Accept-Language': string,
|
276 | Authorization: string
|
277 | |};
|
278 |
|
279 | export type PostApiProfilePhotosProfileResponseBody =
|
280 | | TrovCommonModelProfileProfile
|
281 | | ArgumentException
|
282 | | UnsupportedImageException
|
283 | | DocumentAccessException
|
284 | | UnexpectedErrorException;
|
285 |
|
286 | export type PostApiProfilePhotosProfileInit = {
|
287 | header: postApiProfilePhotosProfileHeader,
|
288 | } & RequestOptions;
|
289 |
|
290 | export type PostApiProfilePhotosProfileOptions = SwaggerFetchPathOptions;
|
291 |
|
292 | export class PostApiProfilePhotosProfile extends SwaggerFetch {
|
293 | constructor(init: PostApiProfilePhotosProfileInit, options: PostApiProfilePhotosProfileOptions) {
|
294 | const finalInit = {
|
295 | ...init,
|
296 | method: 'POST',
|
297 | };
|
298 | super(finalInit, options);
|
299 |
|
300 | this.endpoint = '/api/v4.0/profile/photos/profile';
|
301 | }
|
302 |
|
303 | handleResponseStatus(response: Response, parsedBody: PostApiProfilePhotosProfileResponseBody): ({
|
304 | response: Response,
|
305 | body: ?PostApiProfilePhotosProfileResponseBody,
|
306 | status: RequestStatus,
|
307 | }) {
|
308 | const body = (parsedBody && typeof parsedBody === 'object') ? parsedBody : null;
|
309 | let status = 'MISTAKE';
|
310 |
|
311 | switch (response.status) {
|
312 |
|
313 | case 200:
|
314 | status = 'SUCCESS';
|
315 |
|
316 | if (process.env.DEV_TOOLS) {
|
317 | const TrovCommonModelProfileProfileValidation = Validators.TrovCommonModelProfileProfile.validate(parsedBody);
|
318 | if (TrovCommonModelProfileProfileValidation.hasErrors()) {
|
319 | console.error(JSON.stringify(t.makeJSONError(TrovCommonModelProfileProfileValidation), null, 2));
|
320 | }
|
321 | }
|
322 | break;
|
323 |
|
324 |
|
325 | case 400:
|
326 | status = 'FAILURE';
|
327 |
|
328 | if (process.env.DEV_TOOLS && parsedBody && typeof parsedBody === 'object' && parsedBody.ExceptionType) {
|
329 | switch (parsedBody.ExceptionType) {
|
330 | case 'ArgumentException':
|
331 |
|
332 | if (process.env.DEV_TOOLS) {
|
333 | Validators.ArgumentException.assert(parsedBody);
|
334 | }
|
335 | break;
|
336 |
|
337 | case 'UnsupportedImageException':
|
338 |
|
339 | if (process.env.DEV_TOOLS) {
|
340 | Validators.UnsupportedImageException.assert(parsedBody);
|
341 | }
|
342 | break;
|
343 |
|
344 | default:
|
345 | console.warn(`${this.constructor.name} has no case for a "${response.status}" status and a differentiating key "ExceptionType" of ${JSON.stringify(parsedBody.ExceptionType)}.`);
|
346 | break;
|
347 | }
|
348 | }
|
349 |
|
350 | break;
|
351 |
|
352 | case 404:
|
353 | status = 'FAILURE';
|
354 |
|
355 |
|
356 | if (process.env.DEV_TOOLS) {
|
357 | const DocumentAccessExceptionValidation = Validators.DocumentAccessException.validate(parsedBody);
|
358 | if (DocumentAccessExceptionValidation.hasErrors()) {
|
359 | console.error(JSON.stringify(t.makeJSONError(DocumentAccessExceptionValidation), null, 2));
|
360 | }
|
361 | }
|
362 | break;
|
363 |
|
364 |
|
365 | case 500:
|
366 | status = 'FAILURE';
|
367 |
|
368 | if (process.env.DEV_TOOLS) {
|
369 | const UnexpectedErrorExceptionValidation = Validators.UnexpectedErrorException.validate(parsedBody);
|
370 | if (UnexpectedErrorExceptionValidation.hasErrors()) {
|
371 | console.error(JSON.stringify(t.makeJSONError(UnexpectedErrorExceptionValidation), null, 2));
|
372 | }
|
373 | }
|
374 | break;
|
375 |
|
376 |
|
377 | default:
|
378 | return super.handleResponseStatus(response, parsedBody, true);
|
379 | }
|
380 |
|
381 | return { response, body, status };
|
382 | }
|
383 | }
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 | export type postApiProfilePhotosBackgroundHeader = {|
|
402 | 'Trov-Tenant': string,
|
403 | 'Trov-Market': string,
|
404 | 'Trov-Client': string,
|
405 | 'Accept-Language': string,
|
406 | Authorization: string
|
407 | |};
|
408 |
|
409 | export type PostApiProfilePhotosBackgroundResponseBody =
|
410 | | TrovCommonModelProfileProfile
|
411 | | ArgumentException
|
412 | | UnsupportedImageException
|
413 | | DocumentAccessException
|
414 | | UnexpectedErrorException;
|
415 |
|
416 | export type PostApiProfilePhotosBackgroundInit = {
|
417 | header: postApiProfilePhotosBackgroundHeader,
|
418 | } & RequestOptions;
|
419 |
|
420 | export type PostApiProfilePhotosBackgroundOptions = SwaggerFetchPathOptions;
|
421 |
|
422 | export class PostApiProfilePhotosBackground extends SwaggerFetch {
|
423 | constructor(init: PostApiProfilePhotosBackgroundInit, options: PostApiProfilePhotosBackgroundOptions) {
|
424 | const finalInit = {
|
425 | ...init,
|
426 | method: 'POST',
|
427 | };
|
428 | super(finalInit, options);
|
429 |
|
430 | this.endpoint = '/api/v4.0/profile/photos/background';
|
431 | }
|
432 |
|
433 | handleResponseStatus(response: Response, parsedBody: PostApiProfilePhotosBackgroundResponseBody): ({
|
434 | response: Response,
|
435 | body: ?PostApiProfilePhotosBackgroundResponseBody,
|
436 | status: RequestStatus,
|
437 | }) {
|
438 | const body = (parsedBody && typeof parsedBody === 'object') ? parsedBody : null;
|
439 | let status = 'MISTAKE';
|
440 |
|
441 | switch (response.status) {
|
442 |
|
443 | case 200:
|
444 | status = 'SUCCESS';
|
445 |
|
446 | if (process.env.DEV_TOOLS) {
|
447 | const TrovCommonModelProfileProfileValidation = Validators.TrovCommonModelProfileProfile.validate(parsedBody);
|
448 | if (TrovCommonModelProfileProfileValidation.hasErrors()) {
|
449 | console.error(JSON.stringify(t.makeJSONError(TrovCommonModelProfileProfileValidation), null, 2));
|
450 | }
|
451 | }
|
452 | break;
|
453 |
|
454 |
|
455 | case 400:
|
456 | status = 'FAILURE';
|
457 |
|
458 | if (process.env.DEV_TOOLS && parsedBody && typeof parsedBody === 'object' && parsedBody.ExceptionType) {
|
459 | switch (parsedBody.ExceptionType) {
|
460 | case 'ArgumentException':
|
461 |
|
462 | if (process.env.DEV_TOOLS) {
|
463 | Validators.ArgumentException.assert(parsedBody);
|
464 | }
|
465 | break;
|
466 |
|
467 | case 'UnsupportedImageException':
|
468 |
|
469 | if (process.env.DEV_TOOLS) {
|
470 | Validators.UnsupportedImageException.assert(parsedBody);
|
471 | }
|
472 | break;
|
473 |
|
474 | default:
|
475 | console.warn(`${this.constructor.name} has no case for a "${response.status}" status and a differentiating key "ExceptionType" of ${JSON.stringify(parsedBody.ExceptionType)}.`);
|
476 | break;
|
477 | }
|
478 | }
|
479 |
|
480 | break;
|
481 |
|
482 | case 404:
|
483 | status = 'FAILURE';
|
484 |
|
485 |
|
486 | if (process.env.DEV_TOOLS) {
|
487 | const DocumentAccessExceptionValidation = Validators.DocumentAccessException.validate(parsedBody);
|
488 | if (DocumentAccessExceptionValidation.hasErrors()) {
|
489 | console.error(JSON.stringify(t.makeJSONError(DocumentAccessExceptionValidation), null, 2));
|
490 | }
|
491 | }
|
492 | break;
|
493 |
|
494 |
|
495 | case 500:
|
496 | status = 'FAILURE';
|
497 |
|
498 | if (process.env.DEV_TOOLS) {
|
499 | const UnexpectedErrorExceptionValidation = Validators.UnexpectedErrorException.validate(parsedBody);
|
500 | if (UnexpectedErrorExceptionValidation.hasErrors()) {
|
501 | console.error(JSON.stringify(t.makeJSONError(UnexpectedErrorExceptionValidation), null, 2));
|
502 | }
|
503 | }
|
504 | break;
|
505 |
|
506 |
|
507 | default:
|
508 | return super.handleResponseStatus(response, parsedBody, true);
|
509 | }
|
510 |
|
511 | return { response, body, status };
|
512 | }
|
513 | }
|
514 |
|