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

Attributes inherited from ExpandableUser

#discriminator

Instance Method Summary collapse

Methods inherited from ExpandableUser

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ User

Returns a new instance of User.



22511
22512
22513
22514
22515
22516
22517
22518
22519
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22511

def initialize(incoming={})
  super(:discriminator => 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

#email ⇒ Object (readonly)

Returns the value of attribute email.



22509
22510
22511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22509

def email
  @email
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



22509
22510
22511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22509

def id
  @id
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



22509
22510
22511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22509

def name
  @name
end

#status ⇒ Object (readonly)

Returns the value of attribute status.



22509
22510
22511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22509

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22525
22526
22527
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22525

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

#subtype_to_hash ⇒ Object



22529
22530
22531
22532
22533
22534
22535
22536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22529

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

#to_json ⇒ Object



22521
22522
22523
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22521

def to_json
  JSON.dump(to_hash)
end