Class: TINCheck::Request
- Inherits:
-
Object
- Object
- TINCheck::Request
- Defined in:
- lib/tincheck/request.rb
Constant Summary collapse
- SERVICES =
{ list_match: 'ValidateListMatch', status: 'ServiceStatus', tin_name: 'ValidateTinName', validate_all: 'ValidateTinNameAddressListMatch' }.freeze
- SERVICE_XMLNS =
'http://www.TinCheck.com/WebServices/PVSService/'.freeze
- 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) ⇒ Object
-
#initialize(config = TINCheck.default_config, http: nil, serializer: nil) ⇒ Request
constructor
A new instance of Request.
- #post(xml) ⇒ Object
- #status ⇒ Object
- #tin_name(**kwargs) ⇒ Object
Constructor Details
#initialize(config = TINCheck.default_config, http: nil, serializer: nil) ⇒ Request
Returns a new instance of Request.
22 23 24 25 26 27 28 |
# File 'lib/tincheck/request.rb', line 22 def initialize(config = TINCheck.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.
20 21 22 |
# File 'lib/tincheck/request.rb', line 20 def config @config end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
20 21 22 |
# File 'lib/tincheck/request.rb', line 20 def http @http end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
20 21 22 |
# File 'lib/tincheck/request.rb', line 20 def serializer @serializer end |
Instance Method Details
#call(request_hash) ⇒ Object
30 31 32 33 |
# File 'lib/tincheck/request.rb', line 30 def call(request_hash) r = post(serializer.(format_request(request_hash))) Response.with_http_response(r, parser: @parser) end |
#post(xml) ⇒ Object
35 36 37 |
# File 'lib/tincheck/request.rb', line 35 def post(xml) http.dup.start { |h| h.request(post_request(xml)) } end |
#status ⇒ Object
39 40 41 |
# File 'lib/tincheck/request.rb', line 39 def status(*) call(SERVICES[:status] => {}) end |
#tin_name(**kwargs) ⇒ Object
43 44 45 46 |
# File 'lib/tincheck/request.rb', line 43 def tin_name(**kwargs) require_arguments!(kwargs, :name, :tin) call(SERVICES[:tin_name] => tin_name_arg(**kwargs)) end |