diff --git a/instasent/client.py b/instasent/client.py index b4f5446..79a0147 100644 --- a/instasent/client.py +++ b/instasent/client.py @@ -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' @@ -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}} @@ -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, {})