Class: AbsorbApi::User

Inherits:
Base
  • Object
show all
Includes:
Relations
Defined in:
lib/absorb_api/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from AbsorbApi::Base

Instance Attribute Details

#active_statusObject

Returns the value of attribute active_status.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def active_status
  @active_status
end

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def address
  @address
end

#address2Object

Returns the value of attribute address2.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def address2
  @address2
end

#cc_email_addressesObject

Returns the value of attribute cc_email_addresses.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def cc_email_addresses
  @cc_email_addresses
end

#cityObject

Returns the value of attribute city.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def city
  @city
end

#country_idObject

Returns the value of attribute country_id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def country_id
  @country_id
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def custom_fields
  @custom_fields
end

#date_hiredObject

Returns the value of attribute date_hired.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def date_hired
  @date_hired
end

#date_terminatedObject

Returns the value of attribute date_terminated.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def date_terminated
  @date_terminated
end

#decimal1Object

Returns the value of attribute decimal1.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def decimal1
  @decimal1
end

#decimal2Object

Returns the value of attribute decimal2.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def decimal2
  @decimal2
end

#decimal3Object

Returns the value of attribute decimal3.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def decimal3
  @decimal3
end

#department_idObject

Returns the value of attribute department_id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def department_id
  @department_id
end

#email_addressObject

Returns the value of attribute email_address.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def email_address
  @email_address
end

#employee_numberObject

Returns the value of attribute employee_number.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def employee_number
  @employee_number
end

#external_idObject

Returns the value of attribute external_id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def external_id
  @external_id
end

#first_nameObject

Returns the value of attribute first_name.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def first_name
  @first_name
end

#genderObject

Returns the value of attribute gender.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def gender
  @gender
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def id
  @id
end

#is_adminObject

Returns the value of attribute is_admin.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def is_admin
  @is_admin
end

#is_instructorObject

Returns the value of attribute is_instructor.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def is_instructor
  @is_instructor
end

#is_learnerObject

Returns the value of attribute is_learner.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def is_learner
  @is_learner
end

#job_titleObject

Returns the value of attribute job_title.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def job_title
  @job_title
end

#language_idObject

Returns the value of attribute language_id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def language_id
  @language_id
end

#last_nameObject

Returns the value of attribute last_name.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def last_name
  @last_name
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def location
  @location
end

#middle_nameObject

Returns the value of attribute middle_name.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def middle_name
  @middle_name
end

#notesObject

Returns the value of attribute notes.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def notes
  @notes
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def password
  @password
end

#phoneObject

Returns the value of attribute phone.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def phone
  @phone
end

#postal_codeObject

Returns the value of attribute postal_code.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def postal_code
  @postal_code
end

#province_idObject

Returns the value of attribute province_id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def province_id
  @province_id
end

#reference_numberObject

Returns the value of attribute reference_number.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def reference_number
  @reference_number
end

#role_idsObject

Returns the value of attribute role_ids.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def role_ids
  @role_ids
end

#string1Object

Returns the value of attribute string1.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def string1
  @string1
end

#string2Object

Returns the value of attribute string2.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def string2
  @string2
end

#supervisor_idObject

Returns the value of attribute supervisor_id.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def supervisor_id
  @supervisor_id
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/absorb_api/user.rb', line 5

def username
  @username
end

Class Method Details

.courses_from_collection(users) ⇒ Object

gets all associated courses given a collection of users all calls are called in parallel users are chunked in groups of 105 to keep typhoeus from bogging down



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/absorb_api/user.rb', line 34

def self.courses_from_collection(users)
  courses = []
  users.each_slice(105) do |user_slice|
    AbsorbApi.api.in_parallel do
      user_slice.each do |user|
        courses << AbsorbApi.api.get("users/#{user.id}/courses")
      end
    end
  end
  courses.map { |response| response.body.map { |body| Course.new(body) } }.flatten
end

Instance Method Details

#update(attrs) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
29
# File 'lib/absorb_api/user.rb', line 20

def update(attrs)
  attrs.keys.each { |k| attrs[k.to_s.camelize] = attrs.delete(k) }
  attrs['Username'] = username

  response = AbsorbApi.api.put("users/#{id}", attrs)
  raise ValidationError if response.status == 500
  raise RouteNotFound if response.status == 405

  self
end