Skip to content

Commit 97fff25

Browse files
author
Jarrad Lee
committed
Merged all v2.0.0 changes, see release notes.
1 parent 42c5ea3 commit 97fff25

26 files changed

+609
-761
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
*.gem
2-
*.rbc
3-
.bundle
4-
.config
5-
coverage
6-
InstalledFiles
7-
lib/bundler/man
8-
pkg
9-
rdoc
10-
spec/reports
11-
test/tmp
12-
test/version_tmp
13-
tmp
142

15-
# YARD artifacts
16-
.yardoc
17-
_yardoc
18-
doc/
3+
# RubyMine IDE
4+
.idea
5+
6+
# Other
7+
.DS_Store
8+

LICENSE.txt renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016 TeleSign Corp.
1+
Copyright (c) 2017 TeleSign Corp.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of
44
this software and associated documentation files (the "Software"), to deal in

README.rst

Lines changed: 57 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,134 +2,78 @@
22
TeleSign
33
========
44

5-
**Information**: For more information, visit the `TeleSign website <http://www.TeleSign.com>`_ or the `TeleSign Developer Portal <https://developer.telesign.com/>`_.
6-
7-
**Author**: Telesign Corp.
8-
9-
TeleSign Web Services: Ruby SDK
10-
---------------------------------
11-
12-
**TeleSign web services** conform to the `REST Web Service Design Model <http://en.wikipedia.org/wiki/Representational_state_transfer>`_. Services are exposed as URI-addressable resources through the set of *RESTful* procedures in our **TeleSign REST API**.
13-
14-
The **TeleSign Ruby SDK** is a set of software development tools—a *Ruby Library* that wraps the TeleSign REST API, and it simplifies TeleSign application development in the `Ruby programming language <https://www.ruby-lang.org/>`_. The SDK software is packaged as a Ruby gem called **telesign**, and is distributed using `Ruby Gems <https://rubygems.org/>`_.
15-
16-
The Ruby Classes
17-
------------------
18-
19-
With just two classes, **Telesign::API** abstracts much of the complexity of the TeleSign REST API.
20-
21-
+---------------------------+--------------------------------------------------------------------------+
22-
| Ruby Class | Description |
23-
+===========================+==========================================================================+
24-
| Telesign::API::PhoneId | The **PhoneId** class exposes four services that each provide |
25-
| | information about a specified phone number. |
26-
| | |
27-
| | *standard* |
28-
| | Retrieves the standard set of details about the specified phone |
29-
| | number. This includes the type of phone (for example, land line or |
30-
| | mobile), and its approximate geographic location. |
31-
| | *score* |
32-
| | Retrieves a score for the specified phone number. This ranks the |
33-
| | phone number's "risk level" on a scale from 0 to 1000, so you can |
34-
| | code your web application to handle particular use cases (for |
35-
| | example, to stop things like chargebacks, identity theft, fraud, and |
36-
| | spam). |
37-
| | *contact* |
38-
| | In addition to the information retrieved by *standard*, this service |
39-
| | provides the name and address associated with the specified phone |
40-
| | number. |
41-
| | *live* |
42-
| | In addition to the information retrieved by *standard*, this service |
43-
| | provides actionable data associated with the specified phone number. |
44-
| | *number_deactivation* |
45-
| | In addition to the information retrieved by *standard*, this service |
46-
| | provides information on number deactivation for the phone number |
47-
| | provided. |
48-
+---------------------------+--------------------------------------------------------------------------+
49-
| Telesign::API::Verify | The **Verify** class exposes five services for sending users a |
50-
| | verification token (a three to five-digit number). You can use this |
51-
| | mechanism to test whether you can reach users at the phone number |
52-
| | they supplied, or you can have them use the token to authenticate |
53-
| | themselves with your web application. In addition, this class also |
54-
| | exposes a service that allows you to confirm the result of the |
55-
| | authentication. |
56-
| | |
57-
| | You can use this verification factor in combination with *username* |
58-
| | and *password* to provide *two-factor* authentication for higher |
59-
| | security. |
60-
| | |
61-
| | *call* |
62-
| | Calls the specified phone number and uses speech synthesis to speak |
63-
| | the verification code to the user. |
64-
| | *sms* |
65-
| | Sends a text message containing the verification code to the |
66-
| | specified phone number (supported for mobile phones only). |
67-
| | *smart* |
68-
| | Smart intelligently determines the best service to use based on |
69-
| | the end user device and then attempts to place a call, send an SMS, |
70-
| | or send a push request. |
71-
| | *push* |
72-
| | Sends a push notification containing the verification code to the |
73-
| | specified phone number (supported for registered devices only). |
74-
| | *status* |
75-
| | Retrieves the verification result. You make this call in your web |
76-
| | application after users complete the authentication transaction |
77-
| | (using either a *call* or *sms*). |
78-
| | |
79-
+---------------------------+--------------------------------------------------------------------------+
80-
| Telesign::API::TeleBureau | The **Telebureau** class exposes services for creating, retrieving, |
81-
| | updating and deleting telebureau fraud events. You can use this |
82-
| | mechanism to test whether you can reach Telebureau services. |
83-
| | |
84-
| | *create* |
85-
| | Creates a Telebureau event corresponding to supplied data. |
86-
| | *retrieve* |
87-
| | Retrieves the fraud event status. You make this call in your web |
88-
| | application after completion of create/update transaction for a |
89-
| | Telebureau event. |
90-
| | *delete* |
91-
| | Deletes a previously submitted fraud event. You make this call in |
92-
| | your web application after completion of submit/update transaction |
93-
| | for a Telebureau event. |
94-
| | |
95-
+---------------------------+--------------------------------------------------------------------------+
5+
TeleSign provides the world’s most comprehensive approach to account security for Web and mobile applications.
6+
7+
For more information about TeleSign, visit the `TeleSign website <http://www.TeleSign.com>`_.
8+
9+
TeleSign REST API: Ruby SDK
10+
---------------------------
11+
12+
**TeleSign web services** conform to the `REST Web Service Design Model
13+
<http://en.wikipedia.org/wiki/Representational_state_transfer>`_. Services are exposed as URI-addressable resources
14+
through the set of *RESTful* procedures in our **TeleSign REST API**.
15+
16+
The **TeleSign Ruby SDK** is a set modules and functions — a *Ruby Library* that wraps the
17+
TeleSign REST API, and it simplifies TeleSign application development in the `Ruby programming language
18+
<https://www.ruby-lang.org>`_. The SDK software is distributed on
19+
`GitHub <https://github.com/TeleSign/ruby_telesign>`_ and also as a Ruby Gem using `Ruby Gems <https://rubygems.org>`_.
20+
21+
Documentation
22+
-------------
23+
24+
Detailed documentation for TeleSign REST APIs is available in the `Developer Portal <https://developer.telesign.com/>`_.
9625

