Class: VantivLite::Request
- Inherits:
-
Object
- Object
- VantivLite::Request
- Defined in:
- lib/vantiv_lite/request.rb
Constant Summary collapse
- InvalidConfig =
Class.new(StandardError)
- ResponseError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
- #call(request_hash, *dig_keys) ⇒ Object
-
#initialize(config = VantivLite.default_config, http: nil, serializer: nil) ⇒ Request
constructor
A new instance of Request.
- #post(xml) ⇒ Object
Constructor Details
#initialize(config = VantivLite.default_config, http: nil, serializer: nil) ⇒ Request
Returns a new instance of Request.
24 25 26 27 28 29 30 |
# File 'lib/vantiv_lite/request.rb', line 24 def initialize(config = VantivLite.default_config, http: nil, serializer: nil) raise InvalidConfig, 'invalid or missing config' unless config.is_a?(Config) @config = config @http = http || _http @parser = XML.parser_with(config.xml_lib) @serializer = serializer || XML.serializer_with(config.xml_lib) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/vantiv_lite/request.rb', line 22 def config @config end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
22 23 24 |
# File 'lib/vantiv_lite/request.rb', line 22 def http @http end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
22 23 24 |
# File 'lib/vantiv_lite/request.rb', line 22 def serializer @serializer end |
Instance Method Details
#call(request_hash, *dig_keys) ⇒ Object
32 33 34 |
# File 'lib/vantiv_lite/request.rb', line 32 def call(request_hash, *dig_keys) Response.new(post(serializer.(format_request(request_hash))), *dig_keys, parser: @parser) end |
#post(xml) ⇒ Object
36 37 38 |
# File 'lib/vantiv_lite/request.rb', line 36 def post(xml) http.dup.start { |h| h.request(post_request(xml)) } end |