Sha256: f221cd7ce9f16d28e2690778ea67b9ae4d1b0a63f8834672ada7b9f61bc1c96e

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

module Etsy

  # = Image
  #
  # Represents an image resource of an Etsy listing and contains multiple sizes.
  # Sizes available are:
  #
  # [square] The square image thumbnail (75x75 pixels)
  # [small] The small image thumbnail (170x135 pixels)
  # [thumbnail] The thumbnail for the image, no more than 570px wide
  # [full] The full image for this listing, no more than 1500px wide
  #
  class Image

    include Etsy::Model

    attribute :square, :from => :url_75x75
    attribute :small, :from => :url_170x135
    attribute :thumbnail, :from => :url_570xN
    attribute :full, :from => :url_fullxfull

    # Fetch all images for a given listing.
    #
    def self.find_all_by_listing_id(listing_id)
      get_all("/listings/#{listing_id}/images")
    end

    def self.create(listing, image_path, options = {})
      options[:image] = File.new(image_path)
      options[:multipart] = true
      post("/listings/#{listing.id}/images", options)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
etsy-0.2.2 lib/etsy/image.rb
tailored-etsy-0.2.2 lib/etsy/image.rb
etsy-0.2.1 lib/etsy/image.rb