Class: VantivLite::Config
- Inherits:
-
Object
- Object
- VantivLite::Config
- Defined in:
- lib/vantiv_lite/config.rb
Defined Under Namespace
Classes: Builder
Constant Summary collapse
- InvalidEnvironment =
Class.new(StandardError)
- ENVS =
{ 'sandbox' => URI('https://www.testvantivcnp.com/sandbox/communicator/online'), 'prelive' => URI('https://payments.vantivprelive.com/vap/communicator/online'), 'postlive' => URI('https://payments.vantivcnp.com/vap/communicator/online') }.freeze
- OPTS =
%i[env merchant_id password proxy_url report_group username version xml_lib].freeze
Instance Attribute Summary collapse
-
#proxy_uri ⇒ Object
readonly
Returns the value of attribute proxy_uri.
-
#sandbox ⇒ Object
(also: #sandbox?)
readonly
Returns the value of attribute sandbox.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**opts) ⇒ Config
constructor
A new instance of Config.
- #opts ⇒ Object
- #proxy_args ⇒ Object
- #with(**opts) ⇒ Object
Constructor Details
#initialize(**opts) ⇒ Config
Returns a new instance of Config.
48 49 50 51 52 53 54 55 |
# File 'lib/vantiv_lite/config.rb', line 48 def initialize(**opts) @opts = opts.each_with_object({}) { |(k, v), h| OPTS.include?(k = k.to_sym) && h[k] = v.to_s } defaults! load_xml_lib env_valid? proxy_uri! @uri = ENVS[@opts[:env]] end |
Instance Attribute Details
#proxy_uri ⇒ Object (readonly)
Returns the value of attribute proxy_uri.
45 46 47 |
# File 'lib/vantiv_lite/config.rb', line 45 def proxy_uri @proxy_uri end |
#sandbox ⇒ Object (readonly) Also known as: sandbox?
Returns the value of attribute sandbox.
45 46 47 |
# File 'lib/vantiv_lite/config.rb', line 45 def sandbox @sandbox end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
45 46 47 |
# File 'lib/vantiv_lite/config.rb', line 45 def uri @uri end |
Class Method Details
.build(&blk) ⇒ Object
36 37 38 |
# File 'lib/vantiv_lite/config.rb', line 36 def build(&blk) Config::Builder.(&blk) end |
.with_obj(config) ⇒ Object
40 41 42 |
# File 'lib/vantiv_lite/config.rb', line 40 def with_obj(config) config.is_a?(self) ? config : new(config) end |
Instance Method Details
#opts ⇒ Object
57 58 59 |
# File 'lib/vantiv_lite/config.rb', line 57 def opts @opts.dup end |
#proxy_args ⇒ Object
61 62 63 |
# File 'lib/vantiv_lite/config.rb', line 61 def proxy_args @proxy_uri ? [@proxy_uri.host, @proxy_uri.port, @proxy_uri.user, @proxy_uri.password] : [] end |
#with(**opts) ⇒ Object
65 66 67 |
# File 'lib/vantiv_lite/config.rb', line 65 def with(**opts) self.class.new(@opts.merge(opts)) end |