Class: RestBooks::Categories

Inherits:
Object
  • Object
show all
Includes:
Api
Defined in:
lib/restbooks/categories.rb

Constant Summary

Constants included from Api

Api::AUTHOR_PARAMETERS, Api::BOOK_PARAMETERS, Api::LIST_PARAMETERS, Api::ORDERED_AUTHOR_PARAMETERS, Api::ORDERED_BOOK_PARAMETERS, Api::RANGED_AUTHOR_PARAMETERS, Api::RANGED_BOOK_PARAMETERS

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object

Endpoint: /types

Formats: Atom
Description: View the categories, use pagination
Parameters:
  * order: normally based on the number of favorites, use comments to order them by most discussed lists


33
34
35
36
# File 'lib/restbooks/categories.rb', line 33

def all( options={} )
  create_url( "/types", options, LIST_PARAMETERS )
  return do_request( :category )
end

#books(category_id, options = {}) ⇒ Object

Endpoint: /type/:id/books

Formats: Atom
Description: List all books from given category, use pagination


41
42
43
44
45
# File 'lib/restbooks/categories.rb', line 41

def books( category_id, options={} )
  category_id = category_id.id if category_id.kind_of? RestBooks::Models::Category
  create_url( "/type/#{category_id}/books", options, ORDERED_BOOK_PARAMETERS )
  return do_request( :book )
end

#recent_books(category_id, options = {}) ⇒ Object

Endpoint: /type/:id/books/recent

Formats: Atom, RSS
Description: List recent books for a category (id)
Parameters: Same as /books/recent


61
62
63
64
65
# File 'lib/restbooks/categories.rb', line 61

def recent_books( category_id, options={} )
  category_id = category_id.id if category_id.kind_of? RestBooks::Models::Category
  fcreate_url( "/type/#{category_id}/books/recent", options, BOOK_PARAMETERS )
  return do_request( :book )
end

#top_books(category_id, options = {}) ⇒ Object

Endpoint: /type/:id/books/top

Formats: Atom
Description: List top books for a category (id)
Parameters: Same as /books/top


51
52
53
54
55
# File 'lib/restbooks/categories.rb', line 51

def top_books( category_id, options={} )
  category_id = category_id.id if category_id.kind_of? RestBooks::Models::Category
  create_url( "/type/#{category_id}/books/top", options, RANGED_BOOK_PARAMETERS )
  return do_request( :book )
end