Navigation Menu

Skip to content

Commit

Permalink
add v=1.5 parameter to Netflix client
Browse files Browse the repository at this point in the history
Not sure if it does anything, but Netflix API docs state that the
default version is 1.0 unless v=1.5 is specified.
  • Loading branch information
mislav committed Mar 14, 2012
1 parent e9ef528 commit 58a955e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/movies_controller.rb
Expand Up @@ -35,6 +35,7 @@ def perform_search(query)
if params[:local]
@movies = Movie.search_regexp(@query, :no_escape).page(params[:page])
elsif params[:netflix]
require 'netflix'
@movies = Netflix.search(@query, :expand => %w'directors').titles
render :netflix_search, :layout => !request.xhr?
else
Expand Down
3 changes: 3 additions & 0 deletions lib/netflix.rb
Expand Up @@ -19,6 +19,9 @@ def call(env)
conn.headers[:user_agent] = user_agent
end

# http://developer.netflix.com/docs/REST_API_Conventions#0_pgfId-1009147
conn.params[:v] = '1.5'

oauth_config = Movies::Application.config.netflix
conn.request :oauth,
:consumer_key => oauth_config.consumer_key,
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/netflix_spec.rb
Expand Up @@ -5,7 +5,7 @@
describe Netflix::Title do

before(:all) do
stub_request(:get, 'http://api.netflix.com/catalog/titles?start_index=0&term=mar%20adentro&max_results=5').
stub_request(:get, 'http://api.netflix.com/catalog/titles?start_index=0&term=mar%20adentro&max_results=5&v=1.5').
to_return(:body => read_fixture('netflix-mar_adentro.xml'), :status => 200)

@catalog = Netflix.search('mar adentro')
Expand Down Expand Up @@ -60,7 +60,7 @@
describe Netflix, "autocomplete" do

before(:all) do
stub_request(:get, 'http://api.netflix.com/catalog/titles/autocomplete?term=step').
stub_request(:get, 'http://api.netflix.com/catalog/titles/autocomplete?term=step&v=1.5').
to_return(:body => read_fixture('netflix-autocomplete.xml'), :status => 200)

@result = Netflix.autocomplete('step')
Expand Down

0 comments on commit 58a955e

Please sign in to comment.