6 Commits
Author SHA1 Message Date
chydo d73e6151d4 Merge pull request #8 from exituser/feature/update-version
updated version
2024-04-05 02:11:00 +07:00
chydo 12cd8a4e18 updated version 2024-04-05 02:10:42 +07:00
chydo fc8dda6b9e Merge pull request #7 from exituser/fix/data-error
changed ci to production && fixed get_prices method && fixed GetPrice…
2024-04-05 02:08:02 +07:00
chydo 7f97b60956 changed ci to production && fixed get_prices method && fixed GetPriceData model 2024-04-05 02:07:37 +07:00
chydo 4893fa46a1 Merge pull request #6 from exituser/fix/data-error
fixed: error with data
2024-04-05 01:50:43 +07:00
chydo aac0458437 fixed: error with data
moved: api to init
updated: version up to 0.0.2
2024-04-05 01:50:12 +07:00
7 changed files with 92 additions and 92 deletions
+9 -9
View File
@@ -23,15 +23,15 @@ jobs:
- name: Build package
run: python setup.py sdist bdist_wheel
# - name: Publish package
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package to TestPyPI
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.PYPI_API_TOKEN }}
# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
+79
View File
@@ -0,0 +1,79 @@
from typing import Optional
import requests
from loguru import logger
from . import exceptions
from . import methods
class API:
"""
Main api class
"""
def __init__(
self,
email: str = None,
password: str = None,
key: str = None
):
"""
Initializing the API
:param email: account email address
:param password: account password
:param key: api key
"""
self.email = email
self.password = password
self.key = key
self.api_url = "https://ssl.bs00.ru"
self.methods = methods.Methods(self)
def request(self, method: str, data: dict = None) -> Optional[dict]:
"""
Method for requesting information
:param method: required method
:param data: request parameters
:return: response data
"""
if data is None:
data = {}
data["format"] = "json"
if not data.get("method"):
data["method"] = method
if self.key and not (self.email and self.password):
data["key"] = self.key
elif (self.email and self.password) and not self.key:
data["email"] = self.email
data["password"] = self.password
else:
raise exceptions.NoAuthData(
"email and password OR key is required"
)
try:
result = requests.get(
url=self.api_url,
params=data,
timeout=30
)
result.raise_for_status()
result = result.json()
except Exception as err:
logger.exception(err)
return
if result["response"]["msg"].get("type") == "error":
raise exceptions.RequestError(
result["response"]["msg"]["text"]
)
return result["response"]["data"]
-79
View File
@@ -1,79 +0,0 @@
from typing import Optional
import requests
from loguru import logger
from . import exceptions
from . import methods
class API:
"""
Main api class
"""
def __init__(
self,
email: str = None,
password: str = None,
key: str = None
):
"""
Initializing the API
:param email: account email address
:param password: account password
:param key: api key
"""
self.email = email
self.password = password
self.key = key
self.api_url = "https://ssl.bs00.ru"
self.methods = methods.Methods(self)
def request(self, method: str, data: dict = None) -> Optional[dict]:
"""
Method for requesting information
:param method: required method
:param data: request parameters
:return: response data
"""
if data is None:
data = {}
data["format"] = "json"
if not data.get("method"):
data["method"] = method
if self.key and not (self.email and self.password):
data["key"] = self.key
elif (self.email and self.password) and not self.key:
data["email"] = self.email
data["password"] = self.password
else:
raise exceptions.NoAuthData(
"email and password OR key is required"
)
try:
result = requests.get(
url=self.api_url,
params=data,
timeout=30
)
result.raise_for_status()
result = result.json()
except Exception as err:
logger.exception(err)
return
if result["response"]["msg"].get("type") == "error":
raise exceptions.ApiError(
result["response"]["msg"]["text"]
)
return result["data"]
+1 -1
View File
@@ -10,5 +10,5 @@ class NoAuthData(ApiException):
pass
class ApiError(ApiException):
class RequestError(ApiException):
pass
+1 -1
View File
@@ -81,7 +81,7 @@ class Methods:
def get_prices(
self,
*,
group_directions: int = None
group_directions: str = None
) -> models.GetPricesData:
"""
Implementation of get_prices
+1 -1
View File
@@ -4,7 +4,7 @@ from pydantic import BaseModel
class GetPricesData(BaseModel):
group_directions: str
group_directions: dict
class GetMessageReportData(BaseModel):
+1 -1
View File
@@ -5,7 +5,7 @@ with open('requirements.txt') as f:
setup(
name='prosto_sms',
version='0.0.1',
version='0.0.3',
author='Alex Dennitsev',
author_email='me@chydo.dev',