class Datatrans::Config
Constants
- BASE_URL_DEVELOPMENT
- BASE_URL_PRODUCTION
- DEFAULT_ENVIRONMENT
- DEFAULT_SIGN_KEY
- ENVIRONMENTS
- URLS
Attributes
environment[R]
merchant_id[R]
proxy[R]
sign_key[R]
Public Class Methods
new(options = {})
click to toggle source
Configure with following options
-
:merchant_id (required)
-
:sign_key (defaults to false)
-
:environment (defaults to :development, available environments are defined in
ENVIRONMENTS
) -
:proxy (a hash containing :http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass)
# File lib/datatrans/config.rb, line 33 def initialize(options = {}) @merchant_id = options[:merchant_id] raise ArgumentError.new(":merchant_id is required") unless self.merchant_id self.environment = options[:environment] || DEFAULT_ENVIRONMENT @sign_key = options[:sign_key] || DEFAULT_SIGN_KEY @proxy = options[:proxy] || {} end
Public Instance Methods
environment=(environment)
click to toggle source
# File lib/datatrans/config.rb, line 41 def environment=(environment) environment = environment.try(:to_sym) if ENVIRONMENTS.include?(environment) @environment = environment else raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(', ')}" end end
url(what)
click to toggle source
Access a url, is automatically scoped to environment
# File lib/datatrans/config.rb, line 51 def url(what) URLS[self.environment][what] end
web_transaction(*args)
click to toggle source
# File lib/datatrans/config.rb, line 55 def web_transaction(*args) Web::Transaction.new(self, *args) end
xml_transaction(*args)
click to toggle source
# File lib/datatrans/config.rb, line 59 def xml_transaction(*args) XML::Transaction.new(self, *args) end