Class: MovieAPI

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

Constant Summary collapse

API_URL =
'http://mymovieapi.com/'

Class Method Summary collapse

Class Method Details

.search_by_id(id, options = {}) ⇒ Hash

TODO:

fill out these docs

Queries the API for an IMDB ID

Parameters:

  • id (String)

    A Movie IMDB ID

  • options (Hash) (defaults to: {})

    The options to create a search query

Returns:

  • (Hash)

    Returns a single movie hash



16
17
18
# File 'lib/mmapi.rb', line 16

def self.search_by_id(id, options = {})
  return self.request("#{API_URL}?id=#{URI::encode(id)}" + self.parameterize(options))
end

.search_by_title(title, options = {}) ⇒ Array

Queries the API for a movie title

Parameters:

  • title (String)

    The title of the movie

  • options (Hash) (defaults to: {})

    The options to create a search query

Options Hash (options):

  • :year (Integer) — default: 2013

    The year you wish to search for - defaults to current year

  • :yg (Integer) — default: 0

    When this paramter is 0, the year parameter is disabled

  • :mt (String) — default: 'none'

    The movie type you wish to search for

  • :plot (String) — default: 'simple'

    The plot type you with the API to return

  • :episode (Integer) — default: 1

    When the parameter is 0, “episodes” is not included in the result

  • :offset (Integer) — default: 0

    Paging offset

  • :limit (Integer) — default: 1

    The maximum number of records to return

  • :lang (String) — default: 'en-US'

    The data language you wish to return

  • :aka (String) — default: 'simple'

    The aka type you with to return

  • :release (String) — default: 'simple'

    The release date type you with to return

  • :business (Integer) — default: 0

    Include the business field

  • :tech (Integer) — default: 0

    Include the technical field

Returns:

  • (Array)

    Returns an array of hashes.



39
40
41
# File 'lib/mmapi.rb', line 39

def self.search_by_title(title, options = {})
  return self.request("#{API_URL}?q=#{URI::encode(title)}" + self.parameterize(options))
end