class App42::Shopping::CartService

This is Cloud Persistent Shopping Cart Service. App Developers can use this to create a Shopping Cart. Add Items and Check Out items. It also maintains the transactions and the corresponding Payment Status.

The Payment Gateway interface is not provided by the Platform. It is left to the App developer how he wants to do the Payment Integration. This can be used along with Catalogue or used independently

@see Catalgoue @see Cart @see App42Response @see ItemData @see PaymentStatus

Public Class Methods

new(api_key, secret_key, base_url) click to toggle source

this is a constructor that takes

@param apiKey @param secretKey @param baseURL

# File lib/shopping/CartService.rb, line 39
def initialize(api_key, secret_key, base_url)
  puts "Shopping ->initialize"
  @api_key = api_key
  @secret_key = secret_key
  @base_url = base_url
  @resource = "cart"
  @version = "1.0"
end

Public Instance Methods

add_item(cartID, itemID, itemQuantity, price) click to toggle source

Adds an Item in the Cart with quantity and price. This method does not take currency. Its the bonus of the App developer to maintain the currency. It takes only the price.

@param cartID

- The Cart Id into which item has to be added

@param itemID

- The Item id which has to be added in the cart. If the Catalogue Service is used along

with the Cart Service then the Item ids should be same. @param itemQuantity

- Quantity of the Item to be purchased

@param price

- Price of the item

@return Cart object containing added item.

@raise App42Exception

# File lib/shopping/CartService.rb, line 162
def add_item(cartID, itemID, itemQuantity, price)
  puts "Add Item Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartID, "CartID");
  util.throwExceptionIfNullOrBlank(itemID, "ItemID");
  util.throwExceptionIfNullOrBlank(itemQuantity, "ItemQuantity");
  util.throwExceptionIfNullOrBlank(price, "Price");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42'=>{
      "cart"=>{
      "cartId"=>cartID,
      "item"=>{
      "quantity"=>itemQuantity,
      "amount"=>price
      }
      }
      }}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    puts params
    params.store("body", body)
    params.store("itemId", itemID)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/item/#{itemID}"
    response = connection.post(signature, resource_url, query_params, body)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
check_out(cartId) click to toggle source

Checks out the Cart and put it in CheckOut Stage and returns the Transaction Id The transaction id has to be used in future to update the Payment Status.

@param cartID

- The cart id that has to be checkedout

@return Cart object containing Checked Out Cart Information with the Transaction Id

@raise App42Exception

# File lib/shopping/CartService.rb, line 445
def check_out(cartId)
  puts "Check Out Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"cart"=> {
      "cartId" => cartId,
      }}}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("body", body)
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/checkOut"
    response = connection.put(signature, resource_url, query_params, body)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
create_cart(user) click to toggle source

Creates a Cart Session for the specified User

@param user

- User for whom Cart Session has to be created

@return Cart Object containing Cart Id with Creation Time. The id has to be used in subsequent calls for adding and checking out

@raise App42Exception

# File lib/shopping/CartService.rb, line 60
def create_cart(user)
  puts "Create Cart Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(user, "User");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"cart"=> {
      "userName" => user,
      }}}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("body", body)
    puts params
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}"
    response = connection.post(signature, resource_url, query_params, body)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
decrease_quantity(cartId, itemId, itemQuantity) click to toggle source

To decrease quantity of existing item in the cart.

@return Cart object containing updated item.

@raise App42Exception

# File lib/shopping/CartService.rb, line 859
def decrease_quantity(cartId, itemId, itemQuantity)
  puts "Decrease Quantity Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  util.throwExceptionIfNullOrBlank(itemId, "ItemId");
  util.throwExceptionIfNullOrBlank(itemQuantity, "ItemQuantity");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"cart"=> {
      "cartId" => cartId,
      "itemId" => itemId,
      "quantity" => itemQuantity
      }}}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    puts params
    params.store("body", body)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/decreaseQuantity"
    response = connection.put(signature, resource_url, query_params,body)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
get_cart_details(cartId) click to toggle source

Fetch Cart details. Can be used by the App developer to display Cart Details i.e. Items in a Cart.

@param cartId

- The Cart Id that has to be fetched

@return Cart object containing cart details with all the items which are in it. It also tells the state of the Cart

@raise App42Exception

