dynamicscrm-api
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -14,3 +14,3 @@ /*jslint nomen: true, stupid: true */ | ||
var fs = require("fs"); | ||
var parser = require('xml2json'); | ||
var parseString = require('xml2js').parseString; | ||
var traverse = require('traverse'); | ||
@@ -355,26 +355,26 @@ var Serializer = require('./serializer.js'); | ||
soapHeader = soapHeaderMessage | ||
.replace("{action}", action) | ||
.replace("{messageid}", uuid.v4()) | ||
.replace("{crmurl}", organizationServiceEndpoint); | ||
soapHeader = soapHeaderMessage | ||
.replace("{action}", action) | ||
.replace("{messageid}", uuid.v4()) | ||
.replace("{crmurl}", organizationServiceEndpoint); | ||
if (options.encryptedData) { | ||
security = '<wsse:Security s:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">\ | ||
<u:Timestamp u:Id="_0">\ | ||
<u:Created>' + timeCreated.toISOString() + '</u:Created>\ | ||
<u:Expires>' + timeExpires.toISOString() + '</u:Expires>\ | ||
</u:Timestamp>' + options.encryptedData + '</wsse:Security>'; | ||
if (options.encryptedData) { | ||
security = '<wsse:Security s:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">\ | ||
<u:Timestamp u:Id="_0">\ | ||
<u:Created>' + timeCreated.toISOString() + '</u:Created>\ | ||
<u:Expires>' + timeExpires.toISOString() + '</u:Expires>\ | ||
</u:Timestamp>' + options.encryptedData + '</wsse:Security>'; | ||
soapHeader = soapHeader.replace("{security}", security); | ||
} else if (options.header) { | ||
soapHeader = soapHeader.replace("{security}", options.header); | ||
} else { | ||
return cb(new Error("Neither token or header found.")); | ||
} | ||
soapHeader = soapHeader.replace("{security}", security); | ||
} else if (options.header) { | ||
soapHeader = soapHeader.replace("{security}", options.header); | ||
} else { | ||
return cb(new Error("Neither token or header found.")); | ||
} | ||
xmlrequestbody = template.replace("{requetbody}", body); | ||
xmlrequestbody = template.replace("{requetbody}", body); | ||
soapPostMessage = soapEnvelopeMessage | ||
.replace("{header}", soapHeader) | ||
.replace("{body}", xmlrequestbody); | ||
soapPostMessage = soapEnvelopeMessage | ||
.replace("{header}", soapHeader) | ||
.replace("{body}", xmlrequestbody); | ||
@@ -403,3 +403,3 @@ requestOptions = { | ||
data, | ||
jsondata, | ||
//jsondata, | ||
prefixes, | ||
@@ -412,22 +412,27 @@ data_no_ns; | ||
if (settings.returnJson) { | ||
jsondata = JSON.parse(parser.toJson(xml)); | ||
prefixes = []; | ||
//removes namespaces | ||
data_no_ns = traverse(jsondata).map(function () { | ||
if (this.key !== undefined) { | ||
var pos = this.key.indexOf('xmlns:'), | ||
k = this.key.substring(6, this.key.length) + ':'; | ||
parseString(xml, {explicitArray: false}, function (err, jsondata) { | ||
if (err) { return cb(err); } | ||
if (pos > -1 || this.key.indexOf('xmlns') > -1) { | ||
if (prefixes.lastIndexOf(k) === -1) { | ||
prefixes.push(k); | ||
prefixes = []; | ||
//removes namespaces | ||
data_no_ns = traverse(jsondata).map(function () { | ||
if (this.key !== undefined) { | ||
var pos = this.key.indexOf('xmlns:'), | ||
k = this.key.substring(6, this.key.length) + ':'; | ||
if (pos > -1 || this.key.indexOf('xmlns') > -1) { | ||
if (prefixes.lastIndexOf(k) === -1) { | ||
prefixes.push(k); | ||
} | ||
this.remove(); | ||
} | ||
this.remove(); | ||
} | ||
} | ||
}); | ||
//removes 'xx:' prefixes | ||
data = deepObjCopy(data_no_ns, prefixes); | ||
cb(null, data); | ||
}); | ||
//removes 'xx:' prefixes | ||
data = deepObjCopy(data_no_ns, prefixes); | ||
} else { | ||
cb(null, data); | ||
} | ||
cb(null, data); | ||
}); | ||
@@ -587,9 +592,13 @@ }); | ||
if (faultDetails.length > 0) { | ||
fullMessage = fullMessage + ". Details:" + parser.toJson(faultDetails.toString()); | ||
parseString(faultDetails.toString(), {explicitArray: false}, function (err, data) { | ||
if (err) { return cb(err); } | ||
fullMessage = fullMessage + ". Details:" + data; | ||
return cb(new Error(fullMessage), null); | ||
}); | ||
} | ||
return cb(new Error(fullMessage), null); | ||
} else { | ||
return cb(null, resXml); | ||
} | ||
return cb(null, resXml); | ||
}); | ||
@@ -596,0 +605,0 @@ }); |
100
package.json
{ | ||
"name": "dynamicscrm-api", | ||
"version": "0.0.9", | ||
"description": "Pure SOAP module that allows to invoke Microsoft Dynamics CRM Online services", | ||
"author": "Kidozen <development@kidozen.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Gustavo Machado", | ||
"email": "gus@kidozen.com" | ||
}, | ||
{ | ||
"name" : "Christian Carnero", | ||
"email" : "chris@kidozen.com" | ||
}, | ||
{ | ||
"name" : "Hernán Tierno", | ||
"email" : "hernan.tierno@kidozen.com" | ||
} | ||
], | ||
"main": "index.js", | ||
"scripts": | ||
{ | ||
"test": "mocha -R spec test" | ||
}, | ||
"keywords": ["dynamics", "crm", "Microsoft"], | ||
"license": "MIT", | ||
"dependencies": | ||
{ | ||
"traverse": "0.6.5", | ||
"xml2json": "0.3.2", | ||
"xpath": "0.0.6", | ||
"xmldom": "0.1.19", | ||
"node-uuid": "1.4.0", | ||
"cookie": "0.1.0", | ||
"mem-cache": "0.0.4", | ||
"path" : "0.4.9", | ||
"url" : "0.7.9", | ||
"simple-errors":"0.0.5", | ||
"request": "2.37.0" | ||
}, | ||
"devDependencies": | ||
{ | ||
"mocha": "1.11.0", | ||
"assert": "0.4.9", | ||
"nock": "0.18.2", | ||
"mockuire": "0.0.4" | ||
}, | ||
"directories": | ||
{ | ||
"test": "test" | ||
} | ||
"name": "dynamicscrm-api", | ||
"version": "0.0.10", | ||
"description": "Pure SOAP module that allows to invoke Microsoft Dynamics CRM Online services", | ||
"author": "Kidozen <development@kidozen.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Gustavo Machado", | ||
"email": "gus@kidozen.com" | ||
}, | ||
{ | ||
"name": "Christian Carnero", | ||
"email": "chris@kidozen.com" | ||
}, | ||
{ | ||
"name": "Hernán Tierno", | ||
"email": "hernan.tierno@kidozen.com" | ||
} | ||
], | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha -R spec test" | ||
}, | ||
"keywords": [ | ||
"dynamics", | ||
"crm", | ||
"Microsoft" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"cookie": "0.1.0", | ||
"mem-cache": "0.0.4", | ||
"node-uuid": "1.4.0", | ||
"path": "0.4.9", | ||
"request": "2.37.0", | ||
"simple-errors": "0.0.5", | ||
"traverse": "0.6.5", | ||
"url": "0.7.9", | ||
"xml2js": "0.4.4", | ||
"xmldom": "0.1.19", | ||
"xpath": "0.0.6" | ||
}, | ||
"devDependencies": { | ||
"mocha": "1.11.0", | ||
"assert": "0.4.9", | ||
"nock": "0.18.2", | ||
"mockuire": "0.0.4" | ||
}, | ||
"directories": { | ||
"test": "test" | ||
} | ||
} |
@@ -261,3 +261,3 @@ /*global describe, before, beforeEach, it */ | ||
assert.ok(result2); | ||
var entities = result2.Envelope | ||
@@ -264,0 +264,0 @@ .Body.RetrieveMultipleResponse |
81838
1471
+ Addedxml2js@0.4.4
+ Addedsax@0.6.1(transitive)
+ Addedtldts@6.1.75(transitive)
+ Addedtldts-core@6.1.75(transitive)
+ Addedxml2js@0.4.4(transitive)
+ Addedxmlbuilder@15.1.1(transitive)
- Removedxml2json@0.3.2
- Removednode-expat@2.0.0(transitive)
- Removedtldts@6.1.74(transitive)
- Removedtldts-core@6.1.74(transitive)
- Removedxml2json@0.3.2(transitive)