amocrm-api-wrapper 0.0.20__py3-none-any.whl

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