Module: Unit::ResourceOperations::List::ClassMethods

Defined in:
lib/unit-ruby/util/resource_operations.rb

Instance Method Summary collapse

Instance Method Details

#list(where: {}, limit: 100, offset: 0, sort: nil) ⇒ Object

List resources

Parameters:

  • where (Hash) (defaults to: {})

    Optional. Filters to apply to the list.

  • limit (Integer) (defaults to: 100)

    Optional. Maximum number of resources that will be returned. Maximum is 1000 resources.

  • offset (Integer) (defaults to: 0)

    Optional. Number of resources to skip

  • sort (String) (defaults to: nil)

    Optional. sort: ‘createdAt’ for ascending order or sort: ‘-createdAt’ (leading minus sign) for descending order



55
56
57
58
59
60
61
# File 'lib/unit-ruby/util/resource_operations.rb', line 55

def list(where: {}, limit: 100, offset: 0, sort: nil)
  params = { filter: where, page: { offset: offset, limit: limit },
             sort: sort }.compact
  resources = connection.get(resources_path, params)

  resources.map { |resource| build_resource_from_json_api(resource) }
end