Class: Hexlet::TeacherClient

Inherits:
BaseClient show all
Defined in:
lib/hexlet/teacher_client.rb

Instance Method Summary collapse

Methods inherited from BaseClient

#initialize, #login

Constructor Details

This class inherits a constructor from Hexlet::BaseClient

Instance Method Details

#submit(slug, file) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hexlet/teacher_client.rb', line 3

def submit(slug, file)
  url = @router.api_teacher_lessons_url
  @logger.debug url

  fd = ENV["TEST"] ? "a" : File.new(file, "rb") # FIXME

  attrs = {
    lesson: {
      slug: slug,
      "packs_attributes[]" => [
        {tarball: fd}
      ]
    }
  }

  RestClient.post url, attrs, headers do |response, request, result, &block|
    @logger.debug response
    201 == response.code
  end
end