vtex-node-sdk
A VTEX Node.js SDK.
Installation:
npm install --save vtex-node-sdk
Logger
VTEX Log4js wrapper
var Logger = require('vtex-node-sdk').Logger
var loggerConfig = {
type: 'console',
category: 'myCategory',
verbose: true
}
var logger = Logger(loggerConfig).getLogger()
Logger will receive different log levels based on some configs: verbose
option
will set the log level to INFO
. debugMode
will set the log level to DEBUG
.
Any logging will be disabled if the NODE_ENV
is set to test
License Manager Client
http://licensemanager.vtex.com.br
LicenseManagerClient([lmEnvironment])
Client for the License Manager service.
If no lmEnvironment
paramenter is passed, the stable service will be used.
var LicenseManagerClient = require('vtex-node-sdk').LicenseManagerClient
var lmClient = new LicenseManagerClient()
getAccountDetails
GET /api/license-manager/pvt/accounts/hosts/:host
getAccountDetails(host, vtexIdclientAutCookie)
Returns a promise fulfilling an array with the response
and the body
object of the request.
var vtexIdclientAutCookie = "authtokenvalue=="
lmClient.getAccountDetails("www.basedevmkp.com.br", vtexIdclientAutCookie)
.spread(function(response, body){
console.log(body.MainAccountName)
})
.catch(function(err){
console.error(err)
})
getTopbarInfo
GET /api/license-manager/site/pvt/newtopbar?an=:account
getTopbarInfo(account, vtexIdclientAutCookie)
Returns a promise fulfilling an array with the response
and the body
object of the request
var vtexIdclientAutCookie = "authtokenvalue=="
lmClient.getAccountDetails("basedevmkp", vtexIdclientAutCookie)
.spread(function(response, body){
console.log(body.config)
})
.catch(function(err){
console.error(err)
})
IAM Client
https://iam.vtex.com
IAMClient()
Client for the IAM service.
var IAMClient = require('vtex-node-sdk').IAM
var iam = new IAMClient()
getVtexAuthToken
POST /sts/tokens/assumerole/vtexid
Payload example:
{
"account": "basedevmkp",
"token": "vtexIdclientAutCookieToken=="
}
getVtexAuthToken(account, vtexIdclientAutCookie)
Returns a promise that fullfils an array with the response
and a token
string
var vtexIdClientAutCookie = "1234vtexidtoken=="
iam.getVtexAuthToken("basedevmkp", vtexid)
.spread(function(response, token){
console.log(token)
})
.catch(function(err){
console.error(err)
})
VTEX API Token
S3 GET vtex-id/tokens/vtex-id/tokens/vtexappkey-appvtex.json
Returns app key from S3.
Needs valid AWS credentials.