Class: Snapcat::Response

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

Constant Summary collapse

RECOGNIZED_CONTENT_TYPES =
%w(application/json application/octet-stream)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, additional_fields = {}) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
# File 'lib/snapcat/response.rb', line 6

def initialize(response, additional_fields = {})
  @data = formatted_result(response).merge(additional_fields)
  @code = response.code
  @http_success = response.success?
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/snapcat/response.rb', line 4

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/snapcat/response.rb', line 4

def data
  @data
end

#http_successObject (readonly)

Returns the value of attribute http_success.



4
5
6
# File 'lib/snapcat/response.rb', line 4

def http_success
  @http_success
end

Instance Method Details

#auth_tokenObject



12
13
14
# File 'lib/snapcat/response.rb', line 12

def auth_token
  @data[:auth_token]
end

#success?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
# File 'lib/snapcat/response.rb', line 16

def success?
  if !@data[:logged].nil?
    !!@data[:logged]
  else
    @http_success
  end
end