/
BasicApi.ts
496 lines (404 loc) · 24 KB
/
BasicApi.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpInfo} from '../http/http';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import { isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { CollectionResponseSimplePublicObjectWithAssociationsForwardPaging } from '../models/CollectionResponseSimplePublicObjectWithAssociationsForwardPaging';
import { SimplePublicObject } from '../models/SimplePublicObject';
import { SimplePublicObjectInput } from '../models/SimplePublicObjectInput';
import { SimplePublicObjectInputForCreate } from '../models/SimplePublicObjectInputForCreate';
import { SimplePublicObjectWithAssociations } from '../models/SimplePublicObjectWithAssociations';
/**
* no description
*/
export class BasicApiRequestFactory extends BaseAPIRequestFactory {
/**
* Move an Object identified by `{contactId}` to the recycling bin.
* Archive
* @param contactId
*/
public async archive(contactId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'contactId' is not null or undefined
if (contactId === null || contactId === undefined) {
throw new RequiredError("BasicApi", "archive", "contactId");
}
// Path Params
const localVarPath = '/crm/v3/objects/contacts/{contactId}'
.replace('{' + 'contactId' + '}', encodeURIComponent(String(contactId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["oauth2"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Create a contact with the given properties and return a copy of the object, including the ID. Documentation and examples for creating standard contacts is provided.
* Create
* @param simplePublicObjectInputForCreate
*/
public async create(simplePublicObjectInputForCreate: SimplePublicObjectInputForCreate, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'simplePublicObjectInputForCreate' is not null or undefined
if (simplePublicObjectInputForCreate === null || simplePublicObjectInputForCreate === undefined) {
throw new RequiredError("BasicApi", "create", "simplePublicObjectInputForCreate");
}
// Path Params
const localVarPath = '/crm/v3/objects/contacts';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(simplePublicObjectInputForCreate, "SimplePublicObjectInputForCreate", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["oauth2"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Read an Object identified by `{contactId}`. `{contactId}` refers to the internal object ID. Control what is returned via the `properties` query param.
* Read
* @param contactId
* @param properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.
* @param propertiesWithHistory A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored.
* @param associations A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.
* @param archived Whether to return only results that have been archived.
* @param idProperty The name of a property whose values are unique for this object type
*/
public async getById(contactId: string, properties?: Array<string>, propertiesWithHistory?: Array<string>, associations?: Array<string>, archived?: boolean, idProperty?: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'contactId' is not null or undefined
if (contactId === null || contactId === undefined) {
throw new RequiredError("BasicApi", "getById", "contactId");
}
// Path Params
const localVarPath = '/crm/v3/objects/contacts/{contactId}'
.replace('{' + 'contactId' + '}', encodeURIComponent(String(contactId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (properties !== undefined) {
requestContext.setQueryParam("properties", ObjectSerializer.serialize(properties, "Array<string>", ""));
}
// Query Params
if (propertiesWithHistory !== undefined) {
requestContext.setQueryParam("propertiesWithHistory", ObjectSerializer.serialize(propertiesWithHistory, "Array<string>", ""));
}
// Query Params
if (associations !== undefined) {
requestContext.setQueryParam("associations", ObjectSerializer.serialize(associations, "Array<string>", ""));
}
// Query Params
if (archived !== undefined) {
requestContext.setQueryParam("archived", ObjectSerializer.serialize(archived, "boolean", ""));
}
// Query Params
if (idProperty !== undefined) {
requestContext.setQueryParam("idProperty", ObjectSerializer.serialize(idProperty, "string", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["oauth2"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Read a page of contacts. Control what is returned via the `properties` query param.
* List
* @param limit The maximum number of results to display per page.
* @param after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results.
* @param properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.
* @param propertiesWithHistory A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. Usage of this parameter will reduce the maximum number of objects that can be read by a single request.
* @param associations A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.
* @param archived Whether to return only results that have been archived.
*/
public async getPage(limit?: number, after?: string, properties?: Array<string>, propertiesWithHistory?: Array<string>, associations?: Array<string>, archived?: boolean, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/crm/v3/objects/contacts';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (limit !== undefined) {
requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", "int32"));
}
// Query Params
if (after !== undefined) {
requestContext.setQueryParam("after", ObjectSerializer.serialize(after, "string", ""));
}
// Query Params
if (properties !== undefined) {
requestContext.setQueryParam("properties", ObjectSerializer.serialize(properties, "Array<string>", ""));
}
// Query Params
if (propertiesWithHistory !== undefined) {
requestContext.setQueryParam("propertiesWithHistory", ObjectSerializer.serialize(propertiesWithHistory, "Array<string>", ""));
}
// Query Params
if (associations !== undefined) {
requestContext.setQueryParam("associations", ObjectSerializer.serialize(associations, "Array<string>", ""));
}
// Query Params
if (archived !== undefined) {
requestContext.setQueryParam("archived", ObjectSerializer.serialize(archived, "boolean", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["oauth2"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Perform a partial update of an Object identified by `{contactId}`. `{contactId}` refers to the internal object ID. Provided property values will be overwritten. Read-only and non-existent properties will be ignored. Properties values can be cleared by passing an empty string.
* Update
* @param contactId
* @param simplePublicObjectInput
* @param idProperty The name of a property whose values are unique for this object type
*/
public async update(contactId: string, simplePublicObjectInput: SimplePublicObjectInput, idProperty?: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'contactId' is not null or undefined
if (contactId === null || contactId === undefined) {
throw new RequiredError("BasicApi", "update", "contactId");
}
// verify required parameter 'simplePublicObjectInput' is not null or undefined
if (simplePublicObjectInput === null || simplePublicObjectInput === undefined) {
throw new RequiredError("BasicApi", "update", "simplePublicObjectInput");
}
// Path Params
const localVarPath = '/crm/v3/objects/contacts/{contactId}'
.replace('{' + 'contactId' + '}', encodeURIComponent(String(contactId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (idProperty !== undefined) {
requestContext.setQueryParam("idProperty", ObjectSerializer.serialize(idProperty, "string", ""));
}
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(simplePublicObjectInput, "SimplePublicObjectInput", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["oauth2"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
}
export class BasicApiResponseProcessor {
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to archive
* @throws ApiException if the response code was not in [200, 299]
*/
public async archiveWithHttpInfo(response: ResponseContext): Promise<HttpInfo<void >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("204", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
if (isCodeInRange("0", response.httpStatusCode)) {
const body: Error = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Error", ""
) as Error;
throw new ApiException<Error>(response.httpStatusCode, "An error occurred.", body, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to create
* @throws ApiException if the response code was not in [200, 299]
*/
public async createWithHttpInfo(response: ResponseContext): Promise<HttpInfo<SimplePublicObject >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("201", response.httpStatusCode)) {
const body: SimplePublicObject = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"SimplePublicObject", ""
) as SimplePublicObject;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
if (isCodeInRange("0", response.httpStatusCode)) {
const body: Error = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Error", ""
) as Error;
throw new ApiException<Error>(response.httpStatusCode, "An error occurred.", body, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: SimplePublicObject = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"SimplePublicObject", ""
) as SimplePublicObject;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to getById
* @throws ApiException if the response code was not in [200, 299]
*/
public async getByIdWithHttpInfo(response: ResponseContext): Promise<HttpInfo<SimplePublicObjectWithAssociations >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: SimplePublicObjectWithAssociations = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"SimplePublicObjectWithAssociations", ""
) as SimplePublicObjectWithAssociations;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
if (isCodeInRange("0", response.httpStatusCode)) {
const body: Error = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Error", ""
) as Error;
throw new ApiException<Error>(response.httpStatusCode, "An error occurred.", body, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: SimplePublicObjectWithAssociations = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"SimplePublicObjectWithAssociations", ""
) as SimplePublicObjectWithAssociations;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to getPage
* @throws ApiException if the response code was not in [200, 299]
*/
public async getPageWithHttpInfo(response: ResponseContext): Promise<HttpInfo<CollectionResponseSimplePublicObjectWithAssociationsForwardPaging >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CollectionResponseSimplePublicObjectWithAssociationsForwardPaging", ""
) as CollectionResponseSimplePublicObjectWithAssociationsForwardPaging;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
if (isCodeInRange("0", response.httpStatusCode)) {
const body: Error = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Error", ""
) as Error;
throw new ApiException<Error>(response.httpStatusCode, "An error occurred.", body, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CollectionResponseSimplePublicObjectWithAssociationsForwardPaging", ""
) as CollectionResponseSimplePublicObjectWithAssociationsForwardPaging;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to update
* @throws ApiException if the response code was not in [200, 299]
*/
public async updateWithHttpInfo(response: ResponseContext): Promise<HttpInfo<SimplePublicObject >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: SimplePublicObject = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"SimplePublicObject", ""
) as SimplePublicObject;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
if (isCodeInRange("0", response.httpStatusCode)) {
const body: Error = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Error", ""
) as Error;
throw new ApiException<Error>(response.httpStatusCode, "An error occurred.", body, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: SimplePublicObject = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"SimplePublicObject", ""
) as SimplePublicObject;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}