Class: Io::Flow::V0::Models::LabelEvent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ LabelEvent

Returns a new instance of LabelEvent.



11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11747

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :label, :address, :status, :timestamp], 'LabelEvent')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @label = (x = opts.delete(:label); x.is_a?(::Io::Flow::V0::Models::LabelSummary) ? x : ::Io::Flow::V0::Models::LabelSummary.new(x))
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x))
  @timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime)
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



11745
11746
11747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11745

def address
  @address
end

#descriptionObject (readonly)

Returns the value of attribute description.



11745
11746
11747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11745

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



11745
11746
11747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11745

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



11745
11746
11747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11745

def label
  @label
end

#statusObject (readonly)

Returns the value of attribute status.



11745
11746
11747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11745

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



11745
11746
11747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11745

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11762
11763
11764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11762

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

#to_hashObject



11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11766

def to_hash
  {
    :id => id,
    :label => label.to_hash,
    :address => address.to_hash,
    :status => status.value,
    :timestamp => timestamp,
    :description => description
  }
end

#to_jsonObject



11758
11759
11760
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11758

def to_json
  JSON.dump(to_hash)
end