Skip to content

Commit

Permalink
Only secure channel
Browse files Browse the repository at this point in the history
  • Loading branch information
markitosgv authored Dec 7, 2016
1 parent 5812180 commit b2a62c6
Showing 1 changed file with 13 additions and 30 deletions.
43 changes: 13 additions & 30 deletions instasent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@


class Client(object):
rootEndpoint = 'https://api.instasent.com/'

secureChannel = 'https://api.instasent.com/'
useSecureChannel = True

def __init__(self, token, use_secure_channel=True):
def __init__(self, token):
self.token = token
self.useSecureChannel = use_secure_channel

def send_sms(self, sender, to, text, client_id=''):
if self.useSecureChannel:
url = self.secureChannel + 'sms/'
else:
url = self.rootEndpoint + 'sms/'
url = self.secureChannel + 'sms/'

http_method = 'POST'

Expand All @@ -24,27 +19,21 @@ def send_sms(self, sender, to, text, client_id=''):
return self.execute_request(url, http_method, data)

def get_sms_by_id(self, id):
if self.useSecureChannel:
url = self.secureChannel + 'sms/' + id
else:
url = self.rootEndpoint + 'sms/' + id
url = self.secureChannel + 'sms/' + id

http_method = 'GET'

return self.execute_request(url, http_method)

def get_sms(self, page=1, per_page=10):
if self.useSecureChannel:
url = self.secureChannel + 'sms/?page=' + str(page) + 'per_page=' + str(per_page)
else:
url = self.rootEndpoint + 'sms/?page=' + str(page) + 'per_page=' + str(per_page)
url = self.secureChannel + 'sms/?page=' + str(page) + 'per_page=' + str(per_page)

http_method = 'GET'

return self.execute_request(url, http_method)

def request_verify(self, sender, to, text, token_length='', timeout='', client_id=''):
url = self.secureChannel + 'verify/' if self.useSecureChannel else self.rootEndpoint + 'verify/'
url = self.secureChannel + 'verify/'
http_method = 'POST'
data = {'sms': {'from': sender, 'to': to, 'text': text}}

Expand All @@ -60,52 +49,46 @@ def request_verify(self, sender, to, text, token_length='', timeout='', client_i
return self.execute_request(url, http_method, data)

def check_verify(self, id, token):
url = self.secureChannel + 'verify/' + id if self.useSecureChannel else self.rootEndpoint + 'verify/' + id
url = self.secureChannel + 'verify/' + id
url += '?token=' + token
http_method = 'GET'

return self.execute_request(url, http_method, {})

def get_verify_by_id(self, id):
url = self.secureChannel + 'verify/' + id if self.useSecureChannel else self.rootEndpoint + 'verify/' + id
url = self.secureChannel + 'verify/' + id
http_method = 'GET'

return self.execute_request(url, http_method, {})

def get_verify(self, page=1, per_page=10):
if self.useSecureChannel:
url = self.secureChannel + 'verify/?page=' + str(page) + 'per_page=' + str(per_page)
else:
url = self.rootEndpoint + 'verify/?page=' + str(page) + 'per_page=' + str(per_page)
url = self.secureChannel + 'verify/?page=' + str(page) + 'per_page=' + str(per_page)

http_method = 'GET'

return self.execute_request(url, http_method)

def do_lookup(self, to):
url = self.secureChannel + 'lookup/' if self.useSecureChannel else self.rootEndpoint + 'lookup/'
url = self.secureChannel + 'lookup/'
http_method = 'POST'
data = {'to': to}

return self.execute_request(url, http_method, data)

def get_lookup_by_id(self, id):
url = self.secureChannel + 'lookup/' + id if self.useSecureChannel else self.rootEndpoint + 'lookup/' + id
url = self.secureChannel + 'lookup/' + id
http_method = 'GET'

return self.execute_request(url, http_method, {})

def get_lookups(self, page=1, per_page=10):
if self.useSecureChannel:
url = self.secureChannel + 'lookup/?page=' + str(page) + 'per_page=' + str(per_page)
else:
url = self.rootEndpoint + 'lookup/?page=' + str(page) + 'per_page=' + str(per_page)
url = self.secureChannel + 'lookup/?page=' + str(page) + 'per_page=' + str(per_page)
http_method = 'GET'

return self.execute_request(url, http_method, {})

def get_account_balance(self):
url = self.secureChannel + 'organization/account/' if self.useSecureChannel else self.rootEndpoint + 'organization/account/'
url = self.secureChannel + 'organization/account/'
http_method = 'GET'

return self.execute_request(url, http_method, {})
Expand Down

0 comments on commit b2a62c6

Please sign in to comment.