Class: Io::Flow::V0::Models::User

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

Overview

Represents a single user in the system

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ExpandableUser

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ User

Returns a new instance of User.



16608
16609
16610
16611
16612
16613
16614
16615
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16608

def initialize(incoming={})
  super(:name => ExpandableUser::Types::USER)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :name], 'User')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @email = (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', x, String))
  @name = (x = opts.delete(:name); x.is_a?(::Io::Flow::V0::Models::Name) ? x : ::Io::Flow::V0::Models::Name.new(x))
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



16606
16607
16608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16606

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



16606
16607
16608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16606

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



16606
16607
16608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16606

def name
  @name
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16621
16622
16623
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16621

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

#subtype_to_hashObject



16625
16626
16627
16628
16629
16630
16631
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16625

def subtype_to_hash
  {
    :id => id,
    :email => email,
    :name => name.to_hash
  }
end

#to_jsonObject



16617
16618
16619
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16617

def to_json
  JSON.dump(to_hash)
end