Comparing version 1.2.1 to 1.2.2
@@ -18,3 +18,3 @@ const invoker = require('./invoker') | ||
) { | ||
return this.send('CHANGE_NUMBER_PORTING_REQUEST', { | ||
return this.send('SOAP_CHANGE_NUMBER_PORTING_REQUEST', { | ||
subscriptionId: subscriptionId, | ||
@@ -21,0 +21,0 @@ portDate: portDate |
@@ -5,4 +5,3 @@ const changeCase = require('change-case') | ||
function parseComplexValue (dto, parentKey) { | ||
return dto | ||
.value | ||
return dto.value | ||
.map(function (value) { | ||
@@ -20,5 +19,3 @@ return parse(value, parentKey) | ||
function parseArrayValue (dto) { | ||
return dto | ||
.value | ||
.map(parseValue) | ||
return dto.value.map(parseValue) | ||
} | ||
@@ -50,3 +47,4 @@ | ||
} | ||
default: return null | ||
default: | ||
return null | ||
} | ||
@@ -62,3 +60,3 @@ } | ||
const key = changeCase.camelCase(dto.key[0]) | ||
const key = changeCase.camelCase(dto.key[0]).replace(/_/g, '') | ||
const result = {} | ||
@@ -78,3 +76,3 @@ result[key] = value | ||
if (typeof value === 'number') { | ||
return (parseInt(value, 10) === value) ? 'longValueDTO' : 'doubleValueDTO' | ||
return parseInt(value, 10) === value ? 'longValueDTO' : 'doubleValueDTO' | ||
} | ||
@@ -98,4 +96,4 @@ if (value instanceof Date) { | ||
'@xsi:type': type, | ||
'key': changeCase.constantCase(key), | ||
'value': value | ||
key: changeCase.constantCase(key), | ||
value: value | ||
} | ||
@@ -102,0 +100,0 @@ } |
@@ -9,5 +9,3 @@ const xmlBuilder = require('xmlbuilder') | ||
changeCase.constantCase = function () { | ||
return _cc | ||
.apply(changeCase, arguments) | ||
.replace(/(\w)_(\d)/, '$1$2') | ||
return _cc.apply(changeCase, arguments).replace(/(\w)_(\d)/, '$1$2') | ||
} | ||
@@ -23,3 +21,3 @@ | ||
} | ||
return val | ||
return val !== undefined ? val : '' | ||
} | ||
@@ -53,3 +51,3 @@ | ||
const xsi = getXsi(value, index + 1, type) | ||
const xmlns = (single) ? null : getXmlNs(index + 1) | ||
const xmlns = single ? null : getXmlNs(index + 1) | ||
@@ -64,45 +62,57 @@ let values | ||
values = _.assign(xsi, xmlns, { | ||
'key': changeCase.constantCase(key), | ||
'value': secure(value) | ||
key: changeCase.constantCase(key), | ||
value: secure(value) | ||
}) | ||
break | ||
default: // object, Array, Date | ||
default: | ||
// object, Array, Date | ||
if (value === null) { | ||
return null | ||
} else if (value instanceof Array) { | ||
values = [xsi, xmlns, { key: changeCase.constantCase(key) }] | ||
.concat(value.map(function (item) { | ||
return buildValue(depluralize(key), item, index, true) | ||
})) | ||
values = { ...xsi, | ||
...xmlns, | ||
...{ key: changeCase.constantCase(key) }, | ||
value: value | ||
.map(function (item) { | ||
return buildValue(depluralize(key), item, index, true) | ||
}) | ||
.filter(function (item) { | ||
return item | ||
}) | ||
} | ||
} else if (value instanceof Date) { | ||
values = [xsi, xmlns, { key: changeCase.constantCase(key) }] | ||
.concat([{ | ||
value: secure(value) | ||
}]) | ||
values = { | ||
...xsi, | ||
...xmlns, | ||
...{ key: changeCase.constantCase(key) }, | ||
value: secure(value) | ||
} | ||
} else { | ||
values = [xsi, xmlns, { key: changeCase.constantCase(key) }] | ||
.concat(Object.keys(value).map(function (key) { | ||
return buildValue(key, value[key], index, true) | ||
})) | ||
values = { | ||
...xsi, | ||
...xmlns, | ||
...{ key: changeCase.constantCase(key) }, | ||
value: Object.keys(value) | ||
.map(function (key) { | ||
return buildValue(key, value[key], index, true) | ||
}) | ||
.filter(function (item) { | ||
return item | ||
}) | ||
} | ||
} | ||
values = values.filter(function (item) { return item }) | ||
break | ||
} | ||
const result = {} | ||
const resultKey = (single) ? 'value' : 'values' | ||
result[resultKey] = values | ||
return result | ||
return values | ||
} | ||
function buildEnvelope (hookpointKey, args) { | ||
const arg0 = [ | ||
{ '@xmlns': '' }, | ||
{ 'hookpointKey': { '#text': hookpointKey } } | ||
].concat( | ||
Object.keys(args).map(function (key, ix) { | ||
const arg0 = { | ||
'@xmlns': '', | ||
hookpointKey: { '#text': hookpointKey }, | ||
values: Object.keys(args).map(function (key, ix) { | ||
return buildValue(key, args[key], ix) | ||
}) | ||
) | ||
} | ||
@@ -118,5 +128,5 @@ const xml = xmlBuilder | ||
'@xmlns:xsd': 'http://www.w3.org/2001/XMLSchema', | ||
'executeMethod': { | ||
executeMethod: { | ||
'@xmlns': 'http://soap.CDRator.com/', | ||
'arg0': arg0 | ||
arg0: arg0 | ||
} | ||
@@ -137,7 +147,10 @@ } | ||
if (response['S:Envelope']['S:Body'][0]['S:Fault']) { | ||
callback(response['S:Envelope']['S:Body'][0]['S:Fault'][0]['faultstring'][0]) | ||
callback( | ||
response['S:Envelope']['S:Body'][0]['S:Fault'][0]['faultstring'][0] | ||
) | ||
return | ||
} | ||
const rawResult = response['S:Envelope']['S:Body'][0]['ns2:executeMethodResponse'][0]['return'][0] | ||
const rawResult = | ||
response['S:Envelope']['S:Body'][0]['ns2:executeMethodResponse'][0]['return'][0] | ||
@@ -159,5 +172,5 @@ if (!rawResult.values) { | ||
const result = { | ||
'errorCode': parseInt(rawResult.errorCode[0]), | ||
'status': parseInt(rawResult.status[0]), | ||
'values': values | ||
errorCode: parseInt(rawResult.errorCode[0]), | ||
status: parseInt(rawResult.status[0]), | ||
values: values | ||
} | ||
@@ -164,0 +177,0 @@ callback(null, result) |
{ | ||
"name": "cdrator", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Call CDRator SOAP WebServices using node.js", | ||
@@ -9,3 +9,3 @@ "main": "lib/cdrator", | ||
"lint": "eslint lib/**/*.js test/**/*.js", | ||
"test": "nyc mocha test/**/*.js", | ||
"test": "nyc mocha test/unit --recursive", | ||
"format": "eslint lib/**/*.js test/**/*.js --fix", | ||
@@ -54,8 +54,8 @@ "preversion": "npm run lint && npm test", | ||
"dependencies": { | ||
"change-case": "^2.3.0", | ||
"lodash": "^3.9.3", | ||
"moment": "^2.10.6", | ||
"xml2js": "^0.4.9", | ||
"xmlbuilder": "^2.6.4" | ||
"change-case": "^3.1.0", | ||
"lodash": "^4.17.11", | ||
"moment": "^2.24.0", | ||
"xml2js": "^0.4.19", | ||
"xmlbuilder": "^12.0.0" | ||
} | ||
} |
@@ -41,3 +41,3 @@ const chai = require('chai') | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'CHANGE_NUMBER_PORTING_REQUEST' | ||
const hookpoint = 'SOAP_CHANGE_NUMBER_PORTING_REQUEST' | ||
const subscriptionId = '201305302012345678' | ||
@@ -44,0 +44,0 @@ const portDate = new Date('2019-04-17 09:09:00') |
Sorry, the diff of this file is not supported yet
773835
86
2619
+ Addedcamel-case@3.0.0(transitive)
+ Addedchange-case@3.1.0(transitive)
+ Addedconstant-case@2.0.0(transitive)
+ Addeddot-case@2.1.1(transitive)
+ Addedheader-case@1.0.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedno-case@2.3.2(transitive)
+ Addedparam-case@2.1.1(transitive)
+ Addedpascal-case@2.0.1(transitive)
+ Addedpath-case@2.1.1(transitive)
+ Addedsentence-case@2.1.1(transitive)
+ Addedsnake-case@2.1.0(transitive)
+ Addedtitle-case@2.1.1(transitive)
+ Addedxmlbuilder@12.0.1(transitive)
- Removedcamel-case@1.2.2(transitive)
- Removedchange-case@2.3.1(transitive)
- Removedconstant-case@1.1.2(transitive)
- Removeddot-case@1.1.2(transitive)
- Removedlodash@3.10.1(transitive)
- Removedparam-case@1.1.2(transitive)
- Removedpascal-case@1.1.2(transitive)
- Removedpath-case@1.1.2(transitive)
- Removedsentence-case@1.1.3(transitive)
- Removedsnake-case@1.1.2(transitive)
- Removedtitle-case@1.1.2(transitive)
- Removedxmlbuilder@2.6.5(transitive)
Updatedchange-case@^3.1.0
Updatedlodash@^4.17.11
Updatedmoment@^2.24.0
Updatedxml2js@^0.4.19
Updatedxmlbuilder@^12.0.0