Skip to content

Commit

Permalink
Merge pull request #10 from greensms-ru/first-draft
Browse files Browse the repository at this point in the history
flake8 Lint Fixes
  • Loading branch information
mananjadhav authored Nov 10, 2020
2 parents a25c78c + 1c51271 commit ae0b2ba
Show file tree
Hide file tree
Showing 37 changed files with 757 additions and 700 deletions.
22 changes: 13 additions & 9 deletions examples/account.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from default import client


def account_balance():
res = client.account.balance()
print(res)
res = client.account.balance()
print(res)


def account_token():
res = client.account.token(expire=100)
print(res)
res = client.account.token(expire=100)
print(res)


def account_tariff():
res = client.account.tariff()
print(res)
res = client.account.tariff()
print(res)


if __name__ == '__main__':
account_balance()
account_balance()

account_token()
account_token()

account_tariff()
account_tariff()
15 changes: 9 additions & 6 deletions examples/call.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from default import client


def call_send():
res = client.call.send(to='919987409698')
print(res)
res = client.call.send(to='919987409698')
print(res)


def call_status():
res = client.call.status(id='1fd4ac4d-6e4f-4e32-b6e4-8087d3466f55')
print(res)
res = client.call.status(id='1fd4ac4d-6e4f-4e32-b6e4-8087d3466f55')
print(res)


if __name__ == '__main__':
call_send()
call_send()

call_status()
call_status()
2 changes: 1 addition & 1 deletion examples/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
os.environ['GREENSMS_USER'] = 'username'
os.environ['GREENSMS_PASS'] = 'password'

client = GreenSMS()
client = GreenSMS()
8 changes: 5 additions & 3 deletions examples/general.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from default import client


def status():
res = client.status()
print(res)
res = client.status()
print(res)


if __name__ == '__main__':
status()
status()
15 changes: 9 additions & 6 deletions examples/hlr.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from default import client


def hlr_send():
res = client.hlr.send(to='919987409698', txt='1920')
print(res)
res = client.hlr.send(to='919987409698', txt='1920')
print(res)


def hlr_status():
res = client.hlr.status(id='70d296f5-ac52-403d-a27b-24829c2faebc')
print(res)
res = client.hlr.status(id='70d296f5-ac52-403d-a27b-24829c2faebc')
print(res)


if __name__ == '__main__':
hlr_send()
hlr_send()

hlr_status()
hlr_status()
15 changes: 9 additions & 6 deletions examples/pay.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from default import client


def pay_send():
res = client.pay.send(to='919987409698', amount= 10)
print(res)
res = client.pay.send(to='919987409698', amount=10)
print(res)


def pay_status():
res = client.pay.status(id='60f231d9-16ec-4313-842e-6e6853063482')
print(res)
res = client.pay.status(id='60f231d9-16ec-4313-842e-6e6853063482')
print(res)


if __name__ == '__main__':
pay_send()
pay_send()

pay_status()
pay_status()
16 changes: 10 additions & 6 deletions examples/sms.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from default import client


def sms_send():
res = client.sms.send(to='919987409698', txt='Here is your message for delivery')
print(res)
res = client.sms.send(
to='919987409698', txt='Here is your message for delivery')
print(res)


def sms_status():
res = client.sms.status(id='dc2bac6d-f375-4e19-9a02-ef0148991635')
print(res)
res = client.sms.status(id='dc2bac6d-f375-4e19-9a02-ef0148991635')
print(res)


if __name__ == '__main__':
sms_send()
sms_send()

sms_status()
sms_status()
4 changes: 2 additions & 2 deletions examples/token.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from greensms.client import GreenSMS

os.environ['GREENSMS_TOKEN'] = '1234' # Change this value to your actual Token
os.environ['GREENSMS_TOKEN'] = '1234' # Change this value to your actual Token
token_client = GreenSMS()
res = token_client.account.balance()
res = token_client.account.balance()
15 changes: 9 additions & 6 deletions examples/viber.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from default import client


def viber_send():
res = client.viber.send(to='919987409698',txt='Viber Message')
print(res)
res = client.viber.send(to='919987409698', txt='Viber Message')
print(res)


def viber_status():
res = client.viber.status(id='0b18fab4-0c5d-4a8b-8ee4-057a59596c7d')
print(res)
res = client.viber.status(id='0b18fab4-0c5d-4a8b-8ee4-057a59596c7d')
print(res)


if __name__ == '__main__':
viber_send()
viber_send()

viber_status()
viber_status()
15 changes: 9 additions & 6 deletions examples/voice.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from default import client


def voice_send():
res = client.voice.send(to='919987409698', txt='1234')
print(res)
res = client.voice.send(to='919987409698', txt='1234')
print(res)


def voice_status():
res = client.voice.status(id='41f23094-deda-4cab-ac9c-3ab4f2fee9e6')
print(res)
res = client.voice.status(id='41f23094-deda-4cab-ac9c-3ab4f2fee9e6')
print(res)


if __name__ == '__main__':
voice_send()
voice_send()

voice_status()
voice_status()
8 changes: 5 additions & 3 deletions examples/whois.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from default import client


def whois_lookup():
res = client.whois.lookup(to='4477743336335')
print(res)
res = client.whois.lookup(to='4477743336335')
print(res)


if __name__ == '__main__':
whois_lookup()
whois_lookup()
2 changes: 1 addition & 1 deletion greensms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def test():
return ('Test String')
return ('Test String')
45 changes: 23 additions & 22 deletions greensms/api/module.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
from greensms.utils.validator import validate


class Module:
"""
Module Instance Class
"""
Module Instance Class
Call that inits with default args and has an API function to call the Rest API along with Validation
"""
def __init__(self, rest_client, module_schema, **kwargs):
self.rest_client = rest_client
self.module_schema = module_schema
self.params = {}
Call that inits with default args and has an API function to call the Rest API along with Validation
"""

for key, value in kwargs.items():
self.params[key] = value
def __init__(self, rest_client, module_schema, **kwargs):
self.rest_client = rest_client
self.module_schema = module_schema
self.params = {}

def api_func(self, **kwargs):
for key, value in kwargs.items():
self.params[key] = value

if self.module_schema is not None:
errors = validate(self.module_schema, kwargs)
if errors:
return errors
def api_func(self, **kwargs):

api_params={}
for key, value in kwargs.items():
api_params[key] = value
if self.module_schema is not None:
errors = validate(self.module_schema, kwargs)
if errors:
return errors

request_params = self.params.copy()
request_params['params'] = api_params
api_params = {}
for key, value in kwargs.items():
api_params[key] = value

response = self.rest_client.request(**request_params)
request_params = self.params.copy()
request_params['params'] = api_params

return response
response = self.rest_client.request(**request_params)

return response
Loading

0 comments on commit ae0b2ba

Please sign in to comment.