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.



14537
14538
14539
14540
14541
14542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14537

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.



14535
14536
14537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14535

def id
  @id
end

#userObject (readonly)

Returns the value of attribute user.



14535
14536
14537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14535

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14548
14549
14550
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14548

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

#to_hashObject



14552
14553
14554
14555
14556
14557
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14552

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

#to_jsonObject



14544
14545
14546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14544

def to_json
  JSON.dump(to_hash)
end