class Tvdbjson::Series

Attributes

aliases[RW]
banner_url[RW]
first_aired[RW]
id[RW]
name[RW]
network[RW]
overview[RW]
status[RW]

Public Class Methods

from_response(response) click to toggle source
# File lib/tvdbjson/series.rb, line 57
def self.from_response(response)
  results_array = []

  begin
    response.parsed_response["data"].each do |record|
      hash               = {}
      hash[:id]          = record["id"]
      hash[:name]        = record["seriesName"]
      hash[:overview]    = record["overview"]
      hash[:network]     = record["network"]
      hash[:banner_url]  = "https://thetvdb.com/banners/" + record["banner"]
      hash[:first_aired] = record["firstAired"]
      hash[:status]      = record["status"]
      hash[:aliases]     = record["aliases"]

      result             = Series.new(hash)
      results_array      << result
    end
  rescue NoMethodError
    # Means an empty result set was found, don't do anything special
    # here as this method will return an empty array.
  end
  results_array
end
new(options = {}) click to toggle source
# File lib/tvdbjson/series.rb, line 7
def initialize(options = {})
  @id          = options[:id]
  @name        = options[:name]
  @overview    = options[:overview]
  @network     = options[:network]
  @banner_url  = options[:banner_url]
  @first_aired = options[:first_aired]
  @status      = options[:status]
  @aliases     = options[:aliases]
end
search_by_imdb(str, authentication) click to toggle source
# File lib/tvdbjson/series.rb, line 31
def self.search_by_imdb(str, authentication)
  raise Tvdbjson::RequiredSearchParamMissingError if !str
  raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication)

  hash = {
    :method       => "GET",
    :uri          => "/search/series",
    :after_action => "Tvdbjson::Series.from_response(response)",
    :params       => { "imdbId" => str }
  }
  send_authenticated_request(hash, authentication)
end
search_by_name(str, authentication) click to toggle source
# File lib/tvdbjson/series.rb, line 18
def self.search_by_name(str, authentication)
  raise Tvdbjson::RequiredSearchParamMissingError if !str
  raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication)

  hash = {
    :method       => "GET",
    :uri          => "/search/series",
    :after_action => "Tvdbjson::Series.from_response(response)",
    :params       => { "name" => str }
  }
  send_authenticated_request(hash, authentication)
end
search_by_zap2it_id(str, authentication) click to toggle source
# File lib/tvdbjson/series.rb, line 44
def self.search_by_zap2it_id(str, authentication)
  raise Tvdbjson::RequiredSearchParamMissingError if !str
  raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication)

  hash = {
    :method       => "GET",
    :uri          => "/search/series",
    :after_action => "Tvdbjson::Series.from_response(response)",
    :params       => { "zap2itId" => str }
  }
  send_authenticated_request(hash, authentication)
end