Node.js SDK for the Prototype of our Service Catalogue
How to use
I have wrapped up the SDK to hide a lot of the functionality to help make it clearer how to use the sdk.
The current approach should give you intellisense via typescript defintions. However the functionality needed to give proper type checking on the client side via the use of typescript isn't yet functional. It won't be hard to implement however I didn't have time to figure out how to expose that while keeping the SDK api clean and simple to understand.
There are 3 endpoints you can hit:
- createProduct
- createUsage
- registerUsageOfProduct
However I would suggest just using the 3rd one. This is an endpoint which allows you to provide a usage along with either a ProductName
or ProductId
. If you provide a ProductName
and there is no Product object in the DB it will automatically create it for you.
I think this is a nicer workflow which then allows the accountants to view all the automatically created products and assign the correct business area and pricing to it etc.
Basically this should be all the code you need to implement it into teammo
const SDK = require('finops-andrew-sdk')
const client = new SDK.Client()
const callback = (err, res) => {
if (err) console.error(err);
if (res) console.log(res);
}
client.registerUsageOfProduct({
productName:'TeammoPaymentTypeX',
usage:{
name: 'A usage',
code: '1234'
metadata: {
"Key": "Value",
"Key2": "Value2"
}
}
}, callback)