smsaero-api-async 3.1.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.
- smsaero/__init__.py +1534 -0
- smsaero/command_line.py +53 -0
- smsaero_api_async-3.1.0.dist-info/AUTHORS.md +10 -0
- smsaero_api_async-3.1.0.dist-info/LICENSE +21 -0
- smsaero_api_async-3.1.0.dist-info/METADATA +143 -0
- smsaero_api_async-3.1.0.dist-info/RECORD +9 -0
- smsaero_api_async-3.1.0.dist-info/WHEEL +5 -0
- smsaero_api_async-3.1.0.dist-info/entry_points.txt +2 -0
- smsaero_api_async-3.1.0.dist-info/top_level.txt +1 -0
smsaero/command_line.py
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
"""
|
2
|
+
This module provides a command line interface for sending SMS messages via SmsAero asynchronously.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import argparse
|
6
|
+
import asyncio
|
7
|
+
import pprint
|
8
|
+
import sys
|
9
|
+
|
10
|
+
from smsaero import SmsAero, SmsAeroException
|
11
|
+
|
12
|
+
|
13
|
+
async def main_async() -> None:
|
14
|
+
"""
|
15
|
+
Parses command line arguments and sends an SMS message via SmsAero asynchronously.
|
16
|
+
|
17
|
+
The command line arguments are:
|
18
|
+
--email: The email registered with SmsAero.
|
19
|
+
--api_key: The API key from SmsAero.
|
20
|
+
--phone: The phone number to send the SMS message to.
|
21
|
+
--message: The text of the message to be sent.
|
22
|
+
|
23
|
+
If the SMS message is sent successfully, the response data from SmsAero is printed.
|
24
|
+
If an error occurs, the error message is printed and the program exits with status code 1.
|
25
|
+
"""
|
26
|
+
parser = argparse.ArgumentParser(description="Send SMS via smsaero.ru gate")
|
27
|
+
parser.add_argument("--email", type=str, required=True, help="Your email registered with SmsAero")
|
28
|
+
parser.add_argument("--api_key", type=str, required=True, help="Your SmsAero API key")
|
29
|
+
parser.add_argument("--phone", type=int, required=True, help="Phone number to send SMS to")
|
30
|
+
parser.add_argument("--message", type=str, required=True, help="Message to send")
|
31
|
+
|
32
|
+
args = parser.parse_args()
|
33
|
+
|
34
|
+
api = SmsAero(args.email, args.api_key)
|
35
|
+
try:
|
36
|
+
result = await api.send_sms(args.phone, args.message)
|
37
|
+
pprint.pprint(result)
|
38
|
+
except SmsAeroException as e:
|
39
|
+
print(f"An error occurred: {e}")
|
40
|
+
sys.exit(1)
|
41
|
+
finally:
|
42
|
+
await api.close_session()
|
43
|
+
|
44
|
+
|
45
|
+
def main() -> None:
|
46
|
+
"""
|
47
|
+
Runs the main function asynchronously.
|
48
|
+
"""
|
49
|
+
asyncio.run(main_async())
|
50
|
+
|
51
|
+
|
52
|
+
if __name__ == "__main__":
|
53
|
+
main()
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 SmsAero
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,143 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: smsaero_api_async
|
3
|
+
Version: 3.1.0
|
4
|
+
Summary: SMS Aero Async API client
|
5
|
+
Home-page: https://github.com/smsaero/smsaero_python/
|
6
|
+
Author: SMS Aero
|
7
|
+
Author-email: admin@smsaero.ru
|
8
|
+
License: MIT
|
9
|
+
Keywords: smsaero,api,smsaero_api_async,sms,hlr,viber
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
11
|
+
Classifier: Environment :: Web Environment
|
12
|
+
Classifier: Intended Audience :: Developers
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
14
|
+
Classifier: Operating System :: OS Independent
|
15
|
+
Classifier: Programming Language :: Python
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
24
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
26
|
+
Classifier: Topic :: Communications :: Telephony
|
27
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
28
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
29
|
+
Requires-Python: >=3.7
|
30
|
+
Description-Content-Type: text/markdown
|
31
|
+
License-File: LICENSE
|
32
|
+
License-File: AUTHORS.md
|
33
|
+
Requires-Dist: setuptools
|
34
|
+
Requires-Dist: aiohttp
|
35
|
+
Provides-Extra: dev
|
36
|
+
Requires-Dist: pytest >=8.2.2 ; extra == 'dev'
|
37
|
+
Requires-Dist: flake8 >=7.1.0 ; extra == 'dev'
|
38
|
+
Requires-Dist: ruff >=0.4.10 ; extra == 'dev'
|
39
|
+
Requires-Dist: pylint >=3.2.4 ; extra == 'dev'
|
40
|
+
Requires-Dist: tox >=4.15.1 ; extra == 'dev'
|
41
|
+
Requires-Dist: mypy >=1.10.0 ; extra == 'dev'
|
42
|
+
Requires-Dist: coverage >=7.5.4 ; extra == 'dev'
|
43
|
+
Requires-Dist: bandit >=1.7.9 ; extra == 'dev'
|
44
|
+
Requires-Dist: build >=1.2.1 ; extra == 'dev'
|
45
|
+
Requires-Dist: twine >=5.1.1 ; extra == 'dev'
|
46
|
+
|
47
|
+
# Python async library for sending SMS messages via SMS Aero API
|
48
|
+
|
49
|
+
[](https://badge.fury.io/py/smsaero-api-async)
|
50
|
+
[](https://pypi.org/project/smsaero-api-async/)
|
51
|
+
[](https://pepy.tech/project/smsaero-api-async)
|
52
|
+
[](MIT-LICENSE)
|
53
|
+
|
54
|
+
## Installation (from PyPI):
|
55
|
+
|
56
|
+
```bash
|
57
|
+
pip install -U smsaero-api-async
|
58
|
+
```
|
59
|
+
|
60
|
+
## Usage example:
|
61
|
+
|
62
|
+
Get credentials from account settings page: https://smsaero.ru/cabinet/settings/apikey/
|
63
|
+
|
64
|
+
```python
|
65
|
+
import pprint
|
66
|
+
import asyncio
|
67
|
+
import smsaero
|
68
|
+
|
69
|
+
|
70
|
+
SMSAERO_EMAIL = 'your email'
|
71
|
+
SMSAERO_API_KEY = 'your api key'
|
72
|
+
|
73
|
+
|
74
|
+
async def send_sms(phone: int, message: str) -> None:
|
75
|
+
"""
|
76
|
+
Sends an SMS message
|
77
|
+
|
78
|
+
Parameters:
|
79
|
+
phone (int): The phone number to which the SMS message will be sent.
|
80
|
+
message (str): The content of the SMS message to be sent.
|
81
|
+
"""
|
82
|
+
api = smsaero.SmsAero(SMSAERO_EMAIL, SMSAERO_API_KEY)
|
83
|
+
try:
|
84
|
+
result = await api.send_sms(phone, message)
|
85
|
+
pprint.pprint(result)
|
86
|
+
finally:
|
87
|
+
await api.close_session()
|
88
|
+
|
89
|
+
|
90
|
+
async def send_telegram_code(phone: int, code: int) -> None:
|
91
|
+
"""
|
92
|
+
Sends a Telegram code
|
93
|
+
|
94
|
+
Parameters:
|
95
|
+
phone (int): The phone number to which the Telegram code will be sent.
|
96
|
+
code (int): The Telegram code (4 to 8 digits).
|
97
|
+
"""
|
98
|
+
api = smsaero.SmsAero(SMSAERO_EMAIL, SMSAERO_API_KEY)
|
99
|
+
try:
|
100
|
+
result = await api.send_telegram(phone, code)
|
101
|
+
pprint.pprint(result)
|
102
|
+
finally:
|
103
|
+
await api.close_session()
|
104
|
+
|
105
|
+
|
106
|
+
if __name__ == '__main__':
|
107
|
+
asyncio.run(send_sms(70000000000, 'Hello, World!'))
|
108
|
+
asyncio.run(send_telegram_code(79990000000, 1234))
|
109
|
+
```
|
110
|
+
|
111
|
+
#### Exceptions:
|
112
|
+
|
113
|
+
* `SmsAeroException` - base exception class for all exceptions raised by the library.
|
114
|
+
* `SmsAeroConnectionException` - exception raised when there is a connection error.
|
115
|
+
* `SmsAeroNoMoneyException` - exception raised when there is not enough money in the account.
|
116
|
+
|
117
|
+
|
118
|
+
## Command line usage:
|
119
|
+
|
120
|
+
```bash
|
121
|
+
SMSAERO_EMAIL="your email"
|
122
|
+
SMSAERO_API_KEY="your api key"
|
123
|
+
|
124
|
+
smsaero_send --email "$SMSAERO_EMAIL" --api_key "$SMSAERO_API_KEY" --phone 70000000000 --message 'Hello, World!'
|
125
|
+
```
|
126
|
+
|
127
|
+
## Run on Docker:
|
128
|
+
|
129
|
+
```bash
|
130
|
+
docker pull 'smsaero/smsaero_python_async:latest'
|
131
|
+
docker run -it --rm 'smsaero/smsaero_python_async:latest' smsaero_send --email "your email" --api_key "your api key" --phone 70000000000 --message 'Hello, World!'
|
132
|
+
```
|
133
|
+
|
134
|
+
## Compatibility:
|
135
|
+
|
136
|
+
* Currently version of library is compatible with Python 3.7+.
|
137
|
+
|
138
|
+
|
139
|
+
## License:
|
140
|
+
|
141
|
+
```
|
142
|
+
MIT License
|
143
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
smsaero/__init__.py,sha256=5lzTRXmIJg1R5fO2qWMBgjMbzGLYS_l6FmL7NuUoA44,54778
|
2
|
+
smsaero/command_line.py,sha256=B-v6GmaVZo-KtVGV1NBanYXVxh5QgPnMo0wulHZNM1k,1695
|
3
|
+
smsaero_api_async-3.1.0.dist-info/AUTHORS.md,sha256=rbi5f0bx_ioH_cfbLfvwKZQ1Jne8WbPWTHLszJ-wPa0,206
|
4
|
+
smsaero_api_async-3.1.0.dist-info/LICENSE,sha256=GGmR858t4fTiHuzhyT1CKsmo0tQ82eEicSLDy6SWSLo,1064
|
5
|
+
smsaero_api_async-3.1.0.dist-info/METADATA,sha256=Vc87pmAV7pzoN2aL3RF6dxFx7-KyNoF880mW5C3emcM,4587
|
6
|
+
smsaero_api_async-3.1.0.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
7
|
+
smsaero_api_async-3.1.0.dist-info/entry_points.txt,sha256=zIN16SM-DegJ5aQcx4mHDaX6gCX4CfRwafviKu9Jzl0,59
|
8
|
+
smsaero_api_async-3.1.0.dist-info/top_level.txt,sha256=dcuKhkyQVDasrL6kM8MXsCrOCy6eVmSJzAUArJ0octU,8
|
9
|
+
smsaero_api_async-3.1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
smsaero
|