node-iterable-api
Advanced tools
Comparing version 0.3.3 to 0.4.0
@@ -6,5 +6,5 @@ | ||
if (require.main === module) { | ||
const client = Iterable('api key') | ||
const client = Iterable.create('api key') | ||
client.printResources() | ||
console.log(JSON.stringify(client, null, 2)) | ||
} |
@@ -181,3 +181,19 @@ | ||
] | ||
}, | ||
{ | ||
resource: 'catalogs', | ||
methods: ['get', 'post', 'delete'], | ||
subResources: [ | ||
{ | ||
resource: 'fieldMappings', | ||
urlPrefix: '/catalogs/{catalogName}', | ||
methods: ['get', 'put'] | ||
}, | ||
{ | ||
resource: 'items', | ||
urlPrefix: '/catalogs/{catalogName}', | ||
methods: ['get', 'put', 'post', 'patch', 'delete'] | ||
} | ||
] | ||
} | ||
] |
@@ -10,21 +10,39 @@ | ||
printResources () { | ||
API.forEach(resource => { | ||
console.log(resource.resource) | ||
API.forEach(printResource) | ||
if (resource.methods) { | ||
resource.methods.forEach(method => { | ||
console.log([' ', [padEnd(method.toUpperCase(), 'delete'.length), ['', resource.resource].join('/')].join(' - ')].join('')) | ||
}) | ||
} | ||
function printResource (resource) { | ||
const resourceName = resource.resource | ||
console.log(resourceName) | ||
printMethods(resource) | ||
printActions(resource) | ||
printSubResources(resource, resourceName) | ||
} | ||
if (!resource.actions) { | ||
return | ||
} | ||
function printMethods (resource) { | ||
if (!resource.methods) return | ||
resource.methods.forEach(method => { | ||
console.log([' ', [padEnd(method.toUpperCase(), 'delete'.length), [(typeof resource.urlPrefix === 'undefined' ? '' : resource.urlPrefix), resource.resource].join('/')].join(' - ')].join('')) | ||
}) | ||
} | ||
function printActions (resource) { | ||
if (!resource.actions) return | ||
resource.actions.forEach(action => { | ||
console.log([' ', [padEnd(action.method.toUpperCase(), 'delete'.length), ['', resource.resource, action.name].join('/')].join(' - ')].join('')) | ||
console.log([' ', [padEnd(action.method.toUpperCase(), 'delete'.length), [(typeof resource.urlPrefix === 'undefined' ? '' : resource.urlPrefix), resource.resource, action.name].join('/')].join(' - ')].join('')) | ||
}) | ||
}) | ||
} | ||
function printSubResources (resource, parentName) { | ||
if (typeof resource.subResources === 'undefined') return | ||
resource.subResources.forEach(resource => { | ||
const fullName = `${parentName}.${resource.resource}` | ||
console.log(fullName) | ||
printMethods(resource) | ||
printActions(resource) | ||
printSubResources(resource, fullName) | ||
}) | ||
} | ||
}, | ||
campaigns: require('./resources/campaigns')(request), | ||
catalogs: require('./resources/catalogs')(request), | ||
commerce: require('./resources/commerce')(request), | ||
@@ -31,0 +49,0 @@ email: require('./resources/email')(request), |
@@ -40,3 +40,3 @@ | ||
return ['GET', 'POST', 'PUT', 'DELETE'].reduce((methods, method) => { | ||
return ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].reduce((methods, method) => { | ||
methods[method.toLowerCase()] = (url, data) => { | ||
@@ -43,0 +43,0 @@ return makeRequest(method, url, data) |
{ | ||
"name": "node-iterable-api", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "Wrapper for Iterable API", | ||
@@ -35,3 +35,3 @@ "main": "index.js", | ||
"jest": "^24.8.0", | ||
"standard": "^13.1.0" | ||
"standard": "^14.0.2" | ||
}, | ||
@@ -38,0 +38,0 @@ "standard": { |
@@ -116,3 +116,15 @@ # Node Iterable API | ||
GET - /experiments/metrics | ||
catalogs | ||
GET - /catalogs | ||
POST - /catalogs | ||
DELETE - /catalogs | ||
catalogs.fieldMappings | ||
GET - /catalogs/{catalogName}/fieldMappings | ||
PUT - /catalogs/{catalogName}/fieldMappings | ||
catalogs.items | ||
GET - /catalogs/{catalogName}/items | ||
PUT - /catalogs/{catalogName}/items | ||
POST - /catalogs/{catalogName}/items | ||
PATCH - /catalogs/{catalogName}/items | ||
DELETE - /catalogs/{catalogName}/items | ||
``` | ||
@@ -136,1 +148,4 @@ | ||
``` | ||
### Contributors | ||
- [julianmclain](https://github.com/julianmclain) |
Sorry, the diff of this file is not supported yet
27113
30
806
150