Skip to content

Commit

Permalink
Added number_deactivation and telebureau create, retrieve and delete …
Browse files Browse the repository at this point in the history
…endpoints.
  • Loading branch information
Jarrad Lee committed Nov 22, 2016
1 parent a8bda48 commit 42c5ea3
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 81 deletions.
131 changes: 75 additions & 56 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,81 @@ The Ruby Classes

With just two classes, **Telesign::API** abstracts much of the complexity of the TeleSign REST API.

+------------------------+--------------------------------------------------------------------------+
| Ruby Class | Description |
+========================+==========================================================================+
| Telesign::API::PhoneId | The **PhoneId** class exposes four services that each provide |
| | information about a specified phone number. |
| | |
| | *standard* |
| | Retrieves the standard set of details about the specified phone |
| | number. This includes the type of phone (for example, land line or |
| | mobile), and its approximate geographic location. |
| | *score* |
| | Retrieves a score for the specified phone number. This ranks the |
| | phone number's "risk level" on a scale from 0 to 1000, so you can |
| | code your web application to handle particular use cases (for |
| | example, to stop things like chargebacks, identity theft, fraud, and |
| | spam). |
| | *contact* |
| | In addition to the information retrieved by *standard*, this service |
| | provides the name and address associated with the specified phone |
| | number. |
| | *live* |
| | In addition to the information retrieved by standard, this service |
| | provides actionable data associated with the specified phone number. |
| | |
+------------------------+--------------------------------------------------------------------------+
| Telesign::API::Verify | The **Verify** class exposes five services for sending users a |
| | verification token (a three to five-digit number). You can use this |
| | mechanism to test whether you can reach users at the phone number |
| | they supplied, or you can have them use the token to authenticate |
| | themselves with your web application. In addition, this class also |
| | exposes a service that allows you to confirm the result of the |
| | authentication. |
| | |
| | You can use this verification factor in combination with *username* |
| | and *password* to provide *two-factor* authentication for higher |
| | security. |
| | |
| | *call* |
| | Calls the specified phone number and uses speech synthesis to speak |
| | the verification code to the user. |
| | *sms* |
| | Sends a text message containing the verification code to the |
| | specified phone number (supported for mobile phones only). |
| | *smart* |
| | Smart intelligently determines the best service to use based on |
| | the end user device and then attempts to place a call, send an SMS, |
| | or send a push request. |
| | *push* |
| | Sends a push notification containing the verification code to the |
| | specified phone number (supported for registered devices only). |
| | *status* |
| | Retrieves the verification result. You make this call in your web |
| | application after users complete the authentication transaction |
| | (using either a *call* or *sms*). |
| | |
+------------------------+--------------------------------------------------------------------------+
+---------------------------+--------------------------------------------------------------------------+
| Ruby Class | Description |
+===========================+==========================================================================+
| Telesign::API::PhoneId | The **PhoneId** class exposes four services that each provide |
| | information about a specified phone number. |
| | |
| | *standard* |
| | Retrieves the standard set of details about the specified phone |
| | number. This includes the type of phone (for example, land line or |
| | mobile), and its approximate geographic location. |
| | *score* |
| | Retrieves a score for the specified phone number. This ranks the |
| | phone number's "risk level" on a scale from 0 to 1000, so you can |
| | code your web application to handle particular use cases (for |
| | example, to stop things like chargebacks, identity theft, fraud, and |
| | spam). |
| | *contact* |
| | In addition to the information retrieved by *standard*, this service |
| | provides the name and address associated with the specified phone |
| | number. |
| | *live* |
| | In addition to the information retrieved by *standard*, this service |
| | provides actionable data associated with the specified phone number. |
| | *number_deactivation* |
| | In addition to the information retrieved by *standard*, this service |
| | provides information on number deactivation for the phone number |
| | provided. |
+---------------------------+--------------------------------------------------------------------------+
| Telesign::API::Verify | The **Verify** class exposes five services for sending users a |
| | verification token (a three to five-digit number). You can use this |
| | mechanism to test whether you can reach users at the phone number |
| | they supplied, or you can have them use the token to authenticate |
| | themselves with your web application. In addition, this class also |
| | exposes a service that allows you to confirm the result of the |
| | authentication. |
| | |
| | You can use this verification factor in combination with *username* |
| | and *password* to provide *two-factor* authentication for higher |
| | security. |
| | |
| | *call* |
| | Calls the specified phone number and uses speech synthesis to speak |
| | the verification code to the user. |
| | *sms* |
| | Sends a text message containing the verification code to the |
| | specified phone number (supported for mobile phones only). |
| | *smart* |
| | Smart intelligently determines the best service to use based on |
| | the end user device and then attempts to place a call, send an SMS, |
| | or send a push request. |
| | *push* |
| | Sends a push notification containing the verification code to the |
| | specified phone number (supported for registered devices only). |
| | *status* |
| | Retrieves the verification result. You make this call in your web |
| | application after users complete the authentication transaction |
| | (using either a *call* or *sms*). |
| | |
+---------------------------+--------------------------------------------------------------------------+
| Telesign::API::TeleBureau | The **Telebureau** class exposes services for creating, retrieving, |
| | updating and deleting telebureau fraud events. You can use this |
| | mechanism to test whether you can reach Telebureau services. |
| | |
| | *create* |
| | Creates a Telebureau event corresponding to supplied data. |
| | *retrieve* |
| | Retrieves the fraud event status. You make this call in your web |
| | application after completion of create/update transaction for a |
| | Telebureau event. |
| | *delete* |
| | Deletes a previously submitted fraud event. You make this call in |
| | your web application after completion of submit/update transaction |
| | for a Telebureau event. |
| | |
+---------------------------+--------------------------------------------------------------------------+