9726
Installation
9827
------------
9928

100-
With `Ruby Gems <https://github.com/rubygems/rubygems>`_
101-
installed, type **gem install telesign** at the command prompt.
29+
To install the TeleSign Ruby SDK:
30+
31+
.. code-block:: bash
10232
103-
Ruby Code Example: To Verify a Call
104-
-------------------------------------
33+
$ gem install telesign
10534
106-
Here's a basic code example.
35+
Alternatively, you can download the project source, and execute **gem build telesign.gemspec && gem install telesign-[version].gem**.
10736

108-
::
37+
Ruby Code Example: Messaging
38+
----------------------------
39+
40+
Here's a basic code example with JSON response.
41+
42+
.. code-block:: ruby
10943
11044
require 'telesign'
111-
phone_number = "13103409700"
112-
cust_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"
113-
secret_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="
114-
verify = Telesign::API::Verify.new(cust_id, secret_key) # Instantiate a Verify instance object,
115-
result = verify.call(phone_number) # and use it to call the "call" method.
116-
p result.body
11745
118-
{"reference_id"=>"254CADA5F1D40E0090405467DE244D05", "resource_uri"=>"/v1/verify/254CADA5F1D40E0090405467DE244D05", "sub_resource"=>"call", "errors"=>[], "verify"=>{"code_state"=>"UNKNOWN", "code_entered"=>""}, "status"=>{"updated_on"=>"2016-02-29T05:04:06.814381Z", "code"=>103, "description"=>"Call in progress"}}
46+
customer_id = 'customer_id'
47+
secret_key = 'secret_key'
11948
120-
For more examples, see the Documentation section below.
49+
phone_number = 'phone_number'
50+
message = 'You\'re scheduled for a dentist appointment at 2:30PM.'
51+
message_type = 'ARN'
12152
122-
Authentication
123-
-------------
53+
messaging_client = Telesign::MessagingClient.new(customer_id, secret_key)
54+
response = messaging_client.message(phone_number, message, message_type)
12455
125-
You will need a Customer ID and API Key in order to use TeleSign’s REST API. If you are already a customer and need an API Key, you can generate one in `TelePortal <https://teleportal.telesign.com>`_. If you are not a customer and would like to get an API Key, please contact `support@telesign.com <mailto:support@telesign.com>`_
56+
.. code-block:: javascript
57+
58+
{"reference_id"=>"B56A497C9A74016489525132F8840634",
59+
"status"=>
60+
{"updated_on"=>"2017-03-03T04:13:14.028347Z",
61+
"code"=>103,
62+
"description"=>"Call in progress"}}
63+
64+
For more examples, see the examples folder or visit `TeleSign Developer Portal <https://developer.telesign.com/>`_.
65+
66+
Authentication
67+
--------------
12668

