Class: AddressValidate::API::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/address_validate/api/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_body) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/address_validate/api/response.rb', line 6

def initialize(response_body)
  @response_body = Ox.parse(response_body)
end

Instance Attribute Details

#response_bodyObject (readonly)

Returns the value of attribute response_body.



4
5
6
# File 'lib/address_validate/api/response.rb', line 4

def response_body
  @response_body
end

Instance Method Details

#dataObject



18
19
20
# File 'lib/address_validate/api/response.rb', line 18

def data
  @data ||= errors ? {} : parse_data
end

#errorObject



14
15
16
# File 'lib/address_validate/api/response.rb', line 14

def error
  AddressValidate::API::Error.new(errors) if errors
end

#success?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/address_validate/api/response.rb', line 10

def success?
  errors.nil?
end

#warningObject



22
23
24
# File 'lib/address_validate/api/response.rb', line 22

def warning
  get_field('ReturnText')
end