Class: Io::Flow::V0::Models::LabelForm

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 = {}) ⇒ LabelForm

Returns a new instance of LabelForm.



10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10636

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:tracking_id, :carrier, :tracking_number], 'LabelForm')
  @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)
  @tracking_number = HttpClient::Preconditions.assert_class('tracking_number', opts.delete(: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))
end

Instance Attribute Details

#carrierObject (readonly)

Returns the value of attribute carrier.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def carrier
  @carrier
end

#delivery_estimateObject (readonly)

Returns the value of attribute delivery_estimate.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def delivery_estimate
  @delivery_estimate
end

#descriptionObject (readonly)

Returns the value of attribute description.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def description
  @description
end

#statusObject (readonly)

Returns the value of attribute status.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def timestamp
  @timestamp
end

#tracking_idObject (readonly)

Returns the value of attribute tracking_id.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def tracking_id
  @tracking_id
end

#tracking_numberObject (readonly)

Returns the value of attribute tracking_number.



10634
10635
10636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10634

def tracking_number
  @tracking_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10652
10653
10654
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10652

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

#to_hashObject



10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10656

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

#to_jsonObject



10648
10649
10650
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10648

def to_json
  JSON.dump(to_hash)
end