Class: Io::Flow::V0::Models::TokenReference

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

Overview

Summary data for a given token

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TokenReference

Returns a new instance of TokenReference.



17458
17459
17460
17461
17462
17463
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17458

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :user], 'TokenReference')
  @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))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



17456
17457
17458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17456

def id
  @id
end

#userObject (readonly)

Returns the value of attribute user.



17456
17457
17458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17456

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17469
17470
17471
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17469

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

#to_hashObject



17473
17474
17475
17476
17477
17478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17473

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

#to_jsonObject



17465
17466
17467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17465

def to_json
  JSON.dump(to_hash)
end