|
@@ -5,62 +5,61 @@ from logger import logger
|
|
|
import api
|
|
|
|
|
|
class SmsMan(object):
|
|
|
-
|
|
|
- def __init__(self):
|
|
|
- pass
|
|
|
-
|
|
|
-smsman_token = '7jum0G6_tqXLCIZoAbMo8luIh6HW2IgQ'
|
|
|
-LOGGER = logger('sms_man')
|
|
|
+ smsman_token = '7jum0G6_tqXLCIZoAbMo8luIh6HW2IgQ'
|
|
|
+ LOGGER = logger('sms_man')
|
|
|
|
|
|
-def balance():
|
|
|
- result = requests.get(
|
|
|
- api.host_sms_man + f'/control/get-balance?token={smsman_token}').json().get('balance')
|
|
|
- return result
|
|
|
+ def __init__(self, token: str, logger:logger):
|
|
|
+ self.token = token
|
|
|
+ self.logger=logger
|
|
|
+
|
|
|
+ def balance(self):
|
|
|
+ result= requests.get(api.host_sms_man + f'/control/get-balance?token={self.token}').json().get('balance')
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
-def limits(country_id):
|
|
|
- result = requests.get(api.host_sms_man + f'/stubs/handler_api.php?'
|
|
|
- f'action=getPrices'
|
|
|
- f'&api_key={smsman_token}'
|
|
|
- f'&country={country_id}').json()
|
|
|
- LOGGER.info(result)
|
|
|
- return result
|
|
|
+ def limits(self, country_id):
|
|
|
+ result = requests.get(api.host_sms_man + f'/stubs/handler_api.php?'
|
|
|
+ f'action=getPrices'
|
|
|
+ f'&api_key={self.token}'
|
|
|
+ f'&country={country_id}').json()
|
|
|
+ self.LOGGER.info(result)
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
-def get_number(country_id: int, application_id: str):
|
|
|
- ''' sms-man api get phone number
|
|
|
- :param country_id: which country.
|
|
|
- :param application_id: application id,for example: go.
|
|
|
- :return: :class:`Response <Response>` object
|
|
|
- :rtype: requests.Response
|
|
|
- '''
|
|
|
- result = requests.get(api.host_sms_man + f'/stubs/handler_api.php?action=getNumber&'
|
|
|
- f'api_key={smsman_token}&'
|
|
|
- f'service={application_id}&'
|
|
|
- f'country={country_id}')
|
|
|
- return result
|
|
|
+ def get_number(self, country_id: int, application_id: str):
|
|
|
+ ''' sms-man api get phone number
|
|
|
+ :param country_id: which country.
|
|
|
+ :param application_id: application id,for example: go.
|
|
|
+ :return: :class:`Response <Response>` object
|
|
|
+ :rtype: requests.Response
|
|
|
+ '''
|
|
|
+ result = requests.get(api.host_sms_man + f'/stubs/handler_api.php?action=getNumber&'
|
|
|
+ f'api_key={self.token}&'
|
|
|
+ f'service={application_id}&'
|
|
|
+ f'country={country_id}')
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
-def get_sms(request_id):
|
|
|
- ''' get a sms phone number '''
|
|
|
- result = requests.get(
|
|
|
- api.host_sms_man + f'/control/get-sms?token={smsman_token}&request_id={request_id}').json()
|
|
|
- return result
|
|
|
+ def get_sms(self, request_id):
|
|
|
+ ''' get a sms phone number '''
|
|
|
+ result = requests.get(
|
|
|
+ api.host_sms_man + f'/control/get-sms?token={self.token}&request_id={request_id}').json()
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
-def set_status(request_id, status):
|
|
|
- result = requests.get(
|
|
|
- api.host_sms_man + f'/control/set-status?token={smsman_token}&request_id={request_id}&status={status}').json()
|
|
|
- return result
|
|
|
+ def set_status(self, request_id, status):
|
|
|
+ result = requests.get(
|
|
|
+ api.host_sms_man + f'/control/set-status?token={self.token}&request_id={request_id}&status={status}').json()
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
-def countries():
|
|
|
- result = requests.get(
|
|
|
- api.host_sms_man + f'/stubs/handler_api.php?action=getCountries&api_key={smsman_token}').json()
|
|
|
- return result
|
|
|
+ def countries(self):
|
|
|
+ result = requests.get(
|
|
|
+ api.host_sms_man + f'/stubs/handler_api.php?action=getCountries&api_key={self.token}').json()
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
-def applications():
|
|
|
- result = requests.get(
|
|
|
- api.host_sms_man + f'/control/applications?token={smsman_token}').json()
|
|
|
- return result
|
|
|
+ def applications(self):
|
|
|
+ result = requests.get(
|
|
|
+ api.host_sms_man + f'/control/applications?token={self.token}').json()
|
|
|
+ return result
|