Class: Tvteka::API::APIResponse
- Inherits:
-
Object
- Object
- Tvteka::API::APIResponse
- Defined in:
- lib/tvteka/api.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(request_type, data, response, error) ⇒ APIResponse
constructor
A new instance of APIResponse.
- #successful? ⇒ Boolean
Constructor Details
#initialize(request_type, data, response, error) ⇒ APIResponse
Returns a new instance of APIResponse.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# 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 |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
48 49 50 |
# File 'lib/tvteka/api.rb', line 48 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
48 49 50 |
# File 'lib/tvteka/api.rb', line 48 def error @error end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
48 49 50 |
# File 'lib/tvteka/api.rb', line 48 def success @success end |
Instance Method Details
#successful? ⇒ Boolean
73 74 75 |
# File 'lib/tvteka/api.rb', line 73 def successful? @success end |