Class: Edboxra::V1::Api

Inherits:
Api
  • Object
show all
Defined in:
lib/edboxra/v1/v1_api.rb

Constant Summary collapse

KEY_REGEX =
/__K.*value="(.*)"/

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
29
# File 'lib/edboxra/v1/v1_api.rb', line 19

def (movie)
  postData = JSON.generate({
    :type => "Title",
    :pk => "ID",
    :statements => [{:filters => {:ID => movie.id}}],
    "__K" => @key
  })

  response = RestClient.post("http://www.redbox.com/data.svc/Title", postData, post_headers)
  (movie, JSON.parse(response_object_from(response.body)))
end

#get_moviesObject



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

def get_movies
  resp = RestClient.get("http://www.redbox.com/data.svc/Title/js")

  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