-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
179 additions
and
2 deletions.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
import telnyx | ||
|
||
if __name__ == "__main__": | ||
telnyx.api_key = os.environ.get("TELNYX_SECRET_KEY") | ||
phone_number = 'fill-me' | ||
type = 'sms' | ||
|
||
verify_profiles = telnyx.VerifyProfile.list() | ||
print(verify_profiles) | ||
verification = telnyx.Verification.create( | ||
phone_number=phone_number, | ||
type=type, | ||
verify_profile_id=verify_profiles.data[0].id, | ||
) | ||
print(verification) |
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,19 @@ | ||
import os | ||
|
||
import telnyx | ||
|
||
if __name__ == "__main__": | ||
telnyx.api_key = os.environ.get("TELNYX_SECRET_KEY") | ||
verification_id = "fill-me" | ||
code = "fill-me" | ||
phone_number = "fill-me" | ||
|
||
verification = telnyx.Verification.retrieve(verification_id) | ||
print("Verification status: {}".format(verification)) | ||
verify_resp = verification.verify_by_phone_number( | ||
code=code, phone_number=phone_number | ||
) | ||
if verify_resp["data"]["response_code"] == "accepted": | ||
print("Verify successful!") | ||
else: | ||
print("There was an issue verifying: {}".format(verify_resp["data"])) |
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,16 @@ | ||
import os | ||
|
||
import telnyx | ||
|
||
if __name__ == '__main__': | ||
profile_name = 'fill-me' | ||
|
||
telnyx.api_key = os.environ.get("TELNYX_SECRET_KEY") | ||
res = telnyx.VerifyProfile.create( | ||
name=profile_name, | ||
messaging_enabled=True, | ||
default_timeout_secs=600, | ||
) | ||
print(res) | ||
profiles = telnyx.VerifyProfile.list() | ||
print(len(profiles)) |
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,14 @@ | ||
from telnyx.api_resources.abstract import CreateableAPIResource, ListableAPIResource | ||
|
||
|
||
class Verification(CreateableAPIResource, ListableAPIResource): | ||
OBJECT_NAME = "verification" | ||
|
||
def verify_by_phone_number(self, code, phone_number): | ||
return self.request( | ||
method="post", | ||
url="/v2/verifications/by_phone_number/{}/actions/verify".format( | ||
phone_number | ||
), | ||
params={"code": code}, | ||
) |
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,17 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from telnyx.api_resources.abstract import ( | ||
CreateableAPIResource, | ||
DeletableAPIResource, | ||
ListableAPIResource, | ||
UpdateableAPIResource, | ||
) | ||
|
||
|
||
class VerifyProfile( | ||
CreateableAPIResource, | ||
DeletableAPIResource, | ||
ListableAPIResource, | ||
UpdateableAPIResource, | ||
): | ||
OBJECT_NAME = "verify_profile" |
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
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,29 @@ | ||
import telnyx | ||
|
||
TEST_RESOURCE_ID = "123" | ||
TEST_PHONE_NUMBER = "+13125000000" | ||
VERIFY_CODE = "12345" | ||
VERIFY_PROFILE = "32567" | ||
|
||
|
||
class TestVerification(object): | ||
def test_is_retrievable(self, request_mock): | ||
resource = telnyx.Verification.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested("get", "/v2/verifications/%s" % TEST_RESOURCE_ID) | ||
assert isinstance(resource, telnyx.Verification) | ||
|
||
def test_is_savable(self, request_mock): | ||
_ = telnyx.Verification.create( | ||
phone_number=TEST_PHONE_NUMBER, type="sms", verify_profile_id=VERIFY_PROFILE | ||
) | ||
request_mock.assert_requested("post", "/v2/verifications") | ||
|
||
def test_can_verify_by_phone_number(self, request_mock): | ||
resource = telnyx.Verification.retrieve(TEST_RESOURCE_ID) | ||
resource.verify_by_phone_number( | ||
code=VERIFY_CODE, phone_number=TEST_PHONE_NUMBER | ||
) | ||
request_mock.assert_requested( | ||
"post", | ||
"/v2/verifications/by_phone_number/%s/actions/verify" % TEST_PHONE_NUMBER, | ||
) |
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,30 @@ | ||
import telnyx | ||
|
||
TEST_RESOURCE_ID = "123" | ||
|
||
|
||
class TestVerifyProfile(object): | ||
def test_is_listable(self, request_mock): | ||
resources = telnyx.VerifyProfile.list() | ||
request_mock.assert_requested("get", "/v2/verify_profiles") | ||
assert isinstance(resources.data, list) | ||
assert isinstance(resources.data[0], telnyx.VerifyProfile) | ||
|
||
def test_is_retrievable(self, request_mock): | ||
resource = telnyx.VerifyProfile.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested( | ||
"get", "/v2/verify_profiles/%s" % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, telnyx.VerifyProfile) | ||
|
||
def test_is_saveable(self, request_mock): | ||
resource = telnyx.VerifyProfile.create(name="Hi there") | ||
request_mock.assert_requested("post", "/v2/verify_profiles") | ||
assert isinstance(resource, telnyx.VerifyProfile) | ||
assert resource is resource | ||
|
||
def test_is_modifiable(self, request_mock): | ||
_ = telnyx.VerifyProfile.modify(TEST_RESOURCE_ID, name="hi there") | ||
request_mock.assert_requested( | ||
"patch", "/v2/verify_profiles/%s" % TEST_RESOURCE_ID | ||
) |