Sha256: 7432fb446ca75d2918cf43174f2d761a0e316398a48a9addfa108faed32840f3

Contents?: true

Size: 887 Bytes

Versions: 4

Compression:

Stored size: 887 Bytes

Contents

require 'learn_web/client/lesson/current_lesson'
require 'learn_web/client/lesson/next_lesson'

module LearnWeb
  class Client
    module Lesson
      def current_lesson_endpoint
        "#{API_ROOT}/users/current_lesson"
      end

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

      def current_lesson
        response = @conn.get do |req|
          req.url current_lesson_endpoint
          req.headers['Authorization'] = "Bearer #{token}"
        end

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

      def next_lesson
        response = @conn.get do |req|
          req.url next_lesson_endpoint
          req.headers['Authorization'] = "Bearer #{token}"
          req.params['dir_name'] = File.basename(FileUtils.pwd)
        end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
learn-web-1.0.5 lib/learn_web/client/lesson.rb
learn-web-1.0.4 lib/learn_web/client/lesson.rb
learn-web-1.0.3 lib/learn_web/client/lesson.rb
learn-web-1.0.2 lib/learn_web/client/lesson.rb