Class: Io::Flow::V0::Models::TokenVersion

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



14565
14566
14567
14568
14569
14570
14571
14572
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14565

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14563
14564
14565
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14563

def id
  @id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



14563
14564
14565
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14563

def timestamp
  @timestamp
end

#tokenObject (readonly)

Returns the value of attribute token.



14563
14564
14565
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14563

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type.



14563
14564
14565
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14563

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14578
14579
14580
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14578

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

#to_hashObject



14582
14583
14584
14585
14586
14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14582

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

#to_jsonObject



14574
14575
14576
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14574

def to_json
  JSON.dump(to_hash)
end