Class: Bookboon::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

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_requestObject

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

#categoriesObject



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