-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathdeal-installments-api.ts
More file actions
527 lines (455 loc) · 24.9 KB
/
Copy pathdeal-installments-api.ts
File metadata and controls
527 lines (455 loc) · 24.9 KB
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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
/* tslint:disable */
/* eslint-disable */
/**
* Pipedrive API v2
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { AddAInstallmentResponse } from '../models';
// @ts-ignore
import { AddInstallmentRequestBody } from '../models';
// @ts-ignore
import { DeleteInstallmentResponse } from '../models';
// @ts-ignore
import { GetInstallmentsResponse } from '../models';
// @ts-ignore
import { UpdateInstallmentRequestBody } from '../models';
// @ts-ignore
import { UpdateInstallmentResponse } from '../models';
/**
* DealInstallmentsApi - axios parameter creator
* @export
*/
export const DealInstallmentsApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* Removes an installment from a deal. Only available in Growth and above plans.
* @summary Delete an installment from a deal
* @param {number} id The ID of the deal
* @param {number} installment_id The ID of the installment
* @throws {RequiredError}
*/
deleteInstallment: async (id: number, installment_id: number, ): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('deleteInstallment', 'id', id)
// verify required parameter 'installment_id' is not null or undefined
assertParamExists('deleteInstallment', 'installment_id', installment_id)
const localVarPath = `/deals/{id}/installments/{installment_id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)))
.replace(`{${"installment_id"}}`, encodeURIComponent(String(installment_id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'DELETE', ...baseOptions };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication api_key required
await setApiKeyToObject(localVarHeaderParameter, "x-api-token", configuration)
// authentication oauth2 required
// oauth required
await setOAuthToObject(localVarHeaderParameter, "oauth2", ["deals:full"], configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Lists installments attached to a list of deals. Only available in Growth and above plans.
* @summary List installments added to a list of deals
* @param {Array<number>} deal_ids An array of integers with the IDs of the deals for which the attached installments will be returned. A maximum of 100 deal IDs can be provided.
* @param {string} [cursor] For pagination, the marker (an opaque string value) representing the first item on the next page
* @param {number} [limit] For pagination, the limit of entries to be returned. If not provided, 100 items will be returned. Please note that a maximum value of 500 is allowed.
* @param {'id' | 'billing_date' | 'deal_id'} [sort_by] The field to sort by. Supported fields: `id`, `billing_date`, `deal_id`.
* @param {'asc' | 'desc'} [sort_direction] The sorting direction. Supported values: `asc`, `desc`.
* @throws {RequiredError}
*/
getInstallments: async (deal_ids: Array<number>, cursor?: string, limit?: number, sort_by?: 'id' | 'billing_date' | 'deal_id', sort_direction?: 'asc' | 'desc', ): Promise<RequestArgs> => {
// verify required parameter 'deal_ids' is not null or undefined
assertParamExists('getInstallments', 'deal_ids', deal_ids)
const localVarPath = `/deals/installments`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication api_key required
await setApiKeyToObject(localVarHeaderParameter, "x-api-token", configuration)
// authentication oauth2 required
// oauth required
await setOAuthToObject(localVarHeaderParameter, "oauth2", ["deals:read", "deals:full"], configuration)
if (deal_ids) {
localVarQueryParameter['deal_ids'] = deal_ids;
}
if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (sort_by !== undefined) {
localVarQueryParameter['sort_by'] = sort_by;
}
if (sort_direction !== undefined) {
localVarQueryParameter['sort_direction'] = sort_direction;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Adds an installment to a deal. An installment can only be added if the deal includes at least one one-time product. If the deal contains at least one recurring product, adding installments is not allowed. Only available in Growth and above plans.
* @summary Add an installment to a deal
* @param {number} id The ID of the deal
* @param {AddInstallmentRequestBody} [AddInstallmentRequestBody]
* @throws {RequiredError}
*/
postInstallment: async (id: number, AddInstallmentRequestBody?: AddInstallmentRequestBody, ): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('postInstallment', 'id', id)
const localVarPath = `/deals/{id}/installments`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication api_key required
await setApiKeyToObject(localVarHeaderParameter, "x-api-token", configuration)
// authentication oauth2 required
// oauth required
await setOAuthToObject(localVarHeaderParameter, "oauth2", ["deals:full"], configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, };
localVarRequestOptions.data = serializeDataIfNeeded(AddInstallmentRequestBody, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Edits an installment added to a deal. Only available in Growth and above plans.
* @summary Update an installment added to a deal
* @param {number} id The ID of the deal
* @param {number} installment_id The ID of the installment
* @param {UpdateInstallmentRequestBody} [UpdateInstallmentRequestBody]
* @throws {RequiredError}
*/
updateInstallment: async (id: number, installment_id: number, UpdateInstallmentRequestBody?: UpdateInstallmentRequestBody, ): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('updateInstallment', 'id', id)
// verify required parameter 'installment_id' is not null or undefined
assertParamExists('updateInstallment', 'installment_id', installment_id)
const localVarPath = `/deals/{id}/installments/{installment_id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)))
.replace(`{${"installment_id"}}`, encodeURIComponent(String(installment_id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'PATCH', ...baseOptions };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication api_key required
await setApiKeyToObject(localVarHeaderParameter, "x-api-token", configuration)
// authentication oauth2 required
// oauth required
await setOAuthToObject(localVarHeaderParameter, "oauth2", ["deals:full"], configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, };
localVarRequestOptions.data = serializeDataIfNeeded(UpdateInstallmentRequestBody, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* DealInstallmentsApi - functional programming interface
* @export
*/
export const DealInstallmentsApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = DealInstallmentsApiAxiosParamCreator(configuration)
return {
/**
* Removes an installment from a deal. Only available in Growth and above plans.
* @summary Delete an installment from a deal
* @param {number} id The ID of the deal
* @param {number} installment_id The ID of the installment
* @throws {RequiredError}
*/
async deleteInstallment(id: number, installment_id: number, ): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<DeleteInstallmentResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.deleteInstallment(id, installment_id, );
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Lists installments attached to a list of deals. Only available in Growth and above plans.
* @summary List installments added to a list of deals
* @param {Array<number>} deal_ids An array of integers with the IDs of the deals for which the attached installments will be returned. A maximum of 100 deal IDs can be provided.
* @param {string} [cursor] For pagination, the marker (an opaque string value) representing the first item on the next page
* @param {number} [limit] For pagination, the limit of entries to be returned. If not provided, 100 items will be returned. Please note that a maximum value of 500 is allowed.
* @param {'id' | 'billing_date' | 'deal_id'} [sort_by] The field to sort by. Supported fields: `id`, `billing_date`, `deal_id`.
* @param {'asc' | 'desc'} [sort_direction] The sorting direction. Supported values: `asc`, `desc`.
* @throws {RequiredError}
*/
async getInstallments(deal_ids: Array<number>, cursor?: string, limit?: number, sort_by?: 'id' | 'billing_date' | 'deal_id', sort_direction?: 'asc' | 'desc', ): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<GetInstallmentsResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getInstallments(deal_ids, cursor, limit, sort_by, sort_direction, );
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Adds an installment to a deal. An installment can only be added if the deal includes at least one one-time product. If the deal contains at least one recurring product, adding installments is not allowed. Only available in Growth and above plans.
* @summary Add an installment to a deal
* @param {number} id The ID of the deal
* @param {AddInstallmentRequestBody} [AddInstallmentRequestBody]
* @throws {RequiredError}
*/
async postInstallment(id: number, AddInstallmentRequestBody?: AddInstallmentRequestBody, ): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AddAInstallmentResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.postInstallment(id, AddInstallmentRequestBody, );
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Edits an installment added to a deal. Only available in Growth and above plans.
* @summary Update an installment added to a deal
* @param {number} id The ID of the deal
* @param {number} installment_id The ID of the installment
* @param {UpdateInstallmentRequestBody} [UpdateInstallmentRequestBody]
* @throws {RequiredError}
*/
async updateInstallment(id: number, installment_id: number, UpdateInstallmentRequestBody?: UpdateInstallmentRequestBody, ): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<UpdateInstallmentResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateInstallment(id, installment_id, UpdateInstallmentRequestBody, );
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
};
/**
* DealInstallmentsApi - factory interface
* @export
*/
export const DealInstallmentsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = DealInstallmentsApiFp(configuration)
return {
/**
* Removes an installment from a deal. Only available in Growth and above plans.
* @summary Delete an installment from a deal
* @param {DealInstallmentsApiDeleteInstallmentRequest} requestParameters Request parameters.
* @throws {RequiredError}
*/
deleteInstallment(requestParameters: DealInstallmentsApiDeleteInstallmentRequest, ): Promise<DeleteInstallmentResponse> {
return localVarFp.deleteInstallment(requestParameters.id, requestParameters.installment_id, ).then((request) => request(axios, basePath));
},
/**
* Lists installments attached to a list of deals. Only available in Growth and above plans.
* @summary List installments added to a list of deals
* @param {DealInstallmentsApiGetInstallmentsRequest} requestParameters Request parameters.
* @throws {RequiredError}
*/
getInstallments(requestParameters: DealInstallmentsApiGetInstallmentsRequest, ): Promise<GetInstallmentsResponse> {
return localVarFp.getInstallments(requestParameters.deal_ids, requestParameters.cursor, requestParameters.limit, requestParameters.sort_by, requestParameters.sort_direction, ).then((request) => request(axios, basePath));
},
/**
* Adds an installment to a deal. An installment can only be added if the deal includes at least one one-time product. If the deal contains at least one recurring product, adding installments is not allowed. Only available in Growth and above plans.
* @summary Add an installment to a deal
* @param {DealInstallmentsApiPostInstallmentRequest} requestParameters Request parameters.
* @throws {RequiredError}
*/
postInstallment(requestParameters: DealInstallmentsApiPostInstallmentRequest, ): Promise<AddAInstallmentResponse> {
return localVarFp.postInstallment(requestParameters.id, requestParameters.AddInstallmentRequestBody, ).then((request) => request(axios, basePath));
},
/**
* Edits an installment added to a deal. Only available in Growth and above plans.
* @summary Update an installment added to a deal
* @param {DealInstallmentsApiUpdateInstallmentRequest} requestParameters Request parameters.
* @throws {RequiredError}
*/
updateInstallment(requestParameters: DealInstallmentsApiUpdateInstallmentRequest, ): Promise<UpdateInstallmentResponse> {
return localVarFp.updateInstallment(requestParameters.id, requestParameters.installment_id, requestParameters.UpdateInstallmentRequestBody, ).then((request) => request(axios, basePath));
},
};
};
/**
* Request parameters for deleteInstallment operation in DealInstallmentsApi.
* @export
* @interface DealInstallmentsApiDeleteInstallmentRequest
*/
export interface DealInstallmentsApiDeleteInstallmentRequest {
/**
* The ID of the deal
* @type {number}
* @memberof DealInstallmentsApiDeleteInstallment
*/
readonly id: number
/**
* The ID of the installment
* @type {number}
* @memberof DealInstallmentsApiDeleteInstallment
*/
readonly installment_id: number
}
/**
* Request parameters for getInstallments operation in DealInstallmentsApi.
* @export
* @interface DealInstallmentsApiGetInstallmentsRequest
*/
export interface DealInstallmentsApiGetInstallmentsRequest {
/**
* An array of integers with the IDs of the deals for which the attached installments will be returned. A maximum of 100 deal IDs can be provided.
* @type {Array<number>}
* @memberof DealInstallmentsApiGetInstallments
*/
readonly deal_ids: Array<number>
/**
* For pagination, the marker (an opaque string value) representing the first item on the next page
* @type {string}
* @memberof DealInstallmentsApiGetInstallments
*/
readonly cursor?: string
/**
* For pagination, the limit of entries to be returned. If not provided, 100 items will be returned. Please note that a maximum value of 500 is allowed.
* @type {number}
* @memberof DealInstallmentsApiGetInstallments
*/
readonly limit?: number
/**
* The field to sort by. Supported fields: `id`, `billing_date`, `deal_id`.
* @type {'id' | 'billing_date' | 'deal_id'}
* @memberof DealInstallmentsApiGetInstallments
*/
readonly sort_by?: 'id' | 'billing_date' | 'deal_id'
/**
* The sorting direction. Supported values: `asc`, `desc`.
* @type {'asc' | 'desc'}
* @memberof DealInstallmentsApiGetInstallments
*/
readonly sort_direction?: 'asc' | 'desc'
}
/**
* Request parameters for postInstallment operation in DealInstallmentsApi.
* @export
* @interface DealInstallmentsApiPostInstallmentRequest
*/
export interface DealInstallmentsApiPostInstallmentRequest {
/**
* The ID of the deal
* @type {number}
* @memberof DealInstallmentsApiPostInstallment
*/
readonly id: number
/**
*
* @type {AddInstallmentRequestBody}
* @memberof DealInstallmentsApiPostInstallment
*/
readonly AddInstallmentRequestBody?: AddInstallmentRequestBody
}
/**
* Request parameters for updateInstallment operation in DealInstallmentsApi.
* @export
* @interface DealInstallmentsApiUpdateInstallmentRequest
*/
export interface DealInstallmentsApiUpdateInstallmentRequest {
/**
* The ID of the deal
* @type {number}
* @memberof DealInstallmentsApiUpdateInstallment
*/
readonly id: number
/**
* The ID of the installment
* @type {number}
* @memberof DealInstallmentsApiUpdateInstallment
*/
readonly installment_id: number
/**
*
* @type {UpdateInstallmentRequestBody}
* @memberof DealInstallmentsApiUpdateInstallment
*/
readonly UpdateInstallmentRequestBody?: UpdateInstallmentRequestBody
}
/**
* DealInstallmentsApi - object-oriented interface
* @export
* @class DealInstallmentsApi
* @extends {BaseAPI}
*/
export class DealInstallmentsApi extends BaseAPI {
/**
* Removes an installment from a deal. Only available in Growth and above plans.
* @summary Delete an installment from a deal
* @param {DealInstallmentsApiDeleteInstallmentRequest} requestParameters Request parameters.
* @throws {RequiredError}
* @memberof DealInstallmentsApi
*/
public deleteInstallment(requestParameters: DealInstallmentsApiDeleteInstallmentRequest, ) {
return DealInstallmentsApiFp(this.configuration).deleteInstallment(requestParameters.id, requestParameters.installment_id, ).then((request) => request(this.axios, this.basePath));
}
/**
* Lists installments attached to a list of deals. Only available in Growth and above plans.
* @summary List installments added to a list of deals
* @param {DealInstallmentsApiGetInstallmentsRequest} requestParameters Request parameters.
* @throws {RequiredError}
* @memberof DealInstallmentsApi
*/
public getInstallments(requestParameters: DealInstallmentsApiGetInstallmentsRequest, ) {
return DealInstallmentsApiFp(this.configuration).getInstallments(requestParameters.deal_ids, requestParameters.cursor, requestParameters.limit, requestParameters.sort_by, requestParameters.sort_direction, ).then((request) => request(this.axios, this.basePath));
}
/**
* Adds an installment to a deal. An installment can only be added if the deal includes at least one one-time product. If the deal contains at least one recurring product, adding installments is not allowed. Only available in Growth and above plans.
* @summary Add an installment to a deal
* @param {DealInstallmentsApiPostInstallmentRequest} requestParameters Request parameters.
* @throws {RequiredError}
* @memberof DealInstallmentsApi
*/
public postInstallment(requestParameters: DealInstallmentsApiPostInstallmentRequest, ) {
return DealInstallmentsApiFp(this.configuration).postInstallment(requestParameters.id, requestParameters.AddInstallmentRequestBody, ).then((request) => request(this.axios, this.basePath));
}
/**
* Edits an installment added to a deal. Only available in Growth and above plans.
* @summary Update an installment added to a deal
* @param {DealInstallmentsApiUpdateInstallmentRequest} requestParameters Request parameters.
* @throws {RequiredError}
* @memberof DealInstallmentsApi
*/
public updateInstallment(requestParameters: DealInstallmentsApiUpdateInstallmentRequest, ) {
return DealInstallmentsApiFp(this.configuration).updateInstallment(requestParameters.id, requestParameters.installment_id, requestParameters.UpdateInstallmentRequestBody, ).then((request) => request(this.axios, this.basePath));
}
}