Class: ActiveShipping::Response
- Inherits:
-
Object
- Object
- ActiveShipping::Response
- Defined in:
- lib/active_shipping/response.rb
Overview
Basic Response class for requests against a carrier's API.
Direct Known Subclasses
AddressValidationResponse, CPPWSMerchantDetailsResponse, CPPWSRegisterResponse, DeliveryDateEstimatesResponse, ExternalReturnLabelResponse, LabelResponse, RateResponse, ShippingResponse, StampsAccountInfoResponse, StampsCleanseAddressResponse, StampsPurchasePostageResponse, TrackingResponse
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(success, message, params = {}, options = {}) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
Whether the request was executed successfully or not.
-
#test? ⇒ Boolean
Whether this request was executed against the sandbox or test environment instead of the production environment of the carrier.
Constructor Details
#initialize(success, message, params = {}, options = {}) ⇒ Response
Returns a new instance of Response.
22 23 24 25 26 27 28 |
# File 'lib/active_shipping/response.rb', line 22 def initialize(success, , params = {}, = {}) @success, @message, @params = success, , params.stringify_keys @test = [:test] || false @xml = [:xml] @request = [:request] raise ResponseError.new(self) unless success || [:allow_failure] end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/active_shipping/response.rb', line 6 def @message end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/active_shipping/response.rb', line 5 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
9 10 11 |
# File 'lib/active_shipping/response.rb', line 9 def request @request end |
#test ⇒ Object (readonly)
Returns the value of attribute test.
7 8 9 |
# File 'lib/active_shipping/response.rb', line 7 def test @test end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
8 9 10 |
# File 'lib/active_shipping/response.rb', line 8 def xml @xml end |
Instance Method Details
#success? ⇒ Boolean
Whether the request was executed successfully or not.
33 34 35 |
# File 'lib/active_shipping/response.rb', line 33 def success? @success ? true : false end |
#test? ⇒ Boolean
Whether this request was executed against the sandbox or test environment instead of the production environment of the carrier.
40 41 42 |
# File 'lib/active_shipping/response.rb', line 40 def test? @test ? true : false end |