Class: Lotr::Client
Overview
Client for the Lord of the Rings API
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #movie(movie_id) ⇒ Object (also: #get_movie)
- #movies(options = {}) ⇒ Object (also: #get_movies)
- #quotes_for_movie(movie_id, options = {}) ⇒ Object (also: #get_quotes_for_movie)
- #version ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 |
# File 'lib/lotr/client.rb', line 10 def initialize( = {}) @headers = { "Authorization" => "Bearer #{[:api_key]}" } end |
Instance Method Details
#movie(movie_id) ⇒ Object Also known as: get_movie
24 25 26 27 |
# File 'lib/lotr/client.rb', line 24 def movie(movie_id) resp = self.class.get("/movie/#{movie_id}", headers: @headers) handle_response(resp) end |
#movies(options = {}) ⇒ Object Also known as: get_movies
18 19 20 21 |
# File 'lib/lotr/client.rb', line 18 def movies( = {}) resp = self.class.get("/movie", headers: @headers, query: parse_query_params()) handle_response(resp, multiple_items: true) end |
#quotes_for_movie(movie_id, options = {}) ⇒ Object Also known as: get_quotes_for_movie
30 31 32 33 |
# File 'lib/lotr/client.rb', line 30 def quotes_for_movie(movie_id, = {}) resp = self.class.get("/movie/#{movie_id}/quote", headers: @headers, query: parse_query_params()) handle_response(resp, multiple_items: true) end |