Class: WCC::Media::Client::Response

Inherits:
RestClient::AbstractResponse show all
Defined in:
lib/wcc/media/client/response.rb

Instance Attribute Summary

Attributes inherited from RestClient::AbstractResponse

#client, #raw_body, #raw_response, #request

Instance Method Summary collapse

Methods inherited from RestClient::AbstractResponse

#assert_ok!, #body, #each_page, #error_message, #first, #initialize, #items, #next_page, #next_page?

Constructor Details

This class inherits a constructor from RestClient::AbstractResponse

Instance Method Details

#collection_response?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/wcc/media/client/response.rb', line 13

def collection_response?
  body.key?('pagination')
end

#countObject



9
10
11
# File 'lib/wcc/media/client/response.rb', line 9

def count
  body.dig('pagination', 'total')
end

#next_page_queryObject



21
22
23
24
25
# File 'lib/wcc/media/client/response.rb', line 21

def next_page_query
  {
    offset: page_items.length + skip,
  }
end

#page_itemsObject



17
18
19
# File 'lib/wcc/media/client/response.rb', line 17

def page_items
  body['messages'] || body['series'] || body['speakers'] || body['tags']
end

#skipObject



5
6
7
# File 'lib/wcc/media/client/response.rb', line 5

def skip
  body.dig('pagination', 'offset')
end