Class: Tmdb::Resource
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query_url ⇒ Object
readonly
Returns the value of attribute query_url.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(query_url, filters = {}) ⇒ Resource
constructor
A new instance of Resource.
Methods included from Utils
#has_errors?, #is_api_key_invalid?, #is_api_key_suspended?, #is_item_id_invalid?, #is_session_denied?, #is_update_successful?
Constructor Details
#initialize(query_url, filters = {}) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 |
# File 'lib/tmdb/resource.rb', line 8 def initialize(query_url, filters={}) @params = filters @query_url = query_url end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/tmdb/resource.rb', line 6 def params @params end |
#query_url ⇒ Object (readonly)
Returns the value of attribute query_url.
6 7 8 |
# File 'lib/tmdb/resource.rb', line 6 def query_url @query_url end |
Instance Method Details
#get ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tmdb/resource.rb', line 13 def get = Api.params.merge(@params) begin response = Api.get(@query_url, query: ) rescue Net::HTTP::Exception raise Tmdb::Error, 'Network Exception: TMDB API endpoint is not reachable.' end if has_errors?(response) raise Tmdb::Error, response['status_message'] end response.to_h end |