Class: Telesign::API::Verify
Overview
The Verify class exposes several services for sending users a verification token. You can use this mechanism to simply 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.
This class also exposes a service that is used in conjunction with the first two services, in that it allows you to confirm the result of the authentication.
You can use this verification factor in combination with username & password to provide two-factor authentication for higher security.
Instance Method Summary collapse
-
#call(phone_number, use_case_code = nil, extra = nil, timeout = nil) ⇒ Object
Calls the specified phone number, and using speech synthesis, speaks the verification code to the user.
-
#initialize(customer_id, secret_key, ssl = true, api_host = 'rest.telesign.com', timeout = nil) ⇒ Verify
constructor
A new instance of Verify.
-
#push(phone_number, use_case_code, extra = nil, timeout = nil) ⇒ Object
The push method sends a push notification containing the verification code to the specified phone number (supported for mobile phones only).
-
#smart(phone_number, use_case_code, extra = nil, timeout = nil) ⇒ Object
Calls the specified phone number, and using speech synthesis, speaks the verification code to the user.
-
#sms(phone_number, use_case_code = nil, extra = nil, timeout = nil) ⇒ Object
Sends a text message containing the verification code, to the specified phone number (supported for mobile phones only).
-
#status(reference_id, verify_code = nil, extra = nil, timeout = nil) ⇒ Object
Retrieves the verification result.
Methods inherited from Rest
#execute, #generate_auth_headers
Constructor Details
#initialize(customer_id, secret_key, ssl = true, api_host = 'rest.telesign.com', timeout = nil) ⇒ Verify
Returns a new instance of Verify.
195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/telesign.rb', line 195 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 |
Instance Method Details
#call(phone_number, use_case_code = nil, extra = nil, timeout = nil) ⇒ Object
Calls the specified phone number, and using speech synthesis, speaks the verification code to the user.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/telesign.rb', line 234 def call(phone_number, use_case_code=nil, extra=nil, timeout=nil) params = {:phone_number => phone_number} unless use_case_code.nil? params[:use_case_code] = use_case_code end unless extra.nil? params.merge!(extra) end execute(Net::HTTP::Post, "/v1/verify/call", nil, params, timeout) end |
#push(phone_number, use_case_code, extra = nil, timeout = nil) ⇒ Object
The push method sends a push notification containing the verification code to the specified phone number (supported for mobile phones only).
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/telesign.rb', line 280 def push(phone_number, use_case_code, extra=nil, timeout=nil) params = {:phone_number => phone_number, :ucid => use_case_code} unless extra.nil? params.merge!(extra) end execute(Net::HTTP::Post, "/v2/verify/push", nil, params, timeout) end |
#smart(phone_number, use_case_code, extra = nil, timeout = nil) ⇒ Object
Calls the specified phone number, and using speech synthesis, speaks the verification code to the user.
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/telesign.rb', line 258 def smart(phone_number, use_case_code, extra=nil, timeout=nil) params = {:phone_number => phone_number, :ucid => use_case_code} unless extra.nil? params.merge!(extra) end execute(Net::HTTP::Post, "/v1/verify/smart", nil, params, timeout) end |
#sms(phone_number, use_case_code = nil, extra = nil, timeout = nil) ⇒ Object
Sends a text message containing the verification code, to the specified phone number (supported for mobile phones only).
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/telesign.rb', line 210 def sms(phone_number, use_case_code=nil, extra=nil, timeout=nil) params = {:phone_number => phone_number} unless use_case_code.nil? params[:use_case_code] = use_case_code end unless extra.nil? params.merge!(extra) end execute(Net::HTTP::Post, "/v1/verify/sms", nil, params, timeout) end |
#status(reference_id, verify_code = nil, extra = nil, timeout = nil) ⇒ Object
Retrieves the verification result. You make this call in your web application after users complete the authentication transaction (using either a call or sms).
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/telesign.rb', line 302 def status(reference_id, verify_code=nil, extra=nil, timeout=nil) params = {} unless verify_code.nil? params[:verify_code] = verify_code end unless extra.nil? params.merge!(extra) end execute(Net::HTTP::Get, "/v1/verify/#{reference_id}", params, nil, timeout) end |