kommo-aiatende-api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2695 -0
- package/dist/index.d.ts +2695 -0
- package/dist/index.js +1476 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1413 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2695 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
interface KommoConfig {
|
|
4
|
+
domain: string;
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
refreshToken?: string;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
clientSecret?: string;
|
|
9
|
+
redirectUri?: string;
|
|
10
|
+
}
|
|
11
|
+
interface AccessTokenResponse {
|
|
12
|
+
token_type: string;
|
|
13
|
+
expires_in: number;
|
|
14
|
+
access_token: string;
|
|
15
|
+
refresh_token: string;
|
|
16
|
+
}
|
|
17
|
+
interface Embedded<T> {
|
|
18
|
+
_embedded: T;
|
|
19
|
+
}
|
|
20
|
+
interface CollectionResponse<K extends string, T> {
|
|
21
|
+
_page?: number;
|
|
22
|
+
_links?: {
|
|
23
|
+
self: {
|
|
24
|
+
href: string;
|
|
25
|
+
};
|
|
26
|
+
next?: {
|
|
27
|
+
href: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
_embedded: Record<K, T[]>;
|
|
31
|
+
}
|
|
32
|
+
interface CustomFieldValue {
|
|
33
|
+
value: string | number | boolean;
|
|
34
|
+
enum_id?: number;
|
|
35
|
+
enum_code?: string;
|
|
36
|
+
}
|
|
37
|
+
interface CustomField {
|
|
38
|
+
field_id: number;
|
|
39
|
+
field_name?: string;
|
|
40
|
+
field_code?: string;
|
|
41
|
+
field_type?: string;
|
|
42
|
+
values: CustomFieldValue[];
|
|
43
|
+
}
|
|
44
|
+
interface BaseEntity {
|
|
45
|
+
id: number;
|
|
46
|
+
name: string;
|
|
47
|
+
responsible_user_id?: number;
|
|
48
|
+
group_id?: number;
|
|
49
|
+
created_by?: number;
|
|
50
|
+
updated_by?: number;
|
|
51
|
+
created_at?: number;
|
|
52
|
+
updated_at?: number;
|
|
53
|
+
is_deleted?: boolean;
|
|
54
|
+
custom_fields_values?: CustomField[];
|
|
55
|
+
account_id?: number;
|
|
56
|
+
_links?: {
|
|
57
|
+
self: {
|
|
58
|
+
href: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare class AuthManager {
|
|
64
|
+
private domain;
|
|
65
|
+
private clientId?;
|
|
66
|
+
private clientSecret?;
|
|
67
|
+
private redirectUri?;
|
|
68
|
+
constructor(domain: string, clientId?: string, clientSecret?: string, redirectUri?: string);
|
|
69
|
+
exchangeCodeForToken(code: string): Promise<AccessTokenResponse>;
|
|
70
|
+
refreshToken(refreshToken: string): Promise<AccessTokenResponse>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare abstract class BaseResource {
|
|
74
|
+
protected client: AxiosInstance;
|
|
75
|
+
constructor(client: AxiosInstance);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface Lead {
|
|
79
|
+
id: number;
|
|
80
|
+
name?: string | null;
|
|
81
|
+
price?: number | null;
|
|
82
|
+
responsible_user_id?: number | null;
|
|
83
|
+
group_id?: number | null;
|
|
84
|
+
status_id?: number | null;
|
|
85
|
+
pipeline_id?: number | null;
|
|
86
|
+
loss_reason_id?: number | null;
|
|
87
|
+
created_by?: number | null;
|
|
88
|
+
updated_by?: number | null;
|
|
89
|
+
created_at?: number | null;
|
|
90
|
+
updated_at?: number | null;
|
|
91
|
+
closed_at?: number | null;
|
|
92
|
+
closest_task_at?: number | null;
|
|
93
|
+
is_deleted?: boolean;
|
|
94
|
+
custom_fields_values?: unknown[] | null;
|
|
95
|
+
score?: number | null;
|
|
96
|
+
account_id?: number | null;
|
|
97
|
+
labor_cost?: number | null;
|
|
98
|
+
source_id?: number | null;
|
|
99
|
+
is_price_modified_by_robot?: boolean;
|
|
100
|
+
is_price_computed?: boolean;
|
|
101
|
+
_links?: {
|
|
102
|
+
self?: {
|
|
103
|
+
href: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
_embedded?: {
|
|
107
|
+
tags?: LeadTag[];
|
|
108
|
+
contacts?: LeadContactRef[];
|
|
109
|
+
companies?: LeadCompanyRef[];
|
|
110
|
+
catalog_elements?: LeadCatalogElementRef[];
|
|
111
|
+
loss_reason?: LossReason[] | LossReason;
|
|
112
|
+
source?: {
|
|
113
|
+
id?: number;
|
|
114
|
+
name?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface LeadTag {
|
|
119
|
+
id?: number;
|
|
120
|
+
name?: string;
|
|
121
|
+
color?: string | null;
|
|
122
|
+
}
|
|
123
|
+
interface LeadContactRef {
|
|
124
|
+
id: number;
|
|
125
|
+
is_main?: boolean;
|
|
126
|
+
_links?: {
|
|
127
|
+
self?: {
|
|
128
|
+
href: string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
interface LeadCompanyRef {
|
|
133
|
+
id: number;
|
|
134
|
+
_links?: {
|
|
135
|
+
self?: {
|
|
136
|
+
href: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
interface LeadCatalogElementRef {
|
|
141
|
+
id: number;
|
|
142
|
+
metadata?: Record<string, unknown>;
|
|
143
|
+
quantity?: number;
|
|
144
|
+
catalog_id?: number;
|
|
145
|
+
}
|
|
146
|
+
type LeadWithParam = 'contacts' | 'only_deleted' | 'loss_reason' | 'is_price_modified_by_robot' | 'catalog_elements' | 'source_id' | 'source';
|
|
147
|
+
interface ListLeadsParams {
|
|
148
|
+
with?: LeadWithParam[] | string;
|
|
149
|
+
page?: number;
|
|
150
|
+
limit?: number;
|
|
151
|
+
query?: string;
|
|
152
|
+
order_created_at?: 'asc' | 'desc';
|
|
153
|
+
order_updated_at?: 'asc' | 'desc';
|
|
154
|
+
order_id?: 'asc' | 'desc';
|
|
155
|
+
filter_id?: number[];
|
|
156
|
+
filter_name?: string[];
|
|
157
|
+
filter_price?: number;
|
|
158
|
+
filter_created_by?: number[];
|
|
159
|
+
filter_updated_by?: number[];
|
|
160
|
+
filter_responsible_user_id?: number[];
|
|
161
|
+
filter_created_at_from?: number;
|
|
162
|
+
filter_created_at_to?: number;
|
|
163
|
+
filter_updated_at_from?: number;
|
|
164
|
+
filter_updated_at_to?: number;
|
|
165
|
+
filter_closed_at_from?: number;
|
|
166
|
+
filter_closed_at_to?: number;
|
|
167
|
+
filter_closest_task_at_from?: number;
|
|
168
|
+
filter_closest_task_at_to?: number;
|
|
169
|
+
filter_pipeline_id?: number[];
|
|
170
|
+
filter_statuses?: Array<{
|
|
171
|
+
pipeline_id: number;
|
|
172
|
+
status_id: number;
|
|
173
|
+
}>;
|
|
174
|
+
}
|
|
175
|
+
interface ListLeadsResponse {
|
|
176
|
+
_page: number;
|
|
177
|
+
_links?: {
|
|
178
|
+
self?: {
|
|
179
|
+
href: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
_embedded?: {
|
|
183
|
+
leads?: Lead[];
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
interface LeadTagRef {
|
|
187
|
+
id?: number;
|
|
188
|
+
name?: string;
|
|
189
|
+
}
|
|
190
|
+
interface CreateLeadInput {
|
|
191
|
+
request_id?: string;
|
|
192
|
+
name?: string;
|
|
193
|
+
price?: number;
|
|
194
|
+
status_id?: number;
|
|
195
|
+
pipeline_id?: number;
|
|
196
|
+
created_by?: number;
|
|
197
|
+
updated_by?: number;
|
|
198
|
+
created_at?: number;
|
|
199
|
+
updated_at?: number;
|
|
200
|
+
closed_at?: number;
|
|
201
|
+
loss_reason_id?: string | number;
|
|
202
|
+
responsible_user_id?: number;
|
|
203
|
+
custom_fields_values?: unknown[] | string;
|
|
204
|
+
_embedded?: {
|
|
205
|
+
tags?: LeadTagRef[];
|
|
206
|
+
contacts?: Array<{
|
|
207
|
+
id: number;
|
|
208
|
+
is_main?: boolean;
|
|
209
|
+
}>;
|
|
210
|
+
companies?: Array<{
|
|
211
|
+
id: number;
|
|
212
|
+
}>;
|
|
213
|
+
source?: {
|
|
214
|
+
external_id?: string;
|
|
215
|
+
type?: 'widget' | string;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
tags_to_add?: LeadTagRef[];
|
|
219
|
+
tags_to_delete?: LeadTagRef[];
|
|
220
|
+
}
|
|
221
|
+
interface CreateLeadsResponse {
|
|
222
|
+
_links?: {
|
|
223
|
+
self?: {
|
|
224
|
+
href: string;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
_embedded?: {
|
|
228
|
+
leads?: Array<{
|
|
229
|
+
id: number;
|
|
230
|
+
_links?: {
|
|
231
|
+
self?: {
|
|
232
|
+
href: string;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
}>;
|
|
236
|
+
};
|
|
237
|
+
raw?: unknown;
|
|
238
|
+
}
|
|
239
|
+
interface UpdateLeadInput {
|
|
240
|
+
id: number;
|
|
241
|
+
request_id?: string;
|
|
242
|
+
name?: string;
|
|
243
|
+
price?: number;
|
|
244
|
+
status_id?: number;
|
|
245
|
+
pipeline_id?: number;
|
|
246
|
+
created_by?: number;
|
|
247
|
+
updated_by?: number;
|
|
248
|
+
created_at?: number;
|
|
249
|
+
updated_at?: number;
|
|
250
|
+
closed_at?: number;
|
|
251
|
+
loss_reason_id?: number;
|
|
252
|
+
responsible_user_id?: number;
|
|
253
|
+
custom_fields_values?: unknown[] | string;
|
|
254
|
+
_embedded?: {
|
|
255
|
+
tags?: LeadTagRef[];
|
|
256
|
+
};
|
|
257
|
+
tags_to_add?: LeadTagRef[];
|
|
258
|
+
tags_to_delete?: LeadTagRef[];
|
|
259
|
+
}
|
|
260
|
+
interface UpdateLeadsResponse {
|
|
261
|
+
_links?: {
|
|
262
|
+
self?: {
|
|
263
|
+
href: string;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
_embedded?: {
|
|
267
|
+
leads?: Array<{
|
|
268
|
+
id: number;
|
|
269
|
+
updated_at: number;
|
|
270
|
+
_links?: {
|
|
271
|
+
self?: {
|
|
272
|
+
href: string;
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
}>;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
type UpdateSingleLeadInput = Omit<UpdateLeadInput, 'id'>;
|
|
279
|
+
interface CreateComplexLeadInput {
|
|
280
|
+
request_id?: string;
|
|
281
|
+
name?: string;
|
|
282
|
+
price?: number;
|
|
283
|
+
status_id?: number;
|
|
284
|
+
pipeline_id?: number;
|
|
285
|
+
created_by?: number;
|
|
286
|
+
updated_by?: number;
|
|
287
|
+
created_at?: number;
|
|
288
|
+
updated_at?: number;
|
|
289
|
+
closed_at?: number;
|
|
290
|
+
loss_reason_id?: number;
|
|
291
|
+
responsible_user_id?: number;
|
|
292
|
+
custom_fields_values?: unknown[] | string;
|
|
293
|
+
_embedded?: {
|
|
294
|
+
tags?: LeadTagRef[];
|
|
295
|
+
contacts?: Array<{
|
|
296
|
+
id?: number;
|
|
297
|
+
name?: string;
|
|
298
|
+
first_name?: string;
|
|
299
|
+
last_name?: string;
|
|
300
|
+
created_at?: number;
|
|
301
|
+
responsible_user_id?: number;
|
|
302
|
+
updated_by?: number;
|
|
303
|
+
custom_fields_values?: unknown[];
|
|
304
|
+
}>;
|
|
305
|
+
companies?: Array<{
|
|
306
|
+
id?: number;
|
|
307
|
+
name?: string;
|
|
308
|
+
responsible_user_id?: number;
|
|
309
|
+
custom_fields_values?: unknown[];
|
|
310
|
+
}>;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
interface CreateComplexLeadsResponseItem {
|
|
314
|
+
id: number;
|
|
315
|
+
contact_id?: number;
|
|
316
|
+
company_id?: number;
|
|
317
|
+
request_id: string[];
|
|
318
|
+
merged: boolean;
|
|
319
|
+
}
|
|
320
|
+
type CreateComplexLeadsResponse = CreateComplexLeadsResponseItem[];
|
|
321
|
+
interface LossReason {
|
|
322
|
+
id: number;
|
|
323
|
+
name: string;
|
|
324
|
+
sort: number;
|
|
325
|
+
created_at: number;
|
|
326
|
+
updated_at: number;
|
|
327
|
+
_links?: {
|
|
328
|
+
self?: {
|
|
329
|
+
href: string;
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
interface ListLossReasonsResponse {
|
|
334
|
+
_total_items?: number;
|
|
335
|
+
_embedded?: {
|
|
336
|
+
loss_reasons?: LossReason[];
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare class LeadsResource extends BaseResource {
|
|
341
|
+
list(params?: ListLeadsParams): Promise<ListLeadsResponse>;
|
|
342
|
+
getById(id: number, params?: {
|
|
343
|
+
with?: LeadWithParam[] | string;
|
|
344
|
+
}): Promise<Lead | null>;
|
|
345
|
+
create(items: CreateLeadInput | CreateLeadInput[]): Promise<CreateLeadsResponse>;
|
|
346
|
+
update(items: UpdateLeadInput | UpdateLeadInput[]): Promise<UpdateLeadsResponse>;
|
|
347
|
+
updateOne(id: number, payload: UpdateSingleLeadInput): Promise<UpdateLeadsResponse | Lead>;
|
|
348
|
+
createComplex(items: CreateComplexLeadInput | CreateComplexLeadInput[]): Promise<CreateComplexLeadsResponse>;
|
|
349
|
+
listLossReasons(): Promise<ListLossReasonsResponse>;
|
|
350
|
+
getLossReasonById(id: number): Promise<LossReason>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
interface ContactTag {
|
|
354
|
+
id?: number;
|
|
355
|
+
name?: string;
|
|
356
|
+
color?: string | null;
|
|
357
|
+
}
|
|
358
|
+
interface ContactCompanyRef {
|
|
359
|
+
id: number;
|
|
360
|
+
_links?: {
|
|
361
|
+
self?: {
|
|
362
|
+
href: string;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
interface ContactLeadRef {
|
|
367
|
+
id: number;
|
|
368
|
+
_links?: {
|
|
369
|
+
self?: {
|
|
370
|
+
href: string;
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
interface ContactCustomerRef {
|
|
375
|
+
id: number;
|
|
376
|
+
_links?: {
|
|
377
|
+
self?: {
|
|
378
|
+
href: string;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
interface ContactCatalogElementRef {
|
|
383
|
+
id: number;
|
|
384
|
+
metadata?: Record<string, unknown>;
|
|
385
|
+
quantity?: number;
|
|
386
|
+
catalog_id?: number;
|
|
387
|
+
}
|
|
388
|
+
interface Contact {
|
|
389
|
+
id: number;
|
|
390
|
+
name?: string | null;
|
|
391
|
+
first_name?: string | null;
|
|
392
|
+
last_name?: string | null;
|
|
393
|
+
responsible_user_id?: number | null;
|
|
394
|
+
group_id?: number | null;
|
|
395
|
+
created_by?: number | null;
|
|
396
|
+
updated_by?: number | null;
|
|
397
|
+
created_at?: number | null;
|
|
398
|
+
updated_at?: number | null;
|
|
399
|
+
closest_task_at?: number | null;
|
|
400
|
+
custom_fields_values?: unknown[] | null;
|
|
401
|
+
account_id?: number | null;
|
|
402
|
+
is_deleted?: boolean;
|
|
403
|
+
is_unsorted?: boolean;
|
|
404
|
+
_links?: {
|
|
405
|
+
self?: {
|
|
406
|
+
href: string;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
_embedded?: {
|
|
410
|
+
tags?: ContactTag[];
|
|
411
|
+
companies?: ContactCompanyRef[];
|
|
412
|
+
leads?: ContactLeadRef[];
|
|
413
|
+
catalog_elements?: ContactCatalogElementRef[];
|
|
414
|
+
customers?: ContactCustomerRef[];
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
type ContactWithParam = 'leads' | 'catalog_elements';
|
|
418
|
+
interface ListContactsParams {
|
|
419
|
+
with?: ContactWithParam[] | string;
|
|
420
|
+
page?: number;
|
|
421
|
+
limit?: number;
|
|
422
|
+
query?: string;
|
|
423
|
+
order_updated_at?: 'asc' | 'desc';
|
|
424
|
+
order_id?: 'asc' | 'desc';
|
|
425
|
+
filter_id?: number[];
|
|
426
|
+
filter_name?: string[];
|
|
427
|
+
filter_created_by?: number[];
|
|
428
|
+
filter_updated_by?: number[];
|
|
429
|
+
filter_responsible_user_id?: number[];
|
|
430
|
+
filter_created_at_from?: number;
|
|
431
|
+
filter_created_at_to?: number;
|
|
432
|
+
filter_updated_at_from?: number;
|
|
433
|
+
filter_updated_at_to?: number;
|
|
434
|
+
filter_closest_task_at_from?: number;
|
|
435
|
+
filter_closest_task_at_to?: number;
|
|
436
|
+
}
|
|
437
|
+
interface ListContactsResponse {
|
|
438
|
+
_page: number;
|
|
439
|
+
_links?: {
|
|
440
|
+
self?: {
|
|
441
|
+
href: string;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
_embedded?: {
|
|
445
|
+
contacts?: Contact[];
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
interface ContactTagRef {
|
|
449
|
+
id?: number;
|
|
450
|
+
name?: string;
|
|
451
|
+
}
|
|
452
|
+
interface CreateContactInput {
|
|
453
|
+
request_id?: string;
|
|
454
|
+
name?: string;
|
|
455
|
+
first_name?: string;
|
|
456
|
+
last_name?: string;
|
|
457
|
+
responsible_user_id?: number;
|
|
458
|
+
created_by?: number;
|
|
459
|
+
updated_by?: number;
|
|
460
|
+
created_at?: number;
|
|
461
|
+
updated_at?: number;
|
|
462
|
+
custom_fields_values?: unknown[] | string;
|
|
463
|
+
_embedded?: {
|
|
464
|
+
tags?: ContactTagRef[];
|
|
465
|
+
};
|
|
466
|
+
tags_to_add?: ContactTagRef[];
|
|
467
|
+
tags_to_delete?: ContactTagRef[];
|
|
468
|
+
}
|
|
469
|
+
interface CreateContactsResponse {
|
|
470
|
+
_links?: {
|
|
471
|
+
self?: {
|
|
472
|
+
href: string;
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
_embedded?: {
|
|
476
|
+
contacts?: Array<{
|
|
477
|
+
id: number;
|
|
478
|
+
is_deleted: boolean;
|
|
479
|
+
is_unsorted: boolean;
|
|
480
|
+
request_id?: string;
|
|
481
|
+
_links?: {
|
|
482
|
+
self?: {
|
|
483
|
+
href: string;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
}>;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
interface UpdateContactInput {
|
|
490
|
+
id: number;
|
|
491
|
+
request_id?: string;
|
|
492
|
+
name?: string;
|
|
493
|
+
first_name?: string;
|
|
494
|
+
last_name?: string;
|
|
495
|
+
responsible_user_id?: number;
|
|
496
|
+
created_by?: number;
|
|
497
|
+
updated_by?: number;
|
|
498
|
+
created_at?: number;
|
|
499
|
+
updated_at?: number;
|
|
500
|
+
custom_fields_values?: unknown[] | string;
|
|
501
|
+
_embedded?: {
|
|
502
|
+
tags?: ContactTagRef[];
|
|
503
|
+
};
|
|
504
|
+
tags_to_add?: ContactTagRef[];
|
|
505
|
+
tags_to_delete?: ContactTagRef[];
|
|
506
|
+
}
|
|
507
|
+
interface UpdateContactsResponse {
|
|
508
|
+
_links?: {
|
|
509
|
+
self?: {
|
|
510
|
+
href: string;
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
_embedded?: {
|
|
514
|
+
contacts?: Array<{
|
|
515
|
+
id: number;
|
|
516
|
+
name?: string;
|
|
517
|
+
updated_at: number;
|
|
518
|
+
is_deleted: boolean;
|
|
519
|
+
is_unsorted: boolean;
|
|
520
|
+
_links?: {
|
|
521
|
+
self?: {
|
|
522
|
+
href: string;
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
}>;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
type UpdateSingleContactInput = Omit<UpdateContactInput, 'id'>;
|
|
529
|
+
|
|
530
|
+
declare class ContactsResource extends BaseResource {
|
|
531
|
+
list(params?: ListContactsParams): Promise<ListContactsResponse>;
|
|
532
|
+
getById(id: number, params?: {
|
|
533
|
+
with?: ContactWithParam[] | string;
|
|
534
|
+
}): Promise<Contact | null>;
|
|
535
|
+
create(items: CreateContactInput | CreateContactInput[]): Promise<CreateContactsResponse>;
|
|
536
|
+
update(items: UpdateContactInput | UpdateContactInput[]): Promise<UpdateContactsResponse>;
|
|
537
|
+
updateOne(id: number, payload: UpdateSingleContactInput): Promise<UpdateContactsResponse>;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
interface Task {
|
|
541
|
+
id: number;
|
|
542
|
+
created_by?: number;
|
|
543
|
+
updated_by?: number;
|
|
544
|
+
created_at?: number;
|
|
545
|
+
updated_at?: number;
|
|
546
|
+
responsible_user_id?: number;
|
|
547
|
+
group_id?: number;
|
|
548
|
+
entity_id?: number;
|
|
549
|
+
entity_type?: 'leads' | 'contacts' | 'companies' | string;
|
|
550
|
+
is_completed?: boolean;
|
|
551
|
+
task_type_id?: number;
|
|
552
|
+
text?: string;
|
|
553
|
+
duration?: number;
|
|
554
|
+
complete_till?: number;
|
|
555
|
+
result?: {
|
|
556
|
+
text?: string;
|
|
557
|
+
} | Record<string, unknown> | null;
|
|
558
|
+
account_id?: number;
|
|
559
|
+
request_id?: string;
|
|
560
|
+
_links?: {
|
|
561
|
+
self?: {
|
|
562
|
+
href: string;
|
|
563
|
+
};
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
interface ListTasksParams {
|
|
567
|
+
page?: number;
|
|
568
|
+
limit?: number;
|
|
569
|
+
filter_responsible_user_id?: number[];
|
|
570
|
+
filter_is_completed?: 0 | 1;
|
|
571
|
+
filter_task_type?: number[];
|
|
572
|
+
filter_entity_type?: 'leads' | 'contacts' | 'companies';
|
|
573
|
+
filter_entity_id?: number[];
|
|
574
|
+
filter_id?: number[];
|
|
575
|
+
filter_updated_at_from?: number;
|
|
576
|
+
filter_updated_at_to?: number;
|
|
577
|
+
order_complete_till?: 'asc' | 'desc';
|
|
578
|
+
order_created_at?: 'asc' | 'desc';
|
|
579
|
+
order_id?: 'asc' | 'desc';
|
|
580
|
+
}
|
|
581
|
+
interface ListTasksResponse {
|
|
582
|
+
_page: number;
|
|
583
|
+
_links?: {
|
|
584
|
+
self?: {
|
|
585
|
+
href: string;
|
|
586
|
+
};
|
|
587
|
+
next?: {
|
|
588
|
+
href: string;
|
|
589
|
+
};
|
|
590
|
+
};
|
|
591
|
+
_embedded?: {
|
|
592
|
+
tasks?: Task[];
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
interface CreateTaskInput {
|
|
596
|
+
responsible_user_id?: number;
|
|
597
|
+
entity_id?: number;
|
|
598
|
+
entity_type?: 'leads' | 'contacts' | 'companies';
|
|
599
|
+
is_completed?: boolean;
|
|
600
|
+
task_type_id?: number;
|
|
601
|
+
text: string;
|
|
602
|
+
duration?: number;
|
|
603
|
+
complete_till: number;
|
|
604
|
+
result?: {
|
|
605
|
+
text?: string;
|
|
606
|
+
};
|
|
607
|
+
created_by?: number;
|
|
608
|
+
updated_by?: number;
|
|
609
|
+
created_at?: number;
|
|
610
|
+
updated_at?: number;
|
|
611
|
+
request_id?: string;
|
|
612
|
+
}
|
|
613
|
+
interface CreateTasksResponse {
|
|
614
|
+
_links?: {
|
|
615
|
+
self?: {
|
|
616
|
+
href: string;
|
|
617
|
+
};
|
|
618
|
+
};
|
|
619
|
+
_embedded?: {
|
|
620
|
+
tasks?: Array<{
|
|
621
|
+
id: number;
|
|
622
|
+
request_id?: string;
|
|
623
|
+
_links?: {
|
|
624
|
+
self?: {
|
|
625
|
+
href: string;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
}>;
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
interface UpdateTaskInput {
|
|
632
|
+
id: number;
|
|
633
|
+
responsible_user_id?: number;
|
|
634
|
+
entity_id?: number;
|
|
635
|
+
entity_type?: 'leads' | 'contacts' | 'companies';
|
|
636
|
+
is_completed?: boolean;
|
|
637
|
+
task_type_id?: number;
|
|
638
|
+
text?: string;
|
|
639
|
+
duration?: number;
|
|
640
|
+
complete_till?: number;
|
|
641
|
+
result?: {
|
|
642
|
+
text?: string;
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
interface UpdateTasksResponse {
|
|
646
|
+
_links?: {
|
|
647
|
+
self?: {
|
|
648
|
+
href: string;
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
_embedded?: {
|
|
652
|
+
tasks?: Array<{
|
|
653
|
+
id: number;
|
|
654
|
+
updated_at: number;
|
|
655
|
+
request_id?: string;
|
|
656
|
+
_links?: {
|
|
657
|
+
self?: {
|
|
658
|
+
href: string;
|
|
659
|
+
};
|
|
660
|
+
};
|
|
661
|
+
}>;
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
type UpdateSingleTaskInput = Omit<UpdateTaskInput, 'id'>;
|
|
665
|
+
|
|
666
|
+
declare class TasksResource extends BaseResource {
|
|
667
|
+
list(params?: ListTasksParams): Promise<ListTasksResponse>;
|
|
668
|
+
getById(id: number): Promise<Task>;
|
|
669
|
+
create(items: CreateTaskInput | CreateTaskInput[]): Promise<CreateTasksResponse>;
|
|
670
|
+
update(items: UpdateTaskInput | UpdateTaskInput[]): Promise<UpdateTasksResponse>;
|
|
671
|
+
updateOne(id: number, payload: UpdateSingleTaskInput): Promise<UpdateTasksResponse>;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
type NoteType = 'common' | 'call_in' | 'call_out' | 'service_message' | 'geolocation' | 'sms_in' | 'sms_out' | 'extended_service_message' | 'attachment' | string;
|
|
675
|
+
interface CommonNoteParams {
|
|
676
|
+
text: string;
|
|
677
|
+
}
|
|
678
|
+
interface CallNoteParams {
|
|
679
|
+
uniq: string;
|
|
680
|
+
duration: number;
|
|
681
|
+
source: string;
|
|
682
|
+
link?: string;
|
|
683
|
+
phone: string;
|
|
684
|
+
}
|
|
685
|
+
interface ServiceMessageNoteParams {
|
|
686
|
+
service: string;
|
|
687
|
+
text: string;
|
|
688
|
+
}
|
|
689
|
+
interface GeolocationNoteParams {
|
|
690
|
+
text: string;
|
|
691
|
+
address: string;
|
|
692
|
+
longitude: string;
|
|
693
|
+
latitude: string;
|
|
694
|
+
}
|
|
695
|
+
interface SmsNoteParams {
|
|
696
|
+
text: string;
|
|
697
|
+
phone: string;
|
|
698
|
+
}
|
|
699
|
+
interface AttachmentNoteParams {
|
|
700
|
+
version_uuid?: string;
|
|
701
|
+
file_uuid: string;
|
|
702
|
+
file_name: string;
|
|
703
|
+
}
|
|
704
|
+
type NoteParams = CommonNoteParams | CallNoteParams | ServiceMessageNoteParams | GeolocationNoteParams | SmsNoteParams | AttachmentNoteParams | Record<string, unknown>;
|
|
705
|
+
interface Note {
|
|
706
|
+
id: number;
|
|
707
|
+
entity_id: number;
|
|
708
|
+
created_by?: number;
|
|
709
|
+
updated_by?: number;
|
|
710
|
+
created_at?: number;
|
|
711
|
+
updated_at?: number;
|
|
712
|
+
responsible_user_id?: number;
|
|
713
|
+
group_id?: number;
|
|
714
|
+
note_type: NoteType;
|
|
715
|
+
params?: NoteParams;
|
|
716
|
+
account_id?: number;
|
|
717
|
+
request_id?: string;
|
|
718
|
+
_links?: {
|
|
719
|
+
self?: {
|
|
720
|
+
href: string;
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
type NoteEntityType = 'leads' | 'contacts' | 'companies' | 'contatos' | 'empresas' | string;
|
|
725
|
+
interface ListEntityNotesParams {
|
|
726
|
+
page?: number;
|
|
727
|
+
limit?: number;
|
|
728
|
+
filter_id?: number[] | string[];
|
|
729
|
+
filter_note_type?: NoteType[] | string[];
|
|
730
|
+
filter_updated_at_from?: number;
|
|
731
|
+
filter_updated_at_to?: number;
|
|
732
|
+
order_updated_at?: 'asc' | 'desc';
|
|
733
|
+
order_id?: 'asc' | 'desc';
|
|
734
|
+
}
|
|
735
|
+
interface ListNotesResponse {
|
|
736
|
+
_page: number;
|
|
737
|
+
_links?: {
|
|
738
|
+
self?: {
|
|
739
|
+
href: string;
|
|
740
|
+
};
|
|
741
|
+
next?: {
|
|
742
|
+
href: string;
|
|
743
|
+
};
|
|
744
|
+
};
|
|
745
|
+
_embedded?: {
|
|
746
|
+
notes?: Note[];
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
interface CreateNoteInput {
|
|
750
|
+
entity_id: number;
|
|
751
|
+
note_type: NoteType;
|
|
752
|
+
params?: NoteParams;
|
|
753
|
+
request_id?: string;
|
|
754
|
+
is_need_to_trigger_digital_pipeline?: boolean;
|
|
755
|
+
}
|
|
756
|
+
interface CreateNotesResponse {
|
|
757
|
+
_links?: {
|
|
758
|
+
self?: {
|
|
759
|
+
href: string;
|
|
760
|
+
};
|
|
761
|
+
};
|
|
762
|
+
_embedded?: {
|
|
763
|
+
notes?: Array<{
|
|
764
|
+
id: number;
|
|
765
|
+
entity_id: number;
|
|
766
|
+
request_id?: string;
|
|
767
|
+
_links?: {
|
|
768
|
+
self?: {
|
|
769
|
+
href: string;
|
|
770
|
+
};
|
|
771
|
+
};
|
|
772
|
+
}>;
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
interface UpdateNoteInput {
|
|
776
|
+
id: number;
|
|
777
|
+
entity_id?: number;
|
|
778
|
+
note_type?: NoteType;
|
|
779
|
+
params?: NoteParams;
|
|
780
|
+
}
|
|
781
|
+
interface UpdateSingleNoteInput {
|
|
782
|
+
entity_id?: number;
|
|
783
|
+
note_type?: NoteType;
|
|
784
|
+
params?: NoteParams;
|
|
785
|
+
}
|
|
786
|
+
interface UpdateNotesResponse {
|
|
787
|
+
_links?: {
|
|
788
|
+
self?: {
|
|
789
|
+
href: string;
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
_embedded?: {
|
|
793
|
+
notes?: Array<{
|
|
794
|
+
id: number;
|
|
795
|
+
entity_id: number;
|
|
796
|
+
updated_at: number;
|
|
797
|
+
_links?: {
|
|
798
|
+
self?: {
|
|
799
|
+
href: string;
|
|
800
|
+
};
|
|
801
|
+
};
|
|
802
|
+
}>;
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
declare class NotesResource extends BaseResource {
|
|
807
|
+
private normalizeEntityType;
|
|
808
|
+
listByEntity(entityType: NoteEntityType, entityId: number, params?: ListEntityNotesParams): Promise<ListNotesResponse>;
|
|
809
|
+
listByEntityType(entityType: NoteEntityType, params?: ListEntityNotesParams): Promise<ListNotesResponse>;
|
|
810
|
+
getById(entityType: NoteEntityType, id: number): Promise<Note>;
|
|
811
|
+
create(entityType: NoteEntityType, items: CreateNoteInput | CreateNoteInput[]): Promise<CreateNotesResponse>;
|
|
812
|
+
update(entityType: NoteEntityType, items: UpdateNoteInput | UpdateNoteInput[]): Promise<UpdateNotesResponse>;
|
|
813
|
+
updateOne(entityType: NoteEntityType, id: number | string, payload: UpdateSingleNoteInput): Promise<UpdateNotesResponse>;
|
|
814
|
+
pin(entityType: NoteEntityType, id: number): Promise<void>;
|
|
815
|
+
unpin(entityType: NoteEntityType, id: number): Promise<void>;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
type CustomFieldType = 'text' | 'numeric' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'url' | 'textarea' | 'radiobutton' | 'streetaddress' | 'smart_address' | 'birthday' | 'legal_entity' | 'date_time' | 'price' | 'category' | 'file';
|
|
819
|
+
type EntityType = 'leads' | 'contacts' | 'companies';
|
|
820
|
+
interface CustomFieldEnum {
|
|
821
|
+
id?: number;
|
|
822
|
+
value: string;
|
|
823
|
+
sort?: number;
|
|
824
|
+
code?: string;
|
|
825
|
+
}
|
|
826
|
+
interface CustomFieldRequiredStatus {
|
|
827
|
+
status_id: number;
|
|
828
|
+
pipeline_id: number;
|
|
829
|
+
}
|
|
830
|
+
interface CustomFieldNestedValue {
|
|
831
|
+
id?: number;
|
|
832
|
+
parent_id?: number;
|
|
833
|
+
value: string;
|
|
834
|
+
sort?: number;
|
|
835
|
+
request_id?: string;
|
|
836
|
+
parent_request_id?: string;
|
|
837
|
+
}
|
|
838
|
+
interface BaseCustomField {
|
|
839
|
+
id: number;
|
|
840
|
+
name: string;
|
|
841
|
+
code?: string | null;
|
|
842
|
+
sort?: number;
|
|
843
|
+
type: string;
|
|
844
|
+
entity_type?: string;
|
|
845
|
+
account_id?: number;
|
|
846
|
+
enums?: CustomFieldEnum[] | Record<string, CustomFieldEnum> | null;
|
|
847
|
+
remind?: 'never' | 'day' | 'week' | 'month' | string | null;
|
|
848
|
+
request_id?: string;
|
|
849
|
+
_links?: {
|
|
850
|
+
self?: {
|
|
851
|
+
href: string;
|
|
852
|
+
};
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
interface EntityCustomField extends BaseCustomField {
|
|
856
|
+
entity_type: 'leads' | 'contacts' | 'companies';
|
|
857
|
+
group_id?: number | null;
|
|
858
|
+
is_api_only?: boolean;
|
|
859
|
+
required_statuses?: CustomFieldRequiredStatus[];
|
|
860
|
+
is_predefined?: boolean;
|
|
861
|
+
is_deletable?: boolean;
|
|
862
|
+
tracking_callback?: unknown;
|
|
863
|
+
triggers?: unknown[];
|
|
864
|
+
currency?: unknown;
|
|
865
|
+
hidden_statuses?: unknown[];
|
|
866
|
+
chained_lists?: unknown;
|
|
867
|
+
}
|
|
868
|
+
interface ListCustomField extends BaseCustomField {
|
|
869
|
+
entity_type?: 'catalogs' | 'catalog' | string;
|
|
870
|
+
settings?: Record<string, unknown> | string | null;
|
|
871
|
+
is_visible?: boolean;
|
|
872
|
+
is_required?: boolean;
|
|
873
|
+
nested?: CustomFieldNestedValue[] | null;
|
|
874
|
+
}
|
|
875
|
+
interface ListEntityCustomFieldsResponse {
|
|
876
|
+
_total_items?: number;
|
|
877
|
+
_embedded?: {
|
|
878
|
+
custom_fields?: EntityCustomField[];
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
interface ListListCustomFieldsResponse {
|
|
882
|
+
_total_items?: number;
|
|
883
|
+
_embedded?: {
|
|
884
|
+
custom_fields?: ListCustomField[];
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
interface CreateEntityCustomFieldInput {
|
|
888
|
+
type: CustomFieldType;
|
|
889
|
+
name: string;
|
|
890
|
+
code?: string;
|
|
891
|
+
sort?: number;
|
|
892
|
+
group_id?: number;
|
|
893
|
+
is_api_only?: boolean;
|
|
894
|
+
required_statuses?: CustomFieldRequiredStatus[];
|
|
895
|
+
remind?: 'never' | 'day' | 'week' | 'month' | string | null;
|
|
896
|
+
enums?: Array<{
|
|
897
|
+
value: string;
|
|
898
|
+
sort?: number;
|
|
899
|
+
code?: string;
|
|
900
|
+
}>;
|
|
901
|
+
nested?: CustomFieldNestedValue[];
|
|
902
|
+
}
|
|
903
|
+
interface UpdateEntityCustomFieldInput {
|
|
904
|
+
id: number;
|
|
905
|
+
name?: string;
|
|
906
|
+
code?: string;
|
|
907
|
+
sort?: number;
|
|
908
|
+
group_id?: number;
|
|
909
|
+
is_api_only?: boolean;
|
|
910
|
+
required_statuses?: CustomFieldRequiredStatus[];
|
|
911
|
+
remind?: 'never' | 'day' | 'week' | 'month' | string | null;
|
|
912
|
+
enums?: Array<{
|
|
913
|
+
value: string;
|
|
914
|
+
sort?: number;
|
|
915
|
+
code?: string;
|
|
916
|
+
}>;
|
|
917
|
+
nested?: CustomFieldNestedValue[];
|
|
918
|
+
}
|
|
919
|
+
type UpdateSingleEntityCustomFieldInput = Omit<UpdateEntityCustomFieldInput, 'id'>;
|
|
920
|
+
interface CreateListCustomFieldInput {
|
|
921
|
+
type: CustomFieldType;
|
|
922
|
+
name: string;
|
|
923
|
+
code?: string;
|
|
924
|
+
sort?: number;
|
|
925
|
+
settings?: Record<string, unknown> | string;
|
|
926
|
+
is_visible?: boolean;
|
|
927
|
+
is_required?: boolean;
|
|
928
|
+
remind?: 'never' | 'day' | 'week' | 'month' | string | null;
|
|
929
|
+
enums?: Array<{
|
|
930
|
+
value: string;
|
|
931
|
+
sort?: number;
|
|
932
|
+
code?: string;
|
|
933
|
+
}>;
|
|
934
|
+
nested?: CustomFieldNestedValue[];
|
|
935
|
+
}
|
|
936
|
+
interface UpdateListCustomFieldInput {
|
|
937
|
+
id: number;
|
|
938
|
+
name?: string;
|
|
939
|
+
code?: string;
|
|
940
|
+
sort?: number;
|
|
941
|
+
settings?: Record<string, unknown> | string;
|
|
942
|
+
is_visible?: boolean;
|
|
943
|
+
is_required?: boolean;
|
|
944
|
+
remind?: 'never' | 'day' | 'week' | 'month' | string | null;
|
|
945
|
+
enums?: Array<{
|
|
946
|
+
value: string;
|
|
947
|
+
sort?: number;
|
|
948
|
+
code?: string;
|
|
949
|
+
}>;
|
|
950
|
+
nested?: CustomFieldNestedValue[];
|
|
951
|
+
}
|
|
952
|
+
type UpdateSingleListCustomFieldInput = Omit<UpdateListCustomFieldInput, 'id'>;
|
|
953
|
+
interface CustomFieldGroup {
|
|
954
|
+
id: number;
|
|
955
|
+
name: string;
|
|
956
|
+
sort: string | number;
|
|
957
|
+
entity_type: 'leads' | 'contacts' | 'companies' | string;
|
|
958
|
+
is_predefined: boolean | number;
|
|
959
|
+
type: 'linked_group' | 'custom_field_group' | string;
|
|
960
|
+
fields: number[];
|
|
961
|
+
}
|
|
962
|
+
interface ListCustomFieldGroupsResponse {
|
|
963
|
+
_embedded?: {
|
|
964
|
+
custom_fields_groups?: CustomFieldGroup[];
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
interface CreateCustomFieldGroupInput {
|
|
968
|
+
name: string;
|
|
969
|
+
sort?: string | number;
|
|
970
|
+
request_id?: string;
|
|
971
|
+
}
|
|
972
|
+
interface UpdateCustomFieldGroupInput {
|
|
973
|
+
name?: string;
|
|
974
|
+
sort?: string | number;
|
|
975
|
+
fields?: number[];
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
declare class CustomFieldsResource extends BaseResource {
|
|
979
|
+
listEntity(entityType: EntityType): Promise<ListEntityCustomFieldsResponse>;
|
|
980
|
+
getEntityById(entityType: EntityType, id: number): Promise<EntityCustomField>;
|
|
981
|
+
createEntity(entityType: EntityType, items: CreateEntityCustomFieldInput | CreateEntityCustomFieldInput[]): Promise<ListEntityCustomFieldsResponse>;
|
|
982
|
+
updateEntity(entityType: EntityType, items: UpdateEntityCustomFieldInput | UpdateEntityCustomFieldInput[]): Promise<ListEntityCustomFieldsResponse>;
|
|
983
|
+
updateEntityById(entityType: EntityType, id: number, payload: UpdateSingleEntityCustomFieldInput): Promise<EntityCustomField>;
|
|
984
|
+
deleteEntity(entityType: EntityType, id: number): Promise<void>;
|
|
985
|
+
listList(listId: number): Promise<ListListCustomFieldsResponse>;
|
|
986
|
+
getListById(listId: number, customFieldId: number): Promise<ListCustomField | EntityCustomField>;
|
|
987
|
+
createList(listId: number, items: CreateListCustomFieldInput | CreateListCustomFieldInput[]): Promise<ListListCustomFieldsResponse>;
|
|
988
|
+
updateList(listId: number, items: UpdateListCustomFieldInput | UpdateListCustomFieldInput[]): Promise<ListListCustomFieldsResponse>;
|
|
989
|
+
updateListById(listId: number, customFieldId: number, payload: UpdateSingleListCustomFieldInput): Promise<ListCustomField>;
|
|
990
|
+
deleteList(listId: number, id: number): Promise<void>;
|
|
991
|
+
}
|
|
992
|
+
declare class CustomFieldGroupsResource extends BaseResource {
|
|
993
|
+
list(entityType: EntityType): Promise<ListCustomFieldGroupsResponse>;
|
|
994
|
+
getById(entityType: EntityType, id: number): Promise<CustomFieldGroup>;
|
|
995
|
+
create(entityType: EntityType, items: CreateCustomFieldGroupInput | CreateCustomFieldGroupInput[]): Promise<ListCustomFieldGroupsResponse>;
|
|
996
|
+
update(entityType: EntityType, id: number, payload: UpdateCustomFieldGroupInput): Promise<CustomFieldGroup>;
|
|
997
|
+
delete(entityType: EntityType, id: number): Promise<void>;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
interface UnsortedLead {
|
|
1001
|
+
uid: string;
|
|
1002
|
+
source_uid?: string | null;
|
|
1003
|
+
source_name?: string | null;
|
|
1004
|
+
category: 'sip' | 'forms' | 'chats' | 'mail' | string;
|
|
1005
|
+
pipeline_id: number;
|
|
1006
|
+
created_at: number;
|
|
1007
|
+
metadata: Record<string, unknown>;
|
|
1008
|
+
account_id: number;
|
|
1009
|
+
_links?: {
|
|
1010
|
+
self?: {
|
|
1011
|
+
href: string;
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
1014
|
+
_embedded?: {
|
|
1015
|
+
contacts?: Array<{
|
|
1016
|
+
id: number;
|
|
1017
|
+
_links?: {
|
|
1018
|
+
self?: {
|
|
1019
|
+
href: string;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
}>;
|
|
1023
|
+
companies?: Array<{
|
|
1024
|
+
id: number;
|
|
1025
|
+
_links?: {
|
|
1026
|
+
self?: {
|
|
1027
|
+
href: string;
|
|
1028
|
+
};
|
|
1029
|
+
};
|
|
1030
|
+
}>;
|
|
1031
|
+
leads?: Array<{
|
|
1032
|
+
id: number;
|
|
1033
|
+
_links?: {
|
|
1034
|
+
self?: {
|
|
1035
|
+
href: string;
|
|
1036
|
+
};
|
|
1037
|
+
};
|
|
1038
|
+
}>;
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
interface ListUnsortedLeadsResponse {
|
|
1042
|
+
_page?: number;
|
|
1043
|
+
_links?: {
|
|
1044
|
+
self?: {
|
|
1045
|
+
href: string;
|
|
1046
|
+
};
|
|
1047
|
+
next?: {
|
|
1048
|
+
href: string;
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
_embedded?: {
|
|
1052
|
+
unsorted?: UnsortedLead[];
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
interface CreateUnsortedLeadsResponse {
|
|
1056
|
+
_total_items?: number;
|
|
1057
|
+
_embedded?: {
|
|
1058
|
+
unsorted?: Array<{
|
|
1059
|
+
uid: string;
|
|
1060
|
+
account_id: number;
|
|
1061
|
+
request_id?: string;
|
|
1062
|
+
_links?: {
|
|
1063
|
+
self?: {
|
|
1064
|
+
href: string;
|
|
1065
|
+
};
|
|
1066
|
+
};
|
|
1067
|
+
_embedded?: {
|
|
1068
|
+
contacts?: Array<{
|
|
1069
|
+
id: number;
|
|
1070
|
+
_links?: {
|
|
1071
|
+
self?: {
|
|
1072
|
+
href: string;
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1075
|
+
}>;
|
|
1076
|
+
leads?: Array<{
|
|
1077
|
+
id: number;
|
|
1078
|
+
_links?: {
|
|
1079
|
+
self?: {
|
|
1080
|
+
href: string;
|
|
1081
|
+
};
|
|
1082
|
+
};
|
|
1083
|
+
}>;
|
|
1084
|
+
companies?: Array<{
|
|
1085
|
+
id: number;
|
|
1086
|
+
_links?: {
|
|
1087
|
+
self?: {
|
|
1088
|
+
href: string;
|
|
1089
|
+
};
|
|
1090
|
+
};
|
|
1091
|
+
}>;
|
|
1092
|
+
};
|
|
1093
|
+
}>;
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
interface UnsortedDecisionResponse {
|
|
1097
|
+
uid: string;
|
|
1098
|
+
pipeline_id: number;
|
|
1099
|
+
category: string;
|
|
1100
|
+
created_at: number;
|
|
1101
|
+
_embedded?: {
|
|
1102
|
+
contacts?: Array<{
|
|
1103
|
+
id: number;
|
|
1104
|
+
is_deleted?: boolean;
|
|
1105
|
+
is_unsorted?: boolean;
|
|
1106
|
+
}>;
|
|
1107
|
+
companies?: Array<{
|
|
1108
|
+
id: number;
|
|
1109
|
+
}>;
|
|
1110
|
+
leads?: Array<{
|
|
1111
|
+
id: number;
|
|
1112
|
+
}>;
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
interface LinkUnsortedLeadResponse {
|
|
1116
|
+
uid: string;
|
|
1117
|
+
_embedded?: {
|
|
1118
|
+
leads?: Array<{
|
|
1119
|
+
id: number;
|
|
1120
|
+
}>;
|
|
1121
|
+
contacts?: Array<{
|
|
1122
|
+
id: number;
|
|
1123
|
+
}>;
|
|
1124
|
+
companies?: Array<{
|
|
1125
|
+
id: number;
|
|
1126
|
+
}>;
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
interface UnsortedSummaryResponse {
|
|
1130
|
+
total: number;
|
|
1131
|
+
accepted: number;
|
|
1132
|
+
declined: number;
|
|
1133
|
+
average_sort_time: number;
|
|
1134
|
+
categories: {
|
|
1135
|
+
sip?: {
|
|
1136
|
+
total: number;
|
|
1137
|
+
};
|
|
1138
|
+
forms?: {
|
|
1139
|
+
total: number;
|
|
1140
|
+
};
|
|
1141
|
+
chats?: {
|
|
1142
|
+
total: number;
|
|
1143
|
+
};
|
|
1144
|
+
mail?: {
|
|
1145
|
+
total: number;
|
|
1146
|
+
};
|
|
1147
|
+
[key: string]: {
|
|
1148
|
+
total: number;
|
|
1149
|
+
} | undefined;
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
interface SipMetadata {
|
|
1153
|
+
from: string;
|
|
1154
|
+
phone: string;
|
|
1155
|
+
called_at: number;
|
|
1156
|
+
duration: number;
|
|
1157
|
+
link?: string;
|
|
1158
|
+
service_code?: string;
|
|
1159
|
+
is_call_event_needed?: boolean;
|
|
1160
|
+
call_responsible?: string;
|
|
1161
|
+
}
|
|
1162
|
+
interface FormMetadata {
|
|
1163
|
+
form_id: string | number;
|
|
1164
|
+
form_name: string;
|
|
1165
|
+
form_page: string;
|
|
1166
|
+
ip: string;
|
|
1167
|
+
form_sent_at: number;
|
|
1168
|
+
referer?: string;
|
|
1169
|
+
}
|
|
1170
|
+
interface CreateTagRef {
|
|
1171
|
+
id?: number;
|
|
1172
|
+
name?: string;
|
|
1173
|
+
}
|
|
1174
|
+
interface CreateUnsortedContact {
|
|
1175
|
+
id?: number;
|
|
1176
|
+
name?: string;
|
|
1177
|
+
first_name?: string;
|
|
1178
|
+
last_name?: string;
|
|
1179
|
+
responsible_user_id?: number;
|
|
1180
|
+
created_by?: number;
|
|
1181
|
+
updated_by?: string | number;
|
|
1182
|
+
created_at?: number;
|
|
1183
|
+
updated_at?: number;
|
|
1184
|
+
custom_fields_values?: unknown[] | string;
|
|
1185
|
+
request_id?: string;
|
|
1186
|
+
tags_to_add?: CreateTagRef[];
|
|
1187
|
+
}
|
|
1188
|
+
interface CreateUnsortedCompany {
|
|
1189
|
+
id?: string | number;
|
|
1190
|
+
name?: string;
|
|
1191
|
+
responsible_user_id?: number;
|
|
1192
|
+
created_by?: number;
|
|
1193
|
+
updated_by?: number;
|
|
1194
|
+
created_at?: number;
|
|
1195
|
+
updated_at?: number;
|
|
1196
|
+
custom_fields_values?: unknown[] | string;
|
|
1197
|
+
_embedded?: CreateTagRef[] | {
|
|
1198
|
+
tags?: CreateTagRef[];
|
|
1199
|
+
};
|
|
1200
|
+
request_id?: string;
|
|
1201
|
+
tags_to_add?: CreateTagRef[];
|
|
1202
|
+
}
|
|
1203
|
+
interface CreateUnsortedLead {
|
|
1204
|
+
name?: string;
|
|
1205
|
+
price?: number;
|
|
1206
|
+
status_id?: number;
|
|
1207
|
+
pipeline_id?: number;
|
|
1208
|
+
created_by?: number;
|
|
1209
|
+
updated_by?: number;
|
|
1210
|
+
created_at?: number;
|
|
1211
|
+
updated_at?: number;
|
|
1212
|
+
closed_at?: number;
|
|
1213
|
+
loss_reason_id?: string | number;
|
|
1214
|
+
responsible_user_id?: number;
|
|
1215
|
+
custom_fields_values?: unknown[] | string;
|
|
1216
|
+
_embedded?: {
|
|
1217
|
+
tags?: CreateTagRef[];
|
|
1218
|
+
contacts?: Array<{
|
|
1219
|
+
id: number;
|
|
1220
|
+
is_main?: boolean;
|
|
1221
|
+
}>;
|
|
1222
|
+
companies?: Array<{
|
|
1223
|
+
id: number;
|
|
1224
|
+
}>;
|
|
1225
|
+
source?: {
|
|
1226
|
+
external_id?: string;
|
|
1227
|
+
type?: string;
|
|
1228
|
+
};
|
|
1229
|
+
};
|
|
1230
|
+
tags_to_add?: CreateTagRef[];
|
|
1231
|
+
tags_to_delete?: CreateTagRef[];
|
|
1232
|
+
}
|
|
1233
|
+
interface BaseCreateUnsortedItem<TMetadata> {
|
|
1234
|
+
request_id?: string;
|
|
1235
|
+
source_uid: string;
|
|
1236
|
+
source_name: string;
|
|
1237
|
+
pipeline_id: number | string;
|
|
1238
|
+
created_at: number | string;
|
|
1239
|
+
metadata: TMetadata;
|
|
1240
|
+
_embedded?: {
|
|
1241
|
+
contacts?: CreateUnsortedContact[];
|
|
1242
|
+
companies?: CreateUnsortedCompany[];
|
|
1243
|
+
leads?: CreateUnsortedLead[];
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
type CreateSipUnsortedLeadInput = BaseCreateUnsortedItem<SipMetadata>;
|
|
1247
|
+
type CreateFormUnsortedLeadInput = BaseCreateUnsortedItem<FormMetadata>;
|
|
1248
|
+
interface ListUnsortedLeadsParams {
|
|
1249
|
+
page?: number;
|
|
1250
|
+
limit?: number;
|
|
1251
|
+
uid?: string | string[];
|
|
1252
|
+
category?: Array<'sip' | 'mail' | 'forms' | 'chats' | string>;
|
|
1253
|
+
pipeline_id?: number;
|
|
1254
|
+
order_created_at?: 'asc' | 'desc';
|
|
1255
|
+
}
|
|
1256
|
+
interface UnsortedSummaryParams {
|
|
1257
|
+
uid?: string | string[];
|
|
1258
|
+
created_at?: number;
|
|
1259
|
+
created_at_from?: number;
|
|
1260
|
+
created_at_to?: number;
|
|
1261
|
+
pipeline_id?: number;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
declare class UnsortedResource extends BaseResource {
|
|
1265
|
+
list(params?: ListUnsortedLeadsParams): Promise<ListUnsortedLeadsResponse>;
|
|
1266
|
+
getByUid(uid: string): Promise<UnsortedLead>;
|
|
1267
|
+
createSip(items: CreateSipUnsortedLeadInput | CreateSipUnsortedLeadInput[]): Promise<CreateUnsortedLeadsResponse>;
|
|
1268
|
+
createForms(items: CreateFormUnsortedLeadInput | CreateFormUnsortedLeadInput[]): Promise<CreateUnsortedLeadsResponse>;
|
|
1269
|
+
accept(uid: string, payload?: {
|
|
1270
|
+
user_id?: number;
|
|
1271
|
+
status_id?: number;
|
|
1272
|
+
}): Promise<UnsortedDecisionResponse>;
|
|
1273
|
+
decline(uid: string, payload?: {
|
|
1274
|
+
user_id?: number;
|
|
1275
|
+
}): Promise<UnsortedDecisionResponse>;
|
|
1276
|
+
link(uid: string, payload: {
|
|
1277
|
+
link: {
|
|
1278
|
+
user_id?: string | number;
|
|
1279
|
+
entity_id: string | number;
|
|
1280
|
+
entity_type: 'leads' | string;
|
|
1281
|
+
metadata?: {
|
|
1282
|
+
contact_id?: number;
|
|
1283
|
+
};
|
|
1284
|
+
};
|
|
1285
|
+
}): Promise<LinkUnsortedLeadResponse>;
|
|
1286
|
+
summary(params?: UnsortedSummaryParams): Promise<UnsortedSummaryResponse>;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
declare const KOMMO_PIPELINE_STAGE_COLORS: readonly ["#fffeb2", "#fffd7f", "#fff000", "#ffeab2", "#ffdc7f", "#ffce5a", "#ffdbdb", "#ffc8c8", "#ff8f92", "#d6eaff", "#c1e0ff", "#98cbff", "#ebffb1", "#deff81", "#87f2c0", "#f9deff", "#f3beff", "#ccc8f9", "#eb93ff", "#f2f3f4", "#e6e8ea"];
|
|
1290
|
+
type KommoPipelineStageColor = typeof KOMMO_PIPELINE_STAGE_COLORS[number];
|
|
1291
|
+
interface StatusDescription {
|
|
1292
|
+
level: 'newbie' | 'candidate' | 'master';
|
|
1293
|
+
description: string;
|
|
1294
|
+
}
|
|
1295
|
+
interface PipelineStatus {
|
|
1296
|
+
id: number;
|
|
1297
|
+
name: string;
|
|
1298
|
+
sort: number;
|
|
1299
|
+
is_editable: boolean;
|
|
1300
|
+
pipeline_id: number;
|
|
1301
|
+
color: string;
|
|
1302
|
+
type: 0 | 1 | number;
|
|
1303
|
+
account_id: number;
|
|
1304
|
+
request_id?: string;
|
|
1305
|
+
descriptions?: StatusDescription[];
|
|
1306
|
+
_links?: {
|
|
1307
|
+
self?: {
|
|
1308
|
+
href: string;
|
|
1309
|
+
};
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
interface Pipeline {
|
|
1313
|
+
id: number;
|
|
1314
|
+
name: string;
|
|
1315
|
+
sort: number;
|
|
1316
|
+
is_main: boolean;
|
|
1317
|
+
is_unsorted_on: boolean;
|
|
1318
|
+
is_archive: boolean;
|
|
1319
|
+
account_id: number | string;
|
|
1320
|
+
request_id?: string;
|
|
1321
|
+
_links?: {
|
|
1322
|
+
self?: {
|
|
1323
|
+
href: string;
|
|
1324
|
+
};
|
|
1325
|
+
};
|
|
1326
|
+
_embedded?: {
|
|
1327
|
+
statuses?: PipelineStatus[];
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
interface ListPipelinesResponse {
|
|
1331
|
+
_total_items?: number;
|
|
1332
|
+
_links?: {
|
|
1333
|
+
self?: {
|
|
1334
|
+
href: string;
|
|
1335
|
+
};
|
|
1336
|
+
};
|
|
1337
|
+
_embedded?: {
|
|
1338
|
+
pipelines?: Pipeline[];
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
interface CreatePipelineStatusInput {
|
|
1342
|
+
id?: number;
|
|
1343
|
+
name?: string;
|
|
1344
|
+
sort?: number;
|
|
1345
|
+
color?: KommoPipelineStageColor | string;
|
|
1346
|
+
request_id?: string;
|
|
1347
|
+
descriptions?: StatusDescription[];
|
|
1348
|
+
}
|
|
1349
|
+
interface CreatePipelineInput {
|
|
1350
|
+
name: string;
|
|
1351
|
+
sort?: number;
|
|
1352
|
+
is_main?: boolean;
|
|
1353
|
+
is_unsorted_on?: boolean;
|
|
1354
|
+
request_id?: string;
|
|
1355
|
+
_embedded?: {
|
|
1356
|
+
statuses?: CreatePipelineStatusInput[];
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
interface CreatePipelinesResponse {
|
|
1360
|
+
_total_items?: number;
|
|
1361
|
+
_links?: {
|
|
1362
|
+
self?: {
|
|
1363
|
+
href: string;
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
_embedded?: {
|
|
1367
|
+
pipelines?: Pipeline[];
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
interface UpdatePipelineInput {
|
|
1371
|
+
name?: string;
|
|
1372
|
+
sort?: number;
|
|
1373
|
+
is_main?: boolean;
|
|
1374
|
+
is_unsorted_on?: boolean;
|
|
1375
|
+
}
|
|
1376
|
+
interface ListPipelineStatusesResponse {
|
|
1377
|
+
_total_items?: number;
|
|
1378
|
+
_embedded?: {
|
|
1379
|
+
statuses?: PipelineStatus[];
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
interface CreateStatusInput {
|
|
1383
|
+
name: string;
|
|
1384
|
+
sort: number;
|
|
1385
|
+
color?: KommoPipelineStageColor | string;
|
|
1386
|
+
request_id?: string;
|
|
1387
|
+
descriptions?: StatusDescription[];
|
|
1388
|
+
}
|
|
1389
|
+
interface CreateStatusesResponse {
|
|
1390
|
+
_total_items?: number;
|
|
1391
|
+
_embedded?: {
|
|
1392
|
+
statuses?: PipelineStatus[];
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
interface UpdateStatusInput {
|
|
1396
|
+
name?: string;
|
|
1397
|
+
sort?: number;
|
|
1398
|
+
color?: KommoPipelineStageColor | string;
|
|
1399
|
+
descriptions?: StatusDescription[];
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
declare class PipelinesResource extends BaseResource {
|
|
1403
|
+
list(): Promise<ListPipelinesResponse>;
|
|
1404
|
+
getById(id: number): Promise<Pipeline>;
|
|
1405
|
+
create(items: CreatePipelineInput | CreatePipelineInput[]): Promise<CreatePipelinesResponse>;
|
|
1406
|
+
update(id: number, payload: UpdatePipelineInput): Promise<Pipeline>;
|
|
1407
|
+
delete(id: number): Promise<void>;
|
|
1408
|
+
listStatuses(pipelineId: number, params?: {
|
|
1409
|
+
with?: 'descriptions';
|
|
1410
|
+
}): Promise<ListPipelineStatusesResponse>;
|
|
1411
|
+
getStatusById(pipelineId: number, id: number | string, params?: {
|
|
1412
|
+
with?: 'descriptions';
|
|
1413
|
+
}): Promise<PipelineStatus>;
|
|
1414
|
+
createStatuses(pipelineId: number, items: CreateStatusInput | CreateStatusInput[]): Promise<CreateStatusesResponse>;
|
|
1415
|
+
updateStatus(pipelineId: number, id: number | string, payload: UpdateStatusInput): Promise<PipelineStatus>;
|
|
1416
|
+
deleteStatus(pipelineId: number, id: number | string): Promise<void>;
|
|
1417
|
+
private validateStatusDescriptions;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
interface CompanyTag {
|
|
1421
|
+
id?: number;
|
|
1422
|
+
name?: string;
|
|
1423
|
+
color?: string | null;
|
|
1424
|
+
}
|
|
1425
|
+
interface CompanyContactRef {
|
|
1426
|
+
id: number;
|
|
1427
|
+
_links?: {
|
|
1428
|
+
self?: {
|
|
1429
|
+
href: string;
|
|
1430
|
+
};
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
interface CompanyLeadRef {
|
|
1434
|
+
id: number;
|
|
1435
|
+
_links?: {
|
|
1436
|
+
self?: {
|
|
1437
|
+
href: string;
|
|
1438
|
+
};
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
interface CompanyCatalogElementRef {
|
|
1442
|
+
id: number;
|
|
1443
|
+
metadata?: Record<string, unknown>;
|
|
1444
|
+
quantity?: number;
|
|
1445
|
+
catalog_id?: number;
|
|
1446
|
+
}
|
|
1447
|
+
interface Company {
|
|
1448
|
+
id: number;
|
|
1449
|
+
name?: string | null;
|
|
1450
|
+
responsible_user_id?: number | null;
|
|
1451
|
+
group_id?: number | null;
|
|
1452
|
+
created_by?: number | null;
|
|
1453
|
+
updated_by?: number | null;
|
|
1454
|
+
created_at?: number | null;
|
|
1455
|
+
updated_at?: number | null;
|
|
1456
|
+
closest_task_at?: number | null;
|
|
1457
|
+
custom_fields_values?: unknown[] | null;
|
|
1458
|
+
account_id?: number | null;
|
|
1459
|
+
is_deleted?: boolean;
|
|
1460
|
+
_links?: {
|
|
1461
|
+
self?: {
|
|
1462
|
+
href: string;
|
|
1463
|
+
};
|
|
1464
|
+
};
|
|
1465
|
+
_embedded?: {
|
|
1466
|
+
tags?: CompanyTag[];
|
|
1467
|
+
contacts?: CompanyContactRef[];
|
|
1468
|
+
leads?: CompanyLeadRef[];
|
|
1469
|
+
catalog_elements?: CompanyCatalogElementRef[];
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
type CompanyWithParam = 'leads' | 'contacts' | 'catalog_elements';
|
|
1473
|
+
interface ListCompaniesParams {
|
|
1474
|
+
with?: CompanyWithParam[] | string;
|
|
1475
|
+
page?: number;
|
|
1476
|
+
limit?: number;
|
|
1477
|
+
query?: string;
|
|
1478
|
+
order_updated_at?: 'asc' | 'desc';
|
|
1479
|
+
order_id?: 'asc' | 'desc';
|
|
1480
|
+
filter_id?: number[];
|
|
1481
|
+
filter_name?: string[];
|
|
1482
|
+
filter_created_by?: number[];
|
|
1483
|
+
filter_updated_by?: number[];
|
|
1484
|
+
filter_responsible_user_id?: number[];
|
|
1485
|
+
filter_created_at_from?: number;
|
|
1486
|
+
filter_created_at_to?: number;
|
|
1487
|
+
filter_updated_at_from?: number;
|
|
1488
|
+
filter_updated_at_to?: number;
|
|
1489
|
+
filter_closest_task_at_from?: number;
|
|
1490
|
+
filter_closest_task_at_to?: number;
|
|
1491
|
+
}
|
|
1492
|
+
interface ListCompaniesResponse {
|
|
1493
|
+
_page: number;
|
|
1494
|
+
_links?: {
|
|
1495
|
+
self?: {
|
|
1496
|
+
href: string;
|
|
1497
|
+
};
|
|
1498
|
+
};
|
|
1499
|
+
_embedded?: {
|
|
1500
|
+
companies?: Company[];
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
interface CompanyTagRef {
|
|
1504
|
+
id?: number;
|
|
1505
|
+
name?: string;
|
|
1506
|
+
}
|
|
1507
|
+
interface CreateCompanyInput {
|
|
1508
|
+
request_id?: string;
|
|
1509
|
+
name?: string;
|
|
1510
|
+
responsible_user_id?: number;
|
|
1511
|
+
created_by?: number;
|
|
1512
|
+
updated_by?: number;
|
|
1513
|
+
created_at?: number;
|
|
1514
|
+
updated_at?: number;
|
|
1515
|
+
custom_fields_values?: unknown[] | string;
|
|
1516
|
+
_embedded?: {
|
|
1517
|
+
tags?: CompanyTagRef[];
|
|
1518
|
+
};
|
|
1519
|
+
tags_to_add?: CompanyTagRef[];
|
|
1520
|
+
}
|
|
1521
|
+
interface CreateCompaniesResponse {
|
|
1522
|
+
_links?: {
|
|
1523
|
+
self?: {
|
|
1524
|
+
href: string;
|
|
1525
|
+
};
|
|
1526
|
+
};
|
|
1527
|
+
_embedded?: {
|
|
1528
|
+
companies?: Array<{
|
|
1529
|
+
id: number;
|
|
1530
|
+
is_deleted: boolean;
|
|
1531
|
+
request_id?: string;
|
|
1532
|
+
_links?: {
|
|
1533
|
+
self?: {
|
|
1534
|
+
href: string;
|
|
1535
|
+
};
|
|
1536
|
+
};
|
|
1537
|
+
}>;
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
interface UpdateCompanyInput {
|
|
1541
|
+
id: number;
|
|
1542
|
+
request_id?: string;
|
|
1543
|
+
name?: string;
|
|
1544
|
+
responsible_user_id?: number;
|
|
1545
|
+
created_by?: number;
|
|
1546
|
+
updated_by?: number;
|
|
1547
|
+
created_at?: number;
|
|
1548
|
+
updated_at?: number;
|
|
1549
|
+
custom_fields_values?: unknown[] | string;
|
|
1550
|
+
_embedded?: {
|
|
1551
|
+
tags?: CompanyTagRef[];
|
|
1552
|
+
};
|
|
1553
|
+
tags_to_add?: CompanyTagRef[];
|
|
1554
|
+
tags_to_delete?: CompanyTagRef[];
|
|
1555
|
+
}
|
|
1556
|
+
interface UpdateCompaniesResponse {
|
|
1557
|
+
_links?: {
|
|
1558
|
+
self?: {
|
|
1559
|
+
href: string;
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
_embedded?: {
|
|
1563
|
+
companies?: Array<{
|
|
1564
|
+
id: number;
|
|
1565
|
+
name?: string;
|
|
1566
|
+
updated_at: number;
|
|
1567
|
+
is_deleted: boolean;
|
|
1568
|
+
_links?: {
|
|
1569
|
+
self?: {
|
|
1570
|
+
href: string;
|
|
1571
|
+
};
|
|
1572
|
+
};
|
|
1573
|
+
}>;
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
type UpdateSingleCompanyInput = Omit<UpdateCompanyInput, 'id'>;
|
|
1577
|
+
|
|
1578
|
+
declare class CompaniesResource extends BaseResource {
|
|
1579
|
+
list(params?: ListCompaniesParams): Promise<ListCompaniesResponse>;
|
|
1580
|
+
getById(id: number, params?: {
|
|
1581
|
+
with?: CompanyWithParam[] | string;
|
|
1582
|
+
}): Promise<Company | null>;
|
|
1583
|
+
create(items: CreateCompanyInput | CreateCompanyInput[]): Promise<CreateCompaniesResponse>;
|
|
1584
|
+
update(items: UpdateCompanyInput | UpdateCompanyInput[]): Promise<UpdateCompaniesResponse>;
|
|
1585
|
+
updateOne(id: number, payload: UpdateSingleCompanyInput): Promise<UpdateCompaniesResponse>;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
interface Catalog {
|
|
1589
|
+
id: number;
|
|
1590
|
+
name: string;
|
|
1591
|
+
created_by: number;
|
|
1592
|
+
updated_by: number;
|
|
1593
|
+
created_at: number;
|
|
1594
|
+
updated_at: number;
|
|
1595
|
+
sort: number;
|
|
1596
|
+
type: string;
|
|
1597
|
+
can_link_multiple: boolean;
|
|
1598
|
+
can_be_deleted: boolean;
|
|
1599
|
+
account_id: number;
|
|
1600
|
+
can_add_elements?: boolean;
|
|
1601
|
+
can_show_in_cards?: boolean;
|
|
1602
|
+
sdk_widget_code?: string | null;
|
|
1603
|
+
request_id?: string;
|
|
1604
|
+
_links?: {
|
|
1605
|
+
self?: {
|
|
1606
|
+
href: string;
|
|
1607
|
+
};
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
interface CatalogElementCustomFieldValue {
|
|
1611
|
+
field_id: number;
|
|
1612
|
+
field_name?: string;
|
|
1613
|
+
field_code?: string;
|
|
1614
|
+
field_type?: string;
|
|
1615
|
+
values: Array<{
|
|
1616
|
+
value: string | number | boolean | null;
|
|
1617
|
+
enum_id?: number;
|
|
1618
|
+
}>;
|
|
1619
|
+
}
|
|
1620
|
+
interface CatalogElement {
|
|
1621
|
+
id: number;
|
|
1622
|
+
catalog_id: number;
|
|
1623
|
+
name: string;
|
|
1624
|
+
created_by: number;
|
|
1625
|
+
updated_by: number;
|
|
1626
|
+
created_at: number;
|
|
1627
|
+
updated_at: number;
|
|
1628
|
+
is_deleted: boolean | null;
|
|
1629
|
+
custom_fields_values: unknown[] | null;
|
|
1630
|
+
account_id: number;
|
|
1631
|
+
request_id?: string;
|
|
1632
|
+
_links?: {
|
|
1633
|
+
self?: {
|
|
1634
|
+
href: string;
|
|
1635
|
+
};
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
interface ListCatalogsParams {
|
|
1639
|
+
page?: number;
|
|
1640
|
+
limit?: number;
|
|
1641
|
+
}
|
|
1642
|
+
interface ListCatalogsResponse {
|
|
1643
|
+
_page: number;
|
|
1644
|
+
_links?: {
|
|
1645
|
+
self?: {
|
|
1646
|
+
href: string;
|
|
1647
|
+
};
|
|
1648
|
+
next?: {
|
|
1649
|
+
href: string;
|
|
1650
|
+
};
|
|
1651
|
+
};
|
|
1652
|
+
_embedded?: {
|
|
1653
|
+
catalogs?: Catalog[];
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
interface CreateCatalogInput {
|
|
1657
|
+
name: string;
|
|
1658
|
+
type?: string;
|
|
1659
|
+
sort?: number;
|
|
1660
|
+
can_link_multiple?: boolean;
|
|
1661
|
+
request_id?: string;
|
|
1662
|
+
}
|
|
1663
|
+
interface CreateCatalogsResponse {
|
|
1664
|
+
_links?: {
|
|
1665
|
+
self?: {
|
|
1666
|
+
href: string;
|
|
1667
|
+
};
|
|
1668
|
+
};
|
|
1669
|
+
_embedded?: {
|
|
1670
|
+
catalogs?: Catalog[];
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
interface UpdateCatalogInput {
|
|
1674
|
+
id: number;
|
|
1675
|
+
name?: string;
|
|
1676
|
+
can_link_multiple?: boolean;
|
|
1677
|
+
request_id?: string;
|
|
1678
|
+
}
|
|
1679
|
+
type UpdateSingleCatalogInput = Omit<UpdateCatalogInput, 'id'>;
|
|
1680
|
+
type UpdateCatalogsResponse = Catalog[] | {
|
|
1681
|
+
_links?: {
|
|
1682
|
+
self?: {
|
|
1683
|
+
href: string;
|
|
1684
|
+
};
|
|
1685
|
+
};
|
|
1686
|
+
_embedded?: {
|
|
1687
|
+
catalogs?: Catalog[];
|
|
1688
|
+
};
|
|
1689
|
+
};
|
|
1690
|
+
interface ListCatalogElementsParams {
|
|
1691
|
+
page?: number;
|
|
1692
|
+
limit?: number;
|
|
1693
|
+
query?: string;
|
|
1694
|
+
filter_id?: number[];
|
|
1695
|
+
}
|
|
1696
|
+
interface ListCatalogElementsResponse {
|
|
1697
|
+
_page: number;
|
|
1698
|
+
_links?: {
|
|
1699
|
+
self?: {
|
|
1700
|
+
href: string;
|
|
1701
|
+
};
|
|
1702
|
+
next?: {
|
|
1703
|
+
href: string;
|
|
1704
|
+
};
|
|
1705
|
+
};
|
|
1706
|
+
_embedded?: {
|
|
1707
|
+
elements?: CatalogElement[];
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
interface CreateCatalogElementInput {
|
|
1711
|
+
name: string;
|
|
1712
|
+
custom_fields_values?: CatalogElementCustomFieldValue[] | string;
|
|
1713
|
+
request_id?: string;
|
|
1714
|
+
}
|
|
1715
|
+
interface CreateCatalogElementsResponse {
|
|
1716
|
+
_links?: {
|
|
1717
|
+
self?: {
|
|
1718
|
+
href: string;
|
|
1719
|
+
};
|
|
1720
|
+
};
|
|
1721
|
+
_embedded?: {
|
|
1722
|
+
elements?: CatalogElement[];
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
interface UpdateCatalogElementInput {
|
|
1726
|
+
id: number | string;
|
|
1727
|
+
name?: string;
|
|
1728
|
+
custom_fields_values?: CatalogElementCustomFieldValue[] | string;
|
|
1729
|
+
request_id?: string;
|
|
1730
|
+
}
|
|
1731
|
+
type UpdateSingleCatalogElementInput = Omit<UpdateCatalogElementInput, 'id'>;
|
|
1732
|
+
interface UpdateCatalogElementsResponse {
|
|
1733
|
+
_links?: {
|
|
1734
|
+
self?: {
|
|
1735
|
+
href: string;
|
|
1736
|
+
};
|
|
1737
|
+
};
|
|
1738
|
+
_embedded?: {
|
|
1739
|
+
elements?: CatalogElement[];
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
declare class CatalogsResource extends BaseResource {
|
|
1744
|
+
list(params?: ListCatalogsParams): Promise<ListCatalogsResponse>;
|
|
1745
|
+
getById(id: number): Promise<Catalog>;
|
|
1746
|
+
create(items: CreateCatalogInput | CreateCatalogInput[]): Promise<CreateCatalogsResponse>;
|
|
1747
|
+
update(items: UpdateCatalogInput | UpdateCatalogInput[]): Promise<UpdateCatalogsResponse>;
|
|
1748
|
+
updateOne(id: number, payload: UpdateSingleCatalogInput): Promise<Catalog>;
|
|
1749
|
+
listElements(listId: number, params?: ListCatalogElementsParams): Promise<ListCatalogElementsResponse>;
|
|
1750
|
+
getElementById(listId: number, elementId: number): Promise<CatalogElement>;
|
|
1751
|
+
createElements(listId: number, items: CreateCatalogElementInput | CreateCatalogElementInput[]): Promise<CreateCatalogElementsResponse>;
|
|
1752
|
+
updateElements(listId: number, items: UpdateCatalogElementInput | UpdateCatalogElementInput[]): Promise<UpdateCatalogElementsResponse>;
|
|
1753
|
+
updateElementById(listId: number, elementId: number, payload: UpdateSingleCatalogElementInput): Promise<CatalogElement>;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
type PermissionLevel = 'A' | 'G' | 'M' | 'D';
|
|
1757
|
+
interface EntityRights {
|
|
1758
|
+
view?: PermissionLevel;
|
|
1759
|
+
edit?: PermissionLevel;
|
|
1760
|
+
add?: PermissionLevel;
|
|
1761
|
+
delete?: PermissionLevel;
|
|
1762
|
+
export?: PermissionLevel;
|
|
1763
|
+
}
|
|
1764
|
+
interface StatusRight {
|
|
1765
|
+
entity_type: 'leads' | string;
|
|
1766
|
+
pipeline_id: number;
|
|
1767
|
+
status_id: number;
|
|
1768
|
+
rights: {
|
|
1769
|
+
view?: 'A' | 'D';
|
|
1770
|
+
edit?: 'A' | 'D';
|
|
1771
|
+
delete?: 'A' | 'D';
|
|
1772
|
+
export?: 'A' | 'D';
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
interface User {
|
|
1776
|
+
id: number;
|
|
1777
|
+
name: string;
|
|
1778
|
+
email: string;
|
|
1779
|
+
lang: 'ru' | 'en' | 'es' | 'pt' | string;
|
|
1780
|
+
rights: {
|
|
1781
|
+
leads?: EntityRights;
|
|
1782
|
+
contacts?: EntityRights;
|
|
1783
|
+
companies?: EntityRights;
|
|
1784
|
+
tasks?: EntityRights;
|
|
1785
|
+
mail_access?: boolean;
|
|
1786
|
+
catalog_access?: boolean;
|
|
1787
|
+
is_admin?: boolean;
|
|
1788
|
+
is_free?: boolean;
|
|
1789
|
+
is_active?: boolean;
|
|
1790
|
+
group_id?: number | null;
|
|
1791
|
+
role_id?: number | null;
|
|
1792
|
+
status_rights?: StatusRight[] | null;
|
|
1793
|
+
};
|
|
1794
|
+
uuid?: string | null;
|
|
1795
|
+
amojo_id?: string | null;
|
|
1796
|
+
user_rank?: 'newbie' | 'candidate' | 'master' | string;
|
|
1797
|
+
phone_number?: string | null;
|
|
1798
|
+
_links?: {
|
|
1799
|
+
self?: {
|
|
1800
|
+
href: string;
|
|
1801
|
+
};
|
|
1802
|
+
};
|
|
1803
|
+
_embedded?: {
|
|
1804
|
+
roles?: Array<{
|
|
1805
|
+
id: number;
|
|
1806
|
+
name: string;
|
|
1807
|
+
_links?: {
|
|
1808
|
+
self?: {
|
|
1809
|
+
href: string;
|
|
1810
|
+
};
|
|
1811
|
+
};
|
|
1812
|
+
}>;
|
|
1813
|
+
groups?: Array<{
|
|
1814
|
+
id: number;
|
|
1815
|
+
name: string;
|
|
1816
|
+
}>;
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
interface Role {
|
|
1820
|
+
id: number;
|
|
1821
|
+
name: string;
|
|
1822
|
+
rights: {
|
|
1823
|
+
leads?: EntityRights;
|
|
1824
|
+
contacts?: EntityRights;
|
|
1825
|
+
companies?: EntityRights;
|
|
1826
|
+
tasks?: EntityRights;
|
|
1827
|
+
status_rights?: StatusRight[] | null;
|
|
1828
|
+
mail_access?: boolean;
|
|
1829
|
+
catalog_access?: boolean;
|
|
1830
|
+
is_admin?: boolean;
|
|
1831
|
+
is_free?: boolean;
|
|
1832
|
+
is_active?: boolean;
|
|
1833
|
+
};
|
|
1834
|
+
request_id?: string;
|
|
1835
|
+
_links?: {
|
|
1836
|
+
self?: {
|
|
1837
|
+
href: string;
|
|
1838
|
+
};
|
|
1839
|
+
};
|
|
1840
|
+
_embedded?: {
|
|
1841
|
+
users?: Array<{
|
|
1842
|
+
id: number;
|
|
1843
|
+
}>;
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
type UserWithParam = 'role' | 'group' | 'uuid' | 'amojo_id' | 'user_rank' | 'phone_number';
|
|
1847
|
+
type RoleWithParam = 'users';
|
|
1848
|
+
interface ListUsersParams {
|
|
1849
|
+
with?: UserWithParam[] | string;
|
|
1850
|
+
page?: number;
|
|
1851
|
+
limit?: number;
|
|
1852
|
+
}
|
|
1853
|
+
interface ListUsersResponse {
|
|
1854
|
+
_total_items?: number;
|
|
1855
|
+
_page?: number;
|
|
1856
|
+
_page_count?: number;
|
|
1857
|
+
_links?: {
|
|
1858
|
+
self?: {
|
|
1859
|
+
href: string;
|
|
1860
|
+
};
|
|
1861
|
+
};
|
|
1862
|
+
_embedded?: {
|
|
1863
|
+
users?: User[];
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
interface CreateUserInput {
|
|
1867
|
+
name: string;
|
|
1868
|
+
email: string;
|
|
1869
|
+
password: string;
|
|
1870
|
+
lang?: 'ru' | 'en' | 'es' | 'pt' | string;
|
|
1871
|
+
rights?: {
|
|
1872
|
+
leads?: EntityRights;
|
|
1873
|
+
contacts?: EntityRights;
|
|
1874
|
+
companies?: EntityRights;
|
|
1875
|
+
tasks?: EntityRights;
|
|
1876
|
+
status_rights?: StatusRight[] | null;
|
|
1877
|
+
mail_access?: boolean;
|
|
1878
|
+
catalog_access?: boolean;
|
|
1879
|
+
is_free?: boolean;
|
|
1880
|
+
is_admin?: boolean;
|
|
1881
|
+
role_id?: number | null;
|
|
1882
|
+
group_id?: number | null;
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
interface ListRolesParams {
|
|
1886
|
+
with?: RoleWithParam[] | string;
|
|
1887
|
+
}
|
|
1888
|
+
interface ListRolesResponse {
|
|
1889
|
+
_total_items?: number;
|
|
1890
|
+
_embedded?: {
|
|
1891
|
+
roles?: Role[];
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
interface CreateRoleInput {
|
|
1895
|
+
name: string;
|
|
1896
|
+
rights?: {
|
|
1897
|
+
leads?: EntityRights;
|
|
1898
|
+
contacts?: EntityRights;
|
|
1899
|
+
companies?: EntityRights;
|
|
1900
|
+
tasks?: EntityRights;
|
|
1901
|
+
status_rights?: StatusRight[] | null;
|
|
1902
|
+
mail_access?: boolean;
|
|
1903
|
+
catalog_access?: boolean;
|
|
1904
|
+
};
|
|
1905
|
+
request_id?: string;
|
|
1906
|
+
}
|
|
1907
|
+
interface UpdateRoleInput {
|
|
1908
|
+
id: number;
|
|
1909
|
+
name?: string;
|
|
1910
|
+
rights?: {
|
|
1911
|
+
leads?: EntityRights;
|
|
1912
|
+
contacts?: EntityRights;
|
|
1913
|
+
companies?: EntityRights;
|
|
1914
|
+
tasks?: EntityRights;
|
|
1915
|
+
status_rights?: StatusRight[] | null;
|
|
1916
|
+
mail_access?: boolean;
|
|
1917
|
+
catalog_access?: boolean;
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
declare class UsersResource extends BaseResource {
|
|
1922
|
+
list(params?: ListUsersParams): Promise<ListUsersResponse>;
|
|
1923
|
+
getById(id: number, params?: {
|
|
1924
|
+
with?: UserWithParam[] | string;
|
|
1925
|
+
}): Promise<User>;
|
|
1926
|
+
create(items: CreateUserInput | CreateUserInput[]): Promise<ListUsersResponse>;
|
|
1927
|
+
}
|
|
1928
|
+
declare class RolesResource extends BaseResource {
|
|
1929
|
+
list(params?: ListRolesParams): Promise<ListRolesResponse>;
|
|
1930
|
+
getById(id: number, params?: {
|
|
1931
|
+
with?: RoleWithParam[] | string;
|
|
1932
|
+
}): Promise<Role>;
|
|
1933
|
+
create(items: CreateRoleInput | CreateRoleInput[]): Promise<ListRolesResponse>;
|
|
1934
|
+
update(items: UpdateRoleInput | UpdateRoleInput[]): Promise<ListRolesResponse>;
|
|
1935
|
+
delete(id: number): Promise<void>;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
type EventWithParam = 'contact_name' | 'lead_name' | 'company_name' | 'catalog_name' | 'catalog_element_name';
|
|
1939
|
+
type EventValueChange = Record<string, unknown> | {
|
|
1940
|
+
task?: {
|
|
1941
|
+
text?: string;
|
|
1942
|
+
};
|
|
1943
|
+
helpbot?: {
|
|
1944
|
+
id?: number;
|
|
1945
|
+
};
|
|
1946
|
+
transaction?: {
|
|
1947
|
+
id?: number;
|
|
1948
|
+
};
|
|
1949
|
+
note?: {
|
|
1950
|
+
id?: number;
|
|
1951
|
+
};
|
|
1952
|
+
nps?: {
|
|
1953
|
+
rate?: number;
|
|
1954
|
+
};
|
|
1955
|
+
message?: {
|
|
1956
|
+
id?: string;
|
|
1957
|
+
};
|
|
1958
|
+
tag?: {
|
|
1959
|
+
name?: string;
|
|
1960
|
+
};
|
|
1961
|
+
lead_status?: {
|
|
1962
|
+
id?: number;
|
|
1963
|
+
pipeline_id?: number;
|
|
1964
|
+
};
|
|
1965
|
+
responsible_user?: {
|
|
1966
|
+
id?: number;
|
|
1967
|
+
};
|
|
1968
|
+
task_deadline?: {
|
|
1969
|
+
timestamp?: number;
|
|
1970
|
+
};
|
|
1971
|
+
task_type?: {
|
|
1972
|
+
id?: number;
|
|
1973
|
+
};
|
|
1974
|
+
custom_field_value?: {
|
|
1975
|
+
field_id?: number;
|
|
1976
|
+
field_type?: number;
|
|
1977
|
+
enum_id?: number | null;
|
|
1978
|
+
text?: string;
|
|
1979
|
+
};
|
|
1980
|
+
link?: {
|
|
1981
|
+
entity?: {
|
|
1982
|
+
type?: string;
|
|
1983
|
+
id?: number;
|
|
1984
|
+
};
|
|
1985
|
+
};
|
|
1986
|
+
unlink?: {
|
|
1987
|
+
entity?: {
|
|
1988
|
+
type?: string;
|
|
1989
|
+
id?: number;
|
|
1990
|
+
};
|
|
1991
|
+
};
|
|
1992
|
+
};
|
|
1993
|
+
interface Event {
|
|
1994
|
+
id: string;
|
|
1995
|
+
type: string;
|
|
1996
|
+
entity_id: number;
|
|
1997
|
+
entity_type: string;
|
|
1998
|
+
created_by: number;
|
|
1999
|
+
created_at: number;
|
|
2000
|
+
value_after: EventValueChange[];
|
|
2001
|
+
value_before: EventValueChange[];
|
|
2002
|
+
account_id: number;
|
|
2003
|
+
_links?: {
|
|
2004
|
+
self?: {
|
|
2005
|
+
href: string;
|
|
2006
|
+
};
|
|
2007
|
+
};
|
|
2008
|
+
_embedded?: {
|
|
2009
|
+
entity?: {
|
|
2010
|
+
id: number;
|
|
2011
|
+
name?: string;
|
|
2012
|
+
_links?: {
|
|
2013
|
+
self?: {
|
|
2014
|
+
href: string;
|
|
2015
|
+
};
|
|
2016
|
+
};
|
|
2017
|
+
};
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
type KnownEventType = 'lead_added' | 'lead_deleted' | 'lead_restored' | 'lead_status_changed' | 'lead_linked' | 'lead_unlinked' | 'contact_added' | 'contact_deleted' | 'contact_restored' | 'contact_linked' | 'contact_unlinked' | 'company_added' | 'company_deleted' | 'company_restored' | 'company_linked' | 'company_unlinked' | 'task_added' | 'task_deleted' | 'task_completed' | 'task_type_changed' | 'task_text_changed' | 'task_deadline_changed' | 'task_result_added' | 'incoming_call' | 'outgoing_call' | 'incoming_mail' | 'outgoing_mail' | 'incoming_chat_message' | 'outgoing_chat_message' | 'entity_direct_message' | 'incoming_sms' | 'outgoing_sms' | 'entity_tag_added' | 'entity_tag_deleted' | 'entity_linked' | 'entity_unlinked' | 'sale_field_changed' | 'name_field_changed' | 'ltv_field_changed' | 'custom_field_value_changed' | 'entity_responsible_changed' | 'robot_replied' | 'intent_identified' | 'nps_rate_added' | 'link_followed' | 'common_note_added' | 'common_note_deleted' | 'attachment_note_added' | 'targeting_in_note_added' | 'targeting_out_note_added' | 'geo_note_added' | 'service_note_added' | 'site_visit_note_added' | 'entity_merged' | 'video_opened' | 'video_closed' | 'picture_opened' | 'picture_closed' | 'zoom_conference' | 'key_action_completed' | 'ai_result' | 'talk_created' | 'talk_closed' | 'conversation_answered' | 'meta_chat_subscription_added' | 'meta_chat_subscription_removed' | 'talk_missed_event' | 'page_mention' | 'dropbox_attachment' | `custom_field_${number}_value_changed` | string;
|
|
2021
|
+
interface EventValueFilters {
|
|
2022
|
+
leads_statuses?: Array<{
|
|
2023
|
+
pipeline_id: number;
|
|
2024
|
+
status_id: number;
|
|
2025
|
+
}>;
|
|
2026
|
+
responsible_user_id?: number[] | string;
|
|
2027
|
+
custom_field_values?: number[] | string;
|
|
2028
|
+
value?: string | number;
|
|
2029
|
+
}
|
|
2030
|
+
interface ListEventsParams {
|
|
2031
|
+
with?: EventWithParam[] | string;
|
|
2032
|
+
page?: number;
|
|
2033
|
+
limit?: number;
|
|
2034
|
+
filter_id?: string | string[];
|
|
2035
|
+
filter_created_at_from?: number;
|
|
2036
|
+
filter_created_at_to?: number;
|
|
2037
|
+
filter_created_by?: number[];
|
|
2038
|
+
filter_entity?: Array<'lead' | 'contact' | 'company' | 'task' | `catalog_${number}`> | string;
|
|
2039
|
+
filter_entity_id?: number[];
|
|
2040
|
+
filter_type?: KnownEventType[] | KnownEventType;
|
|
2041
|
+
filter_value_before?: EventValueFilters;
|
|
2042
|
+
filter_value_after?: EventValueFilters;
|
|
2043
|
+
}
|
|
2044
|
+
interface ListEventsResponse {
|
|
2045
|
+
_page: number;
|
|
2046
|
+
_links?: {
|
|
2047
|
+
self?: {
|
|
2048
|
+
href: string;
|
|
2049
|
+
};
|
|
2050
|
+
next?: {
|
|
2051
|
+
href: string;
|
|
2052
|
+
};
|
|
2053
|
+
};
|
|
2054
|
+
_embedded?: {
|
|
2055
|
+
events?: Event[];
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
interface EventTypeDefinition {
|
|
2059
|
+
key: string;
|
|
2060
|
+
type: number;
|
|
2061
|
+
lang: string;
|
|
2062
|
+
}
|
|
2063
|
+
interface ListEventTypesParams {
|
|
2064
|
+
language_code?: 'en' | 'es' | 'pt' | string;
|
|
2065
|
+
}
|
|
2066
|
+
interface ListEventTypesResponse {
|
|
2067
|
+
_total_items?: number;
|
|
2068
|
+
_links?: {
|
|
2069
|
+
self?: {
|
|
2070
|
+
href: string;
|
|
2071
|
+
};
|
|
2072
|
+
};
|
|
2073
|
+
_embedded?: {
|
|
2074
|
+
events_types?: EventTypeDefinition[];
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
declare const eventUtils: {
|
|
2078
|
+
isLeadStatusChanged: (event: Event) => boolean;
|
|
2079
|
+
isCustomFieldChanged: (event: Event) => boolean;
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2082
|
+
declare class EventsResource extends BaseResource {
|
|
2083
|
+
list(params?: ListEventsParams): Promise<ListEventsResponse>;
|
|
2084
|
+
getById(id: string, params?: {
|
|
2085
|
+
with?: EventWithParam[] | string;
|
|
2086
|
+
}): Promise<Event>;
|
|
2087
|
+
listTypes(params?: ListEventTypesParams): Promise<ListEventTypesResponse>;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
declare const KOMMO_TAG_COLORS: readonly ["EBEBEB", "D0D0D0", "F2DDF7", "D1A4DC", "FF8F92", "FFC8C8", "C7DB8C", "DDEBB5", "8699DA", "AABDFF", "FFCE5A", "FFE193", "90CDB0", "C6F4DE", "A9A5D7", "D8D5FF", "86C0FC", "832161", "6A0F49", "0C7C59", "10599D", "9D2B32", "247BA0"];
|
|
2091
|
+
type TagColor = typeof KOMMO_TAG_COLORS[number];
|
|
2092
|
+
type TagEntityType = 'leads' | 'contacts' | 'companies' | string;
|
|
2093
|
+
interface Tag {
|
|
2094
|
+
id: number;
|
|
2095
|
+
name: string;
|
|
2096
|
+
color?: TagColor | string;
|
|
2097
|
+
request_id?: string;
|
|
2098
|
+
}
|
|
2099
|
+
interface ListTagsParams {
|
|
2100
|
+
page?: number;
|
|
2101
|
+
limit?: number;
|
|
2102
|
+
query?: string;
|
|
2103
|
+
filter_id?: number[];
|
|
2104
|
+
filter_name?: string;
|
|
2105
|
+
}
|
|
2106
|
+
interface ListTagsResponse {
|
|
2107
|
+
_page: number;
|
|
2108
|
+
_links?: {
|
|
2109
|
+
self?: {
|
|
2110
|
+
href: string;
|
|
2111
|
+
};
|
|
2112
|
+
next?: {
|
|
2113
|
+
href: string;
|
|
2114
|
+
};
|
|
2115
|
+
};
|
|
2116
|
+
_embedded?: {
|
|
2117
|
+
tags?: Tag[];
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
interface CreateTagInput {
|
|
2121
|
+
name: string;
|
|
2122
|
+
color?: TagColor | string;
|
|
2123
|
+
request_id?: string;
|
|
2124
|
+
}
|
|
2125
|
+
interface CreateTagsResponse {
|
|
2126
|
+
_total_items?: number;
|
|
2127
|
+
_embedded?: {
|
|
2128
|
+
tags?: Array<{
|
|
2129
|
+
id: number;
|
|
2130
|
+
name: string;
|
|
2131
|
+
request_id?: string;
|
|
2132
|
+
}>;
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
interface TagRefInput {
|
|
2136
|
+
id?: number;
|
|
2137
|
+
name?: string;
|
|
2138
|
+
}
|
|
2139
|
+
interface UpdateEntityTagsInput {
|
|
2140
|
+
id: number;
|
|
2141
|
+
_embedded: {
|
|
2142
|
+
tags: TagRefInput[] | null;
|
|
2143
|
+
};
|
|
2144
|
+
}
|
|
2145
|
+
interface EntityUpdateResult {
|
|
2146
|
+
id: number;
|
|
2147
|
+
updated_at: number;
|
|
2148
|
+
_links?: {
|
|
2149
|
+
self?: {
|
|
2150
|
+
href: string;
|
|
2151
|
+
};
|
|
2152
|
+
};
|
|
2153
|
+
}
|
|
2154
|
+
interface UpdateEntityTagsBatchResponse {
|
|
2155
|
+
_links?: {
|
|
2156
|
+
self?: {
|
|
2157
|
+
href: string;
|
|
2158
|
+
};
|
|
2159
|
+
};
|
|
2160
|
+
_embedded?: {
|
|
2161
|
+
leads?: Array<EntityUpdateResult>;
|
|
2162
|
+
contacts?: Array<EntityUpdateResult>;
|
|
2163
|
+
companies?: Array<EntityUpdateResult>;
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
interface UpdateSingleEntityTagsInput {
|
|
2167
|
+
_embedded: {
|
|
2168
|
+
tags: TagRefInput[] | null;
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
interface UpdateEntityTagsSingleResponse {
|
|
2172
|
+
_links?: {
|
|
2173
|
+
self?: {
|
|
2174
|
+
href: string;
|
|
2175
|
+
};
|
|
2176
|
+
};
|
|
2177
|
+
_embedded?: {
|
|
2178
|
+
leads?: Array<EntityUpdateResult>;
|
|
2179
|
+
contacts?: Array<EntityUpdateResult>;
|
|
2180
|
+
companies?: Array<EntityUpdateResult>;
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
declare class TagsResource extends BaseResource {
|
|
2185
|
+
list(entityType: TagEntityType, params?: ListTagsParams): Promise<ListTagsResponse>;
|
|
2186
|
+
create(entityType: TagEntityType, items: CreateTagInput | CreateTagInput[]): Promise<CreateTagsResponse>;
|
|
2187
|
+
updateForMany(entityType: TagEntityType, items: UpdateEntityTagsInput | UpdateEntityTagsInput[]): Promise<UpdateEntityTagsBatchResponse>;
|
|
2188
|
+
updateForOne(entityType: TagEntityType, id: number, payload: UpdateSingleEntityTagsInput): Promise<UpdateEntityTagsSingleResponse>;
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
type LinkSourceEntityType = 'leads' | 'contacts' | 'companies' | string;
|
|
2192
|
+
type LinkTargetEntityType = 'leads' | 'contacts' | 'companies' | 'catalog_elements' | string;
|
|
2193
|
+
interface LinkMetadataInput {
|
|
2194
|
+
catalog_id?: number;
|
|
2195
|
+
quantity?: number;
|
|
2196
|
+
is_main?: boolean;
|
|
2197
|
+
updated_by?: number;
|
|
2198
|
+
}
|
|
2199
|
+
interface EntityLinkMetadata {
|
|
2200
|
+
main_contact?: boolean;
|
|
2201
|
+
quantity?: number;
|
|
2202
|
+
catalog_id?: number;
|
|
2203
|
+
updated_by?: number;
|
|
2204
|
+
}
|
|
2205
|
+
interface EntityLink {
|
|
2206
|
+
to_entity_id: number;
|
|
2207
|
+
to_entity_type: LinkTargetEntityType;
|
|
2208
|
+
metadata?: EntityLinkMetadata | null;
|
|
2209
|
+
}
|
|
2210
|
+
interface EntityLinkWithSource extends EntityLink {
|
|
2211
|
+
entity_id?: number;
|
|
2212
|
+
entity_type?: LinkSourceEntityType;
|
|
2213
|
+
}
|
|
2214
|
+
interface ListEntityLinksParams {
|
|
2215
|
+
filter_to_entity_id?: number;
|
|
2216
|
+
filter_to_entity_type?: LinkTargetEntityType;
|
|
2217
|
+
filter_to_catalog_id?: number;
|
|
2218
|
+
}
|
|
2219
|
+
interface ListEntityLinksResponse {
|
|
2220
|
+
_total_items?: number;
|
|
2221
|
+
_links?: {
|
|
2222
|
+
self?: {
|
|
2223
|
+
href: string;
|
|
2224
|
+
};
|
|
2225
|
+
};
|
|
2226
|
+
_embedded?: {
|
|
2227
|
+
links?: EntityLink[];
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
interface CreateEntityLinkInput {
|
|
2231
|
+
to_entity_id: number;
|
|
2232
|
+
to_entity_type: LinkTargetEntityType;
|
|
2233
|
+
metadata?: LinkMetadataInput;
|
|
2234
|
+
}
|
|
2235
|
+
interface CreateEntityLinksResponse {
|
|
2236
|
+
_total_items?: number;
|
|
2237
|
+
_links?: {
|
|
2238
|
+
self?: {
|
|
2239
|
+
href: string;
|
|
2240
|
+
};
|
|
2241
|
+
};
|
|
2242
|
+
_embedded?: {
|
|
2243
|
+
links?: EntityLinkWithSource[];
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
interface DeleteEntityLinkInput {
|
|
2247
|
+
to_entity_type: LinkTargetEntityType;
|
|
2248
|
+
to_entity_id: number;
|
|
2249
|
+
metadata?: {
|
|
2250
|
+
catalog_id?: number;
|
|
2251
|
+
updated_by?: number;
|
|
2252
|
+
};
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
declare class LinksResource extends BaseResource {
|
|
2256
|
+
list(entity: LinkSourceEntityType, entityId: number, params?: ListEntityLinksParams): Promise<ListEntityLinksResponse>;
|
|
2257
|
+
link(entity: LinkSourceEntityType, entityId: number, items: CreateEntityLinkInput | CreateEntityLinkInput[]): Promise<CreateEntityLinksResponse>;
|
|
2258
|
+
unlink(entity: LinkSourceEntityType, entityId: number, items: DeleteEntityLinkInput | DeleteEntityLinkInput[]): Promise<void>;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
type SalesbotFunctionalityType = 'regular' | 'greeting' | 'marketing' | 'nps' | string;
|
|
2262
|
+
interface Salesbot {
|
|
2263
|
+
id: number;
|
|
2264
|
+
name: string;
|
|
2265
|
+
is_visual_editor: boolean;
|
|
2266
|
+
type_functionality: SalesbotFunctionalityType;
|
|
2267
|
+
settings: {
|
|
2268
|
+
active: boolean;
|
|
2269
|
+
};
|
|
2270
|
+
is_favorite?: boolean;
|
|
2271
|
+
_links?: {
|
|
2272
|
+
self?: {
|
|
2273
|
+
href: string;
|
|
2274
|
+
};
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
interface ListSalesbotsParams {
|
|
2278
|
+
page?: number;
|
|
2279
|
+
limit?: number;
|
|
2280
|
+
filter_type_functionality?: SalesbotFunctionalityType[];
|
|
2281
|
+
filter_id?: number[];
|
|
2282
|
+
with?: 'favorite' | string;
|
|
2283
|
+
}
|
|
2284
|
+
interface ListSalesbotsResponse {
|
|
2285
|
+
_total_items?: number;
|
|
2286
|
+
_page?: number;
|
|
2287
|
+
_page_count?: number;
|
|
2288
|
+
_links?: {
|
|
2289
|
+
self?: {
|
|
2290
|
+
href: string;
|
|
2291
|
+
};
|
|
2292
|
+
};
|
|
2293
|
+
_embedded?: {
|
|
2294
|
+
items?: Salesbot[];
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
interface RunSalesbotInput {
|
|
2298
|
+
entity_id: number;
|
|
2299
|
+
entity_type: 'leads' | 'contacts' | string;
|
|
2300
|
+
}
|
|
2301
|
+
interface RunManySalesbotsItem {
|
|
2302
|
+
bot_id: number;
|
|
2303
|
+
entity_id: number;
|
|
2304
|
+
entity_type: 'leads' | 'contacts' | string;
|
|
2305
|
+
}
|
|
2306
|
+
interface StopSalesbotInput {
|
|
2307
|
+
entity_id: number | string;
|
|
2308
|
+
entity_type: 'leads' | string;
|
|
2309
|
+
}
|
|
2310
|
+
type SalesbotContinueBotType = 'marketingbot' | 'salesbot' | string;
|
|
2311
|
+
type SalesbotExecuteHandler = {
|
|
2312
|
+
handler: 'show';
|
|
2313
|
+
params: {
|
|
2314
|
+
type: 'text';
|
|
2315
|
+
value: string;
|
|
2316
|
+
} | {
|
|
2317
|
+
type: 'buttons';
|
|
2318
|
+
value: string;
|
|
2319
|
+
buttons: string[];
|
|
2320
|
+
} | {
|
|
2321
|
+
type: 'buttons_url';
|
|
2322
|
+
value: string;
|
|
2323
|
+
buttons: string[];
|
|
2324
|
+
};
|
|
2325
|
+
} | {
|
|
2326
|
+
handler: 'goto';
|
|
2327
|
+
params: {
|
|
2328
|
+
type: 'question' | 'answer' | 'finish' | 'question|answer|finish' | string;
|
|
2329
|
+
step: number;
|
|
2330
|
+
};
|
|
2331
|
+
};
|
|
2332
|
+
interface SalesbotContinueInput {
|
|
2333
|
+
data?: Record<string, unknown>;
|
|
2334
|
+
execute_handlers?: SalesbotExecuteHandler[];
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
declare class SalesbotsResource extends BaseResource {
|
|
2338
|
+
list(params?: ListSalesbotsParams): Promise<ListSalesbotsResponse>;
|
|
2339
|
+
run(botId: number | string, payload: RunSalesbotInput): Promise<void>;
|
|
2340
|
+
runMany(items: RunManySalesbotsItem | RunManySalesbotsItem[]): Promise<void>;
|
|
2341
|
+
stop(botId: number, payload: StopSalesbotInput): Promise<void>;
|
|
2342
|
+
continueWidgetExecution(bot: SalesbotContinueBotType, botId: number, continueId: number, payload: SalesbotContinueInput): Promise<void>;
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
interface SourceServicePage {
|
|
2346
|
+
name: string;
|
|
2347
|
+
id: string;
|
|
2348
|
+
link: string;
|
|
2349
|
+
}
|
|
2350
|
+
interface SourceService {
|
|
2351
|
+
type?: string;
|
|
2352
|
+
params?: {
|
|
2353
|
+
waba?: boolean;
|
|
2354
|
+
is_supports_list_message?: boolean;
|
|
2355
|
+
};
|
|
2356
|
+
pages?: SourceServicePage[];
|
|
2357
|
+
}
|
|
2358
|
+
interface Source {
|
|
2359
|
+
id: number;
|
|
2360
|
+
name: string;
|
|
2361
|
+
pipeline_id: number | null;
|
|
2362
|
+
external_id: string;
|
|
2363
|
+
default?: boolean | null;
|
|
2364
|
+
services?: SourceService[] | unknown[];
|
|
2365
|
+
origin_code?: string | null;
|
|
2366
|
+
request_id?: string;
|
|
2367
|
+
_links?: {
|
|
2368
|
+
self?: {
|
|
2369
|
+
href: string;
|
|
2370
|
+
};
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
interface ListSourcesResponse {
|
|
2374
|
+
_total_items?: number;
|
|
2375
|
+
_embedded?: {
|
|
2376
|
+
sources?: Source[];
|
|
2377
|
+
};
|
|
2378
|
+
}
|
|
2379
|
+
interface CreateSourceInput {
|
|
2380
|
+
name: string;
|
|
2381
|
+
pipeline_id?: number | null;
|
|
2382
|
+
external_id: string;
|
|
2383
|
+
default?: boolean | null;
|
|
2384
|
+
origin_code?: string | null;
|
|
2385
|
+
services?: SourceService[] | Record<string, unknown>;
|
|
2386
|
+
request_id?: string;
|
|
2387
|
+
}
|
|
2388
|
+
interface CreateSourcesResponse {
|
|
2389
|
+
_total_items?: number;
|
|
2390
|
+
_embedded?: {
|
|
2391
|
+
sources?: Source[];
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
interface UpdateSourceInput {
|
|
2395
|
+
name?: string;
|
|
2396
|
+
pipeline_id?: number | null;
|
|
2397
|
+
external_id?: string;
|
|
2398
|
+
default?: boolean | null;
|
|
2399
|
+
origin_code?: string | null;
|
|
2400
|
+
services?: SourceService[] | Record<string, unknown>;
|
|
2401
|
+
}
|
|
2402
|
+
interface UpdateSourceBatchInput extends UpdateSourceInput {
|
|
2403
|
+
id: number;
|
|
2404
|
+
}
|
|
2405
|
+
interface UpdateSourcesResponse {
|
|
2406
|
+
_total_items?: number;
|
|
2407
|
+
_embedded?: {
|
|
2408
|
+
sources?: Source[];
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
interface DeleteSourceBatchInput {
|
|
2412
|
+
id: number;
|
|
2413
|
+
}
|
|
2414
|
+
type WebsiteButtonCreationStatus = 'created' | 'creation_pending' | string;
|
|
2415
|
+
interface WebsiteButton {
|
|
2416
|
+
account_id: number;
|
|
2417
|
+
source_id: number;
|
|
2418
|
+
button_id: number;
|
|
2419
|
+
is_duplication_control_enabled: boolean;
|
|
2420
|
+
name: string;
|
|
2421
|
+
creation_status: WebsiteButtonCreationStatus;
|
|
2422
|
+
pipeline_id: number | null;
|
|
2423
|
+
script?: string | null;
|
|
2424
|
+
}
|
|
2425
|
+
interface ListWebsiteButtonsParams {
|
|
2426
|
+
with?: 'scripts' | string;
|
|
2427
|
+
page?: number;
|
|
2428
|
+
limit?: number;
|
|
2429
|
+
}
|
|
2430
|
+
interface ListWebsiteButtonsResponse {
|
|
2431
|
+
_page?: number;
|
|
2432
|
+
_links?: {
|
|
2433
|
+
self?: {
|
|
2434
|
+
href: string;
|
|
2435
|
+
};
|
|
2436
|
+
};
|
|
2437
|
+
_embedded?: {
|
|
2438
|
+
website_buttons?: WebsiteButton[];
|
|
2439
|
+
};
|
|
2440
|
+
}
|
|
2441
|
+
interface CreateWebsiteButtonInput {
|
|
2442
|
+
pipeline_id: number;
|
|
2443
|
+
trusted_websites?: string[];
|
|
2444
|
+
is_used_in_app?: boolean;
|
|
2445
|
+
}
|
|
2446
|
+
interface CreateWebsiteButtonResponse {
|
|
2447
|
+
source_id: number;
|
|
2448
|
+
trusted_websites: string[];
|
|
2449
|
+
}
|
|
2450
|
+
interface UpdateWebsiteButtonInput {
|
|
2451
|
+
trusted_websites: string[];
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
declare class SourcesResource extends BaseResource {
|
|
2455
|
+
list(): Promise<ListSourcesResponse>;
|
|
2456
|
+
getById(id: number): Promise<Source>;
|
|
2457
|
+
create(items: CreateSourceInput | CreateSourceInput[]): Promise<CreateSourcesResponse>;
|
|
2458
|
+
updateOne(id: number, payload: UpdateSourceInput): Promise<Source>;
|
|
2459
|
+
update(items: UpdateSourceBatchInput | UpdateSourceBatchInput[]): Promise<UpdateSourcesResponse>;
|
|
2460
|
+
deleteOne(id: number): Promise<void>;
|
|
2461
|
+
delete(items: DeleteSourceBatchInput | DeleteSourceBatchInput[]): Promise<void>;
|
|
2462
|
+
}
|
|
2463
|
+
declare class WebsiteButtonsResource extends BaseResource {
|
|
2464
|
+
list(params?: ListWebsiteButtonsParams): Promise<ListWebsiteButtonsResponse>;
|
|
2465
|
+
getBySourceId(sourceId: number, params?: {
|
|
2466
|
+
with?: 'scripts' | string;
|
|
2467
|
+
}): Promise<WebsiteButton>;
|
|
2468
|
+
create(payload: CreateWebsiteButtonInput): Promise<CreateWebsiteButtonResponse>;
|
|
2469
|
+
connectOnlineChat(sourceId: number | string): Promise<void>;
|
|
2470
|
+
update(sourceId: number, payload: UpdateWebsiteButtonInput): Promise<WebsiteButton>;
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
type ChatTemplateType = 'waba' | 'amocrm' | string;
|
|
2474
|
+
type ChatTemplateButtonType = 'inline' | 'url' | string;
|
|
2475
|
+
type WabaCategory = 'UTILITY' | 'AUTHENTICATION' | 'MARKETING' | string;
|
|
2476
|
+
type WabaHeaderType = 'text' | 'media' | string;
|
|
2477
|
+
type WabaReviewStatus = 'approved' | 'review' | 'paused' | 'rejected' | string;
|
|
2478
|
+
interface ChatTemplateButton {
|
|
2479
|
+
type: ChatTemplateButtonType;
|
|
2480
|
+
text: string;
|
|
2481
|
+
url?: string;
|
|
2482
|
+
}
|
|
2483
|
+
interface ChatTemplateAttachment {
|
|
2484
|
+
id: string;
|
|
2485
|
+
name: string;
|
|
2486
|
+
type: 'picture' | 'file' | 'document' | 'video' | string;
|
|
2487
|
+
is_external?: boolean;
|
|
2488
|
+
}
|
|
2489
|
+
interface ChatTemplateReview {
|
|
2490
|
+
id: number;
|
|
2491
|
+
source_id: number;
|
|
2492
|
+
status: WabaReviewStatus;
|
|
2493
|
+
reject_reason: string;
|
|
2494
|
+
}
|
|
2495
|
+
interface ChatTemplate {
|
|
2496
|
+
id: number;
|
|
2497
|
+
account_id: number;
|
|
2498
|
+
name: string;
|
|
2499
|
+
content: string;
|
|
2500
|
+
is_editable: boolean;
|
|
2501
|
+
type: ChatTemplateType;
|
|
2502
|
+
buttons?: ChatTemplateButton[];
|
|
2503
|
+
attachment?: ChatTemplateAttachment | null;
|
|
2504
|
+
created_at: number;
|
|
2505
|
+
updated_at: number;
|
|
2506
|
+
external_id?: string;
|
|
2507
|
+
request_id?: string;
|
|
2508
|
+
review_status?: WabaReviewStatus | null;
|
|
2509
|
+
is_on_review?: boolean | null;
|
|
2510
|
+
waba_footer?: string;
|
|
2511
|
+
waba_category?: WabaCategory;
|
|
2512
|
+
waba_language?: string;
|
|
2513
|
+
waba_examples?: Record<string, string>;
|
|
2514
|
+
waba_header?: string | null;
|
|
2515
|
+
waba_header_type?: WabaHeaderType;
|
|
2516
|
+
_embedded?: {
|
|
2517
|
+
reviews?: ChatTemplateReview[];
|
|
2518
|
+
};
|
|
2519
|
+
_links?: {
|
|
2520
|
+
self?: {
|
|
2521
|
+
href: string;
|
|
2522
|
+
};
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
interface ListChatTemplatesParams {
|
|
2526
|
+
page?: number;
|
|
2527
|
+
limit?: number;
|
|
2528
|
+
filter_external_id?: string[];
|
|
2529
|
+
with?: 'reviews' | string;
|
|
2530
|
+
}
|
|
2531
|
+
interface ListChatTemplatesResponse {
|
|
2532
|
+
_page: number;
|
|
2533
|
+
_links?: {
|
|
2534
|
+
self?: {
|
|
2535
|
+
href: string;
|
|
2536
|
+
};
|
|
2537
|
+
next?: {
|
|
2538
|
+
href: string;
|
|
2539
|
+
};
|
|
2540
|
+
};
|
|
2541
|
+
_embedded?: {
|
|
2542
|
+
chat_templates?: ChatTemplate[];
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
interface CreateChatTemplateInput {
|
|
2546
|
+
name: string;
|
|
2547
|
+
content: string;
|
|
2548
|
+
is_editable?: boolean;
|
|
2549
|
+
type?: ChatTemplateType;
|
|
2550
|
+
buttons?: ChatTemplateButton[];
|
|
2551
|
+
attachment?: ChatTemplateAttachment | null;
|
|
2552
|
+
external_id?: string;
|
|
2553
|
+
waba_footer?: string;
|
|
2554
|
+
waba_category?: WabaCategory;
|
|
2555
|
+
waba_language?: string;
|
|
2556
|
+
waba_examples?: Record<string, string>;
|
|
2557
|
+
waba_header?: string | null;
|
|
2558
|
+
waba_header_type?: WabaHeaderType;
|
|
2559
|
+
request_id?: string;
|
|
2560
|
+
}
|
|
2561
|
+
interface CreateChatTemplatesResponse {
|
|
2562
|
+
_total_items?: number;
|
|
2563
|
+
_embedded?: {
|
|
2564
|
+
chat_templates?: ChatTemplate[];
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
interface UpdateChatTemplateInput {
|
|
2568
|
+
id: number;
|
|
2569
|
+
name?: string;
|
|
2570
|
+
content?: string;
|
|
2571
|
+
is_editable?: boolean;
|
|
2572
|
+
type?: ChatTemplateType;
|
|
2573
|
+
buttons?: ChatTemplateButton[];
|
|
2574
|
+
attachment?: ChatTemplateAttachment | null;
|
|
2575
|
+
external_id?: string;
|
|
2576
|
+
waba_footer?: string;
|
|
2577
|
+
waba_category?: WabaCategory;
|
|
2578
|
+
waba_language?: string;
|
|
2579
|
+
waba_examples?: Record<string, string>;
|
|
2580
|
+
waba_header?: string | null;
|
|
2581
|
+
waba_header_type?: WabaHeaderType;
|
|
2582
|
+
}
|
|
2583
|
+
interface UpdateChatTemplatesResponse {
|
|
2584
|
+
_embedded?: {
|
|
2585
|
+
chat_templates?: ChatTemplate[];
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
interface SubmitWhatsAppTemplateReviewResponse {
|
|
2589
|
+
_embedded?: {
|
|
2590
|
+
reviews?: ChatTemplateReview[];
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
type WhatsAppTemplateModerationStatus = 'approved' | 'paused' | 'rejected' | string;
|
|
2594
|
+
interface UpdateWhatsAppTemplateReviewStatusInput {
|
|
2595
|
+
status: WhatsAppTemplateModerationStatus;
|
|
2596
|
+
reject_reason?: string;
|
|
2597
|
+
}
|
|
2598
|
+
interface UpdateWhatsAppTemplateReviewStatusResponse {
|
|
2599
|
+
id: number;
|
|
2600
|
+
source_id: number;
|
|
2601
|
+
status: WhatsAppTemplateModerationStatus;
|
|
2602
|
+
reject_reason: string;
|
|
2603
|
+
}
|
|
2604
|
+
interface DeleteChatTemplateInput {
|
|
2605
|
+
id: number;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
declare class ChatTemplatesResource extends BaseResource {
|
|
2609
|
+
list(params?: ListChatTemplatesParams): Promise<ListChatTemplatesResponse>;
|
|
2610
|
+
getById(id: number, params?: {
|
|
2611
|
+
with?: 'reviews' | string;
|
|
2612
|
+
}): Promise<ChatTemplate>;
|
|
2613
|
+
create(items: CreateChatTemplateInput | CreateChatTemplateInput[]): Promise<CreateChatTemplatesResponse>;
|
|
2614
|
+
update(items: UpdateChatTemplateInput | UpdateChatTemplateInput[]): Promise<UpdateChatTemplatesResponse>;
|
|
2615
|
+
submitForReview(id: number): Promise<SubmitWhatsAppTemplateReviewResponse>;
|
|
2616
|
+
updateReviewStatus(id: number, reviewId: number, payload: UpdateWhatsAppTemplateReviewStatusInput): Promise<UpdateWhatsAppTemplateReviewStatusResponse>;
|
|
2617
|
+
delete(items: DeleteChatTemplateInput | DeleteChatTemplateInput[]): Promise<void>;
|
|
2618
|
+
deleteOne(id: number): Promise<void>;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
declare const KNOWN_WEBHOOK_EVENTS: readonly ["add_lead", "update_lead", "delete_lead", "restore_lead", "add_contact", "update_contact", "delete_contact", "restore_contact", "add_company", "update_company", "delete_company", "restore_company", "add_task", "update_task", "delete_task"];
|
|
2622
|
+
type WebhookEvent = typeof KNOWN_WEBHOOK_EVENTS[number] | string;
|
|
2623
|
+
interface Webhook {
|
|
2624
|
+
id: number;
|
|
2625
|
+
destination: string;
|
|
2626
|
+
created_at: number;
|
|
2627
|
+
updated_at: number;
|
|
2628
|
+
account_id: number;
|
|
2629
|
+
created_by: number;
|
|
2630
|
+
sort: number;
|
|
2631
|
+
disabled: boolean;
|
|
2632
|
+
settings: WebhookEvent[];
|
|
2633
|
+
}
|
|
2634
|
+
interface ListWebhooksParams {
|
|
2635
|
+
filter_destination?: string;
|
|
2636
|
+
}
|
|
2637
|
+
interface ListWebhooksResponse {
|
|
2638
|
+
_total_items?: number;
|
|
2639
|
+
_embedded?: {
|
|
2640
|
+
webhooks?: Webhook[];
|
|
2641
|
+
};
|
|
2642
|
+
}
|
|
2643
|
+
interface CreateWebhookInput {
|
|
2644
|
+
destination: string;
|
|
2645
|
+
settings: WebhookEvent[];
|
|
2646
|
+
sort?: number;
|
|
2647
|
+
}
|
|
2648
|
+
interface DeleteWebhookInput {
|
|
2649
|
+
destination: string;
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
declare class WebhooksResource extends BaseResource {
|
|
2653
|
+
list(params?: ListWebhooksParams): Promise<ListWebhooksResponse>;
|
|
2654
|
+
create(payload: CreateWebhookInput): Promise<Webhook>;
|
|
2655
|
+
delete(payload: DeleteWebhookInput): Promise<void>;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
declare class KommoClient {
|
|
2659
|
+
config: KommoConfig;
|
|
2660
|
+
auth: AuthManager;
|
|
2661
|
+
httpClient: AxiosInstance;
|
|
2662
|
+
leads: LeadsResource;
|
|
2663
|
+
contacts: ContactsResource;
|
|
2664
|
+
tasks: TasksResource;
|
|
2665
|
+
notes: NotesResource;
|
|
2666
|
+
customFields: CustomFieldsResource;
|
|
2667
|
+
customFieldGroups: CustomFieldGroupsResource;
|
|
2668
|
+
unsorted: UnsortedResource;
|
|
2669
|
+
pipelines: PipelinesResource;
|
|
2670
|
+
companies: CompaniesResource;
|
|
2671
|
+
catalogs: CatalogsResource;
|
|
2672
|
+
users: UsersResource;
|
|
2673
|
+
roles: RolesResource;
|
|
2674
|
+
events: EventsResource;
|
|
2675
|
+
tags: TagsResource;
|
|
2676
|
+
links: LinksResource;
|
|
2677
|
+
salesbots: SalesbotsResource;
|
|
2678
|
+
sources: SourcesResource;
|
|
2679
|
+
websiteButtons: WebsiteButtonsResource;
|
|
2680
|
+
chatTemplates: ChatTemplatesResource;
|
|
2681
|
+
webhooks: WebhooksResource;
|
|
2682
|
+
constructor(config: KommoConfig);
|
|
2683
|
+
setAccessToken(token: string): void;
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
declare class KommoApiError extends Error {
|
|
2687
|
+
status?: number;
|
|
2688
|
+
title?: string;
|
|
2689
|
+
detail?: string;
|
|
2690
|
+
type?: string;
|
|
2691
|
+
raw?: unknown;
|
|
2692
|
+
constructor(message: string, info?: Partial<KommoApiError>);
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
export { type AccessTokenResponse, type AttachmentNoteParams, AuthManager, type BaseCreateUnsortedItem, type BaseCustomField, type BaseEntity, type CallNoteParams, type Catalog, type CatalogElement, type CatalogElementCustomFieldValue, CatalogsResource, type ChatTemplate, type ChatTemplateAttachment, type ChatTemplateButton, type ChatTemplateButtonType, type ChatTemplateReview, type ChatTemplateType, ChatTemplatesResource, type CollectionResponse, type CommonNoteParams, CompaniesResource, type Company, type CompanyCatalogElementRef, type CompanyContactRef, type CompanyLeadRef, type CompanyTag, type CompanyTagRef, type CompanyWithParam, type Contact, type ContactCatalogElementRef, type ContactCompanyRef, type ContactCustomerRef, type ContactLeadRef, type ContactTag, type ContactTagRef, type ContactWithParam, ContactsResource, type CreateCatalogElementInput, type CreateCatalogElementsResponse, type CreateCatalogInput, type CreateCatalogsResponse, type CreateChatTemplateInput, type CreateChatTemplatesResponse, type CreateCompaniesResponse, type CreateCompanyInput, type CreateComplexLeadInput, type CreateComplexLeadsResponse, type CreateComplexLeadsResponseItem, type CreateContactInput, type CreateContactsResponse, type CreateCustomFieldGroupInput, type CreateEntityCustomFieldInput, type CreateEntityLinkInput, type CreateEntityLinksResponse, type CreateFormUnsortedLeadInput, type CreateLeadInput, type CreateLeadsResponse, type CreateListCustomFieldInput, type CreateNoteInput, type CreateNotesResponse, type CreatePipelineInput, type CreatePipelineStatusInput, type CreatePipelinesResponse, type CreateRoleInput, type CreateSipUnsortedLeadInput, type CreateSourceInput, type CreateSourcesResponse, type CreateStatusInput, type CreateStatusesResponse, type CreateTagInput, type CreateTagRef, type CreateTagsResponse, type CreateTaskInput, type CreateTasksResponse, type CreateUnsortedCompany, type CreateUnsortedContact, type CreateUnsortedLead, type CreateUnsortedLeadsResponse, type CreateUserInput, type CreateWebhookInput, type CreateWebsiteButtonInput, type CreateWebsiteButtonResponse, type CustomField, type CustomFieldEnum, type CustomFieldGroup, CustomFieldGroupsResource, type CustomFieldNestedValue, type CustomFieldRequiredStatus, type CustomFieldType, type CustomFieldValue, CustomFieldsResource, type DeleteChatTemplateInput, type DeleteEntityLinkInput, type DeleteSourceBatchInput, type DeleteWebhookInput, type Embedded, type EntityCustomField, type EntityLink, type EntityLinkMetadata, type EntityLinkWithSource, type EntityRights, type EntityType, type EntityUpdateResult, type Event, type EventTypeDefinition, type EventValueChange, type EventValueFilters, type EventWithParam, EventsResource, type FormMetadata, type GeolocationNoteParams, KNOWN_WEBHOOK_EVENTS, KOMMO_PIPELINE_STAGE_COLORS, KOMMO_TAG_COLORS, type KnownEventType, KommoApiError, KommoClient, type KommoConfig, type KommoPipelineStageColor, type Lead, type LeadCatalogElementRef, type LeadCompanyRef, type LeadContactRef, type LeadTag, type LeadTagRef, type LeadWithParam, LeadsResource, type LinkMetadataInput, type LinkSourceEntityType, type LinkTargetEntityType, type LinkUnsortedLeadResponse, LinksResource, type ListCatalogElementsParams, type ListCatalogElementsResponse, type ListCatalogsParams, type ListCatalogsResponse, type ListChatTemplatesParams, type ListChatTemplatesResponse, type ListCompaniesParams, type ListCompaniesResponse, type ListContactsParams, type ListContactsResponse, type ListCustomField, type ListCustomFieldGroupsResponse, type ListEntityCustomFieldsResponse, type ListEntityLinksParams, type ListEntityLinksResponse, type ListEntityNotesParams, type ListEventTypesParams, type ListEventTypesResponse, type ListEventsParams, type ListEventsResponse, type ListLeadsParams, type ListLeadsResponse, type ListListCustomFieldsResponse, type ListLossReasonsResponse, type ListNotesResponse, type ListPipelineStatusesResponse, type ListPipelinesResponse, type ListRolesParams, type ListRolesResponse, type ListSalesbotsParams, type ListSalesbotsResponse, type ListSourcesResponse, type ListTagsParams, type ListTagsResponse, type ListTasksParams, type ListTasksResponse, type ListUnsortedLeadsParams, type ListUnsortedLeadsResponse, type ListUsersParams, type ListUsersResponse, type ListWebhooksParams, type ListWebhooksResponse, type ListWebsiteButtonsParams, type ListWebsiteButtonsResponse, type LossReason, type Note, type NoteEntityType, type NoteParams, type NoteType, NotesResource, type PermissionLevel, type Pipeline, type PipelineStatus, PipelinesResource, type Role, type RoleWithParam, RolesResource, type RunManySalesbotsItem, type RunSalesbotInput, type Salesbot, type SalesbotContinueBotType, type SalesbotContinueInput, type SalesbotExecuteHandler, type SalesbotFunctionalityType, SalesbotsResource, type ServiceMessageNoteParams, type SipMetadata, type SmsNoteParams, type Source, type SourceService, type SourceServicePage, SourcesResource, type StatusDescription, type StatusRight, type StopSalesbotInput, type SubmitWhatsAppTemplateReviewResponse, type Tag, type TagColor, type TagEntityType, type TagRefInput, TagsResource, type Task, TasksResource, type UnsortedDecisionResponse, type UnsortedLead, UnsortedResource, type UnsortedSummaryParams, type UnsortedSummaryResponse, type UpdateCatalogElementInput, type UpdateCatalogElementsResponse, type UpdateCatalogInput, type UpdateCatalogsResponse, type UpdateChatTemplateInput, type UpdateChatTemplatesResponse, type UpdateCompaniesResponse, type UpdateCompanyInput, type UpdateContactInput, type UpdateContactsResponse, type UpdateCustomFieldGroupInput, type UpdateEntityCustomFieldInput, type UpdateEntityTagsBatchResponse, type UpdateEntityTagsInput, type UpdateEntityTagsSingleResponse, type UpdateLeadInput, type UpdateLeadsResponse, type UpdateListCustomFieldInput, type UpdateNoteInput, type UpdateNotesResponse, type UpdatePipelineInput, type UpdateRoleInput, type UpdateSingleCatalogElementInput, type UpdateSingleCatalogInput, type UpdateSingleCompanyInput, type UpdateSingleContactInput, type UpdateSingleEntityCustomFieldInput, type UpdateSingleEntityTagsInput, type UpdateSingleLeadInput, type UpdateSingleListCustomFieldInput, type UpdateSingleNoteInput, type UpdateSingleTaskInput, type UpdateSourceBatchInput, type UpdateSourceInput, type UpdateSourcesResponse, type UpdateStatusInput, type UpdateTaskInput, type UpdateTasksResponse, type UpdateWebsiteButtonInput, type UpdateWhatsAppTemplateReviewStatusInput, type UpdateWhatsAppTemplateReviewStatusResponse, type User, type UserWithParam, UsersResource, type WabaCategory, type WabaHeaderType, type WabaReviewStatus, type Webhook, type WebhookEvent, WebhooksResource, type WebsiteButton, type WebsiteButtonCreationStatus, WebsiteButtonsResource, type WhatsAppTemplateModerationStatus, eventUtils };
|