69+
You will need a Customer ID and API Key in order to use TeleSign’s REST API. If you are already a customer and need an
70+
API Key, you can generate one in the `Portal <https://portal.telesign.com>`_.
12771

128-
Support and Feedback
129-
--------------------
72+
Testing
73+
-------
13074

131-
For more information about the Phone Verify and PhoneID Standard services, please contact your TeleSign representative:
75+
To run the Ruby SDK test suite:
13276

133-
Email: `support@telesign.com <mailto:support@telesign.com>`_
77+
.. code-block:: bash
13478
135-
Phone: +1 310 740 9700
79+
$ rake test

RELEASE

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2.0.0
2+
3+
- Major refactor and simplification into generic REST client.
4+
- API parameters are now passed as kwargs to endpoint handlers.
5+
- UserAgent is now set to track client usage and help debug issues.
6+
- generate_telesign_headers is now static and easily extracted from the SDK if
7+
custom behavior/implementation is required.
8+
- Now using net/http/persistent to take advantage of http connection pooling for performance,
9+
thread safety and graceful reconnects
10+
11+
1.0.2
12+
13+
- Fixed gem imports
14+
- Added number_deactivation and telebureau create, retrieve and delete endpoints.
15+
16+
1.0.0
17+
18+
- Initial version supporting commonly used Telesign endpoints.

Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'rake/testtask'
2+
3+
Rake::TestTask.new do |t|
4+
t.libs << 'test'
5+
t.test_files = FileList['test/test*.rb']
6+
t.verbose = true
7+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'telesign'
2+
3+
customer_id = 'customer_id'
4+
secret_key = 'secret_key'
5+
6+
external_id = 'external_id'
7+
8+
av_client = Telesign::AutoVerifyClient.new(customer_id, secret_key)
9+
response = av_client.status(external_id)
10+
11+
if response.ok
12+
puts 'AutoVerify transaction with external_id %s has status code %s and status description %s.' %
13+
[external_id,
14+
response.json['status']['code'],
15+
response.json['status']['description']]
16+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'telesign'
2+
3+
customer_id = 'customer_id'
4+
secret_key = 'secret_key'
5+
6+
phone_number = 'phone_number'
7+
message = 'You\'re scheduled for a dentist appointment at 2:30PM.'
8+
message_type = 'ARN'
9+
10+
messaging_client = Telesign::MessagingClient.new(customer_id, secret_key)
11+
response = messaging_client.message(phone_number, message, message_type)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'telesign'
2+
3+
customer_id = 'customer_id'
4+
secret_key = 'secret_key'
5+
6+
phone_number = 'phone_number'
7+
verify_code = Telesign::Util.random_with_n_digits(5)
8+
message = "Your code is #{verify_code}"
9+
message_type = 'OTP'
10+
11+
messaging_client = Telesign::MessagingClient.new(customer_id, secret_key)
12+
response = messaging_client.message(phone_number, message, message_type)
13+
14+
print 'Please enter the verification code you were sent: '
15+
user_entered_verify_code = gets.strip
16+
17+
if verify_code == user_entered_verify_code
18+
puts 'Your code is correct.'
19+
else
20+
puts 'Your code is incorrect.'
21+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'telesign'
2+
3+
customer_id = 'customer_id'
4+
secret_key = 'secret_key'
5+
6+
phone_number = 'phone_number'
7+
phone_type_voip = '5'
8+
9+
phoneid_client = Telesign::PhoneIdClient.new(customer_id, secret_key)
10+
response = phoneid_client.phoneid(phone_number)
11+
12+
if response.ok
13+
if response.json['phone_type']['code'] == phone_type_voip
14+
puts "Phone number #{phone_number} is a VOIP phone."
15+
else
16+
puts "Phone number #{phone_number} is not a VOIP phone."
17+
end
18+
end

0 commit comments

Comments
 (0)