From 6be3a21c21ccdcdef95d43847d23c7c0306607c0 Mon Sep 17 00:00:00 2001 From: ayushkevich Date: Mon, 12 Aug 2019 16:36:44 +0300 Subject: [PATCH] Custom Properties to the output fields added fix #2 --- creates/CreateLicensee.js | 36 ++++++++++++++++++++++++++++++++++++ creates/CreateProduct.js | 13 +++++++++++++ 2 files changed, 49 insertions(+) diff --git a/creates/CreateLicensee.js b/creates/CreateLicensee.js index 4836998..9b81906 100644 --- a/creates/CreateLicensee.js +++ b/creates/CreateLicensee.js @@ -15,6 +15,24 @@ const createLicensee = async (z, bundle) => { if (bundle.inputData.active !== undefined) { licensee.setActive(bundle.inputData.active); } + if (bundle.inputData.email !== undefined) { + licensee.addProperty('email', bundle.inputData.email); + } + if (bundle.inputData.address1 !== undefined) { + licensee.addProperty('address1', bundle.inputData.address1); + } + if (bundle.inputData.zip !== undefined) { + licensee.addProperty('zip', bundle.inputData.zip); + } + if (bundle.inputData.country !== undefined) { + licensee.addProperty('country', bundle.inputData.country); + } + if (bundle.inputData.companyName !== undefined) { + licensee.addProperty('companyName', bundle.inputData.companyName); + } + if (bundle.inputData.fullName !== undefined) { + licensee.addProperty('fullName', bundle.inputData.fullName); + } licensee = await LicenseeService.create(context, bundle.inputData.productNumber, licensee); return licensee.getProperties(); @@ -38,6 +56,12 @@ module.exports = { { key: 'name', required: false, type: 'string' }, { key: 'number', required: false, type: 'string' }, { key: 'active', required: false, type: 'boolean' }, + { key: 'email', required: false, type: 'string' }, + { key: 'address1', required: false, type: 'string' }, + { key: 'zip', required: false, type: 'string' }, + { key: 'country', required: false, type: 'string' }, + { key: 'companyName', required: false, type: 'string' }, + { key: 'fullName', required: false, type: 'string' }, ], perform: createLicensee, @@ -50,6 +74,12 @@ module.exports = { number: 'P9F6UGCXK', active: true, productNumber: 'productNumber', + email: 'test@netlicensing.com', + address1: 'Radlkoferstraße 2', + zip: '81373', + country: 'Germany', + companyName: 'Company name', + fullName: 'Full name', }, // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom @@ -62,6 +92,12 @@ module.exports = { { key: 'number', label: 'Number' }, { key: 'active', label: 'Active' }, { key: 'productNumber', label: 'Product number' }, + { key: 'email', label: 'Email' }, + { key: 'address1', label: 'Address' }, + { key: 'zip', label: 'ZIP' }, + { key: 'country', label: 'Country' }, + { key: 'companyName', label: 'Company name' }, + { key: 'fullName', label: 'Full name' }, ], }, }; diff --git a/creates/CreateProduct.js b/creates/CreateProduct.js index 6db02f0..9000ed5 100644 --- a/creates/CreateProduct.js +++ b/creates/CreateProduct.js @@ -20,6 +20,13 @@ const createProduct = async (z, bundle) => { if (bundle.inputData.licenseeAutoCreate !== undefined) { product.setLicenseeAutoCreate(bundle.inputData.licenseeAutoCreate); } + if (bundle.inputData.description !== undefined) { + product.setDescription(bundle.inputData.description); + } + if (bundle.inputData.licensingInfo !== undefined) { + product.setLicensingInfo(bundle.inputData.licensingInfo); + } + product = await ProductService.create(context, product); return product.getProperties(); @@ -44,6 +51,8 @@ module.exports = { { key: 'active', required: false, type: 'boolean' }, { key: 'version', required: false, type: 'string' }, { key: 'licenseeAutoCreate', required: false, type: 'boolean' }, + { key: 'description', required: false, type: 'string' }, + { key: 'licensingInfo', required: false, type: 'string' }, ], perform: createProduct, @@ -57,6 +66,8 @@ module.exports = { active: true, version: '1.0', licenseeAutoCreate: true, + description: 'Product description', + licensingInfo: 'Product licensing info', }, // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom @@ -70,6 +81,8 @@ module.exports = { { key: 'active', label: 'Active' }, { key: 'version', label: 'Version' }, { key: 'licenseeAutoCreate', label: 'Licensee Auto Create' }, + { key: 'description', label: 'Product description' }, + { key: 'licensingInfo', label: 'Product licensing info' }, ], }, };