Class: InstagramBasicDisplay::Response
- Inherits:
-
Object
- Object
- InstagramBasicDisplay::Response
- Defined in:
- lib/instagram_basic_display/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#paging ⇒ Object
readonly
Returns the value of attribute paging.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#error ⇒ Nil, Struct
If an error is returned from the Instagram API, returns it as a Struct.
-
#initialize(response) ⇒ Object
constructor
Constructor.
-
#next_page? ⇒ Boolean
Returns whether or not a next page of results from the Instagram API is available.
-
#next_page_link ⇒ String
Returns a link to the next page of results from the Instagram API.
-
#payload ⇒ Struct
Returns the raw payload from Instagram’s API deserialized into a Struct.
-
#previous_page? ⇒ Boolean
Returns whether or not a previous page of results from the Instagram API is available.
-
#previous_page_link ⇒ String
Returns a link to the previous page of results from the Instagram API.
-
#success? ⇒ Boolean
Returns whether the request to the Instagram API was a success.
Constructor Details
#initialize(response) ⇒ Object
Constructor
25 26 27 28 29 30 |
# File 'lib/instagram_basic_display/response.rb', line 25 def initialize(response) @response = response @body = JSON.parse(response.body) @status = response.code @paging = body['paging'] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def body @body end |
#paging ⇒ Object (readonly)
Returns the value of attribute paging.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def paging @paging end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def response @response end |
#status ⇒ Object (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
#error ⇒ Nil, Struct
If an error is returned from the Instagram API, returns it as a Struct
70 71 72 73 74 75 |
# File 'lib/instagram_basic_display/response.rb', line 70 def error return unless body['error'] || body['error_message'] error_response = normalize_error(body) deserialize_json(error_response) end |
#next_page? ⇒ Boolean
Returns whether or not a next page of results from the Instagram API is available
34 35 36 |
# File 'lib/instagram_basic_display/response.rb', line 34 def next_page? !next_page_link.nil? end |
#next_page_link ⇒ String
Returns a link to the next page of results from the Instagram API
46 47 48 |
# File 'lib/instagram_basic_display/response.rb', line 46 def next_page_link paging['next'] if paging end |
#payload ⇒ Struct
Returns the raw payload from Instagram’s API deserialized into a Struct
64 65 66 |
# File 'lib/instagram_basic_display/response.rb', line 64 def payload deserialize_json(body) end |
#previous_page? ⇒ Boolean
Returns whether or not a previous page of results from the Instagram API is available
40 41 42 |
# File 'lib/instagram_basic_display/response.rb', line 40 def previous_page? !previous_page_link.nil? end |
#previous_page_link ⇒ String
Returns a link to the previous page of results from the Instagram API
52 53 54 |
# File 'lib/instagram_basic_display/response.rb', line 52 def previous_page_link paging['previous'] if paging end |
#success? ⇒ Boolean
Returns whether the request to the Instagram API was a success
58 59 60 |
# File 'lib/instagram_basic_display/response.rb', line 58 def success? response. == 'OK' end |