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.



10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10503

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.



10501
10502
10503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10501

def address
  @address
end

#descriptionObject (readonly)

Returns the value of attribute description.



10501
10502
10503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10501

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



10501
10502
10503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10501

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



10501
10502
10503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10501

def label
  @label
end

#statusObject (readonly)

Returns the value of attribute status.



10501
10502
10503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10501

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



10501
10502
10503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10501

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10518
10519
10520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10518

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

#to_hashObject



10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10522

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

#to_jsonObject



10514
10515
10516
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10514

def to_json
  JSON.dump(to_hash)
end