Class: JustWatch::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/just_watch/api.rb

Constant Summary collapse

DEFAULT_LOCALE =
'en_US'
API_VERSION_URL =
'/contentpartner/v2/content'
DOMAIN_URL =
'https://apis.justwatch.com'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.localeObject



13
14
15
# File 'lib/just_watch/api.rb', line 13

def locale
  @locale ||= DEFAULT_LOCALE
end

.tokenObject

Returns the value of attribute token.



11
12
13
# File 'lib/just_watch/api.rb', line 11

def token
  @token
end

Class Method Details

.request(path, params = {}) ⇒ Object



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

def request(path, params = {})
  connection.get([API_VERSION_URL, path].join, params.merge!(token: token)).body
rescue Faraday::ResourceNotFound
  raise JustWatch::NotFoundError
rescue Faraday::UnauthorizedError
  raise JustWatch::UnauthorizedError
rescue Faraday::ServerError
  raise JustWatch::ServerError
end