Class: Chell::Client
- Inherits:
-
Object
- Object
- Chell::Client
- Defined in:
- lib/chell/client.rb
Constant Summary collapse
- FORMATS =
{ json: "application/json", gzip: "application/x-gzip" }.freeze
Instance Method Summary collapse
- #course(id) ⇒ Object
- #course_content(id, version_id) ⇒ Object
- #courses ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
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( = {}) @access_key = .fetch(:access_key) @secret_key = .fetch(:secret_key) @url = .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 |
#courses ⇒ Object
17 18 19 |
# File 'lib/chell/client.rb', line 17 def courses parse_json(resource["/courses"].get.body) end |