Sha256: d69b738604e35a9389ffb03d2416d61571cac37f7db75b55f8f573f58e7aff28

Contents?: true

Size: 1.18 KB

Versions: 20

Compression:

Stored size: 1.18 KB

Contents

module AmazonSellerCentral
  # It turns out you can't get low_price without executing a sub-request, so
  # I'm leaving it alone for now.
  class Listing
    module ClassMethods
      def is_asin?(value)
        value.to_s =~ /^B.{9}$/
      end
    end
    extend ClassMethods

    attr_accessor :sku, :asin, :product_name, :created_at, :quantity, :condition, :price_cents, :low_price_cents, :status

    alias :qty :quantity
    alias :qty= :quantity=

    alias :product :product_name
    alias :product= :product_name=

    def price
      @price_cents.kind_of?(Numeric) ? @price_cents / 100.0 : @price_cents
    end
    def price=(price)
      @price_cents = price.kind_of?(Numeric) ? (price * 100).round : price
    end

    alias :your_price :price
    alias :your_price= :price=

    def low_price
      @low_price_cents.kind_of?(Numeric) ? @low_price_cents / 100.0 : @low_price_cents
    end
    def low_price=(low_price)
      @low_price_cents = low_price.kind_of?(Numeric) ? (low_price * 100).round : low_price
    end

    def save
      puts "Sorry, you want to send this listing as part of an array to the InventoryPage it came from, with InventoryPage#apply_listings"
      false
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
amazon_seller_central-0.3.2 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.3.1 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.3.0 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.16 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.15 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.14 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.13 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.12 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.11 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.10 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.9 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.8 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.7 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.6 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.5 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.4 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.3 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.2 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.1 lib/amazon_seller_central/listing.rb
amazon_seller_central-0.2.0 lib/amazon_seller_central/listing.rb