Class: Io::Flow::V0::Models::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

All of the metadata associated with a given token.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Token

Returns a new instance of Token.



17369
17370
17371
17372
17373
17374
17375
17376
17377
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17369

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :user, :partial, :created_at], 'Token')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @user = (x = opts.delete(:user); x.is_a?(::Io::Flow::V0::Models::UserReference) ? x : ::Io::Flow::V0::Models::UserReference.new(x))
  @partial = HttpClient::Preconditions.assert_class('partial', opts.delete(:partial), String)
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



17367
17368
17369
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17367

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



17367
17368
17369
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17367

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



17367
17368
17369
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17367

def id
  @id
end

#partialObject (readonly)

Returns the value of attribute partial.



17367
17368
17369
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17367

def partial
  @partial
end

#userObject (readonly)

Returns the value of attribute user.



17367
17368
17369
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17367

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17383
17384
17385
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17383

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

#to_hashObject



17387
17388
17389
17390
17391
17392
17393
17394
17395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17387

def to_hash
  {
    :id => id,
    :user => user.to_hash,
    :partial => partial,
    :created_at => created_at,
    :description => description
  }
end

#to_jsonObject



17379
17380
17381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17379

def to_json
  JSON.dump(to_hash)
end