-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat(phone_verify): Add Kavenegar backend #34
Open
SepehrHasanabadi
wants to merge
28
commits into
CuriousLearner:master
Choose a base branch
from
SepehrHasanabadi:kavenegar-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5f3d7f6
ignore vscode files to commit
SepehrHasanabadi d9468a1
chore: using otp method of kavenegar
SepehrHasanabadi a061379
chore: using otp method of kavenegar
SepehrHasanabadi 9c4b316
kavenegar api iranian OTP
SepehrHasanabadi 5596a2e
feat(docs): Add Iranian sending message platform (Kavenegar)
SepehrHasanabadi 7dcdc99
chore(*): Fix test case errors.
SepehrHasanabadi 6659037
refactor(*): Change indentions form tab to space.
SepehrHasanabadi ccbb2e9
chore(): Upgrade requirements
SepehrHasanabadi ca42409
Merge branch 'upgrade' into kavenegar-api
SepehrHasanabadi 6381fdc
refactor(): Phone verification in settings consists the active backend
SepehrHasanabadi de56ea4
refactor(*): Test coverage, code improvements.
SepehrHasanabadi 5884cde
refactor(README): Add Kavenegar Docs to README.rst
SepehrHasanabadi 53c2e27
refactor(*): Phone registration test have DRY approach.
SepehrHasanabadi 87281a7
refactor(*): Test services for available backends, Alter exception ha…
SepehrHasanabadi ca4faad
refactor(init): Resolve flake8 error in test file __init__.
SepehrHasanabadi 92681ff
Merge branch 'master' into kavenegar-api
CuriousLearner 7f2e976
Update to Py3 syntax
CuriousLearner 1847bac
Merge branch 'master' of github.com:CuriousLearner/django-phone-verif…
CuriousLearner e4532ba
Merge branch 'master' of github.com:CuriousLearner/django-phone-verif…
CuriousLearner c59e927
Merge branch 'master' of github.com:CuriousLearner/django-phone-verif…
gutsytechster 391e505
fix: Modify sending sms parameters
SepehrHasanabadi d3aec32
Merge branch 'kavenegar-api' of github.com:SepehrHasanabadi/django-ph…
SepehrHasanabadi b1af51b
Merge branch 'master' into SepehrHasanabadi-kavenegar-api
CuriousLearner 987cbca
refactor(gitignore): add idea folder to gitignore
SepehrHasanabadi facc894
fix(test): Modified kavenegar test_data
SepehrHasanabadi b10b1da
Merge branch 'kavenegar-api' of github.com:SepehrHasanabadi/django-ph…
SepehrHasanabadi 0c45d81
fix(test): Modified tests, Create KavenegarException class.
SepehrHasanabadi 18707fd
fix: modified test kavenegar, Add Kavenegar sandbox
SepehrHasanabadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,6 @@ venv.bak/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# vscode configuration | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
|
||
# Third Party Stuff | ||
from kavenegar import KavenegarAPI, APIException, HTTPException | ||
|
||
# Local | ||
from .base import BaseBackend | ||
|
||
|
||
class KavenegarBackend(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("secret", None) | ||
self.sender = options.get("from", None) | ||
|
||
self.client = KavenegarAPI(self.api_key) | ||
self.exception_class = APIException, HTTPException | ||
|
||
def send_sms(self, number, message): | ||
params = {'sender': self.sender, 'receptor': number, 'message': message, } | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API here states that sender should be a list of strings and you're providing a single sender here 🤔
https://github.com/kavenegar/kavenegar-python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SepehrHasanabadi
Can you please have a look at this when you get the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @SepehrHasanabadi Can you please have a look at this conversation? Have you tested these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, @SepehrHasanabadi, have a look at this comment as well.