sendbee-api 1.7.0__tar.gz → 1.8.0__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.
- {sendbee_api-1.7.0/sendbee_api.egg-info → sendbee_api-1.8.0}/PKG-INFO +102 -32
- sendbee_api-1.7.0/PKG-INFO → sendbee_api-1.8.0/README.md +78 -43
- sendbee_api-1.8.0/pyproject.toml +46 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/bind.py +11 -1
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/client.py +2 -1
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/constants.py +21 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/conversations/models.py +2 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/conversations/query_params.py +2 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/debug.py +8 -1
- sendbee_api-1.8.0/sendbee_api/webhooks/__init__.py +0 -0
- sendbee_api-1.8.0/sendbee_api/webhooks/client.py +16 -0
- sendbee_api-1.8.0/sendbee_api/webhooks/models.py +22 -0
- sendbee_api-1.8.0/sendbee_api/webhooks/query_params.py +9 -0
- sendbee_api-1.7.0/README.md → sendbee_api-1.8.0/sendbee_api.egg-info/PKG-INFO +114 -21
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api.egg-info/SOURCES.txt +15 -2
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api.egg-info/requires.txt +6 -1
- sendbee_api-1.8.0/tests/test_auth.py +110 -0
- sendbee_api-1.8.0/tests/test_bind_request.py +476 -0
- sendbee_api-1.8.0/tests/test_client.py +67 -0
- sendbee_api-1.8.0/tests/test_endpoints_smoke.py +215 -0
- sendbee_api-1.8.0/tests/test_fields.py +105 -0
- sendbee_api-1.8.0/tests/test_formatter.py +79 -0
- sendbee_api-1.8.0/tests/test_models.py +99 -0
- sendbee_api-1.8.0/tests/test_query_params.py +59 -0
- sendbee_api-1.8.0/tests/test_response.py +112 -0
- sendbee_api-1.7.0/setup.py +0 -47
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/LICENSE +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/__init__.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/auth.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/automation/__init__.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/automation/client.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/automation/models.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/automation/query_params.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/contacts/__init__.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/contacts/client.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/contacts/models.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/contacts/query_params.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/conversations/__init__.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/conversations/client.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/exceptions.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/fields.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/formatter.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/models.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/query_params.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/rate_limit/__init__.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/rate_limit/client.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/rate_limit/models.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/rate_limit/query_params.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/response.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/teams/__init__.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/teams/client.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/teams/models.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api/teams/query_params.py +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api.egg-info/dependency_links.txt +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/sendbee_api.egg-info/top_level.txt +0 -0
- {sendbee_api-1.7.0 → sendbee_api-1.8.0}/setup.cfg +0 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 1.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sendbee_api
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: Python client SDK for Sendbee Public API
|
|
5
|
-
|
|
6
|
-
Author: Sendbee ltd
|
|
7
|
-
Author-email: info@sendbee.io
|
|
5
|
+
Author-email: Sendbee ltd <info@sendbee.io>
|
|
8
6
|
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/sendbee/sendbee-python-client
|
|
9
8
|
Project-URL: Source, https://github.com/sendbee/sendbee-python-client
|
|
10
|
-
Keywords: sendbee
|
|
11
|
-
Platform: UNKNOWN
|
|
9
|
+
Keywords: sendbee,api,python
|
|
12
10
|
Classifier: Intended Audience :: Developers
|
|
13
11
|
Classifier: Topic :: Software Development :: Build Tools
|
|
14
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -16,30 +14,32 @@ Classifier: Programming Language :: Python :: 3.6
|
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.7
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Requires-Python: >=3.6
|
|
19
22
|
Description-Content-Type: text/markdown
|
|
20
23
|
License-File: LICENSE
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
Requires-Dist: click>=7.0
|
|
25
|
+
Requires-Dist: requests>=2.20.0
|
|
26
|
+
Requires-Dist: dumpit>=0.5.0
|
|
27
|
+
Requires-Dist: aenum>=2.1.2
|
|
28
|
+
Requires-Dist: ujson<6,>=5.7.0
|
|
29
|
+
Requires-Dist: cryptography>=3.2
|
|
30
|
+
Requires-Dist: curlify>=2.2.1
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest; extra == "dev"
|
|
33
|
+
Requires-Dist: responses>=0.23; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="docs/images/number-logo-tm.png" alt="AI Number">
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
# AI Number Python API Client
|
|
32
41
|
|
|
33
42
|
[](https://badge.fury.io/py/sendbee-api)
|
|
34
|
-
[](https://travis-ci.org/sendbee/sendbee-python-api-client)
|
|
35
|
-
|
|
36
|
-

|
|
37
|
-

|
|
38
|
-

|
|
39
|
-
|
|
40
|
-

|
|
41
|
-

|
|
42
|
-

|
|
43
43
|
|
|
44
44
|
## Table of contents
|
|
45
45
|
|
|
@@ -84,6 +84,10 @@ License-File: LICENSE
|
|
|
84
84
|
- [Managing chatbot (automated responses) status settings](#bot-on-off)
|
|
85
85
|
- [Get chatbot (automated responses) status](#bot-status)
|
|
86
86
|
|
|
87
|
+
#### Webhooks
|
|
88
|
+
|
|
89
|
+
- [Subscribe to webhook](#subscribe-webhook)
|
|
90
|
+
|
|
87
91
|
#### Mics
|
|
88
92
|
|
|
89
93
|
- [Pagination](#pagination)
|
|
@@ -561,6 +565,59 @@ response.chatbot_active # True/False
|
|
|
561
565
|
|
|
562
566
|
```
|
|
563
567
|
|
|
568
|
+
## Webhooks
|
|
569
|
+
|
|
570
|
+
### <a href='#subscribe-webhook'>Subscribe to webhook</a>
|
|
571
|
+
|
|
572
|
+
Register a URL of yours and subscribe it to a webhook event, so we start sending
|
|
573
|
+
you requests when that event happens. This does the same thing as activating a
|
|
574
|
+
webhook URL in the Sendbee Dashboard.
|
|
575
|
+
|
|
576
|
+
```python
|
|
577
|
+
webhook = api.subscribe_webhook(
|
|
578
|
+
url='https://example.com/sendbee/webhook',
|
|
579
|
+
event='message.received'
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
webhook.id # UUID of the webhook endpoint
|
|
583
|
+
webhook.url # the URL you registered
|
|
584
|
+
webhook.active # True/False
|
|
585
|
+
webhook.selected_webhooks # list of all events this URL is subscribed to
|
|
586
|
+
webhook.secret_key # key used to sign requests we send to your URL
|
|
587
|
+
webhook.created_at
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
Both `url` and `event` are required. Calling it again for the same `url` is safe -
|
|
591
|
+
it will not create a duplicate, it just adds the new event to that URL (and
|
|
592
|
+
re-activates it if it was deactivated), so subscribe one event per call:
|
|
593
|
+
|
|
594
|
+
```python
|
|
595
|
+
for event in ('message.received', 'message.sent'):
|
|
596
|
+
api.subscribe_webhook(url='https://example.com/sendbee/webhook', event=event)
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Available events:
|
|
600
|
+
|
|
601
|
+
| Event | Description |
|
|
602
|
+
| --- | --- |
|
|
603
|
+
| `contact.created` | A new contact was created |
|
|
604
|
+
| `contact.subscription_created` | A contact subscribed |
|
|
605
|
+
| `contact.subscription_updated` | A contact's subscription changed |
|
|
606
|
+
| `contact.unsubscribed` | A contact unsubscribed |
|
|
607
|
+
| `message.received` | A message was received from a contact |
|
|
608
|
+
| `message.sent` | A message was sent to a contact |
|
|
609
|
+
| `message.sent_status` | Delivery status of a sent message changed |
|
|
610
|
+
| `whatsapp.message.session.sent_status` | Delivery status of a session message changed |
|
|
611
|
+
| `whatsapp.message.template.sent_status` | Delivery status of a template message changed |
|
|
612
|
+
| `whatsapp.message.template.approval_status` | A message template was approved or rejected |
|
|
613
|
+
| `conversation.change_folder` | A conversation was moved to another folder |
|
|
614
|
+
|
|
615
|
+
An unknown event name returns a `SendbeeRequestApiException`. For the authoritative
|
|
616
|
+
and up to date list, see the [documentation](https://developer.ainumber.com/#webhooks).
|
|
617
|
+
|
|
618
|
+
Once subscribed, see [Authenticate webhook request](#authenticate-webhook-request)
|
|
619
|
+
for how to verify the requests we send you.
|
|
620
|
+
|
|
564
621
|
## Misc
|
|
565
622
|
|
|
566
623
|
### <a href='#pagination'>Pagination</a>
|
|
@@ -646,7 +703,7 @@ except SendbeeRequestApiException as e:
|
|
|
646
703
|
|
|
647
704
|
### <a href='#authenticate-webhook-request'>Authenticate webhook request</a>
|
|
648
705
|
|
|
649
|
-
After activating your webhook URL in Sendbee Dashboard, we will start sending requests on that URL depending on which webhook type is linked with that webhook URL.
|
|
706
|
+
After activating your webhook URL in Sendbee Dashboard or with [Subscribe to webhook](#subscribe-webhook), we will start sending requests on that URL depending on which webhook type is linked with that webhook URL.
|
|
650
707
|
Every request that we make will have authorization token in header, like this:
|
|
651
708
|
|
|
652
709
|
```
|
|
@@ -669,9 +726,24 @@ if not api.auth.check_auth_token(token):
|
|
|
669
726
|
# error! authentication failed!
|
|
670
727
|
```
|
|
671
728
|
|
|
729
|
+
Requests to a webhook URL that has its own secret key also carry a second header,
|
|
730
|
+
`X-Auth-Token`, signed with that key instead of your account secret. You get the
|
|
731
|
+
key back as `webhook.secret_key` from [Subscribe to webhook](#subscribe-webhook).
|
|
732
|
+
Check it the same way, using `SendbeeAuth` directly:
|
|
733
|
+
|
|
734
|
+
```python
|
|
735
|
+
from sendbee_api import SendbeeAuth
|
|
736
|
+
|
|
737
|
+
secret_key = '...' # webhook.secret_key, store it when you subscribe
|
|
738
|
+
|
|
739
|
+
token = '...' # taken from the 'X-Auth-Token' request header
|
|
740
|
+
if not SendbeeAuth(secret_key).check_auth_token(token):
|
|
741
|
+
# error! authentication failed!
|
|
742
|
+
```
|
|
743
|
+
|
|
672
744
|
### <a href='#warnings'>Warnings</a>
|
|
673
745
|
|
|
674
|
-
Sometimes APi returns a
|
|
746
|
+
Sometimes APi returns a warning so you could be warned about something.
|
|
675
747
|
The waning is displayed in standard output:
|
|
676
748
|
|
|
677
749
|

|
|
@@ -692,5 +764,3 @@ api = SendbeeApi(
|
|
|
692
764
|
Once you enabled the internal debug tool, every request to API will output various request and response data in standard output:
|
|
693
765
|
|
|
694
766
|

|
|
695
|
-
|
|
696
|
-
|
|
@@ -1,45 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Summary: Python client SDK for Sendbee Public API
|
|
5
|
-
Home-page: https://github.com/sendbee/sendbee-python-client
|
|
6
|
-
Author: Sendbee ltd
|
|
7
|
-
Author-email: info@sendbee.io
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Source, https://github.com/sendbee/sendbee-python-client
|
|
10
|
-
Keywords: sendbee api python
|
|
11
|
-
Platform: UNKNOWN
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
License-File: LICENSE
|
|
21
|
-
|
|
22
|
-
# Sendbee Python API Client
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/images/number-logo-tm.png" alt="AI Number">
|
|
3
|
+
</p>
|
|
23
4
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.' '. __
|
|
27
|
-
. . . (__\_
|
|
28
|
-
. . . -{{_(|8)
|
|
29
|
-
' . . ' ' . . ' (__/
|
|
30
|
-
|
|
31
|
-
```
|
|
5
|
+
# AI Number Python API Client
|
|
32
6
|
|
|
33
7
|
[](https://badge.fury.io/py/sendbee-api)
|
|
34
|
-
[](https://travis-ci.org/sendbee/sendbee-python-api-client)
|
|
35
|
-
|
|
36
|
-

|
|
37
|
-

|
|
38
|
-

|
|
39
|
-
|
|
40
|
-

|
|
41
|
-

|
|
42
|
-

|
|
43
8
|
|
|
44
9
|
## Table of contents
|
|
45
10
|
|
|
@@ -84,6 +49,10 @@ License-File: LICENSE
|
|
|
84
49
|
- [Managing chatbot (automated responses) status settings](#bot-on-off)
|
|
85
50
|
- [Get chatbot (automated responses) status](#bot-status)
|
|
86
51
|
|
|
52
|
+
#### Webhooks
|
|
53
|
+
|
|
54
|
+
- [Subscribe to webhook](#subscribe-webhook)
|
|
55
|
+
|
|
87
56
|
#### Mics
|
|
88
57
|
|
|
89
58
|
- [Pagination](#pagination)
|
|
@@ -561,6 +530,59 @@ response.chatbot_active # True/False
|
|
|
561
530
|
|
|
562
531
|
```
|
|
563
532
|
|
|
533
|
+
## Webhooks
|
|
534
|
+
|
|
535
|
+
### <a href='#subscribe-webhook'>Subscribe to webhook</a>
|
|
536
|
+
|
|
537
|
+
Register a URL of yours and subscribe it to a webhook event, so we start sending
|
|
538
|
+
you requests when that event happens. This does the same thing as activating a
|
|
539
|
+
webhook URL in the Sendbee Dashboard.
|
|
540
|
+
|
|
541
|
+
```python
|
|
542
|
+
webhook = api.subscribe_webhook(
|
|
543
|
+
url='https://example.com/sendbee/webhook',
|
|
544
|
+
event='message.received'
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
webhook.id # UUID of the webhook endpoint
|
|
548
|
+
webhook.url # the URL you registered
|
|
549
|
+
webhook.active # True/False
|
|
550
|
+
webhook.selected_webhooks # list of all events this URL is subscribed to
|
|
551
|
+
webhook.secret_key # key used to sign requests we send to your URL
|
|
552
|
+
webhook.created_at
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
Both `url` and `event` are required. Calling it again for the same `url` is safe -
|
|
556
|
+
it will not create a duplicate, it just adds the new event to that URL (and
|
|
557
|
+
re-activates it if it was deactivated), so subscribe one event per call:
|
|
558
|
+
|
|
559
|
+
```python
|
|
560
|
+
for event in ('message.received', 'message.sent'):
|
|
561
|
+
api.subscribe_webhook(url='https://example.com/sendbee/webhook', event=event)
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
Available events:
|
|
565
|
+
|
|
566
|
+
| Event | Description |
|
|
567
|
+
| --- | --- |
|
|
568
|
+
| `contact.created` | A new contact was created |
|
|
569
|
+
| `contact.subscription_created` | A contact subscribed |
|
|
570
|
+
| `contact.subscription_updated` | A contact's subscription changed |
|
|
571
|
+
| `contact.unsubscribed` | A contact unsubscribed |
|
|
572
|
+
| `message.received` | A message was received from a contact |
|
|
573
|
+
| `message.sent` | A message was sent to a contact |
|
|
574
|
+
| `message.sent_status` | Delivery status of a sent message changed |
|
|
575
|
+
| `whatsapp.message.session.sent_status` | Delivery status of a session message changed |
|
|
576
|
+
| `whatsapp.message.template.sent_status` | Delivery status of a template message changed |
|
|
577
|
+
| `whatsapp.message.template.approval_status` | A message template was approved or rejected |
|
|
578
|
+
| `conversation.change_folder` | A conversation was moved to another folder |
|
|
579
|
+
|
|
580
|
+
An unknown event name returns a `SendbeeRequestApiException`. For the authoritative
|
|
581
|
+
and up to date list, see the [documentation](https://developer.ainumber.com/#webhooks).
|
|
582
|
+
|
|
583
|
+
Once subscribed, see [Authenticate webhook request](#authenticate-webhook-request)
|
|
584
|
+
for how to verify the requests we send you.
|
|
585
|
+
|
|
564
586
|
## Misc
|
|
565
587
|
|
|
566
588
|
### <a href='#pagination'>Pagination</a>
|
|
@@ -646,7 +668,7 @@ except SendbeeRequestApiException as e:
|
|
|
646
668
|
|
|
647
669
|
### <a href='#authenticate-webhook-request'>Authenticate webhook request</a>
|
|
648
670
|
|
|
649
|
-
After activating your webhook URL in Sendbee Dashboard, we will start sending requests on that URL depending on which webhook type is linked with that webhook URL.
|
|
671
|
+
After activating your webhook URL in Sendbee Dashboard or with [Subscribe to webhook](#subscribe-webhook), we will start sending requests on that URL depending on which webhook type is linked with that webhook URL.
|
|
650
672
|
Every request that we make will have authorization token in header, like this:
|
|
651
673
|
|
|
652
674
|
```
|
|
@@ -669,9 +691,24 @@ if not api.auth.check_auth_token(token):
|
|
|
669
691
|
# error! authentication failed!
|
|
670
692
|
```
|
|
671
693
|
|
|
694
|
+
Requests to a webhook URL that has its own secret key also carry a second header,
|
|
695
|
+
`X-Auth-Token`, signed with that key instead of your account secret. You get the
|
|
696
|
+
key back as `webhook.secret_key` from [Subscribe to webhook](#subscribe-webhook).
|
|
697
|
+
Check it the same way, using `SendbeeAuth` directly:
|
|
698
|
+
|
|
699
|
+
```python
|
|
700
|
+
from sendbee_api import SendbeeAuth
|
|
701
|
+
|
|
702
|
+
secret_key = '...' # webhook.secret_key, store it when you subscribe
|
|
703
|
+
|
|
704
|
+
token = '...' # taken from the 'X-Auth-Token' request header
|
|
705
|
+
if not SendbeeAuth(secret_key).check_auth_token(token):
|
|
706
|
+
# error! authentication failed!
|
|
707
|
+
```
|
|
708
|
+
|
|
672
709
|
### <a href='#warnings'>Warnings</a>
|
|
673
710
|
|
|
674
|
-
Sometimes APi returns a
|
|
711
|
+
Sometimes APi returns a warning so you could be warned about something.
|
|
675
712
|
The waning is displayed in standard output:
|
|
676
713
|
|
|
677
714
|

|
|
@@ -692,5 +729,3 @@ api = SendbeeApi(
|
|
|
692
729
|
Once you enabled the internal debug tool, every request to API will output various request and response data in standard output:
|
|
693
730
|
|
|
694
731
|

|
|
695
|
-
|
|
696
|
-
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sendbee_api"
|
|
7
|
+
version = "1.8.0"
|
|
8
|
+
description = "Python client SDK for Sendbee Public API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.6"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Sendbee ltd", email = "info@sendbee.io" }]
|
|
13
|
+
keywords = ["sendbee", "api", "python"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Topic :: Software Development :: Build Tools",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3.6",
|
|
19
|
+
"Programming Language :: Python :: 3.7",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"click>=7.0",
|
|
29
|
+
"requests>=2.20.0",
|
|
30
|
+
"dumpit>=0.5.0",
|
|
31
|
+
"aenum>=2.1.2",
|
|
32
|
+
"ujson>=5.7.0,<6",
|
|
33
|
+
"cryptography>=3.2",
|
|
34
|
+
"curlify>=2.2.1",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = ["pytest", "responses>=0.23"]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/sendbee/sendbee-python-client"
|
|
42
|
+
Source = "https://github.com/sendbee/sendbee-python-client"
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
include = ["sendbee_api*"]
|
|
46
|
+
exclude = ["tests*"]
|
|
@@ -190,6 +190,10 @@ def bind_request(**request_data):
|
|
|
190
190
|
self.parameters[constants.RequestConst.QUERY]
|
|
191
191
|
)
|
|
192
192
|
self.debug.ok(constants.ResponseConst.RESPONSE_OBJECT, response)
|
|
193
|
+
self.debug.set_curl(
|
|
194
|
+
constants.DebugConst.CURL,
|
|
195
|
+
response.request
|
|
196
|
+
)
|
|
193
197
|
|
|
194
198
|
return response.status_code, response.headers, response.text
|
|
195
199
|
|
|
@@ -213,7 +217,13 @@ def bind_request(**request_data):
|
|
|
213
217
|
self.debug.ok('payload', self.parameters[
|
|
214
218
|
constants.RequestConst.QUERY
|
|
215
219
|
])
|
|
216
|
-
self.debug.ok(
|
|
220
|
+
self.debug.ok(
|
|
221
|
+
constants.ResponseConst.RESPONSE_OBJECT, response
|
|
222
|
+
)
|
|
223
|
+
self.debug.set_curl(
|
|
224
|
+
constants.DebugConst.CURL,
|
|
225
|
+
response.request
|
|
226
|
+
)
|
|
217
227
|
|
|
218
228
|
return response.status_code, response.headers, response.text
|
|
219
229
|
|
|
@@ -3,13 +3,14 @@ import click
|
|
|
3
3
|
from sendbee_api.auth import SendbeeAuth
|
|
4
4
|
from sendbee_api.teams.client import Teams
|
|
5
5
|
from sendbee_api.contacts.client import Contacts
|
|
6
|
+
from sendbee_api.webhooks.client import Webhooks
|
|
6
7
|
from sendbee_api.rate_limit.client import RateLimit
|
|
7
8
|
from sendbee_api.automation.client import Automation
|
|
8
9
|
from sendbee_api.conversations.client import Messages
|
|
9
10
|
from sendbee_api.exceptions import SendbeeRequestApiException
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
class Client(Contacts, Messages, Automation, Teams, RateLimit):
|
|
13
|
+
class Client(Contacts, Messages, Automation, Teams, Webhooks, RateLimit):
|
|
13
14
|
"""Main API class. Sets all API calls."""
|
|
14
15
|
|
|
15
16
|
base_url = 'api-v2.sendbee.io'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from abc import ABCMeta
|
|
1
2
|
from collections import namedtuple
|
|
2
3
|
|
|
3
4
|
|
|
@@ -64,3 +65,23 @@ ResponseDataConst = namedtuple(
|
|
|
64
65
|
'ResponseDataConst', ['DATA', 'META']
|
|
65
66
|
)('data', 'meta')
|
|
66
67
|
|
|
68
|
+
|
|
69
|
+
class ConstMeta(ABCMeta):
|
|
70
|
+
def __setattr__(self, name, value):
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Const(metaclass=ConstMeta):
|
|
75
|
+
"""Helper class """
|
|
76
|
+
__slots__ = ()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class DebugConst(Const):
|
|
80
|
+
PARAMETERS = 'parameters'
|
|
81
|
+
RESPONSE = 'response'
|
|
82
|
+
STATUS_CODE = 'status code'
|
|
83
|
+
FINAL_URL = 'final url'
|
|
84
|
+
HEADERS = 'headers'
|
|
85
|
+
METHOD = 'method'
|
|
86
|
+
QUERY_PARAMETERS = 'query parameters'
|
|
87
|
+
CURL = 'curl'
|
|
@@ -41,6 +41,8 @@ class SentMessage(Model):
|
|
|
41
41
|
|
|
42
42
|
_conversation_id = TextField(index='id', desc='Conversation UUID')
|
|
43
43
|
_message_id = TextField(index='message_id', desc='Message UUID')
|
|
44
|
+
_message_reference_id = TextField(index='message_reference_id',
|
|
45
|
+
desc='Message Reference UUID')
|
|
44
46
|
_status = TextField(index='status', desc='Message status')
|
|
45
47
|
|
|
46
48
|
|
|
@@ -21,6 +21,7 @@ class SendTemplateMessage(QueryParams):
|
|
|
21
21
|
prevent_bot_off = 'prevent_bot_off', 'Prevent turning-off chatbot'
|
|
22
22
|
agent_id = 'agent_id', 'Assigned agent for the conversation'
|
|
23
23
|
attachment = 'attachment', 'Attachment URL for media templates'
|
|
24
|
+
live_inbox = 'live_inbox', 'Trigger real-time events after sending'
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class SendMessage(QueryParams):
|
|
@@ -31,6 +32,7 @@ class SendMessage(QueryParams):
|
|
|
31
32
|
media_url = 'media_url', 'Media URL for media message'
|
|
32
33
|
prevent_bot_off = 'prevent_bot_off', 'Prevent turning-off chatbot'
|
|
33
34
|
agent_id = 'agent_id', 'Assigned agent for the conversation'
|
|
35
|
+
live_inbox = 'live_inbox', 'Trigger real-time events after sending'
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
class ListConversations(QueryParams):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import click
|
|
2
|
-
import
|
|
2
|
+
import curlify
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
STATUS_OK = 'ok'
|
|
@@ -25,6 +25,13 @@ class Debug:
|
|
|
25
25
|
def error(self, key, value):
|
|
26
26
|
self.record(key, value, STATUS_ERROR)
|
|
27
27
|
|
|
28
|
+
def set_curl(self, key, request):
|
|
29
|
+
if self.client.debug:
|
|
30
|
+
try:
|
|
31
|
+
self.ok(key, curlify.to_curl(request, compressed=False))
|
|
32
|
+
except UnicodeDecodeError:
|
|
33
|
+
self.ok(key, '__unable_to_decode__')
|
|
34
|
+
|
|
28
35
|
def record(self, key, value, status):
|
|
29
36
|
if self.client.debug:
|
|
30
37
|
self.recorded_data[key] = {'value': value, 'status': status}
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from sendbee_api import constants
|
|
2
|
+
from sendbee_api.webhooks import models
|
|
3
|
+
from sendbee_api.bind import bind_request
|
|
4
|
+
from sendbee_api.webhooks import query_params
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Webhooks:
|
|
8
|
+
"""Api client for webhooks"""
|
|
9
|
+
|
|
10
|
+
subscribe_webhook = bind_request(
|
|
11
|
+
api_path='/webhooks/subscribe',
|
|
12
|
+
model=models.Webhook,
|
|
13
|
+
method=constants.RequestConst.POST,
|
|
14
|
+
query_parameters=query_params.SubscribeWebhook,
|
|
15
|
+
description='Api client for subscribing to a webhook event'
|
|
16
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from sendbee_api.models import Model
|
|
2
|
+
from sendbee_api.fields import (
|
|
3
|
+
TextField, BooleanField, DatetimeField, ListField
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Webhook(Model):
|
|
8
|
+
"""Data model for a webhook endpoint subscription"""
|
|
9
|
+
|
|
10
|
+
_id = TextField(index='id', desc='UUID')
|
|
11
|
+
_url = TextField(index='url', desc='Webhook endpoint URL')
|
|
12
|
+
_active = BooleanField(index='active', desc='Is the endpoint active')
|
|
13
|
+
_secret_key = TextField(
|
|
14
|
+
index='secret_key',
|
|
15
|
+
desc='Key that signs the X-Auth-Token header on inbound webhooks'
|
|
16
|
+
)
|
|
17
|
+
_selected_webhooks = ListField(
|
|
18
|
+
index='selected_webhooks', desc='Subscribed webhook event names'
|
|
19
|
+
)
|
|
20
|
+
_created_at = DatetimeField(
|
|
21
|
+
index='created_at', desc='Created at', format='%Y-%m-%d %H:%M:%'
|
|
22
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from sendbee_api.query_params import QueryParams
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SubscribeWebhook(QueryParams):
|
|
5
|
+
"""Parameters for subscribing to a webhook event"""
|
|
6
|
+
|
|
7
|
+
url = 'url', 'Webhook endpoint URL that will receive the events'
|
|
8
|
+
event = 'event', 'Webhook event name, e.g. "message.received". ' \
|
|
9
|
+
'See https://developer.ainumber.com/#webhooks'
|