Module: Tango::Default

Defined in:
lib/tango/default.rb

Constant Summary collapse

INTEGRATION_ENDPOINT =
'https://int.tangocard.com'
PRODUCTION_ENDPOINT =
'https://api.tangocard.com'
ENDPOINT =
INTEGRATION_ENDPOINT
MIDDLEWARE =
Faraday::Builder.new do |builder|
  # Encode request params into JSON for PUT/POST requests
  builder.use ::Tango::Request::JsonEncoded

  builder.use ::Tango::Response::RaiseError, ::Tango::Error::ClientError

  # Parse response JSON
  builder.use ::Tango::Response::ParseJson

  builder.use ::Tango::Response::RaiseError, ::Tango::Error::ServerError

  builder.adapter Faraday.default_adapter

end
CONNECTION_OPTIONS =
{
  :headers => {
    :accept => 'application/json',
    :user_agent => "TangoClient Ruby Gem #{::Tango::VERSION}"
  },
  :open_timeout => 5,
  :raw => true,
  :ssl => {
    :ca_file => File.expand_path('../ssl/cacert.pem')
  },
  :timeout => 10,
}
VERSION =
'Version2'

Class Method Summary collapse

Class Method Details

.optionsObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/tango/default.rb', line 45

def self.options
  @options ||= {
    :username => ENV['TANGO_USERNAME'] || '[email protected]',
    :password => ENV['TANGO_PASSWORD'] || 'integrateme',
    :endpoint => ENV['TANGO_ENDPOINT'] || ENDPOINT,
    :version => VERSION,
    :middleware => MIDDLEWARE,
    :connection_options => CONNECTION_OPTIONS
  }
end

.templateObject



56
57
58
59
60
61
62
# File 'lib/tango/default.rb', line 56

def self.template
  template = options.dup
  template[:middleware] = options[:middleware].dup
  template[:connection_options] = options[:connection_options].dup

  template
end