Class: TaxCloud::Responses::Base
- Inherits:
-
Object
- Object
- TaxCloud::Responses::Base
- Defined in:
- lib/tax_cloud/responses/base.rb
Overview
A base TaxCloud SOAP response.
Direct Known Subclasses
Generic, Lookup, TaxCodeGroups, TaxCodes, TaxCodesByGroup, VerifyAddress
Instance Attribute Summary collapse
-
#raw ⇒ Object
Raw response.
Class Method Summary collapse
-
.error_message(value) ⇒ Object
Parameters [value] Location of the error message in the SOAP XML.
-
.error_number(value) ⇒ Object
Parameters [value] Location of the error number in the SOAP XML.
-
.parse(savon_response) ⇒ Object
Parse a SOAP response.
-
.response_type(value) ⇒ Object
Parameters [value] Location of the response type in the SOAP XML.
- .set_dsl(key, value) ⇒ Object
Instance Method Summary collapse
-
#initialize(savon_response) ⇒ Base
constructor
Parameters [savon_response] Response from a SOAP API call.
-
#match(chain) ⇒ Object
Match an element in the SOAP response.
Constructor Details
#initialize(savon_response) ⇒ Base
Parameters
- savon_response
-
Response from a SOAP API call.
10 11 12 13 |
# File 'lib/tax_cloud/responses/base.rb', line 10 def initialize(savon_response) @raw = savon_response.to_hash parse! end |
Instance Attribute Details
#raw ⇒ Object
Raw response.
6 7 8 |
# File 'lib/tax_cloud/responses/base.rb', line 6 def raw @raw end |
Class Method Details
.error_message(value) ⇒ Object
Parameters
- value
-
Location of the error message in the SOAP XML.
24 25 26 |
# File 'lib/tax_cloud/responses/base.rb', line 24 def (value) set_dsl(:error_message, value) end |
.error_number(value) ⇒ Object
Parameters
- value
-
Location of the error number in the SOAP XML.
30 31 32 |
# File 'lib/tax_cloud/responses/base.rb', line 30 def error_number(value) set_dsl(:error_number, value) end |
.parse(savon_response) ⇒ Object
Parse a SOAP response.
Parameters
- savon_response
-
SOAP response.
38 39 40 |
# File 'lib/tax_cloud/responses/base.rb', line 38 def parse(savon_response) new(savon_response) end |
.response_type(value) ⇒ Object
Parameters
- value
-
Location of the response type in the SOAP XML.
18 19 20 |
# File 'lib/tax_cloud/responses/base.rb', line 18 def response_type(value) set_dsl(:response_type, value) end |
.set_dsl(key, value) ⇒ Object
62 63 64 65 66 |
# File 'lib/tax_cloud/responses/base.rb', line 62 def set_dsl(key, value) self.dsl ||= {} self.dsl[key] = value self.dsl end |
Instance Method Details
#match(chain) ⇒ Object
Match an element in the SOAP response.
Parameters
- chain
-
XML path to match.
47 48 49 50 51 52 53 54 55 |
# File 'lib/tax_cloud/responses/base.rb', line 47 def match(chain) current_value = raw chain.split('/').each do |key| current_value = current_value[key.to_sym] next if current_value fail TaxCloud::Errors::UnexpectedSoapResponse.new(raw, key, chain) end current_value end |