UNPKG

baasic-sdk-javascript

Version:

JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).

117 lines (116 loc) 6.06 kB
"use strict"; /* globals module */ /** * @module ShoppingCartItemRoute * @description Baasic Shopping Cart Item Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use BaasicShopping Cart Item Route Service to obtain needed routes while other routes will be obtained through HAL. By convention, all route services use the same function names as their corresponding services. */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var inversify_1 = require("inversify"); var common_1 = require("../../common"); ; var _1 = require("./"); var contracts_1 = require("../../core/contracts"); var ShoppingCartItemRoute = /** @class */ (function (_super) { tslib_1.__extends(ShoppingCartItemRoute, _super); function ShoppingCartItemRoute(appOptions, shoppingCartItemBatchRoute) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.shoppingCartItemBatchRoute = shoppingCartItemBatchRoute; _this.findRoute = 'commerce/carts/items/{?searchQuery,userId,ids,from,to,page,rpp,sort,embed,fields}'; _this.findByUserIdRoute = 'commerce/carts/users/{userId}/products/{?page,rpp,sort,embed,fields}'; _this.getRoute = 'commerce/carts/items/{id}/{?embed,fields}'; _this.getbyUserIdAndProductIdRoute = 'commerce/carts/users/{userId}/products/{productId}/{?embed,fields}'; _this.updateRoute = 'commerce/carts/items/{id}'; _this.updateByUserIdAndProductIdRoute = 'commerce/carts/users/{userId}/products/{productId}'; _this.deleteRoute = 'commerce/carts/items/{id}'; _this.deleteByUserIdAndProductIdRoute = 'commerce/carts/users/{userId}/products/{productId}'; _this.deleteByUserIdRoute = 'commerce/carts/users/{userId}/empty'; _this.createRoute = 'commerce/carts/items'; _this.createByUserIdAndProductIdRoute = 'commerce/carts/users/{userId}/products/{productId}'; _this.purgeRoute = 'commerce/carts/purge'; return _this; } Object.defineProperty(ShoppingCartItemRoute.prototype, "batch", { get: function () { return this.shoppingCartItemBatchRoute; }, enumerable: true, configurable: true }); /** * Parses delete route; this route should be expanded with the Id of shopping cart item resource. * @method * @param id Shopping Cart Id of specific Shopping Cart item resource in the system. * @example shoppingCartItemRoute.delete(<id>); **/ ShoppingCartItemRoute.prototype.delete = function (id) { return _super.prototype.baseDelete.call(this, this.deleteRoute, id); }; /** * Parses delete route; this route should be expanded with the Id of shopping cart item resource. * @method * @param userId User Id of the User resource that the Shopping Cart resource in the system bellongs to. * @param productId Product Id of the Product resource that the Shopping Cart resource in the system is linked to. * @example shoppingCartItemRoute.delete(<user-id>, <product-id>); **/ ShoppingCartItemRoute.prototype.deleteByUserIdAndProductId = function (userId, productId) { var data = { userId: userId, productId: productId }; return _super.prototype.baseDelete.call(this, this.deleteByUserIdAndProductIdRoute, data); }; /** * Parses delete route; this route should be expanded with the userId. * @method * @param userId User Id of the User resource that the Shopping Cart resource in the system bellongs to. * @example shoppingCartItemRoute.deleteByUserId(<user-id>); **/ ShoppingCartItemRoute.prototype.deleteByUserId = function (userId) { var data = { userId: userId }; return _super.prototype.baseDelete.call(this, this.deleteByUserIdRoute, data); }; /** * Parses create route; this URI template doesnt support any additional options. * @method * @example shoppingCartItemRoute.create(); **/ ShoppingCartItemRoute.prototype.create = function () { return _super.prototype.baseCreate.call(this, this.createRoute, {}); }; /** * Parses create route; this URI template doesnt support any additional options. * @method * @param data An shopping cart item object that needs to be inserted into the system. * @example shoppingCartItemRoute.create(data); **/ ShoppingCartItemRoute.prototype.createByUserIdAndProductId = function (data) { return _super.prototype.baseCreate.call(this, this.createByUserIdAndProductIdRoute, data); }; /** * Parses purge route; this URI template does not expose any additional options. * @method * @example shoppingCartItemRoute.purge(); **/ ShoppingCartItemRoute.prototype.purge = function () { return _super.prototype.baseDelete.call(this, this.purgeRoute, {}); }; ShoppingCartItemRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__param(1, inversify_1.inject(_1.TYPES.ShoppingCartItemBatchRoute)), tslib_1.__metadata("design:paramtypes", [Object, _1.ShoppingCartItemBatchRoute]) ], ShoppingCartItemRoute); return ShoppingCartItemRoute; }(common_1.BaseRoute)); exports.ShoppingCartItemRoute = ShoppingCartItemRoute; /** * @overview ***Notes:** - Refer to the [REST API documentation](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points. - [URI Template](https://github.com/Baasic/uritemplate-js) syntax enables expanding the Baasic route templates to Baasic REST URIs providing it with an object that contains URI parameters. - All end-point objects are transformed by the associated route service. */