Class: Tmdb::Api

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/themoviedb/api.rb

Class Method Summary collapse

Class Method Details

.configObject



10
11
12
# File 'lib/themoviedb/api.rb', line 10

def self.config
  @@config ||= {}
end

.etag(etag) ⇒ Object



26
27
28
# File 'lib/themoviedb/api.rb', line 26

def self.etag(etag)
  headers "If-None-Match" => '"' + etag + '"'
end

.key(api_key) ⇒ Object



14
15
16
# File 'lib/themoviedb/api.rb', line 14

def self.key(api_key)
  config[:api_key] = api_key
end

.language(lang) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/themoviedb/api.rb', line 18

def self.language(lang)
  if lang.nil?
    config.delete(:language)
  else
    config[:language] = lang
  end
end

.responseObject



30
31
32
# File 'lib/themoviedb/api.rb', line 30

def self.response
  @@response ||= {}
end

.set_response(hash) ⇒ Object



34
35
36
37
38
# File 'lib/themoviedb/api.rb', line 34

def self.set_response(hash)
  @@response = hash
  # Detect 401 Unauthorized error, which indicates invalid API key
  raise Tmdb::InvalidApiKeyError if hash["code"].to_i == 401
end