Sha256: 735354b5aceb4bcc2858b430a9664bc570c16b182e910c7ef6cf4a65c58c1e5b

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

module CarrierBotAPI
  class Item
    attr_reader :name, :sku, :quantity, :grams, :price, :vendor, :requires_shipping, :taxable, :fulfillment_service, :properties, :product_id, :variant_id

    def initialize(data)
      @name = data[:name]
      @sku = data[:sku]
      @quantity = data[:quantity]
      @grams = data[:grams]
      @price = data[:price]
      @vendor = data[:vendor] || CarrierBotAPI::Configuration['carrierbot_vendor']
      @requires_shipping = data[:requires_shipping]
      @taxable = data[:taxable]
      @fulfillment_service = data[:fulfillment_service] || CarrierBotAPI::Configuration['carrierbot_fulfillment_service'] || 'manual'
      @properties = data[:properties]
      @product_id = data[:product_id]
      @variant_id = data[:variant_id]
    end

    def to_json
      {
        'name': self.name,
        'sku': self.sku,
        'quantity': self.quantity,
        'grams': self.grams,
        'price': self.price,
        'vendor': self.vendor,
        'requires_shipping': self.requires_shipping,
        'taxable': self.taxable,
        'fulfillment_service': self.fulfillment_service,
        'properties': self.properties,
        'product_id': self.product_id,
        'variant_id': self.variant_id
      }
    end
  end
end # module CarrierBotAPI

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
carrierbot_api-0.5.3 lib/carrierbot_api/item.rb
carrierbot_api-0.5.2 lib/carrierbot_api/item.rb
carrierbot_api-0.5.1 lib/carrierbot_api/item.rb
carrierbot_api-0.5.0 lib/carrierbot_api/item.rb
carrierbot_api-0.4.0 lib/carrierbot_api/item.rb
carrierbot_api-0.3.0 lib/carrierbot_api/item.rb