Skip to content

Commit

Permalink
Replace Tmdb.Movies.search/2 for Tmdb.Search to match TMDb API (#3)
Browse files Browse the repository at this point in the history
* Search endpoint added

* delete search module from various resources

* a
  • Loading branch information
agustif authored and seanabrahams committed Sep 6, 2016
1 parent a9482f4 commit f60ca5c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 30 deletions.
5 changes: 0 additions & 5 deletions lib/tmdb/collections/collections.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ defmodule Tmdb.Collections do
], "total_pages" => 1,
"total_results" => 18}
"""
def search(query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/collection?#{URI.encode_query(params)}").body
end

def images(id, params \\ %{}) do
get!("collection/#{id}/images?#{URI.encode_query(params)}").body
end
Expand Down
5 changes: 0 additions & 5 deletions lib/tmdb/companies/companies.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ defmodule Tmdb.Companies do
], "total_pages" => 1,
"total_results" => 3}
"""
def search(query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/company?#{URI.encode_query(params)}").body
end

def movies(id) do
get!("company/#{id}/movies?").body
end
Expand Down
5 changes: 0 additions & 5 deletions lib/tmdb/keywords/keywords.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ defmodule Tmdb.Keywords do
%{"id" => 189274, "name" => "hotel fight"}], "total_pages" => 6,
"total_results" => 109}
"""
def search(query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/keyword?#{URI.encode_query(params)}").body
end

def movies(id) do
get!("keyword/#{id}/movies?").body
end
Expand Down
5 changes: 0 additions & 5 deletions lib/tmdb/lists/lists.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ defmodule Tmdb.Lists do
get!("list/#{id}?").body
end

def search(query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/list?#{URI.encode_query(params)}").body
end

def item_status(list_id, movie_id) do
get!("list/#{list_id}/item_status?movie_id=#{movie_id}").body
end
Expand Down
5 changes: 0 additions & 5 deletions lib/tmdb/movies/movies.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ defmodule Tmdb.Movies do
get!("movie/popular?#{URI.encode_query(params)}&append_to_response=videos").body
end

def search(query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/movie?#{URI.encode_query(params)}&append_to_response=videos").body
end

def similar(id, params \\ %{}) do
get!("movie/#{id}/similar?#{URI.encode_query(params)}&append_to_response=videos").body
end
Expand Down
5 changes: 0 additions & 5 deletions lib/tmdb/people/people.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@ defmodule Tmdb.People do
def latest(params \\ %{}) do
get!("person/latest?#{URI.encode_query(params)}").body
end

def search(query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/person?#{URI.encode_query(params)}").body
end
end
40 changes: 40 additions & 0 deletions lib/tmdb/search/search.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
defmodule Tmdb.Search do
use Tmdb.Base

def companies(query, params \\ %{}) do
search_api("company", query, params)
end

def collections(query, params \\ %{}) do
search_api("collection", query, params)
end

def keywords(query, params \\ %{}) do
search_api("keyword", query, params)
end

def lists(query, params \\ %{}) do
search_api("list", query, params)
end

def movies(query, params \\ %{}) do
search_api("movie", query, params)
end

def multi(query, params \\ %{}) do
search_api("multi", query, params)
end

def persons(query, params \\ %{}) do
search_api("person", query, params)
end

def tv(query, params \\ %{}) do
search_api("tv", query, params)
end

defp search_api(endpoint, query, params \\ %{}) do
params = Map.merge(params, %{"query" => query})
get!("search/#{endpoint}?#{URI.encode_query(params)}").body
end
end

0 comments on commit f60ca5c

Please sign in to comment.