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

Returns a new instance of TokenVersion.



16395
16396
16397
16398
16399
16400
16401
16402
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16395

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.



16393
16394
16395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16393

def id
  @id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



16393
16394
16395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16393

def timestamp
  @timestamp
end

#tokenObject (readonly)

Returns the value of attribute token.



16393
16394
16395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16393

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type.



16393
16394
16395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16393

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16408
16409
16410
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16408

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

#to_hashObject



16412
16413
16414
16415
16416
16417
16418
16419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16412

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

#to_jsonObject



16404
16405
16406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16404

def to_json
  JSON.dump(to_hash)
end