class Tvteka::API::APIResponse

Attributes

data[R]
error[R]
success[R]

Public Class Methods

new(request_type, data, response, error) click to toggle source
# File lib/tvteka/api.rb, line 50
def initialize(request_type, data, response, error)
  @success = (200...300).include?(response.statusCode)
  
  if request_type == :session
    parsed_data = NSJSONSerialization.JSONObjectWithData(data, options:0, error: nil)
    @data = Tvteka::Session.new(parsed_data)
  elsif request_type == :session
    parsed_data = NSJSONSerialization.JSONObjectWithData(data, options:0, error: nil)
    @data = Tvteka::Session.new(parsed_data)
  elsif request_type == :live
    puts data
    parsed_data = NSJSONSerialization.JSONObjectWithData(data, options:0, error: nil)
    @data = Tvteka::Channel.init_from_array(parsed_data)
  elsif request_type == :live_channel
    parsed_data = NSJSONSerialization.JSONObjectWithData(data, options:0, error: nil)
    @data = Tvteka::Show.init_from_array(parsed_data)
  else
    @data = NSJSONSerialization.JSONObjectWithData(data, options: 0, error: nil)
  end
    
  @error = error
end

Public Instance Methods

successful?() click to toggle source
# File lib/tvteka/api.rb, line 73
def successful?
  @success
end