Class: Telesignature::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/telesignature/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Api

Returns a new instance of Api.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/telesignature/api.rb', line 26

def initialize opts = {}
  @customer_id = opts[:customer_id]
  @secret_key = opts[:secret_key]
  api_host = opts[:api_host] || 'rest.telesign.com'
  ssl = opts[:ssl].nil? ? true : opts[:ssl]
  proxy_host = opts[:proxy_host] || nil

  http_root = ssl ? 'https' : 'http'
  proxy = proxy_host ? "#{http_root}://#{proxy_host}" : nil
  url = "#{http_root}://#{api_host}"

  @conn = Faraday.new(url: url) do |faraday|
    faraday.request  :url_encoded
    if defined? Rails
      faraday.response :logger, Rails.logger
    else
      faraday.response :logger                  # log requests to STDOUT
    end
    faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
  end

  @verify = Verify.new(conn: @conn, customer_id: opts[:customer_id], secret_key: opts[:secret_key])
  @phone_id = PhoneId.new(conn: @conn, customer_id: opts[:customer_id], secret_key: opts[:secret_key])
end

Instance Attribute Details

#phone_idObject

NOTE

You can obtain both your Customer ID and Secret Key from the
TeleSign Customer Portal <https://portal.telesign.com/account_profile_api_auth.php>


24
25
26
# File 'lib/telesignature/api.rb', line 24

def phone_id
  @phone_id
end

#verifyObject

NOTE

You can obtain both your Customer ID and Secret Key from the
TeleSign Customer Portal <https://portal.telesign.com/account_profile_api_auth.php>


24
25
26
# File 'lib/telesignature/api.rb', line 24

def verify
  @verify
end