Class: LessonlyApi::Lessons

Inherits:
Request show all
Defined in:
lib/lessonly_api/lessons.rb

Class Method Summary collapse

Methods inherited from Request

client

Methods inherited from ResourceType::Base

#attributes, dump, fields, from_json, #initialize, load

Constructor Details

This class inherits a constructor from LessonlyApi::ResourceType::Base

Class Method Details

.archive(id) ⇒ ResourceType::Lesson

Parameters:

  • id (Integer)

    ID of a lesson to archive

Returns:



39
40
41
42
# File 'lib/lessonly_api/lessons.rb', line 39

def archive(id)
  raw_result = send_put("/lessons/#{id}/archive")
  ResourceType::Lesson.new(raw_result)
end

.assign_lesson(id, assignments = []) ⇒ ResourceType::Assignments

Allow to make assignments to a particular lesson in the API docs.lessonly.com/#assign-lesson

Parameters:

  • id (Integer)

    ID of a lesson

  • assignments (Array) (defaults to: [])

    array with assignments’ attributes to create

Returns:



82
83
84
85
# File 'lib/lessonly_api/lessons.rb', line 82

def assign_lesson(id, assignments = [])
  raw_result = send_post("/lessons/#{id}/assignments", assignments: assignments)
  ResourceType::Assignments.new(raw_result)
end

.lesson_assignments(id, page: 1, per_page: 50) ⇒ ResourceType::LessonAssignment

Retrieve all the assignments for a particular lesson docs.lessonly.com/#lesson-assignments

Parameters:

  • id (Integer)

    ID of a lesson

  • page (Integer) (defaults to: 1)

    the number of the page

  • per_page (Integer) (defaults to: 50)

    the numer of records per page

Returns:

  • (ResourceType::LessonAssignment)

    the response converted to a resource object



61
62
63
64
# File 'lib/lessonly_api/lessons.rb', line 61

def lesson_assignments(id, page: 1, per_page: 50)
  raw_result = send_get("/lessons/#{id}/assignments", page: page, per_page: per_page)
  ResourceType::Assignments.new(raw_result)
end

.lesson_completed_assignments(id) ⇒ ResourceType::LessonAssignmentsCompleted

Retrieves the number of completed assignments for a given lesson docs.lessonly.com/#lesson-completed-assignments-v1-1

Parameters:

  • id (Integer)

    ID of a lesson

Returns:



71
72
73
74
# File 'lib/lessonly_api/lessons.rb', line 71

def lesson_completed_assignments(id)
  raw_result = send_get("/lessons/#{id}/assignments/completed")
  ResourceType::LessonAssignmentsCompleted.new(raw_result)
end

.listResourceType::Lessons

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

Returns:



8
9
10
11
# File 'lib/lessonly_api/lessons.rb', line 8

def list
  raw_result = send_get('/lessons')
  ResourceType::Lessons.new(raw_result)
end

.restore(id) ⇒ ResourceType::Lesson

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

Parameters:

  • id (Integer)

    ID of a lesson to restore

Returns:



49
50
51
52
# File 'lib/lessonly_api/lessons.rb', line 49

def restore(id)
  raw_result = send_put("/lessons/#{id}/restore")
  ResourceType::Lesson.new(raw_result)
end

.show(id) ⇒ ResourceType::Lesson

Retrieve the lesson’s information docs.lessonly.com/#show-lesson-details

Parameters:

  • id (Integer)

    ID of the group

Returns:



18
19
20
21
# File 'lib/lessonly_api/lessons.rb', line 18

def show(id)
  raw_result = send_get("/lessons/#{id}")
  ResourceType::Lesson.new(raw_result)
end

.update(id, attributes = {}) ⇒ ResourceType::Lesson

Parameters:

  • id (Integer)

    ID of a lesson to update

  • attributes (Hash) (defaults to: {})

    hash with lesson’s attributes to update

Returns:



29
30
31
32
# File 'lib/lessonly_api/lessons.rb', line 29

def update(id, attributes = {})
  raw_result = send_put("/lessons/#{id}", attributes)
  ResourceType::Lesson.new(raw_result)
end