Class: Io::Flow::V0::Models::CenterVersion

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

Returns a new instance of CenterVersion.



11139
11140
11141
11142
11143
11144
11145
11146
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11139

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :timestamp, :type, :center], 'CenterVersion')
  @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))
  @center = (x = opts.delete(:center); x.is_a?(::Io::Flow::V0::Models::Center) ? x : ::Io::Flow::V0::Models::Center.new(x))
end

Instance Attribute Details

#center ⇒ Object (readonly)

Returns the value of attribute center.



11137
11138
11139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11137

def center
  @center
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



11137
11138
11139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11137

def id
  @id
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp.



11137
11138
11139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11137

def timestamp
  @timestamp
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



11137
11138
11139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11137

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11152
11153
11154
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11152

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

#to_hash ⇒ Object



11156
11157
11158
11159
11160
11161
11162
11163
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11156

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

#to_json ⇒ Object



11148
11149
11150
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11148

def to_json
  JSON.dump(to_hash)
end