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.



11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11880

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.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def carrier
  @carrier
end

#delivery_estimateObject (readonly)

Returns the value of attribute delivery_estimate.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def delivery_estimate
  @delivery_estimate
end

#descriptionObject (readonly)

Returns the value of attribute description.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def description
  @description
end

#statusObject (readonly)

Returns the value of attribute status.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def timestamp
  @timestamp
end

#tracking_idObject (readonly)

Returns the value of attribute tracking_id.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def tracking_id
  @tracking_id
end

#tracking_numberObject (readonly)

Returns the value of attribute tracking_number.



11878
11879
11880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11878

def tracking_number
  @tracking_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11896
11897
11898
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11896

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

#to_hashObject



11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11900

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



11892
11893
11894
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11892

def to_json
  JSON.dump(to_hash)
end