amocrm-api-wrapper 0.0.16__tar.gz → 0.0.18__tar.gz

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.
@@ -0,0 +1,1230 @@
1
+ Metadata-Version: 2.1
2
+ Name: amocrm-api-wrapper
3
+ Version: 0.0.18
4
+ Summary: Amocrm api wrapper v4
5
+ Home-page: https://github.com/bzdvdn/amocrm-api-wrapper
6
+ Author: bzdvdn
7
+ Author-email: bzdv.dn@gmail.com
8
+ License: MIT
9
+ Platform: UNKNOWN
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+
13
+ # wrapper for amocrm rest api
14
+
15
+ ## Install
16
+
17
+ Install using `pip`...
18
+
19
+ pip install amocrm-api-wrapper
20
+
21
+ ## Usage
22
+
23
+ =======
24
+
25
+ ```python
26
+ from amocrm_api import AmoLegacyClient # for login password auth
27
+ from amocrm_api import AmoOAuthClient # for oauth
28
+ from datetime import datetime
29
+
30
+ client = AmoLegacyClient('<login>', '<password>', '<crm_url>')
31
+ client = AmoOAuthClient('<access_token>', '<refresh_token>', '<crm_url>', '<client_id>', '<client_secret>', '<redirect_uri>')
32
+ dt = datetime.datetime.today().strftime("%a, %d %b %Y %H-%m-%d")
33
+ date_time = f"{dt} UTC"
34
+
35
+ # for Legacy client
36
+ headers = {
37
+ "IF-MODIFIED-SINCE": f"{date_time}",
38
+ "Content-Type": "application/json",
39
+ }
40
+
41
+ client.update_session_params(headers)
42
+ ```
43
+
44
+ ### get account info
45
+
46
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/account-info
47
+ - params:
48
+
49
+ | name | type | default value |
50
+ | :--------------------: | :--: | :-----------: |
51
+ | with_amojo_id | bool | False |
52
+ | with_amojo_rights | bool | False |
53
+ | with_users_groups | bool | False |
54
+ | with_task_types | bool | False |
55
+ | with_version | bool | False |
56
+ | with_ventity_names | bool | False |
57
+ | with_datetime_settings | bool | False |
58
+
59
+ ```python
60
+ account_info = client.get_account_info()
61
+ ```
62
+
63
+ ### create leads
64
+
65
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-add
66
+ - params:
67
+
68
+ | name | type | default value |
69
+ | :-----: | :--: | :-----------: |
70
+ | objects | list | - |
71
+
72
+ ```python
73
+ objects = [
74
+ {
75
+ "name": "Сделка для примера 1",
76
+ "created_by": 0,
77
+ "price": 20000,
78
+ "custom_fields_values": [
79
+ {
80
+ "field_id": 294471,
81
+ "values": [
82
+ {
83
+ "value": "Наш первый клиент"
84
+ }
85
+ ]
86
+ }
87
+ ]
88
+ },
89
+ {
90
+ "name": "Сделка для примера 2",
91
+ "price": 10000,
92
+ "_embedded": {
93
+ "tags": [
94
+ {
95
+ "id": 2719
96
+ }
97
+ ]
98
+ }
99
+ }
100
+ ]
101
+ result = client.create_leads(objects)
102
+ ```
103
+
104
+ ### update leads
105
+
106
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-edit
107
+ - params:
108
+
109
+ | name | type | default value |
110
+ | :-----: | :--: | :-----------: |
111
+ | objects | list | - |
112
+
113
+ ```python
114
+ objects = [
115
+ {
116
+ "id": 54886,
117
+ "pipeline_id": 47521,
118
+ "status_id": 143,
119
+ "date_close": 1589297221,
120
+ "loss_reason_id": 7323,
121
+ "updated_by": 0
122
+ },
123
+ {
124
+ "id": 54884,
125
+ "price": 50000,
126
+ "pipeline_id": 47521,
127
+ "status_id": 525743,
128
+ "_embedded": {
129
+ "tags": None
130
+ }
131
+ }
132
+ ]
133
+ result = client.update_leads(objects)
134
+ ```
135
+
136
+ ### get lead
137
+
138
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads-api#lead-detail
139
+ - params:
140
+
141
+ | name | type | default value |
142
+ | :-----: | :--: | :-----------: |
143
+ | lead_id | int | - |
144
+
145
+ ```python
146
+ lead = client.get_lead(123)
147
+ ```
148
+
149
+ ### get leads
150
+
151
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-list
152
+ - params:
153
+
154
+ | name | type | default value |
155
+ | :---------: | :------------: | :-----------: |
156
+ | limit | int | 250 |
157
+ | page | int | 1 |
158
+ | with_params | Optional[list] | None |
159
+ | filters | Optional[dict] | None |
160
+ | order | Optional[dict] | None |
161
+
162
+ ```python
163
+ leads = client.get_leads(limit=10, page=3, filters={'updated_at__from': '<timestamp>', 'updated_at__to': '<timestamp>'})
164
+ # for any timestamp fields like created_at, updated_at, closed_at u need to user __ like created_at__from, created_at__to
165
+ ```
166
+
167
+ ### get unsorted leads
168
+
169
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-list
170
+ - params:
171
+
172
+ | name | type | default value |
173
+ | :-------------------: | :--------------------: | :-----------: |
174
+ | limit | int | 250 |
175
+ | page | int | 1 |
176
+ | filter_by_uids | Union[str, list, None] | None |
177
+ | filter_by_pipeline_id | Union[str, list, None] | None |
178
+ | filter_by_category | Union[str, list, None] | None |
179
+ | order_by | Optional[dict] | None |
180
+
181
+ ```python
182
+ unsorted_leads = client.get_unsorted_leads(limit=10, page=3, filter_by_pipeline_id=[1, 2310, 8751035])
183
+ ```
184
+
185
+ ### get unsorted lead by uid
186
+
187
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-detail
188
+ - params:
189
+
190
+ | name | type | default value |
191
+ | :--: | :--: | :-----------: |
192
+ | uid | str | - |
193
+
194
+ ```python
195
+ unsorted_lead = client.get_unsorted_by_uid('ufsigkgdjlk13igmd')
196
+ ```
197
+
198
+ ### create unsorted lead by sip
199
+
200
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-add-sip
201
+ - params:
202
+
203
+ | name | type | default value |
204
+ | :---------: | :-----------: | :-----------: |
205
+ | source_uid | str | - |
206
+ | source_name | str | - |
207
+ | metadata | dict | - |
208
+ | conctact | dict | - |
209
+ | lead | dict | - |
210
+ | comapany | dict | - |
211
+ | pipeline_id | Optional[int] | None |
212
+ | created_at | Optional[int] | None |
213
+ | request_id | Optional[int] | None |
214
+
215
+ ```python
216
+ unsorted_lead = {
217
+ "request_id": "123",
218
+ "source_name": "ОАО Коспромсервис",
219
+ "source_uid": "a1fee7c0fc436088e64ba2e8822ba2b3",
220
+ "pipeline_id": 2194576,
221
+ "created_at": 1510261200,
222
+ "leads": {
223
+ "name": "Тех обслуживание",
224
+ "price": 5000,
225
+ "custom_fields_values": [
226
+ {
227
+ "field_id": 284785,
228
+ "values": [
229
+ {
230
+ "value": "Кастомное поле"
231
+ }
232
+ ]
233
+ }
234
+ ],
235
+ "_embedded": {
236
+ "tags": [
237
+ {
238
+ "id": 263809
239
+ }
240
+ ]
241
+ }
242
+ }
243
+ ],
244
+ "contacts":
245
+ {
246
+ "name": "Контакт для примера"
247
+ }
248
+ "companies":
249
+ {
250
+ "name": "ОАО Коспромсервис"
251
+ }
252
+ },
253
+ "metadata": {
254
+ "is_call_event_needed": True,
255
+ "uniq": "a1fe231cc88e64ba2e8822ba2b3ewrw",
256
+ "duration": 54,
257
+ "service_code": "CkAvbEwPam6sad",
258
+ "link": "https://example.com",
259
+ "phone": 79998888888,
260
+ "called_at": 1510261200,
261
+ "from": "onlinePBX"
262
+ }
263
+ }
264
+ result = client.create_unsorted_by_sip(**unsorted_lead)
265
+ ```
266
+
267
+ ### create unsorted lead by form
268
+
269
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-add-form
270
+ - params:
271
+
272
+ | name | type | default value |
273
+ | :---------: | :-----------: | :-----------: |
274
+ | source_uid | str | - |
275
+ | source_name | str | - |
276
+ | metadata | dict | - |
277
+ | conctact | dict | - |
278
+ | lead | dict | - |
279
+ | comapany | dict | - |
280
+ | pipeline_id | Optional[int] | None |
281
+ | created_at | Optional[int] | None |
282
+ | request_id | Optional[int] | None |
283
+
284
+ ```python
285
+ unsorted_lead = {
286
+ "request_id": "123",
287
+ "source_name": "ОАО Коспромсервис",
288
+ "source_uid": "a1fee7c0fc436088e64ba2e8822ba2b3",
289
+ "pipeline_id": 2194576,
290
+ "created_at": 1590830520,
291
+ "leads": {
292
+ "name": "Тех обслуживание",
293
+ "visitor_uid": "5692210d-58d0-468c-acb2-dce7f93eef87",
294
+ "price": 5000,
295
+ "custom_fields_values": [
296
+ {
297
+ "field_id": 284785,
298
+ "values": [
299
+ {
300
+ "value": "Дополнительное поле"
301
+ }
302
+ ]
303
+ }
304
+ ],
305
+ "_embedded": {
306
+ "tags": [
307
+ {
308
+ "name": "Тег для примера"
309
+ }
310
+ ]
311
+ }
312
+ },
313
+ "contacts":
314
+ {
315
+ "name": 234,
316
+ "first_name": "123213",
317
+ "last_name": 234,
318
+ "custom_fields_values": [
319
+ {
320
+ "field_code": "PHONE",
321
+ "values": [
322
+ {
323
+ "value": "+7912321323"
324
+ }
325
+ ]
326
+ }
327
+ ]
328
+ },
329
+ "companies": {
330
+ "name": "ОАО Коспромсервис"
331
+ },
332
+ "metadata": {
333
+ "ip": "123.222.2.22",
334
+ "form_id": "a1fee7c0fc436088e64ba2e8822ba2b3ewrw",
335
+ "form_sent_at": 1590830520,
336
+ "form_name": "Форма заявки для полёта в космос",
337
+ "form_page": "https://example.com",
338
+ "referer": "https://www.google.com/search?&q=elon+musk"
339
+ }
340
+ }
341
+ result = client.create_unsorted_by_form(**unsorted_lead)
342
+ ```
343
+
344
+ ### accept unsorted lead
345
+
346
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-accept
347
+ - params:
348
+
349
+ | name | type | default value |
350
+ | :-------: | :--: | :-----------: |
351
+ | uid | str | - |
352
+ | user_id | int | - |
353
+ | status_id | int | - |
354
+
355
+ ```python
356
+ result = client.accept_unsorted('jkjsoijg2321kgkdu2', 2310, 4444)
357
+ ```
358
+
359
+ ### decline unsorted lead
360
+
361
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-decline
362
+ - params:
363
+
364
+ | name | type | default value |
365
+ | :-----: | :--: | :-----------: |
366
+ | uid | str | - |
367
+ | user_id | int | - |
368
+
369
+ ```python
370
+ result = client.decline_unsorted('jkjsoijg2321kgkdu2', 2310,)
371
+ ```
372
+
373
+ ### link unsorted lead ot another lead
374
+
375
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-link
376
+ - params:
377
+
378
+ | name | type | default value |
379
+ | :-----: | :--: | :-----------: |
380
+ | uid | str | - |
381
+ | user_id | int | - |
382
+ | link | dict | - |
383
+
384
+ ```python
385
+ result = client.link_unsorted('jkjsoijg2321kgkdu2', 2310, link={
386
+ "entity_id": 93144801,
387
+ "entity_type": "leads"
388
+ })
389
+ ```
390
+
391
+ ### get summary unsorted leads
392
+
393
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/unsorted-api#unsorted-summary
394
+ - params:
395
+
396
+ | name | type | default value |
397
+ | :----------------: | :--------------------: | :-----------: |
398
+ | uid | Union[str, list, None] | None |
399
+ | created_at\_\_from | Optional[str] | None |
400
+ | created_at\_\_to | Optional[str] | None |
401
+ | pipeline_id | Union[str, list, None] | None |
402
+
403
+ ```python
404
+ summary_unsorted = client.get_summary_unsorted()
405
+ ```
406
+
407
+ ### get pipelines
408
+
409
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#pipelines-list
410
+
411
+ ```python
412
+ pipelines = client.get_pipelines()
413
+ ```
414
+
415
+ ### craete pipeline
416
+
417
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#pipelines-add
418
+ - params:
419
+
420
+ | name | type | default value |
421
+ | :------------: | :-----------: | :-----------: |
422
+ | name | str | - |
423
+ | sort | int | - |
424
+ | is_main | bool | - |
425
+ | statuses | list | - |
426
+ | is_unsorted_on | bool | False |
427
+ | request_id | Optional[str] | None |
428
+
429
+ ```python
430
+ pipeline = {
431
+ "name": "Воронка доп продаж",
432
+ "is_main": False,
433
+ "is_unsorted_on": True,
434
+ "sort": 20,
435
+ "request_id": "123",
436
+ "statuses": [
437
+ {
438
+ "id": 142,
439
+ "name": "Мое название для успешных сделок"
440
+ },
441
+ {
442
+ "name": "Первичный контакт",
443
+ "sort": 10,
444
+ "color": "#fffeb2"
445
+ }
446
+ ]
447
+ }
448
+ result = client.create_pipeline(**pipeline)
449
+ ```
450
+
451
+ ### edit pipeline
452
+
453
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#pipelines-add
454
+ - params:
455
+
456
+ | name | type | default value |
457
+ | :------------: | :--: | :-----------: |
458
+ | pipeline_id | int | - |
459
+ | name | str | - |
460
+ | sort | int | - |
461
+ | is_main | bool | - |
462
+ | is_unsorted_on | bool | False |
463
+
464
+ ```python
465
+ pipeline = {
466
+ "pipeline_id": 2310,
467
+ "name": "Новое название для воронки",
468
+ "is_main": False,
469
+ "is_unsorted_on": False,
470
+ "sort": 100
471
+ }
472
+ result = client.edit_pipeline(**pipeline)
473
+ ```
474
+
475
+ ### delete pipeline
476
+
477
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#pipeline-delete
478
+ - params:
479
+
480
+ | name | type | default value |
481
+ | :---------: | :--: | :-----------: |
482
+ | pipeline_id | int | - |
483
+
484
+ ```python
485
+ result = client.delete_pipeline(2310)
486
+ ```
487
+
488
+ ### get statuses by pipeline
489
+
490
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#statuses-list
491
+ - params:
492
+
493
+ | name | type | default value |
494
+ | :---------: | :--: | :-----------: |
495
+ | pipeline_id | int | - |
496
+
497
+ ```python
498
+ pipeline_statuses = client.get_pipeline_statuses(2310)
499
+ ```
500
+
501
+ ### get pipeline status
502
+
503
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#status-detail
504
+ - params:
505
+
506
+ | name | type | default value |
507
+ | :---------: | :--: | :-----------: |
508
+ | pipeline_id | int | - |
509
+ | status_id | int | - |
510
+
511
+ ```python
512
+ pipeline_status = client.get_pipeline_status(2310, 123)
513
+ ```
514
+
515
+ ### add statuses to pipeline
516
+
517
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#statuses-add
518
+ - params:
519
+
520
+ | name | type | default value |
521
+ | :---------: | :--: | :-----------: |
522
+ | pipeline_id | int | - |
523
+ | statuses | list | - |
524
+
525
+ ```python
526
+ statuses = [
527
+ {
528
+ "name": "Новый этап",
529
+ "sort": 100,
530
+ "color": "#fffeb2"
531
+ },
532
+ {
533
+ "name": "Новый этап 2",
534
+ "sort": 200,
535
+ "color": "#fffeb2"
536
+ }
537
+ ]
538
+ result = client.add_statuses_to_pipeline(2310, statuses)
539
+ ```
540
+
541
+ ### edit pipeline status
542
+
543
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#statuses-add
544
+ - params:
545
+
546
+ | name | type | default value |
547
+ | :---------: | :--: | :-----------: |
548
+ | pipeline_id | int | - |
549
+ | status_id | int | - |
550
+ | name | str | - |
551
+ | sort | int | - |
552
+ | color | str | - |
553
+
554
+ ```python
555
+ result = client.edit_pipeline_status(2310, 123, 'Новый Этап', sort=500, color="#fffeb2")
556
+ ```
557
+
558
+ ### delete status from pipeline
559
+
560
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#status-delete
561
+ - params:
562
+
563
+ | name | type | default value |
564
+ | :---------: | :--: | :-----------: |
565
+ | pipeline_id | int | - |
566
+ | status_id | int | - |
567
+
568
+ ```python
569
+
570
+ result = client.delete_status_from_pipeline(2310, 123)
571
+ ```
572
+
573
+ ### get contacts
574
+
575
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contacts-list
576
+ - params:
577
+
578
+ | name | type | default value |
579
+ | :---------: | :------------: | :-----------: |
580
+ | limit | int | 250 |
581
+ | page | int | 1 |
582
+ | with_params | Optional[list] | None |
583
+ | filters | Optional[dict] | None |
584
+ | order | Optional[dict] | None |
585
+
586
+ ```python
587
+
588
+ contacts = client.get_contacts(limit=10, page=3, filters={'updated_at__from': '<timestamp>', 'updated_at__to': '<timestamp>'})
589
+ # for any timestamp fields like created_at, updated_at, closed_at u need to user __ like created_at__from, created_at__to
590
+ ```
591
+
592
+ ### get contact
593
+
594
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contact-detail
595
+ - params:
596
+
597
+ | name | type | default value |
598
+ | :--------: | :--: | :-----------: |
599
+ | contact_id | int | - |
600
+
601
+ ```python
602
+
603
+ contact = client.get_contact(123989)
604
+ ```
605
+
606
+ ### create contacts
607
+
608
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contacts-add
609
+ - params:
610
+
611
+ | name | type | default value |
612
+ | :------: | :--: | :-----------: |
613
+ | contacts | list | - |
614
+
615
+ ```python
616
+ conctacts = [
617
+ {
618
+ "first_name": "Петр",
619
+ "last_name": "Смирнов",
620
+ "custom_fields_values": [
621
+ {
622
+ "field_id": 271316,
623
+ "values": [
624
+ {
625
+ "value": "Директор"
626
+ }
627
+ ]
628
+ }
629
+ ]
630
+ },
631
+ {
632
+ "name": "Владимир Смирнов",
633
+ "created_by": 47272
634
+ }
635
+ ]
636
+ result = client.create_contacts(contacts)
637
+ ```
638
+
639
+ ### update contacts
640
+
641
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contacts-edit
642
+ - params:
643
+
644
+ | name | type | default value |
645
+ | :------: | :--: | :-----------: |
646
+ | contacts | list | - |
647
+
648
+ ```python
649
+ conctacts = [
650
+ {
651
+ "id": 3,
652
+ "first_name": "Иван",
653
+ "last_name": "Иванов",
654
+ "custom_fields_values": [
655
+ {
656
+ "field_id": 66192,
657
+ "field_name": "Телефон",
658
+ "values": [
659
+ {
660
+ "value": "79999999999",
661
+ "enum_code": "WORK"
662
+ }
663
+ ]
664
+ }
665
+ ]
666
+ }
667
+ ]
668
+ result = client.update_contacts(contacts)
669
+ ```
670
+
671
+ ### get companies
672
+
673
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/companies-api#companies-list
674
+ - params:
675
+
676
+ | name | type | default value |
677
+ | :---------: | :------------: | :-----------: |
678
+ | limit | int | 250 |
679
+ | page | int | 1 |
680
+ | with_params | Optional[list] | None |
681
+ | filters | Optional[dict] | None |
682
+ | order | Optional[dict] | None |
683
+
684
+ ```python
685
+
686
+ companies = client.get_companies(limit=10, page=3, filters={'updated_at__from': '<timestamp>', 'updated_at__to': '<timestamp>'})
687
+ # for any timestamp fields like created_at, updated_at, closed_at u need to user __ like created_at__from, created_at__to
688
+ ```
689
+
690
+ ### get company
691
+
692
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/companies-api#company-detail
693
+ - params:
694
+
695
+ | name | type | default value |
696
+ | :--------: | :--: | :-----------: |
697
+ | company_id | int | - |
698
+
699
+ ```python
700
+
701
+ company = client.get_company(9988)
702
+ ```
703
+
704
+ ### create companies
705
+
706
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/companies-api#companies-add
707
+ - params:
708
+
709
+ | name | type | default value |
710
+ | :-------: | :--: | :-----------: |
711
+ | companies | list | - |
712
+
713
+ ```python
714
+ companies = [
715
+ {
716
+ "name": "АО Рога и Копыта",
717
+ "custom_fields_values": [
718
+ {
719
+ "field_code": "PHONE",
720
+ "values": [
721
+ {
722
+ "value": "+7912322222",
723
+ "enum_code": "WORK"
724
+ }
725
+ ]
726
+ }
727
+ ]
728
+ }
729
+ ]
730
+ result = client.create_companies(companies)
731
+ ```
732
+
733
+ ### update companies
734
+
735
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/companies-api#companies-edit
736
+ - params:
737
+
738
+ | name | type | default value |
739
+ | :-------: | :--: | :-----------: |
740
+ | companies | list | - |
741
+
742
+ ```python
743
+ companies = [
744
+ {
745
+ "id": 11090825,
746
+ "name": "Новое название компании",
747
+ "custom_fields_values": [
748
+ {
749
+ "field_code": "EMAIL",
750
+ "values": [
751
+ {
752
+ "value": "test@example.com",
753
+ "enum_code": "WORK"
754
+ }
755
+ ]
756
+ }
757
+ ]
758
+ }
759
+ ]
760
+ result = client.update_companies(companies)
761
+ ```
762
+
763
+ ### get catalogs
764
+
765
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#lists-list
766
+ - params:
767
+
768
+ | name | type | default value |
769
+ | :---: | :--: | :-----------: |
770
+ | page | int | 1 |
771
+ | limit | int | 250 |
772
+
773
+ ```python
774
+ catalogs = client.get_catalogs(page=1, limit=5)
775
+ ```
776
+
777
+ ### get catalog
778
+
779
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#list-detail
780
+ - params:
781
+
782
+ | name | type | default value |
783
+ | :--------: | :--: | :-----------: |
784
+ | catalog_id | int | 1 |
785
+
786
+ ```python
787
+ catalog = client.get_catalog(12319)
788
+ ```
789
+
790
+ ### create catalogs
791
+
792
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#lists-add
793
+ - params:
794
+
795
+ | name | type | default value |
796
+ | :------: | :--: | :-----------: |
797
+ | catalogs | list | - |
798
+
799
+ ```python
800
+ catalogs = [
801
+ {
802
+ "name": "Тестовый список",
803
+ "can_add_elements": True,
804
+ "can_link_multiple": False,
805
+ "request_id": "123"
806
+ }
807
+ ]}
808
+ ]
809
+ result = client.create_catalogs(catalogs)
810
+ ```
811
+
812
+ ### update catalogs
813
+
814
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#lists-edit
815
+ - params:
816
+
817
+ | name | type | default value |
818
+ | :------: | :--: | :-----------: |
819
+ | catalogs | list | - |
820
+
821
+ ```python
822
+ catalogs = [
823
+ {
824
+ "id": 5787,
825
+ "name": "Новое имя списка",
826
+ "can_add_elements": True,
827
+ "can_link_multiple": False
828
+ }
829
+ ]
830
+ result = client.update_catalogs(catalogs)
831
+ ```
832
+
833
+ ### get elements from catalog
834
+
835
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#list-elements-list
836
+ - params:
837
+
838
+ | name | type | default value |
839
+ | :---------: | :------------: | :-----------: |
840
+ | catalogs_id | int | - |
841
+ | page | int | 1 |
842
+ | limit | int | 250 |
843
+ | filters | Optional[dict] | None |
844
+
845
+ ```python
846
+ elements = client.get_catalog_elements(5787, page=3, limit=8)
847
+ ```
848
+
849
+ ### get element from catalog
850
+
851
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#list-elements-detail
852
+ - params:
853
+
854
+ | name | type | default value |
855
+ | :---------: | :--: | :-----------: |
856
+ | catalogs_id | int | - |
857
+ | element_id | int | - |
858
+
859
+ ```python
860
+ element = client.get_catalog_element(5787, 2301)
861
+ ```
862
+
863
+ ### add elements to catalog
864
+
865
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#list-elements-add
866
+ - params:
867
+
868
+ | name | type | default value |
869
+ | :---------: | :--: | :-----------: |
870
+ | catalogs_id | int | - |
871
+ | elements | list | - |
872
+
873
+ ```python
874
+ elements = [
875
+ {
876
+ "name": "Новый элемент списка",
877
+ "custom_fields_values": [
878
+ {
879
+ "field_id": 14263,
880
+ "values": [
881
+ {
882
+ "value": 1000
883
+ }
884
+ ]
885
+ }
886
+ ]
887
+ }
888
+ ]
889
+ result = client.add_elements_to_catalog(5787, elements)
890
+ ```
891
+
892
+ ### update elements in catalog
893
+
894
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/catalogs-api#list-elements-edit
895
+ - params:
896
+
897
+ | name | type | default value |
898
+ | :---------: | :--: | :-----------: |
899
+ | catalogs_id | int | - |
900
+ | elements | list | - |
901
+
902
+ ```python
903
+ elements = [
904
+ {
905
+ "id": 986757,
906
+ "name": "Новое имя элемента"
907
+ },
908
+ {
909
+ "id": 986753,
910
+ "name": "Новое имя элемента 2"
911
+ }
912
+ ]
913
+ result = client.update_elements_in_catalog(5787, elements)
914
+ ```
915
+
916
+ ### get users
917
+
918
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/users-api#users-list
919
+ - params:
920
+
921
+ | name | type | default value |
922
+ | :--------: | :--: | :-----------: |
923
+ | page | int | 1 |
924
+ | limit | list | 250 |
925
+ | with_role | bool | False |
926
+ | with_group | bool | False |
927
+
928
+ ```python
929
+ users = client.get_users(page=1, limit=250)
930
+ ```
931
+
932
+ ### get user
933
+
934
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/users-api#user-detail
935
+ - params:
936
+
937
+ | name | type | default value |
938
+ | :--------: | :--: | :-----------: |
939
+ | user_id | int | 1 |
940
+ | with_role | bool | False |
941
+ | with_group | bool | False |
942
+
943
+ ```python
944
+ user = client.get_user(2222, with_role=True, with_group=True)
945
+ ```
946
+
947
+ ### get webhooks
948
+
949
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/webhooks-api#webhooks-list
950
+ - params:
951
+
952
+ | name | type | default value |
953
+ | :--------: | :-----------: | :-----------: |
954
+ | distansion | Optional[str] | None |
955
+
956
+ ```python
957
+ webhooks = client.get_webhooks()
958
+ ```
959
+
960
+ ### subscribe webhook
961
+
962
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/webhooks-api#webhook-subscribe
963
+ - params:
964
+
965
+ | name | type | default value |
966
+ | :--------: | :--: | :-----------: |
967
+ | distansion | str | - |
968
+ | settings | list | - |
969
+
970
+ ```python
971
+ result = client.subscribe_webhook(destination="https://example.test", settings=["add_lead"])
972
+ ```
973
+
974
+ ### get widgets
975
+
976
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/widgets-api#widgets-list
977
+ - params:
978
+
979
+ | name | type | default value |
980
+ | :---: | :--: | :-----------: |
981
+ | page | int | 1 |
982
+ | limit | int | 250 |
983
+
984
+ ```python
985
+ widgets = client.get_widgets(page=3, limit=22)
986
+ ```
987
+
988
+ ### get widget
989
+
990
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/widgets-api#widget-detail
991
+ - params:
992
+
993
+ | name | type | default value |
994
+ | :---------: | :--: | :-----------: |
995
+ | widget_code | str | - |
996
+
997
+ ```python
998
+ widget = client.get_widget('<widget_code>')
999
+ ```
1000
+
1001
+ ### install widget
1002
+
1003
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/widgets-api#widget-install
1004
+ - params:
1005
+
1006
+ | name | type | default value |
1007
+ | :---------: | :--: | :-----------: |
1008
+ | widget_code | str | - |
1009
+ | \*\*kwargs | str | - |
1010
+
1011
+ ```python
1012
+ example ={
1013
+ "login": "example",
1014
+ "password": "eXaMp1E",
1015
+ "phones": {
1016
+ 504141: "1039"
1017
+ },
1018
+ "script_path": "https://example.com/"
1019
+ }
1020
+ result = client.install_widget('<widget_code>', **example)
1021
+ ```
1022
+
1023
+ ### uninstall widget
1024
+
1025
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/widgets-api#widget-uninstall
1026
+ - params:
1027
+
1028
+ | name | type | default value |
1029
+ | :---------: | :--: | :-----------: |
1030
+ | widget_code | str | - |
1031
+
1032
+ ```python
1033
+ result = client.uninstall_widget('<widget_code>')
1034
+ ```
1035
+
1036
+ ### get tasks
1037
+
1038
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tasks-api#tasks-list
1039
+ - params:
1040
+
1041
+ | name | type | default value |
1042
+ | :-----: | :------------: | :-----------: |
1043
+ | page | int | 1 |
1044
+ | limit | int | 250 |
1045
+ | filters | Optional[dict] | None |
1046
+ | order | Optional[dict] | None |
1047
+
1048
+ ```python
1049
+ tasks = client.get_tasks(page=1, limit=10, filters={'updated_at__from': '<timestamp>', 'updated_at__to': '<timestamp>'})
1050
+ # for any timestamp fields like created_at, updated_at, closed_at u need to user __ like created_at__from, created_at__to
1051
+ ```
1052
+
1053
+ ### get task
1054
+
1055
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tasks-api#task-detail
1056
+ - params:
1057
+
1058
+ | name | type | default value |
1059
+ | :-----: | :--: | :-----------: |
1060
+ | task_id | int | - |
1061
+
1062
+ ```python
1063
+ task = client.get_task(1288)
1064
+ ```
1065
+
1066
+ ### add tasks
1067
+
1068
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tasks-api#tasks-add
1069
+ - params:
1070
+
1071
+ | name | type | default value |
1072
+ | :---: | :--: | :-----------: |
1073
+ | tasks | list | - |
1074
+
1075
+ ```python
1076
+ tasks = [
1077
+ {
1078
+ "task_type_id": 1,
1079
+ "text": "Встретиться с клиентом Иван Иванов",
1080
+ "complete_till": 1588885140,
1081
+ "entity_id": 9785993,
1082
+ "entity_type": "leads",
1083
+ "request_id": "example"
1084
+ }
1085
+ ]
1086
+ result = client.add_tasks(tasks=tasks)
1087
+ ```
1088
+
1089
+ ### update tasks
1090
+
1091
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tasks-api#tasks-edit
1092
+ - params:
1093
+
1094
+ | name | type | default value |
1095
+ | :---: | :--: | :-----------: |
1096
+ | tasks | list | - |
1097
+
1098
+ ```python
1099
+ tasks = [
1100
+ {
1101
+ "id": 4745251,
1102
+ "task_type_id": 2,
1103
+ "text": "Новое название для задачи",
1104
+ "complete_till": 1588885140
1105
+ },
1106
+ {
1107
+ "id": 4747929,
1108
+ "task_type_id": 1,
1109
+ "text": "Новое название для задачи 2",
1110
+ "complete_till": 1588885140
1111
+ }
1112
+ ]
1113
+ result = client.update_tasks(tasks=tasks)
1114
+ ```
1115
+
1116
+ ### execution task
1117
+
1118
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tasks-api#tasks-complete
1119
+ - params:
1120
+
1121
+ | name | type | default value |
1122
+ | :----------: | :--: | :-----------: |
1123
+ | task_id | int | - |
1124
+ | is_completed | bool | - |
1125
+ | result | str | - |
1126
+
1127
+ ```python
1128
+ result = client.execution_task(1288, is_completed=True, result="Удалось связаться с клиентом")
1129
+ ```
1130
+
1131
+ ### get tasks by entity type (leads|contacts|companies|customers)
1132
+
1133
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tags-api#tags-list
1134
+ - params:
1135
+
1136
+ | name | type | default value |
1137
+ | :---------: | :------------: | :-----------: |
1138
+ | entity_type | str | - |
1139
+ | page | int | 1 |
1140
+ | limit | int | 250 |
1141
+ | filters | Optional[dict] | None |
1142
+
1143
+ ```python
1144
+ tags = client.get_tags_by_entity_type('leads', page=1, limit=10)
1145
+ ```
1146
+
1147
+ ### add tasks for entity type (leads|contacts|companies|customers)
1148
+
1149
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/tags-api#tags-add
1150
+ - params:
1151
+
1152
+ | name | type | default value |
1153
+ | :---------: | :--: | :-----------: |
1154
+ | entity_type | str | - |
1155
+ | tags | list | - |
1156
+
1157
+ ```python
1158
+ tags = [
1159
+ {
1160
+ "name": "Tag 1"
1161
+ },
1162
+ {
1163
+ "name": "Tag 2",
1164
+ "request_id": "my_request_id"
1165
+ },
1166
+ {
1167
+ "name": "Tag 3"
1168
+ }
1169
+ ]
1170
+ tags = client.add_tags_for_entity_type('leads', tags=tags)
1171
+ ```
1172
+
1173
+ ### get custom fields
1174
+
1175
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/custom-fields#common-info
1176
+
1177
+ ```python
1178
+ contacts_cf = client.get_contacts_custom_fields()
1179
+ leads_cf = client.get_leads_custom_fields()
1180
+ companies_cf = client.get_companies_custom_fields()
1181
+ customers_cf = client.get_customers_custom_fields()
1182
+ customer_segments_cf = client.get_customer_segments_custom_fields()
1183
+ customer_segments_cf = client.get_customer_segments_custom_fields()
1184
+ get_catalog_custom_fields = client.get_customer_segments_custom_fields('<catalog_id>')
1185
+ ```
1186
+
1187
+ ### get custom field
1188
+
1189
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/custom-fields#custom-field-detail
1190
+
1191
+ ```python
1192
+ contacts_cf = client.get_contacts_custom_field('<id>')
1193
+ leads_cf = client.get_leads_custom_field('<id>')
1194
+ companies_cf = client.get_companies_custom_field('<id>')
1195
+ customers_cf = client.get_customers_custom_field('<id>')
1196
+ customer_segments_cf = client.get_customer_segments_custom_field('<id>')
1197
+ get_catalog_custom_fields = client.get_catalog_custom_field('<catalog_id>', '<id>')
1198
+ ```
1199
+
1200
+ ### create custom field
1201
+
1202
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/custom-fields#custom-fields-add
1203
+
1204
+ ```python
1205
+ contacts_cf = client.create_contacts_custom_field(['<cf>'])
1206
+ leads_cf = client.create_leads_custom_field(['<cf>'])
1207
+ companies_cf = client.create_companies_custom_field(['<cf>'])
1208
+ customers_cf = client.create_customers_custom_field(['<cf>'])
1209
+ customer_segments_cf = client.create_customer_segments_custom_field(['<cf>'])
1210
+ get_catalog_custom_fields = client.create_catalog_custom_field('<catalog_id>', ['<cf>'])
1211
+ ```
1212
+
1213
+ ### update custom field
1214
+
1215
+ - doc - https://www.amocrm.ru/developers/content/crm_platform/custom-fields#custom-fields-edit
1216
+
1217
+ ```python
1218
+ contacts_cf = client.update_contacts_custom_field(['<cf>'])
1219
+ leads_cf = client.update_leads_custom_field(['<cf>'])
1220
+ companies_cf = client.update_companies_custom_field(['<cf>'])
1221
+ customers_cf = client.update_customers_custom_field(['<cf>'])
1222
+ customer_segments_cf = client.update_customer_segments_custom_field(['<cf>'])
1223
+ get_catalog_custom_fields = client.update_catalog_custom_field('<catalog_id>', ['<cf>'])
1224
+ ```
1225
+
1226
+ ### changelog
1227
+
1228
+ - 0.0.12 - add entity notes methods, rename updatecustomers_segments_custom_fields -> update_customers_segments_custom_fields
1229
+
1230
+