Class: Bookboon::Client
- Inherits:
-
Object
- Object
- Bookboon::Client
- Defined in:
- lib/bookboon/client.rb
Instance Attribute Summary collapse
-
#last_request ⇒ Object
Returns the value of attribute last_request.
Instance Method Summary collapse
- #book(id) ⇒ Object
- #categories ⇒ Object
- #category(id) ⇒ Object
- #download_book(id, handle) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #search(term) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 |
# File 'lib/bookboon/client.rb', line 5 def initialize if block_given? yield(config) end end |
Instance Attribute Details
#last_request ⇒ Object
Returns the value of attribute last_request.
3 4 5 |
# File 'lib/bookboon/client.rb', line 3 def last_request @last_request end |
Instance Method Details
#book(id) ⇒ Object
23 24 25 |
# File 'lib/bookboon/client.rb', line 23 def book(id) get("books/#{id}") end |
#categories ⇒ Object
11 12 13 |
# File 'lib/bookboon/client.rb', line 11 def categories get("categories") end |
#category(id) ⇒ Object
15 16 17 |
# File 'lib/bookboon/client.rb', line 15 def category(id) get("categories/#{id}") end |
#download_book(id, handle) ⇒ Object
27 28 29 30 31 |
# File 'lib/bookboon/client.rb', line 27 def download_book(id, handle) post("books/#{id}/download", body: { handle: handle }) @last_request.headers['location'] end |
#search(term) ⇒ Object
19 20 21 |
# File 'lib/bookboon/client.rb', line 19 def search(term) get("search", query: { q: term }) end |