diff --git a/README.md b/README.md index 01ceba6..e3a242e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,14 @@ Tmdb::Api.language("de") The default language is english. The API supports translations just be aware that it does not fall back to English in the event that a field hasn't been translated. + +You can add miscellaneous query params filters with this: + +```ruby +Tmdb::Person.search_filters(include_adult: true, page: 1, region: 'USA') +Tmdb::Movie.search_filters(include_adult: true, page: 1, region: 'USA', year: 1980, primary_release_year: 1980) +``` + ## Resources Current available resources: diff --git a/lib/themoviedb/resource.rb b/lib/themoviedb/resource.rb index 4365758..0219853 100644 --- a/lib/themoviedb/resource.rb +++ b/lib/themoviedb/resource.rb @@ -19,6 +19,14 @@ def self.endpoint_id @@endpoint_id[name.downcase] end + def self.filters + @@filters ||= {} + end + + def self.search_filters(options) + filters.merge! options + end + # Get the basic resource information for a specific id. def self.detail(id, conditions = {}) search = Tmdb::Search.new("/#{endpoints[:singular]}/#{endpoint_id + id.to_s}") @@ -37,7 +45,7 @@ def self.list(conditions = {}) def self.search(query) search = Tmdb::Search.new search.resource(endpoints[:singular].to_s) - search.query(query) + search.query(query).filter(filters) search.fetch.collect do |result| new(result) end