Class: Lotr::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/lotr/client.rb

Overview

Client for the Lord of the Rings API

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/lotr/client.rb', line 10

def initialize(options = {})
  @headers = { "Authorization" => "Bearer #{options[: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(options = {})
  resp = self.class.get("/movie", headers: @headers, query: parse_query_params(options))
  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, options = {})
  resp = self.class.get("/movie/#{movie_id}/quote", headers: @headers, query: parse_query_params(options))
  handle_response(resp, multiple_items: true)
end

#versionObject



14
15
16
# File 'lib/lotr/client.rb', line 14

def version
  Lotr::VERSION
end