Module: AnotherApi::ResponseHasMetadata

Extended by:
ActiveSupport::Concern
Included in:
BaseController
Defined in:
lib/another_api/response_has_metadata.rb

Constant Summary collapse

5.seconds

Instance Method Summary collapse

Instance Method Details

#collection_response_metadata(query) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/another_api/response_has_metadata.rb', line 9

def (query)
  total_count = query.total_count
  total_pages = total_count.fdiv(query.page_size).ceil
  {
    offset: query.offset_value,
    count: query.page_count,
    total_count:,
    total_pages:,
    has_more: total_pages > query.page,
    request_id: request.request_id,
    request_started_at: started_processing_request_at.iso8601,
    request_ended_at: Time.zone.now.iso8601,
    next_poll_at: RECOMMENDED_POLL_INTERVAL.from_now.iso8601
  }
end

#single_item_response_metadataObject



25
26
27
28
29
30
31
32
# File 'lib/another_api/response_has_metadata.rb', line 25

def 
  {
    request_id: request.request_id,
    request_started_at: started_processing_request_at.iso8601,
    request_ended_at: Time.zone.now.iso8601,
    next_poll_at: RECOMMENDED_POLL_INTERVAL.from_now.iso8601
  }
end