UNPKG

baasic-sdk-javascript

Version:

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

104 lines (103 loc) 5.3 kB
"use strict"; /* globals module */ /** * @module commerceRoute * @description Baasic Commerce Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Commerce Product Route Definition to obtain a 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 contracts_1 = require("../../core/contracts"); var CommerceRoute = /** @class */ (function (_super) { tslib_1.__extends(CommerceRoute, _super); function CommerceRoute(appOptions) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.findRoute = 'commerce/subscriptions/{?customerId,systemName,searchQuery,plan,statuses,productId,firstName,lastName,page,rpp,sort,embed,fields}'; _this.getRoute = 'commerce/subscriptions/{id}/{?embed,fields}'; _this.validateVATRoute = 'commerce/vat-validations/{?countryCode,vatId}'; _this.preprocessRoute = 'commerce/subscriptions/preprocess'; _this.subscribeRoute = 'commerce/subscriptions'; _this.cancelRoute = 'commerce/subscriptions/{systemName}/{id}/{?requestRefund,refundAmount}'; return _this; } /** * Parses find commerce route which can be expanded with additional options. Supported items are: * - `customerId` - The customer identifier. * - `systemName` - The commerce payment gateway system name. * - `searchQuery` - A string value used to identify commerce resources using the phrase search. * - `plan` - Product name. * - `statuses` - Subscription status unique identifier or abbreviation in CSV format. * - `productId` - Product unique identifier. * - `firstName` - Customer first name. * - `lastName` - Customer last name. * - `page` - A value used to set the page number, i.e. to retrieve certain commerce subset from the storage. * - `rpp` - A value used to limit the size of result set per page. * - `sort` - A string used to set the commerce property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @example commerceRoute.find({searchQuery: '<search-phrase>'}); **/ CommerceRoute.prototype.find = function (options) { return _super.prototype.baseFind.call(this, this.findRoute, options); }; /** * Parses get route; this route doesn't expose any properties. * @method * @example commerceRoute.get(id, options); **/ CommerceRoute.prototype.get = function (id, options) { return _super.prototype.baseGet.call(this, this.getRoute, id, options); }; /** * Parses validate VAT route; this route doesn't expose any properties. * @method * @example commerceRoute.validateVAT({ countryCode: 'DE', vatId: 'DE999999999' }); **/ CommerceRoute.prototype.validateVAT = function (countryCode, vatId) { return _super.prototype.baseCreate.call(this, this.validateVATRoute, { countryCode: countryCode, vatId: vatId }); }; /** * Parses subscription pre-process commerce route; this URI template does not expose any additional options. * @method * @example commerceRoute.preprocess(); **/ CommerceRoute.prototype.preprocess = function () { return _super.prototype.baseCreate.call(this, this.preprocessRoute, {}); }; /** * Parses subscription commerce route; this URI template does not expose any additional options. * @method * @example commerceRoute.subscribe(); **/ CommerceRoute.prototype.subscribe = function () { return _super.prototype.baseCreate.call(this, this.subscribeRoute, {}); }; /** * Parses cancel subscription commerce route; this URI template does not expose any additional options. * @method * @example commerceRoute.cancel({ systemName: '<system-name>' }); **/ CommerceRoute.prototype.cancel = function (data) { return _super.prototype.baseCreate.call(this, this.cancelRoute, data); }; CommerceRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [Object]) ], CommerceRoute); return CommerceRoute; }(common_1.BaseRoute)); exports.CommerceRoute = CommerceRoute; /** * @copyright (c) 2017 Mono Ltd * @license MIT * @author Mono Ltd * @overview ***Notes:** - Refer to the [Baasic REST API](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. */