Class: ReactiveShipping::ShippingResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/reactive_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.

Parameters:

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

    a customizable set of options

  • 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 (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/reactive_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.

Returns:

  • (String)


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

class ShippingResponse < Response
  attr_reader :shipping_id, :tracking_number

  # Initializes a new ShippingResponse instance.
  #
  # @param success (see ReactiveShipping::Response#initialize)
  # @param message (see ReactiveShipping::Response#initialize)
  # @param params (see ReactiveShipping::Response#initialize)
  # @option options (see ReactiveShipping::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.

Returns:

  • (String)


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

class ShippingResponse < Response
  attr_reader :shipping_id, :tracking_number

  # Initializes a new ShippingResponse instance.
  #
  # @param success (see ReactiveShipping::Response#initialize)
  # @param message (see ReactiveShipping::Response#initialize)
  # @param params (see ReactiveShipping::Response#initialize)
  # @option options (see ReactiveShipping::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