Class: ReactiveShipping::AddressValidationResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/reactive_shipping/address_validation_response.rb

Overview

Response object class for calls to Carrier#validate_address.

Instance Attribute Summary collapse

Attributes inherited from Response

#message, #request, #test, #xml

Instance Method Summary collapse

Methods inherited from Response

#success?, #test?

Constructor Details

#initialize(success, message, params = {}, options = {}) ⇒ AddressValidationResponse

Returns a new instance of AddressValidationResponse.



11
12
13
14
15
16
# File 'lib/reactive_shipping/address_validation_response.rb', line 11

def initialize(success, message, params = {}, options = {})
  @validity = options[:validity]
  @candidate_addresses = options[:candidate_addresses]
  @classification = options[:classification]
  super
end

Instance Attribute Details

#candidate_addressesObject (readonly)

Returns the value of attribute candidate_addresses.



9
10
11
# File 'lib/reactive_shipping/address_validation_response.rb', line 9

def candidate_addresses
  @candidate_addresses
end

#classificationObject (readonly)

Returns the value of attribute classification.



9
10
11
# File 'lib/reactive_shipping/address_validation_response.rb', line 9

def classification
  @classification
end

#locationString

The Location to be validated

Returns:

  • (String)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/reactive_shipping/address_validation_response.rb', line 8

class AddressValidationResponse < Response
  attr_reader :validity, :classification, :candidate_addresses, :options, :params

  def initialize(success, message, params = {}, options = {})
    @validity = options[:validity]
    @candidate_addresses = options[:candidate_addresses]
    @classification = options[:classification]
    super
  end

  def address_match?
    @validity == :valid
  end

  def residential?
    @classification == :residential
  end

  def commercial?
    @classification == :commercial
  end
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/reactive_shipping/address_validation_response.rb', line 9

def options
  @options
end

#paramsObject (readonly)

Returns the value of attribute params.



9
10
11
# File 'lib/reactive_shipping/address_validation_response.rb', line 9

def params
  @params
end

#validityObject (readonly)

Returns the value of attribute validity.



9
10
11
# File 'lib/reactive_shipping/address_validation_response.rb', line 9

def validity
  @validity
end

Instance Method Details

#address_match?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/reactive_shipping/address_validation_response.rb', line 18

def address_match?
  @validity == :valid
end

#commercial?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/reactive_shipping/address_validation_response.rb', line 26

def commercial?
  @classification == :commercial
end

#residential?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/reactive_shipping/address_validation_response.rb', line 22

def residential?
  @classification == :residential
end