Sha256: 400c741ce5f6027ee85969031776543aee99428b7f21b8172852a3e56678b223

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

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 :height, :from => :full_height
    attribute :width, :from => :full_width
    attribute :full, :from => :url_fullxfull

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

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

    # Delete image
    #
    def self.destroy(listing, image, options = {})
      options.merge!(:require_secure => true)
      delete("/listings/#{listing.id}/images/#{image.id}", options)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
etsy-0.3.3 lib/etsy/image.rb
cardmagic-etsy-0.3.9 lib/etsy/image.rb
cardmagic-etsy-0.3.8 lib/etsy/image.rb
cardmagic-etsy-0.3.7 lib/etsy/image.rb
cardmagic-etsy-0.3.6 lib/etsy/image.rb
cardmagic-etsy-0.3.5 lib/etsy/image.rb
cardmagic-etsy-0.3.4 lib/etsy/image.rb
cardmagic-etsy-0.3.3 lib/etsy/image.rb
cardmagic-etsy-0.3.2 lib/etsy/image.rb