lib/tvdb2/client.rb in tvdb2-0.1.0 vs lib/tvdb2/client.rb in tvdb2-0.1.1

- old
+ new

@@ -37,11 +37,11 @@ # # @param [String] apikey your tvdb apikey (you can get one at # https://thetvdb.com/?tab=apiregister). Required. # @param [Symbol, String] language the language in which you want get data. # You can change later. Optional. Default is `nil` that is `EN`. - def initialize(apikey:, language: nil) + def initialize(apikey:, language: 'en') @language = language response = post('/login', apikey: apikey) raise RequestError.new(response) if response.code != 200 @token = response.parsed_response['token'] end @@ -58,16 +58,15 @@ # Inside the block change the language in which you want get data. # # @example # got = client.best_search('Game of Thrones') + # ep = got['3x9'] # client.with_language(:it) do |c| - # ep = got['1x1'] # Get episode data in italian - # puts ep.name # print the title of episode 1x1 in italian + # puts ep.name # print the title of episode 3x9 in italian # end - # ep = got['1x1'] # Get episode data in default language - # puts ep.name # print the title of episode 1x1 in english + # puts ep.name # print the title of episode 3x9 in english # # @param [Symbol, String] locale the language in which you want get data. # @yield block called with the selected language. def with_language(locale, &block) tmp_language = @language @@ -96,16 +95,18 @@ protected # :nodoc: # language param is required to invalidate memoist cache on different language def get(path, params = {}, language = @language) + puts ">>> GET API REQUEST to '#{path}' with language '#{language}'" if ENV['DEBUG'] self.class.get(URI.escape(path), headers: build_headers, query: params) end memoize :get # :nodoc: def post(path, params = {}, language = @language) + puts ">>> POST API REQUEST to '#{path}' with language '#{language}'" if ENV['DEBUG'] self.class.post(URI.escape(path), headers: build_headers, body: params.to_json) end memoize :post # :nodoc: @@ -145,7 +146,7 @@ end end end -# Alias of {Client} +# Alias of {Tvdb2::Client} TVDB = Tvdb2::Client