Class: Io::Flow::V0::Models::TrackingForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Top level tracking information which contains labels. In cases where shipments are re-labeled, you will see multiple labels for each tracking allowing simple access to see where a shipment is - with which carrier and with the local tracking number

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TrackingForm

Returns a new instance of TrackingForm.



40067
40068
40069
40070
40071
40072
40073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40067

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @status = (x = opts.delete(:status); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x)))
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
  @window = (x = opts.delete(:window); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DatetimeRange) ? x : ::Io::Flow::V0::Models::DatetimeRange.new(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



40065
40066
40067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40065

def attributes
  @attributes
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



40065
40066
40067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40065

def order_number
  @order_number
end

#statusObject (readonly)

Returns the value of attribute status.



40065
40066
40067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40065

def status
  @status
end

#windowObject (readonly)

Returns the value of attribute window.



40065
40066
40067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40065

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40079
40080
40081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40079

def copy(incoming={})
  TrackingForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



40083
40084
40085
40086
40087
40088
40089
40090
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40083

def to_hash
  {
    :status => status.nil? ? nil : status.value,
    :order_number => order_number,
    :attributes => attributes.nil? ? nil : attributes,
    :window => window.nil? ? nil : window.to_hash
  }
end

#to_jsonObject



40075
40076
40077
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40075

def to_json
  JSON.dump(to_hash)
end