Class: Omdb::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/omdb/api.rb

Instance Method Summary collapse

Instance Method Details

#fetch(title, year = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/omdb/api.rb', line 20

def fetch(title, year = nil)
  res = network.call({t: title, year: nil})
  if res[:data]["Response"] == "False"
    response = {:status => 404}
  else
    response = {
      status: res[:code],
      movie: parse_movie(res[:data])
    }
  end
end

#search(search_term) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/omdb/api.rb', line 5

def search(search_term)
  res = network.call({s: search_term})
  if res[:data]["Response"] == "False"
    response = {
      :movies => {},
      :status => 404
    }
  else
    response = {
      :movies => parse_movies(res[:data]),
      :status => res[:code]
    }
  end
end