Sha256: c2322e4bd2ff4aa1394c994304f02b85a8d29aa4b3b6e6d9f2b990dc2f4bf534
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'faraday' require 'json' module Telesignature class ServiceBase # attr_accessor :customer_id, :secret_key, :api_host def initialize opts = {} @customer_id = opts[:customer_id] @secret_key = opts[:secret_key] api_host = opts[:api_host] ssl = opts[:ssl] || nil 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 faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end def validate_response response resp_obj = JSON.load response.body if response.status != 200 if response.status == 401 raise AuthorizationError.new resp_obj['errors'], response else raise TelesignError.new resp_obj['errors'], response end end resp_obj end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
telesignature-0.0.9 | lib/telesignature/service_base.rb |
telesignature-0.0.8 | lib/telesignature/service_base.rb |