Class: RestBooks::Authors

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

Constant Summary

Constants included from Api

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

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object

Endpoint: /authors

Formats: Atom
Description: List all authors (20 items)
Parameters:
   * letter: display the authors with ... as the first letter of their name
   * born: authors born in ...
   * death: author who dies in ...
   * lang: language of the author
   * order: normally from A to Z, use desc to reverse order


37
38
39
40
# File 'lib/restbooks/authors.rb', line 37

def all( options={} )
  create_url( "/authors", options, ORDERED_AUTHOR_PARAMETERS )
  return do_request( :author )
end

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

Endpoint: /author/:id/books

Formats: Atom
Description: List all books for an author (id)
Parameters: Same as /books


73
74
75
76
77
# File 'lib/restbooks/authors.rb', line 73

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

#recent(options = {}) ⇒ Object

Endpoint: /authors/recent

Formats: Atom
Description: List recent authors (20 items)
Parameters:
   * letter: display the authors with ... as the first letter of their name
   * born: authors born in ...
   * death: author who dies in ...
   * lang: language of the author


64
65
66
67
# File 'lib/restbooks/authors.rb', line 64

def recent( options={} )
  create_url( "/authors/recent", options, AUTHOR_PARAMETERS )
  return do_request( :author )
end

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

Endpoint: /author/:id/books/recent

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


93
94
95
96
97
# File 'lib/restbooks/authors.rb', line 93

def recent_books( author_id, options={} )
  author_id = author_id.id if author_id.kind_of? RestBooks::Models::Author
  create_url( "/author/#{author_id}/books/recent", options, BOOK_PARAMETERS )
  return do_request( :book )
end

#top(options = {}) ⇒ Object

Endpoint: /authors/top

Formats: Atom
Description: List top authors (20 items)
Parameters:
   * letter: display the authors with ... as the first letter of their name
   * born: authors born in ...
   * death: author who dies in ...
   * lang: language of the author
   * range: normally overall, week will display the most popular for the previous week and month for the last 4 weeks


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

def top( options={} )
  create_url( "/authors/top", options, RANGED_AUTHOR_PARAMETERS )
  return do_request( :author )
end

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

Endpoint: /author/:id/books/top

Formats: Atom
Description: List top books for an author (id)
Parameters: Same as /books/top


83
84
85
86
87
# File 'lib/restbooks/authors.rb', line 83

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