lib/ruby-tmdb/tmdb.rb in ruby-tmdb-0.0.20 vs lib/ruby-tmdb/tmdb.rb in ruby-tmdb-0.0.21
- old
+ new
@@ -1,10 +1,11 @@
class Tmdb
require 'net/http'
require 'uri'
require 'cgi'
+ require 'yaml'
@@api_key = ""
@@api_response = {}
def self.api_key
@@ -18,9 +19,10 @@
def self.base_api_url
"http://api.themoviedb.org/2.1/"
end
def self.api_call(method, data, language = "en")
+ raise ArgumentError, "Tmdb.api_key must be set before using the API" if(Tmdb.api_key.nil? || Tmdb.api_key.empty?)
url = Tmdb.base_api_url + method + '/' + language + '/yaml/' + Tmdb.api_key + '/' + CGI::escape(data.to_s)
response = @@api_response[url] ||= begin
Tmdb.get_url(url)
end
if(response.code.to_i != 200)
\ No newline at end of file