Class: ActiveShipping::ShippingResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/active_shipping/shipping_response.rb

Overview

Note:

Some carriers provide more information that others, so not all attributes will be set, depending on what carrier you are using.

Responce object class for calls to Carrier#create_shipment.

Instance Attribute Summary collapse

Attributes inherited from Response

#message, #params, #request, #test, #xml

Instance Method Summary collapse

Methods inherited from Response

#success?, #test?

Constructor Details

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

Initializes a new ShippingResponse instance.

Options Hash (options):

  • :shipping_id (String)

    Populates #shipping_id.

  • :tracking_number (String)

    Populates #tracking_number.

  • :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.

  • :allow_failure (Boolean)

    Allows a failed response without raising.



28
29
30
31
32
# File 'lib/active_shipping/shipping_response.rb', line 28

def initialize(success, message, params = {}, options = {})
  @shipping_id = options[:shipping_id]
  @tracking_number = options[:tracking_number]
  super
end

Instance Attribute Details

#shipping_idString

The unique identifier of the shipment, which can be used to further interact with the carrier's API.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_shipping/shipping_response.rb', line 17

class ShippingResponse < Response
  attr_reader :shipping_id, :tracking_number

  # Initializes a new ShippingResponse instance.
  #
  # @param success (see ActiveShipping::Response#initialize)
  # @param message (see ActiveShipping::Response#initialize)
  # @param params (see ActiveShipping::Response#initialize)
  # @option options (see ActiveShipping::Response#initialize)
  # @option options [String] :shipping_id Populates {#shipping_id}.
  # @option options [String] :tracking_number Populates {#tracking_number}.
  def initialize(success, message, params = {}, options = {})
    @shipping_id = options[:shipping_id]
    @tracking_number = options[:tracking_number]
    super
  end
end

#tracking_numberString

The tracking number of the shipments, which can be shared with the customer and be used for Carrier#find_tracking_info.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_shipping/shipping_response.rb', line 17

class ShippingResponse < Response
  attr_reader :shipping_id, :tracking_number

  # Initializes a new ShippingResponse instance.
  #
  # @param success (see ActiveShipping::Response#initialize)
  # @param message (see ActiveShipping::Response#initialize)
  # @param params (see ActiveShipping::Response#initialize)
  # @option options (see ActiveShipping::Response#initialize)
  # @option options [String] :shipping_id Populates {#shipping_id}.
  # @option options [String] :tracking_number Populates {#tracking_number}.
  def initialize(success, message, params = {}, options = {})
    @shipping_id = options[:shipping_id]
    @tracking_number = options[:tracking_number]
    super
  end
end