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.



19382
19383
19384
19385
19386
19387
19388
19389
19390
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19382

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))
  @status = (x = (x = opts.delete(:status); x.nil? ? "active" : x); x.is_a?(::Io::Flow::V0::Models::UserStatus) ? x : ::Io::Flow::V0::Models::UserStatus.apply(x))
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



19380
19381
19382
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19380

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



19380
19381
19382
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19380

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



19380
19381
19382
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19380

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



19380
19381
19382
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19380

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19396
19397
19398
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19396

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

#subtype_to_hashObject



19400
19401
19402
19403
19404
19405
19406
19407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19400

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

#to_jsonObject



19392
19393
19394
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19392

def to_json
  JSON.dump(to_hash)
end