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.



71564
71565
71566
71567
71568
71569
71570
71571
71572
71573
71574
71575
71576
71577
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71564

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)
  @service_id = (x = opts.delete(:service_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('service_id', x, 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))
  @cost = (x = opts.delete(:cost); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)))
  @ratecard_owner = (x = opts.delete(:ratecard_owner); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x)))
end

Instance Attribute Details

#carrierObject (readonly)

Returns the value of attribute carrier.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def carrier
  @carrier
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def carrier_tracking_number
  @carrier_tracking_number
end

#costObject (readonly)

Returns the value of attribute cost.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def cost
  @cost
end

#delivery_estimateObject (readonly)

Returns the value of attribute delivery_estimate.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def delivery_estimate
  @delivery_estimate
end

#descriptionObject (readonly)

Returns the value of attribute description.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def description
  @description
end

#ratecard_ownerObject (readonly)

Returns the value of attribute ratecard_owner.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def ratecard_owner
  @ratecard_owner
end

#service_idObject (readonly)

Returns the value of attribute service_id.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def service_id
  @service_id
end

#statusObject (readonly)

Returns the value of attribute status.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def timestamp
  @timestamp
end

#tracking_idObject (readonly)

Returns the value of attribute tracking_id.



71562
71563
71564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71562

def tracking_id
  @tracking_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



71583
71584
71585
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71583

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

#to_hashObject



71587
71588
71589
71590
71591
71592
71593
71594
71595
71596
71597
71598
71599
71600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71587

def to_hash
  {
    :tracking_id => tracking_id,
    :status => status.value,
    :carrier => carrier,
    :service_id => service_id,
    :carrier_tracking_number => carrier_tracking_number,
    :delivery_estimate => delivery_estimate,
    :description => description,
    :timestamp => timestamp,
    :cost => cost.nil? ? nil : cost.to_hash,
    :ratecard_owner => ratecard_owner.nil? ? nil : ratecard_owner.value
  }
end

#to_jsonObject



71579
71580
71581
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71579

def to_json
  JSON.dump(to_hash)
end