Installation
------------
Expand Down
102 changes: 101 additions & 1 deletion lib/telesign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ def call_forward(phone_number,
timeout)
end

# In addition to the information retrieved by standard, this service provides
# information on call forwarding for the phone number provided.
def number_deactivation(phone_number,
use_case_code,
extra=nil,
timeout=nil)

params = {:ucid => use_case_code}

unless extra.nil?
params.merge!(extra)
end

execute(Net::HTTP::Get,
"/v1/phoneid/number_deactivation/#{phone_number}",
params,
nil,
timeout)
end

end

# The Verify class exposes several services for sending users a verification
Expand Down Expand Up @@ -270,7 +290,7 @@ def push(phone_number,
end

execute(Net::HTTP::Post,
"/v1/verify/push",
"/v2/verify/push",
nil,
params,
timeout)
Expand Down Expand Up @@ -301,5 +321,85 @@ def status(reference_id,
timeout)
end
end


# The **Telebureau** class exposes services for creating, retrieving, updating and
# deleting telebureau fraud events. You can use this mechanism to simply test whether
# you can reach telebureau services.
class TeleBureau < Telesign::API::Rest

def initialize(customer_id,
secret_key,
ssl=true,
api_host='rest.telesign.com',
timeout=nil)

super(customer_id,
secret_key,
ssl,
api_host,
timeout)
end

# Creates a telebureau event corresponding to supplied data.
def create(phone_number,
fraud_type,
occurred_at,
extra=nil,
timeout=nil)

params = {:phone_number => phone_number,
:fraud_type => fraud_type,
:occurred_at => occurred_at}

unless extra.nil?
params.merge!(extra)
end

execute(Net::HTTP::Post,
"/v1/telebureau/event",
nil,
params,
timeout)
end

# Retrieves the fraud event status. You make this call in your web application after
# completion of create transaction for a telebureau event.
def retrieve(reference_id,
extra=nil,
timeout=nil)

params = {}

unless extra.nil?
params.merge!(extra)
end

execute(Net::HTTP::Get,
"/v1/telebureau/event/#{reference_id}",
params,
nil,
timeout)
end

# Deletes a previously submitted fraud event. You make this call in your web application
# after completion of the create transaction for a telebureau event.
def delete(reference_id,
extra=nil,
timeout=nil)

params = {}

unless extra.nil?
params.merge!(extra)
end

execute(Net::HTTP::Delete,
"/v1/telebureau/event/#{reference_id}",
params,
nil,
timeout)
end
end
end
end
Loading

0 comments on commit 42c5ea3

Please sign in to comment.