class LessonlyApi::Users

The collection of methods to fetch users' data.

Public Class Methods

archive(id) click to toggle source

Archive a user docs.lessonly.com/#archive-user

@param id [Integer] ID of a user to archive @return [ResourceType::User] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 53
def archive(id)
  raw_result = send_put("/users/#{id}/archive")
  ResourceType::User.new(raw_result)
end
create(attributes = {}) click to toggle source

Create a user docs.lessonly.com/#create-user

@param attributes [Hash] hash with user's attributes @return [ResourceType::User] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 32
def create(attributes = {})
  raw_result = send_post('/users', attributes)
  ResourceType::User.new(raw_result)
end
create_user_assignments(id, assignments = []) click to toggle source

Create assignments for a user docs.lessonly.com/#create-user-assignments

@param id [Integer] ID of a user @param assignments [Array] array with assignments' attributes to create @return [ResourceType::UserAssignments] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 118
def create_user_assignments(id, assignments = [])
  raw_result = send_post("/users/#{id}/assignments", assignments: assignments)
  ResourceType::UserAssignments.new(raw_result)
end
delete(id) click to toggle source

Delete a user docs.lessonly.com/#delete-user

@param id [Integer] ID of a user to delete @return [ResourceType::User] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 73
def delete(id)
  raw_result = send_delete("/users/#{id}")
  # TODO: there should be other type, possibly
  ResourceType::User.new(raw_result)
end
list(page: 1, per_page: 50, **filters) click to toggle source

Retrieve all users docs.lessonly.com/#list-users

@param page [Integer] the number of the page @param per_page [Integer] the numer of records per page @param filters [Hash] additional filters @return [ResourceType::Users] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 12
def list(page: 1, per_page: 50, **filters)
  raw_result = send_get('/users', page: page, per_page: per_page, filter: filters)
  ResourceType::Users.new(raw_result)
end
restore(id) click to toggle source

Restore an archived user docs.lessonly.com/#restore-user

@param id [Integer] ID of a user to restore @return [ResourceType::User] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 63
def restore(id)
  raw_result = send_put("/users/#{id}/restore")
  ResourceType::User.new(raw_result)
end
show(id) click to toggle source

Retrieve all the user's details including their custom field data docs.lessonly.com/#show-user-details

@param id [Integer] ID of the user @return [ResourceType::User] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 22
def show(id)
  raw_result = send_get("/users/#{id}")
  LessonlyApi::ResourceType::User.new(raw_result)
end
update(id, attributes = {}) click to toggle source

Update a user docs.lessonly.com/#update-user

@param id [Integer] ID of a user to update @param attributes [Hash] hash with user's attributes to update @return [ResourceType::User] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 43
def update(id, attributes = {})
  raw_result = send_put("/users/#{id}", attributes)
  ResourceType::User.new(raw_result)
end
update_user_groups(id, attributes = {}) click to toggle source

Update a user’s involvement in various groups docs.lessonly.com/#update-user-groups

@param id [Integer] ID of a user @param attributes [Hash] hash with user's groups attributes to update @return [ResourceType::UserGroup] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 96
def update_user_groups(id, attributes = {})
  raw_result = send_put("/users/#{id}/groups", attributes)
  # TODO: there should be other type, possibly
  ResourceType::UserGroup.new(raw_result)
end
user_assignments(id) click to toggle source

Return a list of assignments for a given user docs.lessonly.com/#user-assignments

@param id [Integer] ID of a user @return [ResourceType::UserAssignments] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 107
def user_assignments(id)
  raw_result = send_get("/users/#{id}/assignments")
  ResourceType::UserAssignments.new(raw_result)
end
user_groups(id) click to toggle source

Return the list of a user’s group memberships and groups they are managing docs.lessonly.com/#user-groups

@param id [Integer] ID of a user @return [ResourceType::UserGroup] the response converted to a resource object

# File lib/lessonly_api/users.rb, line 84
def user_groups(id)
  raw_result = send_get("/users/#{id}/groups")
  # TODO: there should be other type, possibly
  ResourceType::UserGroup.new(raw_result)
end