class CardConnect::Connection
Public Class Methods
new(config = CardConnect.configuration)
click to toggle source
# File lib/cardconnect/connection.rb, line 6 def initialize(config = CardConnect.configuration) @config = config end
Public Instance Methods
connection()
click to toggle source
# File lib/cardconnect/connection.rb, line 10 def connection @connection ||= Faraday.new(faraday_options) do |f| f.request :basic_auth, @config.api_username, @config.api_password f.request :json f.response :json, content_type: /\bjson$/ f.response :raise_error f.adapter Faraday.default_adapter end end
faraday_options()
click to toggle source
# File lib/cardconnect/connection.rb, line 30 def faraday_options { url: @config.endpoint, headers: { user_agent: "CardConnectRubyGem/#{CardConnect::VERSION}" }, }.merge(@config.connection_options) end
ping_server()
click to toggle source
# File lib/cardconnect/connection.rb, line 22 def ping_server connection.get('/cardconnect/rest/') rescue Faraday::ResourceNotFound => e return e rescue Faraday::ClientError => e return e end