Class: Edboxra::V2::Api

Inherits:
Api
  • Object
show all
Defined in:
lib/edboxra/v2/v2_api.rb

Constant Summary collapse

KEY_REGEX =
/rb\.api\.key *= * [',"](.*?)[',"]/

Instance Method Summary collapse

Methods inherited from Api

#initialize

Constructor Details

This class inherits a constructor from Edboxra::Api

Instance Method Details

#add_metadata_to(movie) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/edboxra/v2/v2_api.rb', line 19

def (movie)
  postData = JSON.generate({
    :productType => 1,
    :id => movie.id,
    :descCharLimit => 2000
  })

  response = RestClient.post("http://www.redbox.com/api/Product/GetDetail/", postData, post_headers)
  (movie, JSON.parse(response.body))
end

#get_moviesObject



9
10
11
12
13
14
15
16
17
# File 'lib/edboxra/v2/v2_api.rb', line 9

def get_movies
  resp = RestClient.get("http://www.redbox.com/api/product/js/__titles")

  match = /=\ *(\[.*\])/.match(resp.body)
  raise "couldn't find movies in #{resp.body}" unless match

  json = JSON.parse(match[1])
  json.map{|movie| map_movie(movie)}
end