Class: Chell::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/chell/client.rb

Constant Summary collapse

FORMATS =
{
  json: "application/json",
  gzip: "application/x-gzip"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# File 'lib/chell/client.rb', line 11

def initialize(options = {})
  @access_key = options.fetch(:access_key)
  @secret_key = options.fetch(:secret_key)
  @url = options.fetch(:url)
end

Instance Method Details

#course(id) ⇒ Object



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

def course(id)
  path = "/courses/#{id}"
  headers = { accept: FORMATS[:json] }

  response = resource[path].get(headers)
  parse_json(response.body)
end

#course_content(id, version_id) ⇒ Object



29
30
31
32
33
34
# File 'lib/chell/client.rb', line 29

def course_content(id, version_id)
  path = "/courses/#{id}/versions/#{version_id}"
  headers = { accept: FORMATS[:gzip] }

  resource[path].get(headers).body
end

#coursesObject



17
18
19
# File 'lib/chell/client.rb', line 17

def courses
  parse_json(resource["/courses"].get.body)
end