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

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ User

Returns a new instance of User.



24048
24049
24050
24051
24052
24053
24054
24055
24056
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24048

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

#emailObject (readonly)

Returns the value of attribute email.



24046
24047
24048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24046

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



24046
24047
24048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24046

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



24046
24047
24048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24046

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



24046
24047
24048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24046

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24062
24063
24064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24062

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

#subtype_to_hashObject



24066
24067
24068
24069
24070
24071
24072
24073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24066

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

#to_jsonObject



24058
24059
24060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24058

def to_json
  JSON.dump(to_hash)
end