Class: DesignHuddle::User

Inherits:
Object
  • Object
show all
Defined in:
lib/design_huddle/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ User

Returns a new instance of User.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/design_huddle/user.rb', line 6

def initialize(user)
  @user_id = user["user_id"]
  @account_user_id = user["account_user_id"]
  @user_code = user["user_code"]
  @test = user["test"]
  @email_address = user["email_address"]
  @first_name = user["first_name"]
  @last_name = user["last_name"]
  @user_properties = user["user_properties"]
  @date_created = user["date_created"]
  @date_updated = user["date_updated"]
  @last_activity = user["last_activity"]
  @project_count = user["project_count"]
  @account = user["account"]
  @user_roles = user["user_roles"]
  @user_status = user["user_status"]
  @user_type = user["user_type"]
  self
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def 
  @account
end

#account_user_idObject

Returns the value of attribute account_user_id.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def 
  @account_user_id
end

#date_createdObject

Returns the value of attribute date_created.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def date_created
  @date_created
end

#date_updatedObject

Returns the value of attribute date_updated.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def date_updated
  @date_updated
end

#email_addressObject

Returns the value of attribute email_address.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def email_address
  @email_address
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def first_name
  @first_name
end

#last_activityObject

Returns the value of attribute last_activity.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def last_activity
  @last_activity
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def last_name
  @last_name
end

#project_countObject

Returns the value of attribute project_count.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def project_count
  @project_count
end

#testObject

Returns the value of attribute test.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def test
  @test
end

#user_codeObject

Returns the value of attribute user_code.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def user_code
  @user_code
end

#user_idObject

Returns the value of attribute user_id.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def user_id
  @user_id
end

#user_propertiesObject

Returns the value of attribute user_properties.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def user_properties
  @user_properties
end

#user_rolesObject

Returns the value of attribute user_roles.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def user_roles
  @user_roles
end

#user_statusObject

Returns the value of attribute user_status.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def user_status
  @user_status
end

#user_typeObject

Returns the value of attribute user_type.



3
4
5
# File 'lib/design_huddle/user.rb', line 3

def user_type
  @user_type
end

Class Method Details

.create(**args) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/design_huddle/user.rb', line 30

def self.create(**args)
  DesignHuddle.client.call(
    method: :post,
    path: "/partners/api/account/users",
    payload: args.to_json
  )
end

.fetch(user_id) ⇒ Object



46
47
48
# File 'lib/design_huddle/user.rb', line 46

def self.fetch(user_id)
  DesignHuddle.client.call(path: "/partners/api/account/users/#{user_id}")["data"]
end

.listObject



38
39
40
# File 'lib/design_huddle/user.rb', line 38

def self.list
  DesignHuddle.client.call(path: "/partners/api/account/users")["data"]["items"].map { |user| User.new(user) }
end

.retrieve(user_id) ⇒ Object



42
43
44
# File 'lib/design_huddle/user.rb', line 42

def self.retrieve(user_id)
  User.new(User.fetch(user_id))
end

Instance Method Details

#reloadObject



26
27
28
# File 'lib/design_huddle/user.rb', line 26

def reload
  initialize(User.fetch(user_id))
end