Class: Io::Flow::V0::Models::LabelVersion

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

Returns a new instance of LabelVersion.



10708
10709
10710
10711
10712
10713
10714
10715
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10708

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



10706
10707
10708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10706

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



10706
10707
10708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10706

def label
  @label
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



10706
10707
10708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10706

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



10706
10707
10708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10706

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10721
10722
10723
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10721

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

#to_hashObject



10725
10726
10727
10728
10729
10730
10731
10732
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10725

def to_hash
  {
    :id => id,
    :timestamp => timestamp,
    :type => type.value,
    :label => label.to_hash
  }
end

#to_jsonObject



10717
10718
10719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10717

def to_json
  JSON.dump(to_hash)
end