Module: LearnWeb::Client::Lesson

Included in:
LearnWeb::Client
Defined in:
lib/learn_web/client/lesson.rb,
lib/learn_web/client/lesson/next_lesson.rb,
lib/learn_web/client/lesson/current_lesson.rb,
lib/learn_web/client/lesson/current_status.rb

Defined Under Namespace

Classes: CurrentLesson, CurrentStatus, NextLesson

Instance Method Summary collapse

Instance Method Details

#current_lessonObject



20
21
22
23
24
25
26
27
# File 'lib/learn_web/client/lesson.rb', line 20

def current_lesson
  response = get(
    current_lesson_endpoint,
    headers: { 'Authorization' => "Bearer #{token}" }
  )

  LearnWeb::Client::Lesson::CurrentLesson.new(response)
end

#current_lesson_endpointObject



8
9
10
# File 'lib/learn_web/client/lesson.rb', line 8

def current_lesson_endpoint
  "#{API_ROOT}/users/current_lesson"
end

#current_statusObject



39
40
41
42
43
44
45
46
# File 'lib/learn_web/client/lesson.rb', line 39

def current_status
  response = get(
    current_status_endpoint,
    headers: { 'Authorization' => "Bearer #{token}" }
  )

  LearnWeb::Client::Lesson::CurrentStatus.new(response)
end

#current_status_endpointObject



16
17
18
# File 'lib/learn_web/client/lesson.rb', line 16

def current_status_endpoint
  "#{API_ROOT}/users/current_lesson/status"
end

#next_lessonObject



29
30
31
32
33
34
35
36
37
# File 'lib/learn_web/client/lesson.rb', line 29

def next_lesson
  response = get(
    next_lesson_endpoint,
    headers: { 'Authorization' => "Bearer #{token}" },
    params: { 'dir_name' => File.basename(FileUtils.pwd) }
  )

  LearnWeb::Client::Lesson::NextLesson.new(response)
end

#next_lesson_endpointObject



12
13
14
# File 'lib/learn_web/client/lesson.rb', line 12

def next_lesson_endpoint
  "#{API_ROOT}/users/next_lesson"
end