bestsms 3.0.0.0__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.
- bestsms/__init__.py +76 -0
- bestsms/_config.py +7 -0
- bestsms/api/__init__.py +0 -0
- bestsms/api/v204/__init__.py +0 -0
- bestsms/api/v204/_config.py +11 -0
- bestsms/api/v204/actions/__init__.py +68 -0
- bestsms/api/v204/actions/dtos/__init__.py +0 -0
- bestsms/api/v204/actions/dtos/action_api_result_dto.py +16 -0
- bestsms/api/v204/actions/requests/__init__.py +55 -0
- bestsms/api/v204/actions/requests/_common.py +63 -0
- bestsms/api/v204/actions/requests/abort.py +119 -0
- bestsms/api/v204/actions/requests/reschedule.py +137 -0
- bestsms/api/v204/actions/requests/resubmit.py +128 -0
- bestsms/api/v204/actions/responses/__init__.py +8 -0
- bestsms/api/v204/actions/responses/action_api_result.py +60 -0
- bestsms/api/v204/addressbook/__init__.py +67 -0
- bestsms/api/v204/addressbook/contactgroups/__init__.py +0 -0
- bestsms/api/v204/addressbook/contactgroups/dtos/__init__.py +0 -0
- bestsms/api/v204/addressbook/contactgroups/dtos/contact_group_api_create_request_dto.py +12 -0
- bestsms/api/v204/addressbook/contactgroups/dtos/contact_group_api_result_dto.py +19 -0
- bestsms/api/v204/addressbook/contactgroups/dtos/contact_group_list_api_result_dto.py +20 -0
- bestsms/api/v204/addressbook/contactgroups/requests/__init__.py +94 -0
- bestsms/api/v204/addressbook/contactgroups/requests/_common.py +69 -0
- bestsms/api/v204/addressbook/contactgroups/requests/create.py +85 -0
- bestsms/api/v204/addressbook/contactgroups/requests/delete.py +88 -0
- bestsms/api/v204/addressbook/contactgroups/requests/detail.py +88 -0
- bestsms/api/v204/addressbook/contactgroups/requests/list.py +107 -0
- bestsms/api/v204/addressbook/contactgroups/responses/__init__.py +0 -0
- bestsms/api/v204/addressbook/contactgroups/responses/contact_group_api_result.py +87 -0
- bestsms/api/v204/addressbook/contactgroups/responses/contact_group_list_api_result.py +91 -0
- bestsms/api/v204/addressbook/contacts/__init__.py +68 -0
- bestsms/api/v204/addressbook/contacts/dtos/__init__.py +0 -0
- bestsms/api/v204/addressbook/contacts/dtos/contact_api_result_dto.py +15 -0
- bestsms/api/v204/addressbook/contacts/dtos/contact_list_api_result_dto.py +18 -0
- bestsms/api/v204/addressbook/contacts/dtos/contact_model.py +46 -0
- bestsms/api/v204/addressbook/contacts/requests/__init__.py +114 -0
- bestsms/api/v204/addressbook/contacts/requests/_common.py +64 -0
- bestsms/api/v204/addressbook/contacts/requests/create.py +91 -0
- bestsms/api/v204/addressbook/contacts/requests/delete.py +77 -0
- bestsms/api/v204/addressbook/contacts/requests/detail.py +77 -0
- bestsms/api/v204/addressbook/contacts/requests/list.py +99 -0
- bestsms/api/v204/addressbook/contacts/requests/update.py +97 -0
- bestsms/api/v204/addressbook/contacts/responses/__init__.py +0 -0
- bestsms/api/v204/addressbook/contacts/responses/contact_api_result.py +72 -0
- bestsms/api/v204/addressbook/contacts/responses/contact_list_api_result.py +74 -0
- bestsms/api/v204/addressbook/groupcontacts/__init__.py +0 -0
- bestsms/api/v204/addressbook/groupcontacts/dtos/__init__.py +0 -0
- bestsms/api/v204/addressbook/groupcontacts/dtos/group_contact_api_create_request_dto.py +12 -0
- bestsms/api/v204/addressbook/groupcontacts/dtos/group_contact_api_result_dto.py +19 -0
- bestsms/api/v204/addressbook/groupcontacts/dtos/group_contact_list_api_result_dto.py +20 -0
- bestsms/api/v204/addressbook/groupcontacts/requests/__init__.py +95 -0
- bestsms/api/v204/addressbook/groupcontacts/requests/_common.py +69 -0
- bestsms/api/v204/addressbook/groupcontacts/requests/create.py +85 -0
- bestsms/api/v204/addressbook/groupcontacts/requests/delete.py +87 -0
- bestsms/api/v204/addressbook/groupcontacts/requests/detail.py +88 -0
- bestsms/api/v204/addressbook/groupcontacts/requests/list.py +107 -0
- bestsms/api/v204/addressbook/groupcontacts/responses/__init__.py +0 -0
- bestsms/api/v204/addressbook/groupcontacts/responses/group_contact_api_result.py +88 -0
- bestsms/api/v204/addressbook/groupcontacts/responses/group_contact_list_api_result.py +92 -0
- bestsms/api/v204/addressbook/groups/__init__.py +0 -0
- bestsms/api/v204/addressbook/groups/dtos/__init__.py +0 -0
- bestsms/api/v204/addressbook/groups/dtos/group_api_result_dto.py +14 -0
- bestsms/api/v204/addressbook/groups/dtos/group_list_api_result_dto.py +18 -0
- bestsms/api/v204/addressbook/groups/dtos/group_model.py +19 -0
- bestsms/api/v204/addressbook/groups/requests/__init__.py +115 -0
- bestsms/api/v204/addressbook/groups/requests/_common.py +64 -0
- bestsms/api/v204/addressbook/groups/requests/create.py +92 -0
- bestsms/api/v204/addressbook/groups/requests/delete.py +77 -0
- bestsms/api/v204/addressbook/groups/requests/detail.py +77 -0
- bestsms/api/v204/addressbook/groups/requests/list.py +96 -0
- bestsms/api/v204/addressbook/groups/requests/update.py +97 -0
- bestsms/api/v204/addressbook/groups/responses/__init__.py +0 -0
- bestsms/api/v204/addressbook/groups/responses/group_api_result.py +75 -0
- bestsms/api/v204/addressbook/groups/responses/group_list_api_result.py +76 -0
- bestsms/api/v204/messaging/__init__.py +0 -0
- bestsms/api/v204/messaging/dtos/__init__.py +0 -0
- bestsms/api/v204/messaging/dtos/common_api_request_dto.py +37 -0
- bestsms/api/v204/messaging/dtos/message_api_result_dto.py +12 -0
- bestsms/api/v204/messaging/dtos/recipient_model.py +35 -0
- bestsms/api/v204/messaging/dtos/sms_api_request_dto.py +15 -0
- bestsms/api/v204/messaging/requests/__init__.py +16 -0
- bestsms/api/v204/messaging/requests/_common.py +174 -0
- bestsms/api/v204/messaging/requests/sms_api.py +290 -0
- bestsms/api/v204/messaging/responses/__init__.py +8 -0
- bestsms/api/v204/messaging/responses/message_api_result.py +69 -0
- bestsms/api/v204/reports/__init__.py +0 -0
- bestsms/api/v204/reports/dtos/__init__.py +0 -0
- bestsms/api/v204/reports/dtos/recipient_dto.py +33 -0
- bestsms/api/v204/reports/dtos/sms_message_in_dto.py +24 -0
- bestsms/api/v204/reports/dtos/sms_received_dto.py +17 -0
- bestsms/api/v204/reports/dtos/sms_reply_dto.py +38 -0
- bestsms/api/v204/reports/dtos/sms_reply_recipient_dto.py +15 -0
- bestsms/api/v204/reports/dtos/sms_reply_recipient_reply_dto.py +18 -0
- bestsms/api/v204/reports/dtos/status_dto.py +38 -0
- bestsms/api/v204/reports/requests/__init__.py +44 -0
- bestsms/api/v204/reports/requests/_common.py +63 -0
- bestsms/api/v204/reports/requests/sms_received.py +144 -0
- bestsms/api/v204/reports/requests/sms_reply.py +111 -0
- bestsms/api/v204/reports/requests/status.py +104 -0
- bestsms/api/v204/reports/responses/__init__.py +26 -0
- bestsms/api/v204/reports/responses/sms_received_result.py +74 -0
- bestsms/api/v204/reports/responses/sms_reply_result.py +97 -0
- bestsms/api/v204/reports/responses/status_request_result.py +75 -0
- bestsms/api/v300/__init__.py +0 -0
- bestsms/api/v300/actions/__init__.py +14 -0
- bestsms/api/v300/actions/builders/__init__.py +0 -0
- bestsms/api/v300/actions/builders/abort.py +15 -0
- bestsms/api/v300/actions/builders/reschedule.py +15 -0
- bestsms/api/v300/actions/models/__init__.py +0 -0
- bestsms/api/v300/actions/models/responses/__init__.py +0 -0
- bestsms/api/v300/addressbook/__init__.py +24 -0
- bestsms/api/v300/addressbook/builders/__init__.py +0 -0
- bestsms/api/v300/addressbook/builders/contact.py +137 -0
- bestsms/api/v300/addressbook/builders/contact_group.py +72 -0
- bestsms/api/v300/addressbook/builders/group.py +108 -0
- bestsms/api/v300/addressbook/builders/group_contact.py +73 -0
- bestsms/api/v300/addressbook/models/__init__.py +0 -0
- bestsms/api/v300/addressbook/models/requests/__init__.py +0 -0
- bestsms/api/v300/addressbook/models/requests/contact_request.py +48 -0
- bestsms/api/v300/addressbook/models/requests/group_request.py +17 -0
- bestsms/api/v300/addressbook/models/responses/__init__.py +0 -0
- bestsms/api/v300/addressbook/models/responses/contact_group_list_response.py +20 -0
- bestsms/api/v300/addressbook/models/responses/contact_group_response.py +16 -0
- bestsms/api/v300/addressbook/models/responses/contact_list_response.py +19 -0
- bestsms/api/v300/addressbook/models/responses/contact_response.py +60 -0
- bestsms/api/v300/addressbook/models/responses/group_contact_list_response.py +20 -0
- bestsms/api/v300/addressbook/models/responses/group_contact_response.py +16 -0
- bestsms/api/v300/addressbook/models/responses/group_list_response.py +19 -0
- bestsms/api/v300/addressbook/models/responses/group_response.py +26 -0
- bestsms/api/v300/messaging/__init__.py +9 -0
- bestsms/api/v300/messaging/builders/__init__.py +0 -0
- bestsms/api/v300/messaging/builders/sms.py +159 -0
- bestsms/api/v300/messaging/models/__init__.py +0 -0
- bestsms/api/v300/messaging/models/requests/__init__.py +0 -0
- bestsms/api/v300/messaging/models/requests/sms_request.py +35 -0
- bestsms/api/v300/messaging/models/responses/__init__.py +0 -0
- bestsms/api/v300/messaging/models/responses/sms_action_result.py +19 -0
- bestsms/api/v300/messaging/models/responses/sms_received.py +24 -0
- bestsms/api/v300/messaging/models/responses/sms_recipient.py +48 -0
- bestsms/api/v300/messaging/models/responses/sms_reply.py +30 -0
- bestsms/api/v300/messaging/models/responses/sms_response.py +15 -0
- bestsms/api/v300/messaging/models/responses/sms_status.py +45 -0
- bestsms/api/v300/optout/__init__.py +0 -0
- bestsms/api/v300/optout/builders/__init__.py +0 -0
- bestsms/api/v300/optout/builders/optout.py +202 -0
- bestsms/api/v300/optout/models/__init__.py +0 -0
- bestsms/api/v300/optout/models/requests/__init__.py +0 -0
- bestsms/api/v300/optout/models/requests/optout_batch_request.py +19 -0
- bestsms/api/v300/optout/models/requests/optout_request.py +19 -0
- bestsms/api/v300/optout/models/responses/__init__.py +0 -0
- bestsms/api/v300/optout/models/responses/optout_list_response.py +19 -0
- bestsms/api/v300/optout/models/responses/optout_response.py +30 -0
- bestsms/api/v300/reports/__init__.py +19 -0
- bestsms/api/v300/reports/builders/__init__.py +0 -0
- bestsms/api/v300/reports/builders/sms_received.py +18 -0
- bestsms/api/v300/reports/builders/sms_reply.py +17 -0
- bestsms/api/v300/reports/builders/status.py +18 -0
- bestsms/api/v300/reports/models/__init__.py +0 -0
- bestsms/api/v300/reports/models/responses/__init__.py +0 -0
- bestsms/core/__init__.py +0 -0
- bestsms/core/auth.py +17 -0
- bestsms/core/deprecated_alias.py +30 -0
- bestsms/core/destination.py +46 -0
- bestsms/core/dict_compat.py +76 -0
- bestsms/core/dtos/__init__.py +0 -0
- bestsms/core/dtos/error_dto.py +12 -0
- bestsms/core/dtos/error_with_message_id_dto.py +12 -0
- bestsms/core/dtos/list_request_dto.py +12 -0
- bestsms/core/file_attachment.py +97 -0
- bestsms/core/http_client.py +55 -0
- bestsms/core/legacy_kwargs.py +30 -0
- bestsms/core/model_conversion.py +90 -0
- bestsms/core/model_proxy.py +205 -0
- bestsms/core/response_parser.py +69 -0
- bestsms/core/send_mode.py +15 -0
- bestsms/core/serialization.py +38 -0
- bestsms/helpers/__init__.py +0 -0
- bestsms/helpers/custom_json_encoder.py +5 -0
- bestsms/helpers/functions.py +47 -0
- bestsms/legacy/__init__.py +68 -0
- bestsms/models.py +50 -0
- bestsms/webhooks/__init__.py +47 -0
- bestsms-3.0.0.0.dist-info/METADATA +631 -0
- bestsms-3.0.0.0.dist-info/RECORD +187 -0
- bestsms-3.0.0.0.dist-info/WHEEL +5 -0
- bestsms-3.0.0.0.dist-info/licenses/LICENSE +21 -0
- bestsms-3.0.0.0.dist-info/top_level.txt +1 -0
bestsms/__init__.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
class BestSMS():
|
|
2
|
+
|
|
3
|
+
def __init__(self, **kwargs):
|
|
4
|
+
self.AuthToken = kwargs.get("AuthToken")
|
|
5
|
+
self.BaseURL = kwargs.get("BaseURL")
|
|
6
|
+
|
|
7
|
+
self._messaging = None
|
|
8
|
+
self._reports = None
|
|
9
|
+
self._actions = None
|
|
10
|
+
self._addressbook = None
|
|
11
|
+
self._optout = None
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def Messaging(self):
|
|
15
|
+
|
|
16
|
+
""" bestsms.api.v300.messaging - Messaging() """
|
|
17
|
+
|
|
18
|
+
if self._messaging == None:
|
|
19
|
+
from bestsms.core.auth import BestSMSApiUser
|
|
20
|
+
from bestsms.api.v300.messaging import Messaging
|
|
21
|
+
|
|
22
|
+
self._messaging = Messaging(BestSMSApiUser(AuthToken=self.AuthToken, BaseURL=self.BaseURL))
|
|
23
|
+
|
|
24
|
+
return self._messaging
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def Reports(self):
|
|
28
|
+
|
|
29
|
+
""" bestsms.api.v300.reports - Reports() """
|
|
30
|
+
|
|
31
|
+
if self._reports == None:
|
|
32
|
+
from bestsms.core.auth import BestSMSApiUser
|
|
33
|
+
from bestsms.api.v300.reports import Reports
|
|
34
|
+
|
|
35
|
+
self._reports = Reports(BestSMSApiUser(AuthToken=self.AuthToken, BaseURL=self.BaseURL))
|
|
36
|
+
|
|
37
|
+
return self._reports
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def Actions(self):
|
|
41
|
+
|
|
42
|
+
""" bestsms.api.v300.actions - Actions() """
|
|
43
|
+
|
|
44
|
+
if self._actions == None:
|
|
45
|
+
from bestsms.core.auth import BestSMSApiUser
|
|
46
|
+
from bestsms.api.v300.actions import Actions
|
|
47
|
+
|
|
48
|
+
self._actions = Actions(BestSMSApiUser(AuthToken=self.AuthToken, BaseURL=self.BaseURL))
|
|
49
|
+
|
|
50
|
+
return self._actions
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def Addressbook(self):
|
|
54
|
+
|
|
55
|
+
""" bestsms.api.v300.addressbook - Addressbook() """
|
|
56
|
+
|
|
57
|
+
if self._addressbook == None:
|
|
58
|
+
from bestsms.core.auth import BestSMSApiUser
|
|
59
|
+
from bestsms.api.v300.addressbook import Addressbook
|
|
60
|
+
|
|
61
|
+
self._addressbook = Addressbook(BestSMSApiUser(AuthToken=self.AuthToken, BaseURL=self.BaseURL))
|
|
62
|
+
|
|
63
|
+
return self._addressbook
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def OptOut(self):
|
|
67
|
+
|
|
68
|
+
""" bestsms.api.v300.optout.builders.optout - OptOut() """
|
|
69
|
+
|
|
70
|
+
if self._optout == None:
|
|
71
|
+
from bestsms.core.auth import BestSMSApiUser
|
|
72
|
+
from bestsms.api.v300.optout.builders.optout import OptOut
|
|
73
|
+
|
|
74
|
+
self._optout = OptOut(BestSMSApiUser(AuthToken=self.AuthToken, BaseURL=self.BaseURL))
|
|
75
|
+
|
|
76
|
+
return self._optout
|
bestsms/_config.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Backward-compatibility shim: the legacy config now lives in bestsms/api/v204/_config.py.
|
|
2
|
+
# Alias the same module object (not a re-export) so writes through either path stay in sync.
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from bestsms.api.v204 import _config as _v204_config
|
|
6
|
+
|
|
7
|
+
sys.modules[__name__] = _v204_config
|
bestsms/api/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Legacy-client-only config (read by bestsms/api/v204 and bestsms/legacy). The v3.00 facades use bestsms/core/auth.py instead.
|
|
2
|
+
__AuthToken__ = ""
|
|
3
|
+
__Sender__ = ""
|
|
4
|
+
__APIKey__ = ""
|
|
5
|
+
__APIVersion__ = "3.00"
|
|
6
|
+
__APIURL__ = "https://api.bestsms.com.au/api/v"+__APIVersion__;
|
|
7
|
+
__APIHeaders__ = {
|
|
8
|
+
"Content-Type": "application/json",
|
|
9
|
+
"Accept": "application/json",
|
|
10
|
+
"encoding": "utf-8"
|
|
11
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from bestsms.api.v204 import _config
|
|
2
|
+
|
|
3
|
+
class BestSMS():
|
|
4
|
+
|
|
5
|
+
def __init__(self, **kwargs):
|
|
6
|
+
for key, value in kwargs.items():
|
|
7
|
+
|
|
8
|
+
if key == "AuthToken":
|
|
9
|
+
self.AuthToken = _config.__AuthToken__ = value
|
|
10
|
+
_config.__APIHeaders__["Authorization"] = f"Basic {self.AuthToken}"
|
|
11
|
+
|
|
12
|
+
if key == "Sender":
|
|
13
|
+
self.Sender = _config.__Sender__ = value
|
|
14
|
+
|
|
15
|
+
if key == "APIKey":
|
|
16
|
+
self.APIKey = _config.__APIKey__ = value
|
|
17
|
+
|
|
18
|
+
self._messaging = None
|
|
19
|
+
self._reports = None
|
|
20
|
+
self._actions = None
|
|
21
|
+
self._addressbook = None
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Renamed since v2.3.0.0
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def Messaging(self, **kwargs):
|
|
29
|
+
|
|
30
|
+
""" bestsms.messaging.__init__.py - Messaging() """
|
|
31
|
+
|
|
32
|
+
if self._messaging == None:
|
|
33
|
+
from bestsms.api.v204.messaging.requests import Messaging
|
|
34
|
+
|
|
35
|
+
self._messaging = Messaging(**kwargs)
|
|
36
|
+
|
|
37
|
+
return self._messaging
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def Reports(self, **kwargs):
|
|
41
|
+
|
|
42
|
+
""" bestsms.reports._reference.py - Reference() """
|
|
43
|
+
|
|
44
|
+
if self._reports == None:
|
|
45
|
+
from bestsms.api.v204.reports.requests import Reports
|
|
46
|
+
self._reports = Reports(**kwargs)
|
|
47
|
+
|
|
48
|
+
return self._reports
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def Actions(self, **kwargs):
|
|
52
|
+
|
|
53
|
+
""" bestsms.actions._reference.py - Reference() """
|
|
54
|
+
|
|
55
|
+
if self._actions == None:
|
|
56
|
+
from bestsms.api.v204.actions.requests import Actions
|
|
57
|
+
self._actions = Actions(**kwargs)
|
|
58
|
+
|
|
59
|
+
return self._actions
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def Addressbook(self, **kwargs):
|
|
63
|
+
|
|
64
|
+
if self._addressbook == None:
|
|
65
|
+
from bestsms.api.v204.addressbook import Addressbook
|
|
66
|
+
self._addressbook = Addressbook(**kwargs)
|
|
67
|
+
|
|
68
|
+
return self._addressbook
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from bestsms.helpers.functions import Functions
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class ActionApiResultDTO:
|
|
7
|
+
Result: str = None
|
|
8
|
+
MessageID: str = None
|
|
9
|
+
JobNum: str = None
|
|
10
|
+
Status: str = None
|
|
11
|
+
Action: str = None
|
|
12
|
+
ErrorMessage: list[str] = field(default_factory=list)
|
|
13
|
+
|
|
14
|
+
def __repr__(self):
|
|
15
|
+
return Functions.__pretty_class__(self, self)
|
|
16
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
class Actions(object):
|
|
2
|
+
|
|
3
|
+
def __init__(self):
|
|
4
|
+
self._abort = None
|
|
5
|
+
self._pacing = None
|
|
6
|
+
self._reschedule = None
|
|
7
|
+
self._resubmit = None
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def Abort(self,**kwargs):
|
|
11
|
+
|
|
12
|
+
from bestsms.api.v204.actions.requests.abort import Abort
|
|
13
|
+
|
|
14
|
+
if self._abort != None:
|
|
15
|
+
del(self._abort)
|
|
16
|
+
|
|
17
|
+
self._abort = Abort(kwargs)
|
|
18
|
+
|
|
19
|
+
return self._abort
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def Pacing(self,**kwargs):
|
|
23
|
+
|
|
24
|
+
from bestsms.api.v204.actions.requests.pacing import Pacing
|
|
25
|
+
|
|
26
|
+
if self._pacing != None:
|
|
27
|
+
del(self._pacing)
|
|
28
|
+
|
|
29
|
+
self._pacing = Pacing(kwargs)
|
|
30
|
+
|
|
31
|
+
return self._pacing
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def Reschedule(self,**kwargs):
|
|
35
|
+
|
|
36
|
+
from bestsms.api.v204.actions.requests.reschedule import Reschedule
|
|
37
|
+
|
|
38
|
+
if self._reschedule != None:
|
|
39
|
+
del(self._reschedule)
|
|
40
|
+
|
|
41
|
+
self._reschedule = Reschedule(kwargs)
|
|
42
|
+
|
|
43
|
+
return self._reschedule
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def Resubmit(self,**kwargs):
|
|
47
|
+
|
|
48
|
+
from bestsms.api.v204.actions.requests.resubmit import Resubmit
|
|
49
|
+
|
|
50
|
+
if self._resubmit != None:
|
|
51
|
+
del(self._resubmit)
|
|
52
|
+
|
|
53
|
+
self._resubmit = Resubmit(kwargs)
|
|
54
|
+
|
|
55
|
+
return self._resubmit
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from bestsms.api.v204 import _config
|
|
2
|
+
from bestsms.helpers.functions import Functions
|
|
3
|
+
|
|
4
|
+
class Common:
|
|
5
|
+
|
|
6
|
+
AuthToken = _config.__AuthToken__
|
|
7
|
+
Sender = _config.__Sender__
|
|
8
|
+
APIKey = _config.__APIKey__
|
|
9
|
+
APIVersion = _config.__APIVersion__
|
|
10
|
+
APIURL = _config.__APIURL__
|
|
11
|
+
APIHeaders = _config.__APIHeaders__
|
|
12
|
+
|
|
13
|
+
MessageID = ""
|
|
14
|
+
|
|
15
|
+
""" Constructor """
|
|
16
|
+
def __init__(self,kwargs):
|
|
17
|
+
|
|
18
|
+
self.AuthToken = _config.__AuthToken__
|
|
19
|
+
self.Sender = _config.__Sender__
|
|
20
|
+
self.APIKey = _config.__APIKey__
|
|
21
|
+
self.APIVersion = _config.__APIVersion__
|
|
22
|
+
self.APIURL = _config.__APIURL__
|
|
23
|
+
self.APIHeaders = _config.__APIHeaders__
|
|
24
|
+
|
|
25
|
+
self.MessageID = ""
|
|
26
|
+
|
|
27
|
+
self.SetArgsCommon(kwargs)
|
|
28
|
+
|
|
29
|
+
""" Destructor """
|
|
30
|
+
def __del__(self):
|
|
31
|
+
self.AuthToken = ""
|
|
32
|
+
self.Sender = ""
|
|
33
|
+
self.APIKey = ""
|
|
34
|
+
self.APIVersion = ""
|
|
35
|
+
self.APIURL = ""
|
|
36
|
+
self.APIHeaders = ""
|
|
37
|
+
|
|
38
|
+
self.MessageID = ""
|
|
39
|
+
|
|
40
|
+
""" Set Args """
|
|
41
|
+
def SetArgsCommon(self, kwargs):
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# AuthToken / Send / APIKey can be overriden in the BestSMS.Set.xxx() functions
|
|
45
|
+
# Default initialization happens in /__init__.py
|
|
46
|
+
#
|
|
47
|
+
|
|
48
|
+
if "AuthToken" in kwargs:
|
|
49
|
+
self.AuthToken = _config.__AuthToken__ = kwargs.pop("AuthToken")
|
|
50
|
+
self.APIHeaders["Authorization"] = _config.__APIHeaders__["Authorization"] = f"Basic {self.AuthToken}"
|
|
51
|
+
|
|
52
|
+
if "Sender" in kwargs:
|
|
53
|
+
self.Sender = _config.__Sender__ = kwargs.pop("Sender")
|
|
54
|
+
|
|
55
|
+
if "APIKey" in kwargs:
|
|
56
|
+
self.APIKey = _config.__APIKey__ = kwargs.pop("APIKey")
|
|
57
|
+
|
|
58
|
+
if "MessageID" in kwargs:
|
|
59
|
+
self.MessageID = kwargs.pop("MessageID")
|
|
60
|
+
|
|
61
|
+
def __pretty__(self,obj):
|
|
62
|
+
|
|
63
|
+
return Functions.__pretty__(self,obj)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from bestsms.api.v204.actions.requests._common import Common
|
|
6
|
+
from bestsms.api.v204.actions.responses import ActionApiResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Abort(Common):
|
|
10
|
+
|
|
11
|
+
""" Constructor """
|
|
12
|
+
def __init__(self, kwargs):
|
|
13
|
+
|
|
14
|
+
super().__init__(kwargs)
|
|
15
|
+
|
|
16
|
+
#self.SetArgs(kwargs)
|
|
17
|
+
|
|
18
|
+
""" Update Data """
|
|
19
|
+
#def SetArgs(self, kwargs):
|
|
20
|
+
|
|
21
|
+
#super().SetArgs(kwargs)
|
|
22
|
+
|
|
23
|
+
""" API Data """
|
|
24
|
+
@property
|
|
25
|
+
def APIDataWithSender(self):
|
|
26
|
+
return {
|
|
27
|
+
"Sender": self.Sender,
|
|
28
|
+
"APIKey": self.APIKey,
|
|
29
|
+
"MessageID" : self.MessageID
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def APIDataWithAuthToken(self):
|
|
34
|
+
return {}
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def APIData(self):
|
|
38
|
+
if self.AuthToken :
|
|
39
|
+
return self.APIDataWithAuthToken
|
|
40
|
+
return self.APIDataWithSender
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def BuildAPIURL(self):
|
|
44
|
+
|
|
45
|
+
url = self.APIURL+"/set/abort"
|
|
46
|
+
|
|
47
|
+
if self.AuthToken :
|
|
48
|
+
url = f"{url}/{self.MessageID}"
|
|
49
|
+
|
|
50
|
+
return url
|
|
51
|
+
|
|
52
|
+
""" Private function to POST message to BestSMS REST API """
|
|
53
|
+
def __PostMessage(self):
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
if self.AuthToken :
|
|
57
|
+
r = requests.patch(self.BuildAPIURL, data=json.dumps(self.APIData), headers=self.APIHeaders)
|
|
58
|
+
else :
|
|
59
|
+
r = requests.post(self.BuildAPIURL, data=json.dumps(self.APIData), headers=self.APIHeaders)
|
|
60
|
+
r.raise_for_status()
|
|
61
|
+
except requests.exceptions.HTTPError as e:
|
|
62
|
+
return ActionApiResult(response=r)
|
|
63
|
+
except requests.exceptions.RequestException as e: # This is the correct syntax
|
|
64
|
+
return ActionApiResult(error=str(e))
|
|
65
|
+
|
|
66
|
+
return ActionApiResult(response=r)
|
|
67
|
+
|
|
68
|
+
""" Private async function to POST message to BestSMS REST API """
|
|
69
|
+
async def __PostMessageAsync(self):
|
|
70
|
+
|
|
71
|
+
return self.__PostMessage()
|
|
72
|
+
|
|
73
|
+
""" Function to send message """
|
|
74
|
+
def SendRequest(self, **kwargs):
|
|
75
|
+
|
|
76
|
+
if kwargs != None and len(kwargs) > 0:
|
|
77
|
+
self.__init__(kwargs)
|
|
78
|
+
|
|
79
|
+
if not self.AuthToken :
|
|
80
|
+
|
|
81
|
+
if not self.Sender :
|
|
82
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
83
|
+
|
|
84
|
+
if not self.APIKey :
|
|
85
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
86
|
+
|
|
87
|
+
if not self.MessageID:
|
|
88
|
+
return ActionApiResult(error="Missing MessageID")
|
|
89
|
+
|
|
90
|
+
return self.__PostMessage()
|
|
91
|
+
|
|
92
|
+
""" Async Function to send message """
|
|
93
|
+
async def SendRequestAsync(self, **kwargs):
|
|
94
|
+
|
|
95
|
+
if kwargs != None and len(kwargs) > 0:
|
|
96
|
+
self.__init__(kwargs)
|
|
97
|
+
|
|
98
|
+
if not self.AuthToken :
|
|
99
|
+
|
|
100
|
+
if not self.Sender :
|
|
101
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
102
|
+
|
|
103
|
+
if not self.APIKey :
|
|
104
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
105
|
+
|
|
106
|
+
if not self.MessageID:
|
|
107
|
+
return ActionApiResult(error="Missing MessageID")
|
|
108
|
+
|
|
109
|
+
return await asyncio.create_task(self.__PostMessageAsync())
|
|
110
|
+
|
|
111
|
+
def __repr__(self):
|
|
112
|
+
return self.__pretty__(self.APIData)
|
|
113
|
+
|
|
114
|
+
def __str__(self):
|
|
115
|
+
|
|
116
|
+
if self.AuthToken :
|
|
117
|
+
return 'Abort(AuthToken='+self.AuthToken+ ')'
|
|
118
|
+
|
|
119
|
+
return 'Abort(Sender='+self.Sender+', APIKey='+str(self.APIKey)+ ')'
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
import requests
|
|
3
|
+
import json
|
|
4
|
+
import asyncio
|
|
5
|
+
|
|
6
|
+
from bestsms.api.v204.actions.requests._common import Common
|
|
7
|
+
from bestsms.api.v204.actions.responses import ActionApiResult
|
|
8
|
+
|
|
9
|
+
class Reschedule(Common):
|
|
10
|
+
|
|
11
|
+
SendTime = datetime.now()
|
|
12
|
+
|
|
13
|
+
""" Constructor """
|
|
14
|
+
def __init__(self, kwargs):
|
|
15
|
+
|
|
16
|
+
super().__init__(kwargs)
|
|
17
|
+
|
|
18
|
+
self.SetArgsChild(kwargs)
|
|
19
|
+
|
|
20
|
+
""" Destructor """
|
|
21
|
+
def __del__(self):
|
|
22
|
+
self.SendTime = ""
|
|
23
|
+
|
|
24
|
+
""" Update Data """
|
|
25
|
+
def SetArgsChild(self, kwargs):
|
|
26
|
+
|
|
27
|
+
#super().SetArgs(kwargs)
|
|
28
|
+
|
|
29
|
+
for key, value in kwargs.items():
|
|
30
|
+
|
|
31
|
+
if key == "SendTime":
|
|
32
|
+
self.SendTime = datetime.fromisoformat(value)
|
|
33
|
+
|
|
34
|
+
""" API Data """
|
|
35
|
+
@property
|
|
36
|
+
def APIDataWithSender(self):
|
|
37
|
+
return {
|
|
38
|
+
"Sender": self.Sender,
|
|
39
|
+
"APIKey": self.APIKey,
|
|
40
|
+
"MessageID" : self.MessageID,
|
|
41
|
+
"SendTime": self.SendTime.strftime("%Y-%m-%dT%H:%M:%S")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def APIDataWithAuthToken(self):
|
|
46
|
+
return {
|
|
47
|
+
"SendTime": self.SendTime.strftime("%Y-%m-%dT%H:%M:%S")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def APIData(self):
|
|
52
|
+
if self.AuthToken :
|
|
53
|
+
return self.APIDataWithAuthToken
|
|
54
|
+
return self.APIDataWithSender
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def BuildAPIURL(self):
|
|
58
|
+
|
|
59
|
+
url = self.APIURL+"/set/reschedule"
|
|
60
|
+
|
|
61
|
+
if self.AuthToken :
|
|
62
|
+
url = f"{url}/{self.MessageID}"
|
|
63
|
+
|
|
64
|
+
return url
|
|
65
|
+
|
|
66
|
+
""" Private function to POST message to BestSMS REST API """
|
|
67
|
+
def __PostMessage(self):
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
if self.AuthToken :
|
|
71
|
+
r = requests.patch(self.BuildAPIURL, data=json.dumps(self.APIData), headers=self.APIHeaders)
|
|
72
|
+
else :
|
|
73
|
+
r = requests.post(self.BuildAPIURL, data=json.dumps(self.APIData), headers=self.APIHeaders)
|
|
74
|
+
r.raise_for_status()
|
|
75
|
+
except requests.exceptions.HTTPError as e:
|
|
76
|
+
return ActionApiResult(response=r)
|
|
77
|
+
except requests.exceptions.RequestException as e: # This is the correct syntax
|
|
78
|
+
return ActionApiResult(error=str(e))
|
|
79
|
+
|
|
80
|
+
return ActionApiResult(response=r)
|
|
81
|
+
|
|
82
|
+
""" Private async function to POST message to BestSMS REST API """
|
|
83
|
+
async def __PostMessageAsync(self):
|
|
84
|
+
|
|
85
|
+
return self.__PostMessage()
|
|
86
|
+
|
|
87
|
+
""" Function to send message """
|
|
88
|
+
def SendRequest(self, **kwargs):
|
|
89
|
+
|
|
90
|
+
if kwargs != None and len(kwargs) > 0:
|
|
91
|
+
self.__init__(kwargs)
|
|
92
|
+
|
|
93
|
+
if not self.AuthToken :
|
|
94
|
+
if not self.Sender :
|
|
95
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
96
|
+
|
|
97
|
+
if not self.APIKey :
|
|
98
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
99
|
+
|
|
100
|
+
if not self.MessageID:
|
|
101
|
+
return ActionApiResult(error="Missing MessageID")
|
|
102
|
+
|
|
103
|
+
if not self.SendTime:
|
|
104
|
+
return ActionApiResult(error="Missing SendTime")
|
|
105
|
+
|
|
106
|
+
return self.__PostMessage()
|
|
107
|
+
|
|
108
|
+
""" Async Function to send message """
|
|
109
|
+
async def SendRequestAsync(self, **kwargs):
|
|
110
|
+
|
|
111
|
+
if kwargs != None and len(kwargs) > 0:
|
|
112
|
+
self.__init__(kwargs)
|
|
113
|
+
|
|
114
|
+
if not self.AuthToken :
|
|
115
|
+
if not self.Sender :
|
|
116
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
117
|
+
|
|
118
|
+
if not self.APIKey :
|
|
119
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
120
|
+
|
|
121
|
+
if not self.MessageID:
|
|
122
|
+
return ActionApiResult(error="Missing MessageID")
|
|
123
|
+
|
|
124
|
+
if not self.SendTime:
|
|
125
|
+
return ActionApiResult(error="Missing SendTime")
|
|
126
|
+
|
|
127
|
+
return await asyncio.create_task(self.__PostMessageAsync())
|
|
128
|
+
|
|
129
|
+
def __repr__(self):
|
|
130
|
+
return self.__pretty__(self.APIData)
|
|
131
|
+
|
|
132
|
+
def __str__(self):
|
|
133
|
+
|
|
134
|
+
if self.AuthToken :
|
|
135
|
+
return 'Reschedule(AuthToken='+self.AuthToken+ ')'
|
|
136
|
+
|
|
137
|
+
return 'Reschedule(Sender='+self.Sender+', APIKey='+str(self.APIKey)+ ')'
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
import asyncio
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from bestsms.api.v204.actions.requests._common import Common
|
|
7
|
+
from bestsms.api.v204.actions.responses import ActionApiResult
|
|
8
|
+
|
|
9
|
+
class Resubmit(Common):
|
|
10
|
+
|
|
11
|
+
SendTime = datetime.now()
|
|
12
|
+
|
|
13
|
+
""" Constructor """
|
|
14
|
+
def __init__(self, kwargs):
|
|
15
|
+
|
|
16
|
+
super().__init__(kwargs)
|
|
17
|
+
|
|
18
|
+
self.SetArgsChild(kwargs)
|
|
19
|
+
|
|
20
|
+
""" Update Data """
|
|
21
|
+
def SetArgsChild(self, kwargs):
|
|
22
|
+
|
|
23
|
+
#super().SetArgs(kwargs)
|
|
24
|
+
|
|
25
|
+
for key, value in kwargs.items():
|
|
26
|
+
if key == "SendTime":
|
|
27
|
+
self.SendTime = datetime.fromisoformat(value)
|
|
28
|
+
|
|
29
|
+
""" API Data """
|
|
30
|
+
@property
|
|
31
|
+
def APIDataWithSender(self):
|
|
32
|
+
return {
|
|
33
|
+
"Sender": self.Sender,
|
|
34
|
+
"APIKey": self.APIKey,
|
|
35
|
+
"MessageID" : self.MessageID,
|
|
36
|
+
"SendTime": self.SendTime.strftime("%Y-%m-%dT%H:%M:%S")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def APIDataWithAuthToken(self):
|
|
41
|
+
return {
|
|
42
|
+
"SendTime": self.SendTime.strftime("%Y-%m-%dT%H:%M:%S")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def APIData(self):
|
|
47
|
+
if self.AuthToken :
|
|
48
|
+
return self.APIDataWithAuthToken
|
|
49
|
+
return self.APIDataWithSender
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def BuildAPIURL(self):
|
|
53
|
+
|
|
54
|
+
url = self.APIURL+"/set/resubmit"
|
|
55
|
+
|
|
56
|
+
if self.AuthToken :
|
|
57
|
+
url = f"{url}/{self.MessageID}"
|
|
58
|
+
|
|
59
|
+
return url
|
|
60
|
+
|
|
61
|
+
""" Private function to POST message to BestSMS REST API """
|
|
62
|
+
def __PostMessage(self):
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
if self.AuthToken :
|
|
66
|
+
r = requests.patch(self.BuildAPIURL, data=json.dumps(self.APIData), headers=self.APIHeaders)
|
|
67
|
+
else :
|
|
68
|
+
r = requests.post(self.BuildAPIURL, data=json.dumps(self.APIData), headers=self.APIHeaders)
|
|
69
|
+
r.raise_for_status()
|
|
70
|
+
except requests.exceptions.HTTPError as e:
|
|
71
|
+
return ActionApiResult(response=r)
|
|
72
|
+
except requests.exceptions.RequestException as e: # This is the correct syntax
|
|
73
|
+
return ActionApiResult(error=str(e))
|
|
74
|
+
|
|
75
|
+
return ActionApiResult(response=r)
|
|
76
|
+
|
|
77
|
+
""" Private async function to POST message to BestSMS REST API """
|
|
78
|
+
async def __PostMessageAsync(self):
|
|
79
|
+
|
|
80
|
+
return self.__PostMessage()
|
|
81
|
+
|
|
82
|
+
""" Function to send message """
|
|
83
|
+
def SendRequest(self, **kwargs):
|
|
84
|
+
|
|
85
|
+
if kwargs != None and len(kwargs) > 0:
|
|
86
|
+
self.__init__(kwargs)
|
|
87
|
+
|
|
88
|
+
if not self.AuthToken :
|
|
89
|
+
|
|
90
|
+
if not self.Sender :
|
|
91
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
92
|
+
|
|
93
|
+
if not self.APIKey :
|
|
94
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
95
|
+
|
|
96
|
+
if not self.MessageID:
|
|
97
|
+
return ActionApiResult(error="Missing MessageID")
|
|
98
|
+
|
|
99
|
+
return self.__PostMessage()
|
|
100
|
+
|
|
101
|
+
""" Async Function to send message """
|
|
102
|
+
async def SendRequestAsync(self, **kwargs):
|
|
103
|
+
|
|
104
|
+
if kwargs != None and len(kwargs) > 0:
|
|
105
|
+
self.__init__(kwargs)
|
|
106
|
+
|
|
107
|
+
if not self.AuthToken :
|
|
108
|
+
|
|
109
|
+
if not self.Sender :
|
|
110
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
111
|
+
|
|
112
|
+
if not self.APIKey :
|
|
113
|
+
return ActionApiResult(error="Missing AuthToken")
|
|
114
|
+
|
|
115
|
+
if not self.MessageID:
|
|
116
|
+
return ActionApiResult(error="Missing MessageID")
|
|
117
|
+
|
|
118
|
+
return await asyncio.create_task(self.__PostMessageAsync())
|
|
119
|
+
|
|
120
|
+
def __repr__(self):
|
|
121
|
+
return self.__pretty__(self.APIData)
|
|
122
|
+
|
|
123
|
+
def __str__(self):
|
|
124
|
+
|
|
125
|
+
if self.AuthToken :
|
|
126
|
+
return 'Resubmit(AuthToken='+self.AuthToken+')'
|
|
127
|
+
|
|
128
|
+
return 'Resubmit(Sender='+self.Sender+', APIKey='+str(self.APIKey)+ ')'
|