# File lib/shopping/CartService.rb, line 109
def get_cart_details(cartId)
  puts "Get Cart Details Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    puts params
    params.store("cartId", cartId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/#{cartId}/details"
    response = connection.get(signature, resource_url, query_params)
    puts "Response is #{response}"
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
get_item(cartId, itemId) click to toggle source

Fetches the specified Item from the specified Cart

@param cartId

- The cart id from which item has to be fetched

@param itemId

- The item for which the information has to be fetched

@return Cart Object

@raise App42Exception

# File lib/shopping/CartService.rb, line 265
def get_item(cartId, itemId)
  puts "Get Item Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  util.throwExceptionIfNullOrBlank(itemId, "ItemId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("cartId", cartId)
    params.store("itemId", itemId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/#{cartId}/#{itemId}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
get_items(cartId) click to toggle source

Fetches the Items from the specified Cart

@param cartId

- The cart id from which items have to be fetched

@return Cart object which contains all items in the cart

@raise App42Exception

# File lib/shopping/CartService.rb, line 220
def get_items(cartId)
  puts "Get Items Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("cartId", cartId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/#{cartId}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
get_payment_by_cart(cartId) click to toggle source

Fetches Payment information for the specified Cart Id

@param cartID

- Cart Id for which the payment information has to be fetched

@return Cart object which contains Payment History for the specified Cart

@raise App42Exception

# File lib/shopping/CartService.rb, line 594
def get_payment_by_cart(cartId)
  puts "Get Payments By Cart Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("cartId", cartId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payments/cart/#{cartId}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
get_payment_history_all() click to toggle source

History of all carts. It gives all the carts which are in AUTHORIZED, DECLINED, PENDING state.

@return ArrayList containing Cart objects. Payment history can be retrieved from individual Cart object.

@raise App42Exception

# File lib/shopping/CartService.rb, line 773
def get_payment_history_all()
  puts "Get Payment History By User Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartList = nil;
  cartList = Array.new
  util = Util.new
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payment/history"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartList = cart.buildArrayResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartList
end
get_payment_history_by_user(userId) click to toggle source

History of Carts and Payments for a User. It gives all the carts which are in AUTHORIZED, DECLINED, PENDING state.

@param userId

- User Id for whom payment history has to be fetched

@return ArrayList containing Cart objects. Payment history can be retrieved from individual Cart object.

@raise App42Exception

# File lib/shopping/CartService.rb, line 733
def get_payment_history_by_user(userId)
  puts "Get Payment History By User Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartList = nil;
  cartList = Array.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(userId, "UserId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("userId", userId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payment/history/#{userId}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartList = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartList
end
get_payments_by_status(paymentStatus) click to toggle source

Fetches Payment information based on Status

@param paymentStatus

- Status of type which payment information has to be fetched

@return ArrayList containing Cart objects. Payment history can be retrieved from individual Cart object.

@raise App42Exception

# File lib/shopping/CartService.rb, line 686
def get_payments_by_status(paymentStatus)
  puts "Get Payments By Status Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartList = nil;
  cartList = Array.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(paymentStatus, "paymentStatus");
  begin
    if (PaymentStatus.new.isAvailable(paymentStatus) == nil)
      raise App42NotFoundException.new("Payment Status #{paymentStatus} does not Exist ");
    end
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new

    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("status", paymentStatus)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payments/status/#{paymentStatus}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartList = cart.buildArrayResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartList
end
get_payments_by_user(userId) click to toggle source

Fetches Payment information for a User. This can be used to display Order and Payment History

@param userId

- User Id for whom payment information has to be fetched

@return ArrayList containing Cart objects. Payment history can be retrieved from individual Cart object.

@raise App42Exception

# File lib/shopping/CartService.rb, line 550
def get_payments_by_user(userId)
  puts "Is Empty Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartList = nil;
  cartList = Array.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(userId, "UserId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
      'userId' => userId
    }
    query_params = params.clone
    params.store("userId", userId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payments/user/#{userId}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartList = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartList
end
get_payments_by_user_and_status(userId, paymentStatus) click to toggle source

Fetches Payment information based on User Id and Status

@param userId

- User Id for whom payment information has to be fetched

@return ArrayList containing Cart objects. Payment history can be retrieved from individual Cart object. @return Payment History

@raise App42Exception

# File lib/shopping/CartService.rb, line 638
def get_payments_by_user_and_status(userId, paymentStatus)
  puts "Get Payments By User and Status Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartList = nil;
  cartList = Array.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(userId, "UserId");
  util.throwExceptionIfNullOrBlank(paymentStatus, "paymentStatus");
  begin
    if (PaymentStatus.new.isAvailable(paymentStatus) == nil)
      raise App42NotFoundException.new("Payment Status #{paymentStatus} does not Exist ");
    end
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("userId", userId)
    params.store("status", paymentStatus)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payments/user/#{userId}/#{paymentStatus}"
    response = connection.get(signature, resource_url, query_params)
    cart = CartResponseBuilder.new
    cartList = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartList
end
increase_quantity(cartID, itemID, itemQuantity) click to toggle source

To increase quantity of existing item in the cart.

@return Cart object containing updated item.

@raise App42Exception

# File lib/shopping/CartService.rb, line 811
def increase_quantity(cartID, itemID, itemQuantity)
  puts "Increase Quantity Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartID, "Cart Id");
  util.throwExceptionIfNullOrBlank(itemID, "Item Id");
  util.throwExceptionIfNullOrBlank(itemQuantity, "Quantity");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"cart"=> {
      "cartId" => cartID,
      "itemId" => itemID,
      "quantity" => itemQuantity
      }}}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("body", body)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/increaseQuantity"
    response = connection.put(signature, resource_url, query_params, body)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
is_empty(cartId) click to toggle source

Checks whether the Cart is Empty or not

@param cartId

- The cart id to check for empty

@return Cart object (isEmpty method on Cart object can be used to check status)

@raise App42Exception

# File lib/shopping/CartService.rb, line 398
def is_empty(cartId)
  puts "Is Empty Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  cartStatus = false;
  util.throwExceptionIfNullOrBlank(cartId, "cartId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("cartId", cartId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/#{cartId}/isEmpty"
    response = connection.get(signature, resource_url, query_params)
    puts "Response is #{response}"
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
    cartStatus = cartObj.isEmpty()
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartStatus
end
payment(cartId, transactionID, paymentStatus) click to toggle source

Update Payment Status of the Cart. When a Cart is checkout, it is in Checkout state. The payment status has to be updated based on the Payment Gateway interaction

@param cartID

- The cart id for which the payment status has to be updated

@param transactionID

- Transaction id for which the payment status has to be updated

@param paymentStatus

- Payment Status to be updated. The probable values are PaymentStatus.DECLINED, PaymentStatus.AUTHORIZED, PaymentStatus.PENDING

@return Cart object which contains Payment Status

@raise App42Exception

# File lib/shopping/CartService.rb, line 496
def payment(cartId, transactionID, paymentStatus)
  puts "Is Empty Called "
  puts "Base url #{@base_url}"
  response = nil;
  cartObj = nil;
  cartObj = Cart.new
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  util.throwExceptionIfNullOrBlank(transactionID, "TransactionID");
  util.throwExceptionIfNullOrBlank(paymentStatus, "paymentStatus");
  begin
    if (PaymentStatus.new.isAvailable(paymentStatus) == nil)
      raise App42NotFoundException.new("Payment Status #{paymentStatus} does not Exist ");
    end
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"cart"=> {
      "cartId" => cartId,
      "transactionId" => transactionID,
      "status" => paymentStatus,
      }}}.to_json
    puts "Body #{body}"
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("body", body)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/payment"
    response = connection.put(signature, resource_url, query_params, body)
    cart = CartResponseBuilder.new
    cartObj = cart.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return cartObj
end
remove_all_items(cartId) click to toggle source

Removes all Items from the specified Cart

@param cartId

- The cart id from which items have to be removed

@return App42Response if removed successfully

@raise App42Exception

# File lib/shopping/CartService.rb, line 356
def remove_all_items(cartId)
  puts "Remove All Item Called "
  puts "Base url #{@base_url}"
  response = nil;
  responseObj = App42Response.new();
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("cartId", cartId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/#{cartId}"
    response = connection.delete(signature, resource_url, query_params)
    responseObj.strResponse=(response)
    responseObj.isResponseSuccess=(true)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return responseObj
end
remove_item(cartId, itemId) click to toggle source

Removes the specified item from the specified Cart

@param cartId

- The cart id from which the item has to be removed

@param itemId

- Id of the Item which has to be removed

@return App42Response if removed successfully

@raise App42Exception

# File lib/shopping/CartService.rb, line 312
def remove_item(cartId, itemId)
  puts "Remove Item Called "
  puts "Base url #{@base_url}"
  response = nil;
  responseObj = App42Response.new();
  util = Util.new
  util.throwExceptionIfNullOrBlank(cartId, "CartId");
  util.throwExceptionIfNullOrBlank(itemId, "ItemId");
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = Hash.new
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("cartId", cartId)
    params.store("itemId", itemId)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/#{cartId}/#{itemId}"
    response = connection.delete(signature, resource_url, query_params)
    responseObj.strResponse=(response)
    responseObj.isResponseSuccess=(true)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return responseObj
end