Class: Io::Flow::V0::Models::TrackingLabelForm

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

Overview

Represents a specific label being tracked as part of the tracking bucket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TrackingLabelForm

Returns a new instance of TrackingLabelForm.



54734
54735
54736
54737
54738
54739
54740
54741
54742
54743
54744
54745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54734

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:tracking_id, :carrier, :carrier_tracking_number], 'TrackingLabelForm')
  @tracking_id = HttpClient::Preconditions.assert_class('tracking_id', opts.delete(:tracking_id), String)
  @status = (x = (x = opts.delete(:status); x.nil? ? "pending" : x); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x))
  @carrier = HttpClient::Preconditions.assert_class('carrier', opts.delete(:carrier), String)
  @carrier_tracking_number = HttpClient::Preconditions.assert_class('carrier_tracking_number', opts.delete(:carrier_tracking_number), String)
  @delivery_estimate = (x = opts.delete(:delivery_estimate); x.nil? ? nil : HttpClient::Preconditions.assert_class('delivery_estimate', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
  @timestamp = (x = opts.delete(:timestamp); x.nil? ? nil : HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @parent_id = (x = opts.delete(:parent_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('parent_id', x, String))
end

Instance Attribute Details

#carrierObject (readonly)

Returns the value of attribute carrier.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def carrier
  @carrier
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def carrier_tracking_number
  @carrier_tracking_number
end

#delivery_estimateObject (readonly)

Returns the value of attribute delivery_estimate.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def delivery_estimate
  @delivery_estimate
end

#descriptionObject (readonly)

Returns the value of attribute description.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def description
  @description
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def parent_id
  @parent_id
end

#statusObject (readonly)

Returns the value of attribute status.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def timestamp
  @timestamp
end

#tracking_idObject (readonly)

Returns the value of attribute tracking_id.



54732
54733
54734
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54732

def tracking_id
  @tracking_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



54751
54752
54753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54751

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

#to_hashObject



54755
54756
54757
54758
54759
54760
54761
54762
54763
54764
54765
54766
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54755

def to_hash
  {
    :tracking_id => tracking_id,
    :status => status.value,
    :carrier => carrier,
    :carrier_tracking_number => carrier_tracking_number,
    :delivery_estimate => delivery_estimate,
    :description => description,
    :timestamp => timestamp,
    :parent_id => parent_id
  }
end

#to_jsonObject



54747
54748
54749
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54747

def to_json
  JSON.dump(to_hash)
end