Class: App42::Shopping::CartService
- Inherits:
-
Object
- Object
- App42::Shopping::CartService
- Defined in:
- lib/shopping/CartService.rb
Overview
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
Instance Method Summary collapse
-
#add_item(cartID, itemID, itemQuantity, price) ⇒ Object
Adds an Item in the Cart with quantity and price.
-
#check_out(cartId) ⇒ Object
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.
-
#create_cart(user) ⇒ Object
Creates a Cart Session for the specified User.
-
#decrease_quantity(cartId, itemId, itemQuantity) ⇒ Object
To decrease quantity of existing item in the cart.
-
#get_cart_details(cartId) ⇒ Object
Fetch Cart details.
-
#get_item(cartId, itemId) ⇒ Object
Fetches the specified Item from the specified Cart.
-
#get_items(cartId) ⇒ Object
Fetches the Items from the specified Cart.
-
#get_payment_by_cart(cartId) ⇒ Object
Fetches Payment information for the specified Cart Id.
-
#get_payment_history_all ⇒ Object
History of all carts.
-
#get_payment_history_by_user(userId) ⇒ Object
History of Carts and Payments for a User.
-
#get_payments_by_status(paymentStatus) ⇒ Object
Fetches Payment information based on Status.
-
#get_payments_by_user(userId) ⇒ Object
Fetches Payment information for a User.
-
#get_payments_by_user_and_status(userId, paymentStatus) ⇒ Object
Fetches Payment information based on User Id and Status.
-
#increase_quantity(cartID, itemID, itemQuantity) ⇒ Object
To increase quantity of existing item in the cart.
-
#initialize(api_key, secret_key, base_url) ⇒ CartService
constructor
this is a constructor that takes.
-
#is_empty(cartId) ⇒ Object
Checks whether the Cart is Empty or not.
-
#payment(cartId, transactionID, paymentStatus) ⇒ Object
Update Payment Status of the Cart.
-
#remove_all_items(cartId) ⇒ Object
Removes all Items from the specified Cart.
-
#remove_item(cartId, itemId) ⇒ Object
Removes the specified item from the specified Cart.
Constructor Details
#initialize(api_key, secret_key, base_url) ⇒ CartService
this is a constructor that takes
39 40 41 42 43 44 45 46 |
# 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 |
Instance Method Details
#add_item(cartID, itemID, itemQuantity, price) ⇒ Object
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.
with the Cart Service then the Item ids should be same.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# 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., } 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) ⇒ Object
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.
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# 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., } 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) ⇒ Object
Creates a Cart Session for the specified User
adding and checking out
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# 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., } 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) ⇒ Object
To decrease quantity of existing item in the cart.
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
# 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., } 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) ⇒ Object
Fetch Cart details. Can be used by the App developer to display Cart Details i.e. Items in a Cart.
the Cart
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# 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., } 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) ⇒ Object
Fetches the specified Item from the specified Cart
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# 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., } 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) ⇒ Object
Fetches the Items from the specified Cart
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# 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., } 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) ⇒ Object
Fetches Payment information for the specified Cart Id
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# 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., } 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 ⇒ Object
History of all carts. It gives all the carts which are in AUTHORIZED, DECLINED, PENDING state.
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
# 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., } 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) ⇒ Object
History of Carts and Payments for a User. It gives all the carts which are in AUTHORIZED, DECLINED, PENDING state.
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
# 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., } 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) ⇒ Object
Fetches Payment information based on Status
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# 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., } 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) ⇒ Object
Fetches Payment information for a User. This can be used to display Order and Payment History
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# 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., '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) ⇒ Object
Fetches Payment information based on User Id and Status
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 |
# 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., } 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) ⇒ Object
To increase quantity of existing item in the cart.
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
# 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., } 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) ⇒ Object
Checks whether the Cart is Empty or not
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# 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., } 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) ⇒ Object
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
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# 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., } 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) ⇒ Object
Removes all Items from the specified Cart
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# 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., } 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) ⇒ Object
Removes the specified item from the specified Cart
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# 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., } 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 |