jpriddle

/oss / TrustMe

TrustMe

Nov 2014 · Source ·
API Git Rspec Ruby RubyGems TeleSign

This library is a wrapper for the TeleSign REST API. Currently the Verify Call and Verify SMS web services are supported. The Verify Call web service sends a verification code to a user in a voice message with a phone call. The Verify SMS web service sends a verification code to a user in a text message via SMS. The user enters this code in a web application to verify their identity.

See also:

Configuration

Set global credentials:

TrustMe.config do |c|
  c.customer_id = "1234"
  c.secret_key  = "secret"
end

If you need different credentials per-instance:

trust_me = TrustMe.new "5678", "secret2"

Usage

Send a verification call to a customer and save the verification code:

class VerifyController < ApplicationController
  def create
    trust_me = TrustMe.new
    call     = trust_me.send_verification_call! current_user.phone

    current_user.update_attribute! :verification_code, call[:code]
  end
end

Or send a verification SMS to a customer:

class VerifyController < ApplicationController
  def create
    trust_me = TrustMe.new
    sms     = trust_me.send_verification_sms! current_user.phone

    current_user.update_attribute! :verification_code, sms[:code]
  end
end

The customer verifies the code:

class VerifyController < ApplicationController
  def update
    if params[:code] == current_user.verification_code
      current_user.set_verified!
    end
  end
end

Note on Patches/Pull Requests

License

MIT License - see LICENSE in this repo.