Sha256: e1350f8ea19b9f3ba62a812d3daada0cd64c5ad06e870ff334445dd21862eda4

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module AbsorbApi
  class User < Base
    include Orm
    include Relations

    attr_accessor :id, :department_id, :first_name, :middle_name, :last_name, :username, :password, :email_address, :cc_email_addresses, :language_id, :gender, :address, :address2, :city, :province_id, :country_id, :postal_code, :phone, :employee_number, :location, :job_title, :reference_number, :date_hired, :date_terminated, :notes, :custom_fields, :role_ids, :active_status, :is_learner, :is_admin, :is_instructor, :external_id, :supervisor_id

    has_many :courses
    has_many :enrollments, klass: :course_enrollment
    has_many :certificates

    # 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 getting bogged down
    def self.courses_from_collection(users)
      courses = []
      users.each_slice(105) do |user_slice|
        api.in_parallel do
          user_slice.each do |user|
            courses << api.get("users/#{user.id}/courses")
          end
        end
      end
      courses.map { |response| response.body.map { |body| Course.new(body) } }.flatten
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
absorb_api-0.1.2 lib/absorb_api/user.rb
absorb_api-0.1.1 lib/absorb_api/user.rb
absorb_api-0.1.0 lib/absorb_api/user.rb