Method: ActiveShipping::Response#initialize

Defined in:
lib/active_shipping/response.rb

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

Returns a new instance of Response.

Parameters:

  • success (Boolean)

    Whether the request was considered successful, i.e. this response object will have the expected data set.

  • message (String)

    A status message. Usuaully set when success is false, but can also be set for successful responses.

  • params (Hash) (defaults to: {})

    Response parameters

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :test (Boolean) — default: default: false

    Whether this reponse was a result of a request executed against the sandbox or test environment of the carrier's API.

  • :xml (String)

    The raw XML of the response.

  • :request (String)

    The payload of the request.

Raises:



21
22
23
24
25
26
27
# File 'lib/active_shipping/response.rb', line 21

def initialize(success, message, params = {}, options = {})
  @success, @message, @params = success, message, params.stringify_keys
  @test = options[:test] || false
  @xml = options[:xml]
  @request = options[:request]
  raise ResponseError.new(self) unless success
end