-
Notifications
You must be signed in to change notification settings - Fork 64
feat(phone_verify): Add Kavenegar backend #34
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
base: master
Are you sure you want to change the base?
Changes from 13 commits
5f3d7f6
d9468a1
a061379
9c4b316
5596a2e
7dcdc99
6659037
ccbb2e9
ca42409
6381fdc
de56ea4
5884cde
53c2e27
87281a7
ca4faad
92681ff
7f2e976
1847bac
e4532ba
c59e927
391e505
d3aec32
b1af51b
987cbca
facc894
b10b1da
0c45d81
18707fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,3 +102,6 @@ venv.bak/ | |
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
|
|
||
| # vscode configuration | ||
| .vscode | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from __future__ import absolute_import | ||
|
|
||
| # Third Party Stuff | ||
| from kavenegar import KavenegarAPI, APIException, HTTPException | ||
|
|
||
| # Local | ||
| from .base import BaseBackend | ||
|
|
||
|
|
||
| class KavenegarException(APIException, HTTPException): | ||
| pass | ||
|
|
||
|
|
||
| class KavenegarBackend(BaseBackend): | ||
| def __init__(self, **options): | ||
| super(KavenegarBackend, self).__init__(**options) | ||
CuriousLearner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Lower case it just to be sure | ||
| options = {key.lower(): value for key, value in options.items()} | ||
| self.api_key = options.get("secret", None) | ||
| self.sender = options.get("from", None) | ||
|
|
||
| self.client = KavenegarAPI(self.api_key) | ||
| self.exception_class = KavenegarException | ||
|
|
||
| def send_sms(self, number, message): | ||
| params = {'receptor': number, 'template': '', 'token': message, 'type': 'sms'} | ||
| self.client.sms_send(params) | ||
|
|
||
| def send_bulk_sms(self, numbers, message): | ||
| params = {'sender': self.sender, 'receptor': numbers, 'message': message, } | ||
|
||
| self.client.sms_sendarray(params) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ python-dotenv==0.10.0 | |
| phonenumbers==8.10.2 | ||
| django-phonenumber-field==2.1.0 | ||
| twilio==6.21.0 | ||
| kavenegar==1.1.2 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| # Testing | ||
| # ------------------------------------- | ||
| pytest==4.2.1 | ||
| pytest-django==3.4.4 | ||
| pytest==5.3.1 | ||
| pytest-django==3.7.0 | ||
| pytest-cov==2.6.1 | ||
|
|
||
| django-dynamic-fixture==2.0.0 | ||
| django-dynamic-fixture==3.0.2 | ||
| flake8-mypy==17.8.0 | ||
| pytest-mock==1.10.0 | ||
| tox==3.13.2 |
Uh oh!
There was an error while loading. Please reload this page.