class Prodigi::Collection

Attributes

data[R]
has_more[R]
next_url[R]

Public Class Methods

from_response(response, key:, type:) click to toggle source
# File lib/prodigi/collection.rb, line 5
def self.from_response(response, key:, type:)
  body = response.body
  new(
    data: body[key].map { |attrs| type.new(attrs) },
    has_more: body.dig("hasMore"),
    next_url: body.dig("nextUrl")
  )
end
new(data:, has_more:, next_url:) click to toggle source
# File lib/prodigi/collection.rb, line 14
def initialize(data:, has_more:, next_url:)
  @data = data
  @has_more = has_more
  if @has_more == true; @next_url = next_url else @next_url = nil end
end