Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding smsir backend support #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions phone_verify/backends/smsir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

# Third Party Stuff
from sms_ir import SmsIr
from requests import ConnectionError

# Local
from .base import BaseBackend


class SmsIrBackend(BaseBackend):
def __init__(self, **options):
super().__init__(**options)

# Lower case it just to be sure
options = {key.lower(): value for key, value in options.items()}
self._api_key = options.get("api_key", None)
self._linenumber = options.get("linenumber", None)

self.client = SmsIr(
api_key=self._api_key,
linenumber=self._linenumber,
)
self.exception_class = ConnectionError

def send_sms(self, number, message):
self.client.send_sms(
number,
message,
self._linenumber,
)

def send_bulk_sms(self, numbers, message):
self.client.send_bulk_sms(
numbers,
message,
self._linenumber,
)
1 change: 1 addition & 0 deletions requirements/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ phonenumbers==8.13.2
django-phonenumber-field==7.0.1
twilio==7.15.4
nexmo==2.5.2
smsir-python==1.0.4