Module: OneApiSdk::Client::Books

Included in:
OneApiSdk::Client
Defined in:
lib/one_api_sdk/books.rb

Instance Method Summary collapse

Instance Method Details

#book(id, query_params = "") ⇒ Hash

Request one specific book

Parameters:

  • id (String)

    the unique id of the book

  • query_params (String) (defaults to: "")

    the query parameters you want to include in your search IE: “?sort=name:asc”

Returns:

  • (Hash)

    The returned book object



23
24
25
26
# File 'lib/one_api_sdk/books.rb', line 23

def book(id,query_params="")
  response = call_with_token("#{Constants::BOOK_BASE_PATH}/#{id}#{query_params}")
  JSON.parse(response.body)
end

#book_chapters(id, query_params = "") ⇒ Hash

Request one specific book

Parameters:

  • id (String)

    the unique id of the book

  • query_params (String) (defaults to: "")

    the query parameters you want to include in your search IE: “?sort=name:desc”

Returns:

  • (Hash)

    The returned book object



33
34
35
36
# File 'lib/one_api_sdk/books.rb', line 33

def book_chapters(id,query_params="")
  response = call_with_token("#{Constants::BOOK_BASE_PATH}/#{id}/chapter#{query_params}")
  JSON.parse(response.body)
end

#books(query_params = "") ⇒ Array<Hash>

List of all “The Lord of the Rings” books

Parameters:

  • query_params (String) (defaults to: "")

    the query parameters you want to include in your search IE: “?name=The Two Towers”

Returns:

  • (Array<Hash>)

    An array of books



13
14
15
16
# File 'lib/one_api_sdk/books.rb', line 13

def books(query_params="")
  response = call_with_token("#{Constants::BOOK_BASE_PATH}#{query_params}")
  JSON.parse(response.body)
end