Skip to content
Closed
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
17 changes: 17 additions & 0 deletions examples/phoneid_consent/consent_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the Consent History feature of the PhoneID Consent API to retrieve
# the complete consent history for a phone number.
# You can specify the add-on(s) the consent history is for.

from __future__ import print_function
from telesignenterprise.phoneid import PhoneIdClient

customer_id = "Put your customer ID between these quotes."
api_key = "Put your API key between these quotes."

phone_number = "Put the complete phone number you want to retrieve the consent history for here."

phoneid = PhoneIdClient(customer_id, api_key)

response = phoneid.consent_history(phone_number)

print(response.json)
19 changes: 19 additions & 0 deletions examples/phoneid_consent/search_phoneid_consent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use the Search feature of the PhoneID Consent API to retrieve
# specific consent information about a phone number.
# You can specify the add-on(s) the consent information is for.

from __future__ import print_function
from telesignenterprise.phoneid import PhoneIdClient

customer_id = "Put your customer ID between these quotes."
api_key = "Put your API key between these quotes."

phone_number = "Put the complete phone number you want to retrieve specific consent history information for here."
consent_method = "1"

params = {"consent_method" : consent_method, "addons": {"contact" : {}}}
phoneid = PhoneIdClient(customer_id, api_key)

response = phoneid.consent_search(phone_number, **params)

print(response.json)
19 changes: 19 additions & 0 deletions examples/phoneid_consent/send_phoneid_consent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use the Send feature of the PhoneID Consent API to send
# consent information for a phone number for one or more add-ons.

from __future__ import print_function
from telesignenterprise.phoneid import PhoneIdClient

customer_id = "Put your customer ID between these quotes."
api_key = "Put your API key between these quotes."

phone_number = "Put the complete phone number you want to send consent information for here."
consent_method = "1"
consent_timestamp = "2019-07-12T02:39:27Z"

params = {"consent_method" : consent_method, "consent_timestamp" : consent_timestamp, "addons": {"contact" : {}}}
phoneid = PhoneIdClient(customer_id, api_key)

response = phoneid.consent_send(phone_number, **params)

print(response.json)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = "2.1.4"
version = "2.1.5"

try:
with open("README") as f:
Expand Down
32 changes: 29 additions & 3 deletions telesignenterprise/phoneid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from telesign.phoneid import PhoneIdClient as _PhoneIdClient

PHONEID_STANDARD_RESOURCE = "/v1/phoneid/standard/{phone_number}"
PHONEID_CONSENT_RESOURCE = "/consent/{phone_number}"
PHONEID_CONSENT_HISTORY_RESOURCE = "/consent/history/{phone_number}"
PHONEID_SCORE_RESOURCE = "/v1/phoneid/score/{phone_number}"
PHONEID_CONTACT_RESOURCE = "/v1/phoneid/contact/{phone_number}"
PHONEID_LIVE_RESOURCE = "/v1/phoneid/live/{phone_number}"
Expand All @@ -26,11 +28,35 @@ def standard(self, phone_number, **params):
"""
The PhoneID Standard API that provides phone type and telecom carrier information to identify which phone
numbers can receive SMS messages and/or a potential fraud risk.

See https://developer.telesign.com/docs/rest_phoneid-standard for detailed API documentation.
"""
return self.get(PHONEID_STANDARD_RESOURCE.format(phone_number=phone_number),
**params)
return self.get(PHONEID_STANDARD_RESOURCE.format(phone_number=phone_number), **params)

def consent_send(self, phone_number, **params):
"""
The PhoneID Consent API's send feature allows you to send consent information for an add-on or add-ons that require(s) it.
"""
return self.post(PHONEID_CONSENT_RESOURCE.format(phone_number=phone_number), **params)

def consent_search(self, phone_number, **params):
"""
The PhoneID Consent API's search feature allows you to search for and retrieve consent information for an end user by phone number.
"""
return self.get(PHONEID_CONSENT_RESOURCE.format(phone_number=phone_number), **params)

def consent_history(self, phone_number):
"""
The PhoneID Consent API's retrieve all history feature allows you to retrieve all available consent history for a phone number.
"""

return self.get(PHONEID_CONSENT_HISTORY_RESOURCE.format(phone_number=phone_number))

def consent_delete(self, phone_number, **params):
"""
The PhoneID Consent API's delete feature allows you to delete consent information for a phone number.
"""
return self.delete(PHONEID_CONSENT_RESOURCE.format(phone_number=phone_number), **params)

def score(self, phone_number, ucid, **params):
"""
Expand Down