From 0bc952ba62509b9cd8cf676eba9e5270bbc4972d Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Thu, 20 Feb 2020 13:14:17 +0530 Subject: [PATCH 01/14] Added user redemptions related API calls. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ lib/validate.js | 19 ++++++++++++++++++- services/users.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d44ea7..18c9503 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,21 @@ The preferred way to install the OST JavaScript SDK is to use the npm package ma .catch(function(err) { console.log(JSON.stringify(err)); }); ``` +* Get User redemption detail using the userId and redemptionId. + + ```js + // Mandatory API parameters + + // UserId of user for whom user details needs to be fetched. + let userId = 'c2c__'; + // RedemptionId of user for whom redemption details needs to be fetched. + let redemptionId = 'c2c__'; + + usersService.getUserRedemption({ user_id: userId, redemption_id: redemptionId }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + * Get Users List. Pagination is supported by this API. ```js @@ -121,6 +136,30 @@ The preferred way to install the OST JavaScript SDK is to use the npm package ma .then(function(res) { console.log(JSON.stringify(res)); }) .catch(function(err) { console.log(JSON.stringify(err)); }); ``` + +* Get Users Redemptions List. Pagination is supported by this API. + + ```js + // Mandatory API parameters + + // UserId of user for whom redemption details needs to be fetched. + let userId = 'c2c__'; + + // Optional API parameters + + // Pagination identifier from the previous API call response. Not needed for page one. + let paginationIdentifier = 'e77y___'; + + // Limit. + let limit = 10; + + // Status of redemption. + let status = 'FULFILLED'; + + usersService.getRedemptions({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, status: status }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` ### Devices Module diff --git a/lib/validate.js b/lib/validate.js index 81e58ab..bb277c5 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -71,6 +71,23 @@ ValidateKlass.prototype = { } }, + /** + * Get redemption uid from params. + * + * @param {object} params + * @param {string} params.redemption_id + */ + getRedemptionId: function (params) { + const oThis = this; + if (oThis.isValid(params.redemption_id)) { + let redemption_id = params.redemption_id; + delete params.redemption_id; + return redemption_id + } else { + throw new Error('redemption_id missing or invalid in request params.'); + } + }, + /** * Get webhook id from params. @@ -170,4 +187,4 @@ ValidateKlass.prototype = { }; -module.exports = new ValidateKlass(); \ No newline at end of file +module.exports = new ValidateKlass(); diff --git a/services/users.js b/services/users.js index 71cb6ae..db8bf6a 100644 --- a/services/users.js +++ b/services/users.js @@ -26,6 +26,7 @@ const users = function (requestObj) { // Define the url prefix oThis.urlPrefix = '/users'; + oThis.redemptionsUrlPrefix = '/redemptions'; return oThis; }; @@ -71,6 +72,36 @@ users.prototype = { params = params || {}; return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params), params); + }, + + /** + * Get user redemptions list. + * + * @param {object} params + * + * @returns {*} + */ + getRedemptions: function(params) { + const oThis = this; + + params = params || {}; + + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix, params); + }, + + /** + * Get user redemption by redemption id. + * + * @param {object} params + * + * @returns {*} + */ + getUserRedemption: function(params) { + const oThis = this; + + params = params || {}; + + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix + validate.getRedemptionId(params), params); } }; From 021406e071ca4637af50b8b163bd00ffe97454c8 Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Thu, 20 Feb 2020 13:23:46 +0530 Subject: [PATCH 02/14] Created new service for user redemptions. --- README.md | 86 ++++++++++++++++++++++------------------- services/manifest.js | 8 +++- services/redemptions.js | 67 ++++++++++++++++++++++++++++++++ services/users.js | 31 --------------- 4 files changed, 120 insertions(+), 72 deletions(-) create mode 100644 services/redemptions.js diff --git a/README.md b/README.md index 18c9503..15b8183 100644 --- a/README.md +++ b/README.md @@ -100,21 +100,6 @@ The preferred way to install the OST JavaScript SDK is to use the npm package ma .catch(function(err) { console.log(JSON.stringify(err)); }); ``` -* Get User redemption detail using the userId and redemptionId. - - ```js - // Mandatory API parameters - - // UserId of user for whom user details needs to be fetched. - let userId = 'c2c__'; - // RedemptionId of user for whom redemption details needs to be fetched. - let redemptionId = 'c2c__'; - - usersService.getUserRedemption({ user_id: userId, redemption_id: redemptionId }) - .then(function(res) { console.log(JSON.stringify(res)); }) - .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` - * Get Users List. Pagination is supported by this API. ```js @@ -137,30 +122,6 @@ The preferred way to install the OST JavaScript SDK is to use the npm package ma .catch(function(err) { console.log(JSON.stringify(err)); }); ``` -* Get Users Redemptions List. Pagination is supported by this API. - - ```js - // Mandatory API parameters - - // UserId of user for whom redemption details needs to be fetched. - let userId = 'c2c__'; - - // Optional API parameters - - // Pagination identifier from the previous API call response. Not needed for page one. - let paginationIdentifier = 'e77y___'; - - // Limit. - let limit = 10; - - // Status of redemption. - let status = 'FULFILLED'; - - usersService.getRedemptions({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, status: status }) - .then(function(res) { console.log(JSON.stringify(res)); }) - .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` - ### Devices Module * Initialize Devices service object to perform device specific actions. @@ -776,3 +737,50 @@ For executing transactions, you need to understand the 4 modules described below let resp = webhooksService.verifySignature(version, stringifiedData,requestTimestamp, signature, webhookSecret); console.log(resp); ``` + +### Redemptions Module + +* Initialize Redemptions service object to perform user redemption specific actions. + + ```js + const redemptionsService = ostObj.services.redemptions; + ``` + +* Get User redemption detail using the userId and redemptionId. + + ```js + // Mandatory API parameters + + // UserId of user for whom user details needs to be fetched. + let userId = 'c2c__'; + // RedemptionId of user for whom redemption details needs to be fetched. + let redemptionId = 'c2c__'; + + redemptionsService.get({ user_id: userId, redemption_id: redemptionId }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + +* Get Users Redemptions List. Pagination is supported by this API. + + ```js + // Mandatory API parameters + + // UserId of user for whom redemption details needs to be fetched. + let userId = 'c2c__'; + + // Optional API parameters + + // Pagination identifier from the previous API call response. Not needed for page one. + let paginationIdentifier = 'e77y___'; + + // Limit. + let limit = 10; + + // Status of redemption. + let status = 'FULFILLED'; + + redemptionsService.getList({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, status: status }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` diff --git a/services/manifest.js b/services/manifest.js index 168384e..670a716 100644 --- a/services/manifest.js +++ b/services/manifest.js @@ -21,6 +21,7 @@ const rootPrefix = ".." , transactionsKlass = require(rootPrefix + '/services/transactions') , baseTokensKlass = require(rootPrefix + '/services/base_tokens') , webhooksKlass = require(rootPrefix + '/services/webhooks') + , redemptionsKlass = require(rootPrefix + '/services/redemptions') ; // hide request object @@ -51,6 +52,7 @@ const manifest = function (params) { oThis.transactions = new transactionsKlass(_requestObj); oThis.base_tokens = new baseTokensKlass(_requestObj); oThis.webhooks = new webhooksKlass(_requestObj); + oThis.redemptions = new redemptionsKlass(_requestObj); return oThis; }; @@ -81,7 +83,9 @@ manifest.prototype = { base_tokens: null, - webhooks: null + webhooks: null, + + redemptions: null, }; -module.exports = manifest; \ No newline at end of file +module.exports = manifest; diff --git a/services/redemptions.js b/services/redemptions.js new file mode 100644 index 0000000..d5c95c6 --- /dev/null +++ b/services/redemptions.js @@ -0,0 +1,67 @@ +"use strict"; + +/** + * Redemptions Service + * + * @module services/redemptions + */ + +const rootPrefix = ".." + , validate = require(rootPrefix + '/lib/validate') +; + +// hide request object +var _requestObj = null; + +/** + * Redemptions Service constructor + * + * @constructor + */ +const redemptions = function (requestObj) { + const oThis = this; + + // Assign request object + _requestObj = requestObj; + + // Define the url prefix + oThis.urlPrefix = '/users'; + oThis.redemptionsUrlPrefix = '/redemptions'; + + return oThis; +}; + +redemptions.prototype = { + /** + * Get user redemptions list. + * + * @param {object} params + * + * @returns {*} + */ + getList: function(params) { + const oThis = this; + + params = params || {}; + + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix, params); + }, + + /** + * Get user redemption by redemption id. + * + * @param {object} params + * + * @returns {*} + */ + get: function(params) { + const oThis = this; + + params = params || {}; + + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix + validate.getRedemptionId(params), params); + } + +}; + +module.exports = redemptions; diff --git a/services/users.js b/services/users.js index db8bf6a..179d1cc 100644 --- a/services/users.js +++ b/services/users.js @@ -72,38 +72,7 @@ users.prototype = { params = params || {}; return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params), params); - }, - - /** - * Get user redemptions list. - * - * @param {object} params - * - * @returns {*} - */ - getRedemptions: function(params) { - const oThis = this; - - params = params || {}; - - return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix, params); - }, - - /** - * Get user redemption by redemption id. - * - * @param {object} params - * - * @returns {*} - */ - getUserRedemption: function(params) { - const oThis = this; - - params = params || {}; - - return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix + validate.getRedemptionId(params), params); } - }; module.exports = users; From 3e3179a5ec00b72a2efe7b5bce9e857570f95932 Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 13:02:55 +0530 Subject: [PATCH 03/14] Bug fix. --- services/redemptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/redemptions.js b/services/redemptions.js index d5c95c6..a2a610d 100644 --- a/services/redemptions.js +++ b/services/redemptions.js @@ -44,7 +44,7 @@ redemptions.prototype = { params = params || {}; - return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix, params); + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + oThis.redemptionsUrlPrefix, params); }, /** @@ -59,7 +59,7 @@ redemptions.prototype = { params = params || {}; - return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + "/" + oThis.redemptionsUrlPrefix + validate.getRedemptionId(params), params); + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + oThis.redemptionsUrlPrefix + validate.getRedemptionId(params), params); } }; From 78f0a50fddda745ac8d97cbc3884f1bf40c1acc8 Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 15:39:39 +0530 Subject: [PATCH 04/14] Bug fix. --- services/redemptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/redemptions.js b/services/redemptions.js index a2a610d..61ea8c3 100644 --- a/services/redemptions.js +++ b/services/redemptions.js @@ -59,7 +59,7 @@ redemptions.prototype = { params = params || {}; - return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + oThis.redemptionsUrlPrefix + validate.getRedemptionId(params), params); + return _requestObj.get(oThis.urlPrefix + "/" + validate.getUserId(params) + oThis.redemptionsUrlPrefix + '/' + validate.getRedemptionId(params), params); } }; From 29215888a7bedd56467b045c5c2aafc039a7de9d Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 16:47:45 +0530 Subject: [PATCH 05/14] Added support for redeemable SKU ids. --- README.md | 48 +++++++++++++++++++++++++-- lib/validate.js | 17 ++++++++++ services/manifest.js | 4 +++ services/redeemable_skus.js | 66 +++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 services/redeemable_skus.js diff --git a/README.md b/README.md index 15b8183..66ae802 100644 --- a/README.md +++ b/README.md @@ -777,10 +777,52 @@ For executing transactions, you need to understand the 4 modules described below // Limit. let limit = 10; - // Status of redemption. - let status = 'FULFILLED'; + // Array of user redemption uuids. + let userRedemptionUuids = ['13518427-e6d1-46f7-9e3e-dd726ad37a69']; - redemptionsService.getList({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, status: status }) + redemptionsService.getList({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, user_redemption_uuids: userRedemptionUuids }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + + +### Redeemable SKUs Module + +* Initialize Redeemable Skus service object to perform user redemption specific actions. + + ```js + const redeemableSkusService = ostObj.services.redeemable_skus; + ``` + +* Get Redeemable SKU detail using the redeemable SKU id. + + ```js + // Mandatory API parameters + + // RedeemableSkuId of product for whom details needs to be fetched. + let redeemableSkuId = 'c2c__'; + + redeemableSkusService.get({ redeemable_sku_id: redeemableSkuId }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + +* Get Redeemable SKUs List. Pagination is supported by this API. + + ```js + // Mandatory API parameters + // Optional API parameters + + // Pagination identifier from the previous API call response. Not needed for page one. + let paginationIdentifier = 'e77y___'; + + // Limit. + let limit = 10; + + // Array of redeemable SKU ids. + let ids = ['1', '2']; + + redeemableSkusService.getList({limit: limit, pagination_identifier: paginationIdentifier, ids: ids }) .then(function(res) { console.log(JSON.stringify(res)); }) .catch(function(err) { console.log(JSON.stringify(err)); }); ``` diff --git a/lib/validate.js b/lib/validate.js index bb277c5..03dea57 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -71,6 +71,23 @@ ValidateKlass.prototype = { } }, + /** + * Get redeemable sku id from params. + * + * @param {object} params + * @param {string} params.redeemable_sku_id + */ + getRedeemableSkuId: function (params) { + const oThis = this; + if (oThis.isValid(params.redeemable_sku_id)) { + var redeemableSkuId = params.redeemable_sku_id; + delete params.redeemable_sku_id; + return redeemableSkuId + } else { + throw new Error('redeemable_sku_id missing or invalid in request params'); + } + }, + /** * Get redemption uid from params. * diff --git a/services/manifest.js b/services/manifest.js index 670a716..2ed0930 100644 --- a/services/manifest.js +++ b/services/manifest.js @@ -22,6 +22,7 @@ const rootPrefix = ".." , baseTokensKlass = require(rootPrefix + '/services/base_tokens') , webhooksKlass = require(rootPrefix + '/services/webhooks') , redemptionsKlass = require(rootPrefix + '/services/redemptions') + , redeemableSkusKlass = require(rootPrefix + '/services/redeemable_skus') ; // hide request object @@ -53,6 +54,7 @@ const manifest = function (params) { oThis.base_tokens = new baseTokensKlass(_requestObj); oThis.webhooks = new webhooksKlass(_requestObj); oThis.redemptions = new redemptionsKlass(_requestObj); + oThis.redeemable_skus = new redeemableSkusKlass(_requestObj); return oThis; }; @@ -86,6 +88,8 @@ manifest.prototype = { webhooks: null, redemptions: null, + + redeemable_skus: null, }; module.exports = manifest; diff --git a/services/redeemable_skus.js b/services/redeemable_skus.js new file mode 100644 index 0000000..9d35bbe --- /dev/null +++ b/services/redeemable_skus.js @@ -0,0 +1,66 @@ +"use strict"; + +/** + * Redeemable SKUs Service + * + * @module services/redeemable_skus + */ + +const rootPrefix = ".." + , validate = require(rootPrefix + '/lib/validate') +; + +// hide request object +var _requestObj = null; + +/** + * Redeemable SKUs Service constructor. + * + * @constructor + */ +const redeemable_skus = function (requestObj) { + const oThis = this; + + // Assign request object. + _requestObj = requestObj; + + // Define the url prefix. + oThis.urlPrefix = '/redeemable-skus'; + + return oThis; +}; + +redeemable_skus.prototype = { + /** + * Get redeemable skus list. + * + * @param {object} params + * + * @returns {*} + */ + getList: function(params) { + const oThis = this; + + params = params || {}; + + return _requestObj.get(oThis.urlPrefix, params); + }, + + /** + * Get redeemable sku by redeemable sku id. + * + * @param {object} params + * + * @returns {*} + */ + get: function(params) { + const oThis = this; + + params = params || {}; + + return _requestObj.get(oThis.urlPrefix + "/" + validate.getRedeemableSkuId(params), params); + } + +}; + +module.exports = redeemable_skus; From f7ff53bdcfa721fa260f03d9710c1b728568e15d Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 17:02:51 +0530 Subject: [PATCH 06/14] Updated test cases for redemption related products. --- test/index.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/test/index.js b/test/index.js index 927e7a3..eebd438 100644 --- a/test/index.js +++ b/test/index.js @@ -34,6 +34,8 @@ const rootPrefix = "..", transactionsService = ostObj.services.transactions, baseTokensService = ostObj.services.base_tokens, webhooksService = ostObj.services.webhooks, + redemptionsService = ostObj.services.redemptions, + redeemableSkusService = ostObj.services.redeemable_skus, userId = process.env.OST_KIT_USER_ID, @@ -44,7 +46,9 @@ const rootPrefix = "..", sessionAddrs = process.env.OST_KIT_SESSION_ADDRESS, ruleAddress = process.env.OST_KIT_RULE_ADDRESS, user2TokenHolderAddress = process.env.OST_KIT_USER2_TOKEN_HOLDER_ADDRESS, - recoveryOwnerAddrs = process.env.OST_KIT_RECOVERY_OWNER_ADDRESS + recoveryOwnerAddress = process.env.OST_KIT_RECOVERY_OWNER_ADDRESS, + redemptionId = process.env.OST_KIT_USER_REDEMPTION_ID, + redeemableSkuId = process.env.OST_KIT_REDEEMABLE_SKU_ID ; let webhookId = null; @@ -227,7 +231,7 @@ function getRecoveryOwnerAddress() { it("test get recovery owners", async function () { let res = await recoveryOwnersService.get({ user_id: userId, - recovery_owner_address: recoveryOwnerAddrs //"0x4e9314f004026F89Fc52790c3357b2D34FBA93b0" + recovery_owner_address: recoveryOwnerAddress //"0x4e9314f004026F89Fc52790c3357b2D34FBA93b0" }).catch(function (err) { console.log(JSON.stringify(err)); assert.fail('get recovery owners'); @@ -373,6 +377,57 @@ function deleteWebhook() { }); } + +function getRedemption() { + it("Test get user redemption", async function () { + let res = await redemptionsService.get({ + user_id: userId, + redemption_id: redemptionId + }).catch(function (err) { + console.log(JSON.stringify(err)); + assert.fail('Get user redemption.'); + }); + assert.equal(res.success, true); + }); +} + + +function listRedemptions() { + it("Test list user redemptions", async function () { + let res = await redemptionsService.getList({ + user_id: userId, + redemption_id: redemptionId + }).catch(function (err) { + console.log(JSON.stringify(err)); + assert.fail('List user redemptions.'); + }); + assert.equal(res.success, true); + }); +} + +function getRedeemableSku() { + it("Test get redeemable SKU by id", async function () { + let res = await redeemableSkusService.get({ + redeemable_sku_id: redeemableSkuId + }).catch(function (err) { + console.log(JSON.stringify(err)); + assert.fail('Get redeemable SKU.'); + }); + assert.equal(res.success, true); + }); +} + +function listRedeemableSkus() { + it("Test list redeemable SKUs", async function () { + let res = await redeemableSkusService.getList({}).catch(function (err) { + console.log(JSON.stringify(err)); + assert.fail('List redeemable SKUs.'); + }); + assert.equal(res.success, true); + }); +} + + function testWebhookRequestSignature() { it ("Tests webhook request signature.", async function () { let version = "2", @@ -444,6 +499,10 @@ async function testcases() { await updateWebhook(); await deleteWebhook(); testWebhookRequestSignature(); + getRedemption(); + listRedemptions(); + getRedeemableSku(); + listRedeemableSkus() } testcases(); From 3720a309a5c01ec4759091fad8a0f4058d35da0c Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 17:18:34 +0530 Subject: [PATCH 07/14] Updated changelog. --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- package.json | 2 +- test/index.js | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 533581b..5ccc55c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +[OST Javascript SDK v2.2.3](https://github.com/ostdotcom/ost-sdk-js/tree/v2.2.3) +--- + +* Added redemptions module to call user redemptions management OST APIs. +* Added redeemable SKUs module to call redeemable SKUs OST APIs. + [OST Javascript SDK v2.2.2](https://github.com/ostdotcom/ost-sdk-js/tree/v2.2.2) --- diff --git a/VERSION b/VERSION index b1b25a5..5859406 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.2 +2.2.3 diff --git a/package.json b/package.json index 20f6872..18edad3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ostdotcom/ost-sdk-js", - "version": "2.2.2", + "version": "2.2.3", "description": "OST Platform SDK for JavaScript.", "main": "index.js", "scripts": { diff --git a/test/index.js b/test/index.js index eebd438..de48f80 100644 --- a/test/index.js +++ b/test/index.js @@ -47,7 +47,7 @@ const rootPrefix = "..", ruleAddress = process.env.OST_KIT_RULE_ADDRESS, user2TokenHolderAddress = process.env.OST_KIT_USER2_TOKEN_HOLDER_ADDRESS, recoveryOwnerAddress = process.env.OST_KIT_RECOVERY_OWNER_ADDRESS, - redemptionId = process.env.OST_KIT_USER_REDEMPTION_ID, + redemptionId = process.env.OST_KIT_REDEMPTION_ID, redeemableSkuId = process.env.OST_KIT_REDEEMABLE_SKU_ID ; From 4165d89b57063028e4f12dbfd6940b840fdb7f46 Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 18:05:54 +0530 Subject: [PATCH 08/14] Bug fix. --- test/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/index.js b/test/index.js index de48f80..9ea1911 100644 --- a/test/index.js +++ b/test/index.js @@ -395,8 +395,7 @@ function getRedemption() { function listRedemptions() { it("Test list user redemptions", async function () { let res = await redemptionsService.getList({ - user_id: userId, - redemption_id: redemptionId + user_id: userId }).catch(function (err) { console.log(JSON.stringify(err)); assert.fail('List user redemptions.'); From db923ec517309eef69815a2c8940095c0ad2992f Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Fri, 21 Feb 2020 19:06:11 +0530 Subject: [PATCH 09/14] Updated readme. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 66ae802..22bb52d 100644 --- a/README.md +++ b/README.md @@ -751,9 +751,9 @@ For executing transactions, you need to understand the 4 modules described below ```js // Mandatory API parameters - // UserId of user for whom user details needs to be fetched. + // UserId of user for whom redemption details needs to be fetched. let userId = 'c2c__'; - // RedemptionId of user for whom redemption details needs to be fetched. + // RedemptionId of user. let redemptionId = 'c2c__'; redemptionsService.get({ user_id: userId, redemption_id: redemptionId }) @@ -761,7 +761,7 @@ For executing transactions, you need to understand the 4 modules described below .catch(function(err) { console.log(JSON.stringify(err)); }); ``` -* Get Users Redemptions List. Pagination is supported by this API. +* Get User Redemptions List. Pagination is supported by this API. ```js // Mandatory API parameters @@ -811,6 +811,8 @@ For executing transactions, you need to understand the 4 modules described below ```js // Mandatory API parameters + // No mandatory parameters. + // Optional API parameters // Pagination identifier from the previous API call response. Not needed for page one. From d279548dc5f8ddd416c310a5d44f849d6ccc550e Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Tue, 25 Feb 2020 13:15:31 +0530 Subject: [PATCH 10/14] Minor change. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 22bb52d..995b1b0 100644 --- a/README.md +++ b/README.md @@ -753,6 +753,7 @@ For executing transactions, you need to understand the 4 modules described below // UserId of user for whom redemption details needs to be fetched. let userId = 'c2c__'; + // RedemptionId of user. let redemptionId = 'c2c__'; From 941353a77f7198160f6d5c096797714e72fc760b Mon Sep 17 00:00:00 2001 From: Dhananjay8 Date: Thu, 27 Feb 2020 15:33:17 +0530 Subject: [PATCH 11/14] updated readme --- README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/README.md b/README.md index 995b1b0..2f01b32 100644 --- a/README.md +++ b/README.md @@ -829,3 +829,95 @@ For executing transactions, you need to understand the 4 modules described below .then(function(res) { console.log(JSON.stringify(res)); }) .catch(function(err) { console.log(JSON.stringify(err)); }); ``` + +### Redemption Modules + +Two modules of redemption, "Redeemable SKUs" and "User Redemptions", are described below. + +#### Redeemable SKUs Module + +* Initialize Redeemable SKUs service object to perform redeemable skus specific actions. + + ```js + const redeemableSkusService = ostObj.services.redeemable_skus; + ``` +* Get Redeemable SKU detail using the redeemable sku id. + + ```js + // Mandatory API parameters + + // Fetch details of following redeemable sku. + let redeemableSkuId = 'c2c__'; + + redeemableSkusService.get({ redeemable_sku_id: redeemableSkuId }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + +* Get Redeemable SKUs List. Pagination is supported by this API. + + ```js + // Mandatory API parameters + // NOTE: No mandatory parameters. + + // Optional API parameters + + // Limit. + let limit = 10; + + // Array of redeemable SKU ids. + let redeemableSkuIds = ['1001', '1002']; + + // Pagination identifier from the previous API call response. Not needed for page one. + let paginationIdentifier = 'e77y___'; + + redeemableSkusService.getList({limit: limit, pagination_identifier: paginationIdentifier, redeemable_sku_ids: redeemableSkuIds }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + +#### User Redemptions Module + +* Initialize Redemptions service object to perform user redemption specific actions. + + ```js + const redemptionsService = ostObj.services.redemptions; + ``` + +* Get User redemption details using the userId and redemptionId. + + ```js + // Mandatory API parameters + + // UserId of user for whom redemption details needs to be fetched. + let userId = 'c2c__'; + + // Unique identifier of the redemption of user. + let redemptionId = 'c2c__'; + + redemptionsService.get({ user_id: userId, redemption_id: redemptionId }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` + +* Get User Redemptions List. Pagination is supported by this API. + + ```js + // Mandatory API parameters + let userId = 'c2c__'; + + // Optional API parameters + + // Limit. + let limit = 10; + + // Array of user redemption uuids. + let redemptionIds = ['a743___', 'a743___'] + + // Pagination identifier from the previous API call response. Not needed for page one. + let paginationIdentifier = 'e77y___'; + + redemptionsService.getList({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, redemption_ids: redemptionIds }) + .then(function(res) { console.log(JSON.stringify(res)); }) + .catch(function(err) { console.log(JSON.stringify(err)); }); + ``` \ No newline at end of file From 2affcf6984ac432d6fbd1af44002365cc74098c4 Mon Sep 17 00:00:00 2001 From: Dhananjay8 Date: Thu, 27 Feb 2020 16:03:48 +0530 Subject: [PATCH 12/14] updated readme --- README.md | 94 +------------------------------------------------------ 1 file changed, 1 insertion(+), 93 deletions(-) diff --git a/README.md b/README.md index 2f01b32..a3368e8 100644 --- a/README.md +++ b/README.md @@ -737,98 +737,6 @@ For executing transactions, you need to understand the 4 modules described below let resp = webhooksService.verifySignature(version, stringifiedData,requestTimestamp, signature, webhookSecret); console.log(resp); ``` - -### Redemptions Module - -* Initialize Redemptions service object to perform user redemption specific actions. - - ```js - const redemptionsService = ostObj.services.redemptions; - ``` - -* Get User redemption detail using the userId and redemptionId. - - ```js - // Mandatory API parameters - - // UserId of user for whom redemption details needs to be fetched. - let userId = 'c2c__'; - - // RedemptionId of user. - let redemptionId = 'c2c__'; - - redemptionsService.get({ user_id: userId, redemption_id: redemptionId }) - .then(function(res) { console.log(JSON.stringify(res)); }) - .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` - -* Get User Redemptions List. Pagination is supported by this API. - - ```js - // Mandatory API parameters - - // UserId of user for whom redemption details needs to be fetched. - let userId = 'c2c__'; - - // Optional API parameters - - // Pagination identifier from the previous API call response. Not needed for page one. - let paginationIdentifier = 'e77y___'; - - // Limit. - let limit = 10; - - // Array of user redemption uuids. - let userRedemptionUuids = ['13518427-e6d1-46f7-9e3e-dd726ad37a69']; - - redemptionsService.getList({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, user_redemption_uuids: userRedemptionUuids }) - .then(function(res) { console.log(JSON.stringify(res)); }) - .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` - - -### Redeemable SKUs Module - -* Initialize Redeemable Skus service object to perform user redemption specific actions. - - ```js - const redeemableSkusService = ostObj.services.redeemable_skus; - ``` - -* Get Redeemable SKU detail using the redeemable SKU id. - - ```js - // Mandatory API parameters - - // RedeemableSkuId of product for whom details needs to be fetched. - let redeemableSkuId = 'c2c__'; - - redeemableSkusService.get({ redeemable_sku_id: redeemableSkuId }) - .then(function(res) { console.log(JSON.stringify(res)); }) - .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` - -* Get Redeemable SKUs List. Pagination is supported by this API. - - ```js - // Mandatory API parameters - // No mandatory parameters. - - // Optional API parameters - - // Pagination identifier from the previous API call response. Not needed for page one. - let paginationIdentifier = 'e77y___'; - - // Limit. - let limit = 10; - - // Array of redeemable SKU ids. - let ids = ['1', '2']; - - redeemableSkusService.getList({limit: limit, pagination_identifier: paginationIdentifier, ids: ids }) - .then(function(res) { console.log(JSON.stringify(res)); }) - .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` ### Redemption Modules @@ -912,7 +820,7 @@ Two modules of redemption, "Redeemable SKUs" and "User Redemptions", are describ let limit = 10; // Array of user redemption uuids. - let redemptionIds = ['a743___', 'a743___'] + let redemptionIds = ['a743___', 'a743___']; // Pagination identifier from the previous API call response. Not needed for page one. let paginationIdentifier = 'e77y___'; From 4a5c2f1ce909590ad19a48e2693ca3c8d56303e2 Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Tue, 25 Feb 2020 13:24:28 +0530 Subject: [PATCH 13/14] Updated readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3368e8..3ccd359 100644 --- a/README.md +++ b/README.md @@ -828,4 +828,4 @@ Two modules of redemption, "Redeemable SKUs" and "User Redemptions", are describ redemptionsService.getList({ user_id: userId, limit: limit, pagination_identifier: paginationIdentifier, redemption_ids: redemptionIds }) .then(function(res) { console.log(JSON.stringify(res)); }) .catch(function(err) { console.log(JSON.stringify(err)); }); - ``` \ No newline at end of file + ``` From cdb73c4696190d92816a92b1020ce2e9f6ef3ebb Mon Sep 17 00:00:00 2001 From: shlokgilda Date: Tue, 3 Mar 2020 18:05:27 +0530 Subject: [PATCH 14/14] Updated travis.yml config. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 00a8e9a..9667f4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,9 @@ notifications: on_success: always on_failure: always node_js: + - "10" - "9" - "8" - - "7" before_install: - sudo apt-get update - sudo apt-get install nodejs