Skip to content

Commit

Permalink
Custom Properties to the output fields added fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
yushkevich committed Aug 12, 2019
1 parent 5e3c751 commit 6be3a21
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
36 changes: 36 additions & 0 deletions creates/CreateLicensee.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,

Expand All @@ -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
Expand All @@ -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' },
],
},
};
13 changes: 13 additions & 0 deletions creates/CreateProduct.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,

Expand All @@ -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
Expand All @@ -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' },
],
},
};

0 comments on commit 6be3a21

Please sign in to comment.