Sha256: edfeecabc67fb9d19845768b2f48bfe1ab578d4ca3a5c064929e430ea18a24d3

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# -----------------------------------------------------------------------
#  Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
# -----------------------------------------------------------------------

require 'App42Response.rb'

#
#
# This Cart object is the value object which contains the properties of Cart
# along with the setter & getter for those properties.
#
#

module App42
  module Shopping
    class Cart < App42Response
      attr_accessor :userName, :cartId, :creationTime, :checkOutTime, :state, :isEmpty, :cartSession, :totalAmount, :itemList, :payment

      @userName
      @cartId
      @creationTime
      @checkOutTime
      @state
      @isEmpty
      @cartSession
      @totalAmount
      @itemList = Array.new
      @payment
    end

    class Item
      attr_accessor :itemId, :name, :quantity, :image, :price, :totalAmount

      @itemId
      @name
      @quantity
      @image
      @price
      @totalAmount

      #
      # This is a constructor that takes no parameter
      #
      #
      def initialize(cart)
        cart.itemList.push(self)
      end

      #
      # Returns the Cart Response in JSON format.
      #
      # @return the response in JSON format.
      #

      def to_s
        return "name : #{@name}" + "itemId : #{@itemId}" + "price : #{@price}" + "quantity : #{@quantity}";
      end
    end

    class Payment
      attr_accessor :transactionId, :totalAmount, :date, :status

      @transactionId
      @totalAmount
      @date
      @status

      #
      # This is a constructor that takes no parameter
      #
      #
      def initialize(cart)
        cart.payment = self
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
App42_RUBY_SDK-0.8.3 lib/shopping/Cart.rb