class SmartRecruiters::Collection

Attributes

content[R]
limit[R]
next_page_id[R]
offset[R]
total_found[R]

Public Class Methods

from_response(response, type:) click to toggle source
# File lib/smartrecruiters/collection.rb, line 7
def self.from_response(response, type:)
  body = response.body

  if body.is_a?(Array)
    new(
      content: body.map { |attrs| type.new(attrs) },
      limit: nil, offset: nil, next_page_id: nil, total_found: nil
    )
  else
    new(
      content: body['content'].map { |attrs| type.new(attrs) },
      limit: body['limit'],
      offset: body['offset'],
      next_page_id: body['nextPageId'],
      total_found: body['totalFound']
    )
  end
end
new(content:, limit:, offset:, next_page_id:, total_found:) click to toggle source
# File lib/smartrecruiters/collection.rb, line 26
def initialize(content:, limit:, offset:, next_page_id:, total_found:)
  @content = content
  @limit = limit
  @offset = offset
  @next_page_id = next_page_id
  @total_found = total_found
end