Class: InstagramBasicDisplay::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



21
22
23
24
25
26
# File 'lib/instagram_basic_display/response.rb', line 21

def initialize(response)
  @response = response
  @body = JSON.parse(response.body)
  @status = response.code
  @paging = body['paging']
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



19
20
21
# File 'lib/instagram_basic_display/response.rb', line 19

def body
  @body
end

#pagingObject (readonly)

Returns the value of attribute paging.



19
20
21
# File 'lib/instagram_basic_display/response.rb', line 19

def paging
  @paging
end

#responseObject (readonly)

Returns the value of attribute response.



19
20
21
# File 'lib/instagram_basic_display/response.rb', line 19

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



19
20
21
# File 'lib/instagram_basic_display/response.rb', line 19

def status
  @status
end

Instance Method Details

#errorObject



52
53
54
55
56
57
# File 'lib/instagram_basic_display/response.rb', line 52

def error
  return unless body['error'] || body['error_message']

  error_response = normalize_error(body)
  deserialize_json(error_response)
end

#next_page?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/instagram_basic_display/response.rb', line 28

def next_page?
  !next_page_link.nil?
end


36
37
38
# File 'lib/instagram_basic_display/response.rb', line 36

def next_page_link
  paging['next'] if paging
end

#payloadObject



48
49
50
# File 'lib/instagram_basic_display/response.rb', line 48

def payload
  deserialize_json(body)
end

#previous_page?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/instagram_basic_display/response.rb', line 32

def previous_page?
  !previous_page_link.nil?
end


40
41
42
# File 'lib/instagram_basic_display/response.rb', line 40

def previous_page_link
  paging['previous'] if paging
end

#success?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/instagram_basic_display/response.rb', line 44

def success?
  response.message == 'OK'
end