Sha256: 6697af4507802218e32b005d65b062f7a57f5a91019a730c1c3a014857c1c607

Contents?: true

Size: 1.36 KB

Versions: 18

Compression:

Stored size: 1.36 KB

Contents

module Unsplash # :nodoc: 

  # Unsplash Curated Batch operations.
  class CuratedBatch < Client

    class << self

      # Get a specific curated batch.
      # @param id [Integer] The ID of the batch.
      # @return [Unsplash::CuratedBatch] The requested batch.
      def find(id)
        batch = Unsplash::CuratedBatch.new JSON.parse(connection.get("/curated_batches/#{id}").body)
        batch.curator = Unsplash::User.new batch.curator
        batch
      end

      # Get a list of all curated batches.
      # @param page  [Integer] Which page of search results to return.
      # @param per_page [Integer] The number of search results per page.
      # @return [Array] A single page of the +Unsplash::CuratedBatch+ list.
      def all(page = 1, per_page = 10)
        params = {
          page:     page,
          per_page: per_page
        }
        list = JSON.parse(connection.get("/curated_batches/", params).body)
        list.map do |cb|
          batch = Unsplash::CuratedBatch.new cb
          batch.curator = Unsplash::User.new batch.curator
          batch
        end
      end
    end

    # Get a list of the photos contained in this batch.
    # @return [Array] The list of +Unsplash::Photo+s in the batch.
    def photos
      list = JSON.parse(connection.get("/curated_batches/#{id}/photos").body)
      list.map { |photo| Unsplash::Photo.new photo }
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
unsplash-1.5.5 lib/unsplash/curated_batch.rb
unsplash-1.5.4 lib/unsplash/curated_batch.rb
unsplash-1.5.3 lib/unsplash/curated_batch.rb
unsplash-1.5.2 lib/unsplash/curated_batch.rb
unsplash-1.5.1 lib/unsplash/curated_batch.rb
unsplash-1.5.0 lib/unsplash/curated_batch.rb
unsplash-1.4.3 lib/unsplash/curated_batch.rb
unsplash-1.4.2 lib/unsplash/curated_batch.rb
unsplash-1.4.1 lib/unsplash/curated_batch.rb
unsplash-1.4.0 lib/unsplash/curated_batch.rb
unsplash-1.3.1 lib/unsplash/curated_batch.rb
unsplash-1.3.0 lib/unsplash/curated_batch.rb
unsplash-1.2.1 lib/unsplash/curated_batch.rb
unsplash-1.2.0 lib/unsplash/curated_batch.rb
unsplash-1.1.0 lib/unsplash/curated_batch.rb
unsplash-1.0.0 lib/unsplash/curated_batch.rb
unsplash-1.0.0.pre.rc.2 lib/unsplash/curated_batch.rb
unsplash-1.0.0.pre.rc.1 lib/unsplash/curated_batch.rb