serwersmsv2api 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: serwersmsv2api
3
+ Version: 0.0.1
4
+ Summary: Python client for remote communication with SerwerSMS.pl API v2
5
+ Home-page: https://serwersms.pl
6
+ Author: SerwerSMS
7
+ Author-email: dev@serwersms.pl
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # SerwerSMS.pl Python Client API
17
+ Python client for remote communication with SerwerSMS.pl API v2
18
+
19
+ Attention. The current version works based on the API token.
20
+
21
+ In order to authorize via an API Token, it must be generated on the Customer Panel side in the Interface Settings → HTTPS API → API Tokens menu. The authorization header format follows the Bearer token format.
22
+
23
+ #### Example usage
24
+ ```python
25
+ import sys
26
+ import json
27
+
28
+ from serwersms import SerwerSMS
29
+
30
+ api = SerwerSMS('token')
31
+
32
+ try:
33
+
34
+ params = {
35
+ 'test': 'true',
36
+ 'details': 'true'
37
+ }
38
+
39
+ response = api.message.send_sms('500600700', 'Test message', 'INFORMACJA', params)
40
+
41
+ result = json.loads(response)
42
+
43
+ if 'items' not in result:
44
+ raise Exception('Empty items')
45
+
46
+ for item in result['items']:
47
+ print(item['id'] + ' - ' + item['phone'] + ' - ' + item['status'])
48
+
49
+ except Exception:
50
+
51
+ print('ERROR: ', sys.exc_info()[1])
52
+ ```
53
+
54
+ #### Sending SMS
55
+ ```python
56
+ api = SerwerSMS('token')
57
+
58
+ try:
59
+
60
+ params = {
61
+ 'details': 'true'
62
+ }
63
+
64
+ response = api.message.send_sms('500600700', 'Test message', 'INFORMACJA', params)
65
+
66
+ print(response)
67
+
68
+ except Exception:
69
+
70
+ print('ERROR: ', sys.exc_info()[1])
71
+ ```
72
+
73
+ #### Sending personalized SMS
74
+ ```python
75
+ api = SerwerSMS('token')
76
+
77
+ try:
78
+
79
+ messages = []
80
+
81
+ message1 = {
82
+ 'phone': '500600700',
83
+ 'text': 'First message'
84
+ }
85
+
86
+ messages.append(message1)
87
+
88
+ message2 = {
89
+ 'phone': '600700800',
90
+ 'text': 'Second message'
91
+ }
92
+
93
+ messages.append(message2)
94
+
95
+ params = {
96
+ 'details': 'true'
97
+ }
98
+
99
+ response = api.message.send_personalized(messages, 'INFORMACJA', params)
100
+
101
+ print(response)
102
+
103
+ except Exception:
104
+
105
+ print('ERROR: ', sys.exc_info()[1])
106
+ ```
107
+
108
+ #### Downloading delivery reports
109
+ ```python
110
+ api = SerwerSMS('token')
111
+
112
+ try:
113
+
114
+ params = {
115
+ 'id': 'aca3944055'
116
+ }
117
+
118
+ response = api.message.reports(params)
119
+
120
+ print(response)
121
+
122
+ except Exception:
123
+
124
+ print('ERROR: ', sys.exc_info()[1])
125
+ ```
126
+
127
+ #### Downloading incoming messages
128
+ ```python
129
+ api = SerwerSMS('token')
130
+
131
+ try:
132
+
133
+ params = {
134
+ 'phone': '500600700'
135
+ }
136
+ response = api.message.recived('ndi',params)
137
+
138
+ print(response)
139
+
140
+ except Exception:
141
+
142
+ print('ERROR: ', sys.exc_info()[1])
143
+ ```
144
+
145
+ ## Requirements
146
+ Python 3.5.*
147
+
148
+ ## Documentation
149
+ http://dev.serwersms.pl
150
+
151
+ ## API Console
152
+ http://apiconsole.serwersms.pl
@@ -0,0 +1,137 @@
1
+ # SerwerSMS.pl Python Client API
2
+ Python client for remote communication with SerwerSMS.pl API v2
3
+
4
+ Attention. The current version works based on the API token.
5
+
6
+ In order to authorize via an API Token, it must be generated on the Customer Panel side in the Interface Settings → HTTPS API → API Tokens menu. The authorization header format follows the Bearer token format.
7
+
8
+ #### Example usage
9
+ ```python
10
+ import sys
11
+ import json
12
+
13
+ from serwersms import SerwerSMS
14
+
15
+ api = SerwerSMS('token')
16
+
17
+ try:
18
+
19
+ params = {
20
+ 'test': 'true',
21
+ 'details': 'true'
22
+ }
23
+
24
+ response = api.message.send_sms('500600700', 'Test message', 'INFORMACJA', params)
25
+
26
+ result = json.loads(response)
27
+
28
+ if 'items' not in result:
29
+ raise Exception('Empty items')
30
+
31
+ for item in result['items']:
32
+ print(item['id'] + ' - ' + item['phone'] + ' - ' + item['status'])
33
+
34
+ except Exception:
35
+
36
+ print('ERROR: ', sys.exc_info()[1])
37
+ ```
38
+
39
+ #### Sending SMS
40
+ ```python
41
+ api = SerwerSMS('token')
42
+
43
+ try:
44
+
45
+ params = {
46
+ 'details': 'true'
47
+ }
48
+
49
+ response = api.message.send_sms('500600700', 'Test message', 'INFORMACJA', params)
50
+
51
+ print(response)
52
+
53
+ except Exception:
54
+
55
+ print('ERROR: ', sys.exc_info()[1])
56
+ ```
57
+
58
+ #### Sending personalized SMS
59
+ ```python
60
+ api = SerwerSMS('token')
61
+
62
+ try:
63
+
64
+ messages = []
65
+
66
+ message1 = {
67
+ 'phone': '500600700',
68
+ 'text': 'First message'
69
+ }
70
+
71
+ messages.append(message1)
72
+
73
+ message2 = {
74
+ 'phone': '600700800',
75
+ 'text': 'Second message'
76
+ }
77
+
78
+ messages.append(message2)
79
+
80
+ params = {
81
+ 'details': 'true'
82
+ }
83
+
84
+ response = api.message.send_personalized(messages, 'INFORMACJA', params)
85
+
86
+ print(response)
87
+
88
+ except Exception:
89
+
90
+ print('ERROR: ', sys.exc_info()[1])
91
+ ```
92
+
93
+ #### Downloading delivery reports
94
+ ```python
95
+ api = SerwerSMS('token')
96
+
97
+ try:
98
+
99
+ params = {
100
+ 'id': 'aca3944055'
101
+ }
102
+
103
+ response = api.message.reports(params)
104
+
105
+ print(response)
106
+
107
+ except Exception:
108
+
109
+ print('ERROR: ', sys.exc_info()[1])
110
+ ```
111
+
112
+ #### Downloading incoming messages
113
+ ```python
114
+ api = SerwerSMS('token')
115
+
116
+ try:
117
+
118
+ params = {
119
+ 'phone': '500600700'
120
+ }
121
+ response = api.message.recived('ndi',params)
122
+
123
+ print(response)
124
+
125
+ except Exception:
126
+
127
+ print('ERROR: ', sys.exc_info()[1])
128
+ ```
129
+
130
+ ## Requirements
131
+ Python 3.5.*
132
+
133
+ ## Documentation
134
+ http://dev.serwersms.pl
135
+
136
+ ## API Console
137
+ http://apiconsole.serwersms.pl
@@ -0,0 +1,7 @@
1
+ [build-system]
2
+ requires = [
3
+ "requests",
4
+ "setuptools>=42",
5
+ "wheel"
6
+ ]
7
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,28 @@
1
+ [metadata]
2
+ name = serwersmsv2api
3
+ version = 0.0.1
4
+ author = SerwerSMS
5
+ author_email = dev@serwersms.pl
6
+ description = Python client for remote communication with SerwerSMS.pl API v2
7
+ long_description = file: README.md
8
+ long_description_content_type = text/markdown
9
+ url = https://serwersms.pl
10
+ project_urls =
11
+ classifiers =
12
+ Programming Language :: Python :: 3
13
+ License :: OSI Approved :: MIT License
14
+ Operating System :: OS Independent
15
+
16
+ [options]
17
+ package_dir =
18
+ = src
19
+ packages = find:
20
+ python_requires = >=3.9
21
+
22
+ [options.packages.find]
23
+ where = src
24
+
25
+ [egg_info]
26
+ tag_build =
27
+ tag_date = 0
28
+
@@ -0,0 +1 @@
1
+ from .serwersms import SerwerSMS
@@ -0,0 +1,65 @@
1
+ class Account:
2
+
3
+ def __init__(self, param):
4
+
5
+ self.master = param
6
+
7
+ '''
8
+ * Register new account
9
+ *
10
+ * param array params
11
+ * option string "phone"
12
+ * option string "email"
13
+ * option string "first_name"
14
+ * option string "last_name"
15
+ * option string "company"
16
+ * return array
17
+ * option bool "success"
18
+ '''
19
+ def add(self, options):
20
+
21
+ return self.master.call('account/add', options)
22
+
23
+ '''
24
+ * Return limits SMS
25
+ * param array params
26
+ * option bool "show_type"
27
+ * return array
28
+ * option array "items"
29
+ * option string "type" Type of message
30
+ * option string "chars_limit" The maximum length of message
31
+ * option string "value" Limit messages
32
+ *
33
+ '''
34
+ def limits(self, options):
35
+
36
+ return self.master.call('account/limits', options)
37
+
38
+ '''
39
+ * Return contact details
40
+ *
41
+ * return array
42
+ * option string "telephone"
43
+ * option string "email"
44
+ * option string "form"
45
+ * option string "faq"
46
+ * option array "account_maintainer"
47
+ * option string "name"
48
+ * option string "email"
49
+ * option string "telephone"
50
+ * option string "photo"
51
+ '''
52
+ def help(self):
53
+
54
+ return self.master.call('account/help', {})
55
+
56
+ '''
57
+ * Return messages from the administrator
58
+ *
59
+ * return array
60
+ * option bool "new" Marking unread message
61
+ * option string "message"
62
+ '''
63
+ def messages(self):
64
+
65
+ return self.master.call('account/messages', {})
@@ -0,0 +1,77 @@
1
+ class Blacklist:
2
+
3
+ def __init__(self, param):
4
+
5
+ self.master = param
6
+
7
+ '''
8
+ * Add phone to the blacklist
9
+ *
10
+ * param string phone
11
+ * return array
12
+ * option bool "success"
13
+ * option int "id"
14
+ '''
15
+ def add(self, phone):
16
+
17
+ options = {
18
+ 'phone': phone
19
+ }
20
+
21
+ return self.master.call('blacklist/add', options)
22
+
23
+ '''
24
+ * List of blacklist phones
25
+ *
26
+ * param string phone
27
+ * param array params
28
+ * option int "page" The number of the displayed page
29
+ * option int "limit" Limit items are displayed on the single page
30
+ * return array
31
+ * option array "paging"
32
+ * option int "page" The number of current page
33
+ * option int "count" The number of all pages
34
+ * option array "items"
35
+ * option string "phone"
36
+ * option string "added" Date of adding phone
37
+ '''
38
+ def index(self, phone, params):
39
+
40
+ default = {
41
+ 'phone': phone
42
+ }
43
+
44
+ options = params.copy()
45
+ options.update(default)
46
+
47
+ return self.master.call('blacklist/index', options)
48
+
49
+ '''
50
+ * Checking if phone is blacklisted
51
+ *
52
+ * param string phone
53
+ * return array
54
+ * option bool "exists"
55
+ '''
56
+ def check(self, phone):
57
+
58
+ options = {
59
+ 'phone': phone
60
+ }
61
+
62
+ return self.master.call('blacklist/check', options)
63
+
64
+ '''
65
+ * Deleting phone from the blacklist
66
+ *
67
+ * param string phone
68
+ * return array
69
+ * option bool "success"
70
+ '''
71
+ def delete(self, phone):
72
+
73
+ options = {
74
+ 'phone': phone
75
+ }
76
+
77
+ return self.master.call('blacklist/delete', options)
@@ -0,0 +1,173 @@
1
+ class Contact:
2
+
3
+ def __init__(self, param):
4
+
5
+ self.master = param
6
+
7
+ '''
8
+ * Add new contact
9
+ *
10
+ * param string group_id
11
+ * param string phone
12
+ * param array params
13
+ * option string "email"
14
+ * option string "first_name"
15
+ * option string "last_name"
16
+ * option string "company"
17
+ * option string "tax_id"
18
+ * option string "address"
19
+ * option string "city"
20
+ * option string "description"
21
+ * return array
22
+ * option bool "success"
23
+ * option int "id"
24
+ '''
25
+ def add(self, group_id, phone, params):
26
+
27
+ default = {
28
+ 'group_id': group_id,
29
+ 'phone': phone
30
+ }
31
+
32
+ options = params.copy()
33
+ options.update(default)
34
+
35
+ return self.master.call('contacts/add', options)
36
+
37
+ '''
38
+ * List of contacts
39
+ *
40
+ * param int group_id
41
+ * param string search
42
+ * param array params
43
+ * option int "page" The number of the displayed page
44
+ * option int "limit" Limit items are displayed on the single page
45
+ * option string "sort" Values: first_name|last_name|phone|company|tax_id|email|address|city|description
46
+ * option string "order" Values: asc|desc
47
+ * return array
48
+ * option array "paging"
49
+ * option int "page" The number of current page
50
+ * option int "count" The number of all pages
51
+ * options array "items"
52
+ * option int "id"
53
+ * option string "phone"
54
+ * option string "email"
55
+ * option string "company"
56
+ * option string "first_name"
57
+ * option string "last_name"
58
+ * option string "tax_id"
59
+ * option string "address"
60
+ * option string "city"
61
+ * option string "description"
62
+ * option bool "blacklist"
63
+ * option int "group_id"
64
+ * option string "group_name"
65
+ '''
66
+ def index(self, group_id, search, params):
67
+
68
+ default = {
69
+ 'group_id': group_id,
70
+ 'search': search
71
+ }
72
+
73
+ options = params.copy()
74
+ options.update(default)
75
+
76
+ return self.master.call('contacts/index', options)
77
+
78
+ '''
79
+ * View single contact
80
+ *
81
+ * param int id
82
+ * return array
83
+ * option integer "id"
84
+ * option string "phone"
85
+ * option string "email"
86
+ * option string "company"
87
+ * option string "first_name"
88
+ * option string "last_name"
89
+ * option string "tax_id"
90
+ * option string "address"
91
+ * option string "city"
92
+ * option string "description"
93
+ * option bool "blacklist"
94
+ '''
95
+ def view(self, id):
96
+
97
+ options = {
98
+ 'id': id
99
+ }
100
+
101
+ return self.master.call('contacts/view', options)
102
+
103
+ '''
104
+ * Editing a contact
105
+ *
106
+ * param int id
107
+ * param string group_id
108
+ * param string phone
109
+ * param array params
110
+ * option string "email"
111
+ * option string "first_name"
112
+ * option string "last_name"
113
+ * option string "company"
114
+ * option string "tax_id"
115
+ * option string "address"
116
+ * option string "city"
117
+ * option string "description"
118
+ * return array
119
+ * option bool "success"
120
+ * option int "id"
121
+ '''
122
+ def edit(self, id, group_id, phone, params):
123
+
124
+ default = {
125
+ 'id': id,
126
+ 'group_id': group_id,
127
+ 'phone': phone
128
+ }
129
+
130
+ options = params.copy()
131
+ options.update(default)
132
+
133
+ return self.master.call('contacts/edit', options)
134
+
135
+ '''
136
+ * Deleting a phone from contacts
137
+ *
138
+ * param int id
139
+ * return array
140
+ * option bool "success"
141
+ '''
142
+ def delete(self, id):
143
+
144
+ options = {
145
+ 'id': id
146
+ }
147
+
148
+ return self.master.call('contacts/delete', options)
149
+
150
+ '''
151
+ * Import contact list
152
+ *
153
+ * param string group_name
154
+ * param array contact[]
155
+ * option string "phone"
156
+ * option string "email"
157
+ * option string "first_name"
158
+ * option string "last_name"
159
+ * option string "company"
160
+ * return array
161
+ * option bool "success"
162
+ * option int "id"
163
+ * option int "correct" Number of contacts imported correctly
164
+ * option int "failed" Number of errors
165
+ '''
166
+ def imports(self, group_name, contacts):
167
+
168
+ options = {
169
+ 'group_name': group_name,
170
+ 'contact': contacts
171
+ }
172
+
173
+ return self.master.call('contacts/import', options)
@@ -0,0 +1,18 @@
1
+ class Error:
2
+
3
+ def __init__(self, param):
4
+
5
+ self.master = param
6
+
7
+ '''
8
+ * Preview error
9
+ *
10
+ * param int code
11
+ * return array
12
+ * option int "code"
13
+ * option string "type"
14
+ * option string "message"
15
+ '''
16
+ def view(self, code):
17
+
18
+ return self.master.call('error/' + str(code), {})