Class: AddressValidator::Response
- Inherits:
-
Object
- Object
- AddressValidator::Response
- Extended by:
- Forwardable
- Defined in:
- lib/address_validator/response.rb
Instance Attribute Summary collapse
-
#api_response ⇒ Object
readonly
Returns the value of attribute api_response.
Instance Method Summary collapse
- #address ⇒ Object
- #ambiguous? ⇒ Boolean
- #error ⇒ Object
-
#initialize(api_response) ⇒ Response
constructor
A new instance of Response.
- #no_canidates? ⇒ Boolean
- #ok? ⇒ Boolean
- #response ⇒ Object
- #success? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(api_response) ⇒ Response
Returns a new instance of Response.
10 11 12 |
# File 'lib/address_validator/response.rb', line 10 def initialize(api_response) @api_response = api_response end |
Instance Attribute Details
#api_response ⇒ Object (readonly)
Returns the value of attribute api_response.
7 8 9 |
# File 'lib/address_validator/response.rb', line 7 def api_response @api_response end |
Instance Method Details
#address ⇒ Object
43 44 45 |
# File 'lib/address_validator/response.rb', line 43 def address AddressValidator::Address.from_xml(response['AddressKeyFormat']) end |
#ambiguous? ⇒ Boolean
35 36 37 |
# File 'lib/address_validator/response.rb', line 35 def ambiguous? response.has_key?('AmbiguousAddressIndicator') end |
#error ⇒ Object
26 27 28 29 |
# File 'lib/address_validator/response.rb', line 26 def error _error_container = response['Response']['Error'] _error_container && _error_container['ErrorDescription'] end |
#no_canidates? ⇒ Boolean
39 40 41 |
# File 'lib/address_validator/response.rb', line 39 def no_canidates? response.has_key?('NoCandidatesIndicator') end |
#ok? ⇒ Boolean
14 15 16 |
# File 'lib/address_validator/response.rb', line 14 def ok? @api_response.ok? end |
#response ⇒ Object
22 23 24 |
# File 'lib/address_validator/response.rb', line 22 def response @response ||= self['AddressValidationResponse'] end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/address_validator/response.rb', line 18 def success? ok? && response['Response']['ResponseStatusCode'] == '1' end |
#valid? ⇒ Boolean
31 32 33 |
# File 'lib/address_validator/response.rb', line 31 def valid? response.has_key?('ValidAddressIndicator') end |