Git Product home page Git Product logo

telesignature's Introduction

telesign

Ruby TeleSign SDK

example

require 'telesignature'

customer_id = 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890'
secret_key = 'EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=='
phone_number = '4445551212'

require 'telesignature'

ta = Telesignature::Api.new customer_id: customer_id,
                            secret_key: secret_key

phone_info = ta.phone_id.standard phone_number

p "##################"
p phone_info.data
p phone_info.headers
p phone_info.status
p phone_info.raw_data
p "##################"

phone_info = ta.phone_id.contact phone_number, 'PWRT'

p "##################"
p phone_info.data
p phone_info.headers
p phone_info.status
p phone_info.raw_data
p "##################"

phone_info = ta.phone_id.score phone_number, 'PWRT'

p "##################"
p phone_info.data
p phone_info.headers
p phone_info.status
p phone_info.raw_data
p "##################"

begin
  phone_info = ta.phone_id.live phone_number, 'RXPF'
rescue Telesignature::AuthorizationError => e
  puts e.message
end

p "##################"
p phone_info.data
p phone_info.headers
p phone_info.status
p phone_info.raw_data
p "##################"

phone_info = ta.verify.sms phone_number: phone_number #, verify_code: '12345'

p "##################"
p phone_info.data
p phone_info.headers
p phone_info.status
p phone_info.raw_data
p phone_info.verify_code
p "##################"

status_info = ta.verify.status phone_info.data['reference_id'], phone_info.verify_code
# status_info = ta.verify.status phone_info.data['reference_id'], '12345'

p "\n\n\n"
p "##################"
p status_info.data
p status_info.headers
p status_info.status
p status_info.raw_data
p status_info.verify_code
p "##################"

stubs mode

If you're running this in a Rails app, there is a stubs mode Sinatra app available.

Enable it by setting ENV['TELESIGN_STUBBED'] to something truthy.

The Sinatra app will run on "http://localhost:11989".

Currently stubs mode supports:

post '/v1/verify/sms' post '/v1/verify/call'

Both of which always return a success response.

get '/v1/verify/:reference_id'

Returns VALID for any verify_code which does not contain '666'.

get '/v1/phoneid/standard/:phone_number'

See codes for triggering different phone-type responses.

telesignature's People

Contributors

hmorales avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.