Module: StrawberryAPI::Client::Collections

Included in:
StrawberryAPI::Client
Defined in:
lib/strawberry_api/client/collections.rb

Instance Method Summary collapse

Instance Method Details

#collection(id:) ⇒ StrawberryAPI::Collection

Fetches a collection

Parameters:

  • id (Integer)

    Id of the collection to retrieve

Returns:



22
23
24
25
# File 'lib/strawberry_api/client/collections.rb', line 22

def collection(id:)
  data = get("/collections/#{id}").parse['collection']
  data.nil? ? nil : Collection.new(data)
end

#collectionsArray<StrawberryAPI::Collection>

Fetches all collections

Returns:



10
11
12
13
14
# File 'lib/strawberry_api/client/collections.rb', line 10

def collections
  get("/collections").parse['array']&.map do |collection|
    Collection.new(collection)
  end
end