Comparing version 1.1.0 to 1.2.0
@@ -59,3 +59,3 @@ const changeCase = require('change-case') | ||
const key = changeCase.camelCase(dto.key[0]) | ||
const key = changeCase.camelCase(dto.key[0]).replace(/_/g, '') | ||
const result = {} | ||
@@ -62,0 +62,0 @@ result[key] = value |
@@ -44,3 +44,3 @@ const http = require('http') | ||
if (context || context === undefined) { | ||
data = _.assign(data, {context: context || defaultContext}) | ||
data = _.assign(data, { context: context || defaultContext }) | ||
} | ||
@@ -82,2 +82,2 @@ const envelope = soaper.buildEnvelope(hookpointKey, data) | ||
module.exports = {send} | ||
module.exports = { send } |
@@ -69,3 +69,3 @@ const xmlBuilder = require('xmlbuilder') | ||
} else if (value instanceof Array) { | ||
values = [xsi, xmlns, {key: changeCase.constantCase(key)}] | ||
values = [xsi, xmlns, { key: changeCase.constantCase(key) }] | ||
.concat(value.map(function (item) { | ||
@@ -75,3 +75,3 @@ return buildValue(depluralize(key), item, index, true) | ||
} else if (value instanceof Date) { | ||
values = [xsi, xmlns, {key: changeCase.constantCase(key)}] | ||
values = [xsi, xmlns, { key: changeCase.constantCase(key) }] | ||
.concat([{ | ||
@@ -81,3 +81,3 @@ value: secure(value) | ||
} else { | ||
values = [xsi, xmlns, {key: changeCase.constantCase(key)}] | ||
values = [xsi, xmlns, { key: changeCase.constantCase(key) }] | ||
.concat(Object.keys(value).map(function (key) { | ||
@@ -100,4 +100,4 @@ return buildValue(key, value[key], index, true) | ||
const arg0 = [ | ||
{'@xmlns': ''}, | ||
{'hookpointKey': { '#text': hookpointKey }} | ||
{ '@xmlns': '' }, | ||
{ 'hookpointKey': { '#text': hookpointKey } } | ||
].concat( | ||
@@ -125,3 +125,3 @@ Object.keys(args).map(function (key, ix) { | ||
return xml.end({pretty: true}) | ||
return xml.end({ pretty: true }) | ||
} | ||
@@ -128,0 +128,0 @@ |
{ | ||
"name": "cdrator", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Call CDRator SOAP WebServices using node.js", | ||
@@ -8,3 +8,6 @@ "main": "lib/cdrator", | ||
"scripts": { | ||
"test": "gulp lint test", | ||
"lint": "eslint lib/**/*.js test/**/*.js", | ||
"test": "nyc mocha test/**/*.js", | ||
"format": "eslint lib/**/*.js test/**/*.js --fix", | ||
"prepare": "npm run lint && npm test", | ||
"patch-release": "npm version patch && npm publish && git push origin master --follow-tags", | ||
@@ -35,25 +38,24 @@ "minor-release": "npm version minor && npm publish && git push origin master --follow-tags", | ||
"devDependencies": { | ||
"chai": "^3.0.0", | ||
"chai": "^4.2.0", | ||
"chai-xml": "^0.3.2", | ||
"eslint-config-standard": "^5.3.5", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-node": "^5.1.1", | ||
"eslint-plugin-promise": "^2.0.0", | ||
"eslint-plugin-standard": "^2.0.0", | ||
"gulp": "^3.9.0", | ||
"gulp-eslint": "^4.0.0", | ||
"gulp-jshint": "^1.11.0", | ||
"gulp-mocha": "^2.1.1", | ||
"proxyquire": "^1.7.3", | ||
"sinon": "^1.15.3", | ||
"sinon-as-promised": "^4.0.0", | ||
"sinon-chai": "^2.8.0" | ||
"eslint": "^5.16.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.17.2", | ||
"eslint-plugin-node": "^8.0.1", | ||
"eslint-plugin-promise": "^4.1.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"mocha": "^6.1.3", | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.17.0", | ||
"proxyquire": "^2.1.0", | ||
"sinon": "^7.3.1", | ||
"sinon-chai": "^3.3.0" | ||
}, | ||
"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" | ||
} | ||
} |
@@ -35,6 +35,17 @@ const chai = require('chai') | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, {subscriptionId: '201305302012345678', campaignKey: '201601072066121201'}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { subscriptionId: '201305302012345678', campaignKey: '201601072066121201' }) | ||
}) | ||
}) | ||
describe('changeNumberPortingDate', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'CHANGE_NUMBER_PORTING_REQUEST' | ||
const subscriptionId = '201305302012345678' | ||
const portDate = new Date('2019-04-17 09:09:00') | ||
cdrator.changeNumberPortingDate(subscriptionId, portDate) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { subscriptionId, portDate }) | ||
}) | ||
}) | ||
describe('checkUsernameAvailability', function () { | ||
@@ -45,6 +56,28 @@ it('calls send with the correct parameters', function () { | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, {username: 'username'}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { username: 'username' }) | ||
}) | ||
}) | ||
describe('createRechargeTicket', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_CREATE_RECHARGE_TICKET' | ||
const billingGroupId = 'billingGroupId' | ||
const reference = 'reference' | ||
const ticketId = 'ticketId' | ||
cdrator.createRechargeTicket(billingGroupId, reference, ticketId) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { billingGroupId, reference, ticketId, ticketType: 'BASE' }) | ||
}) | ||
}) | ||
describe('deleteRechargeTicket', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_DELETE_RECHARGE_TICKET' | ||
const billingGroupId = 'billingGroupId' | ||
cdrator.deleteRechargeTicket(billingGroupId) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { billingGroupId }) | ||
}) | ||
}) | ||
describe('doAddressCheck', function () { | ||
@@ -55,3 +88,3 @@ it('calls send with the correct parameters', function () { | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, {personalId: '197001010101'}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { personalId: '197001010101' }) | ||
}) | ||
@@ -65,3 +98,3 @@ }) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, {personalId: '197001010101'}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { personalId: '197001010101' }) | ||
}) | ||
@@ -89,15 +122,24 @@ }) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, {invoice: '20160101123456'}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { invoice: '20160101123456' }) | ||
}) | ||
}) | ||
describe('getRechargeTicket', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_GET_RECHARGE_TICKET' | ||
const billingGroupId = 'billingGroupId' | ||
cdrator.getRechargeTicket(billingGroupId) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { billingGroupId }) | ||
}) | ||
}) | ||
describe('reservePhoneNumber', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_RESERVE_PHONE_NUMBER' | ||
cdrator.reservePhoneNumber('0706123456', 30) | ||
const phoneNumber = '0706123456' | ||
const reserveTime = 30 | ||
cdrator.reservePhoneNumber(phoneNumber, reserveTime) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { | ||
phoneNumber: '0706123456', | ||
reserveTime: 30 | ||
}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { phoneNumber, reserveTime }) | ||
}) | ||
@@ -109,7 +151,7 @@ }) | ||
const hookpoint = 'SOAP_SUBSCRIBE_PRODUCT_OPTIONS' | ||
cdrator.subscribeProductOptions({id: '201305302066666666'}, {id: '201305302066666667'}) | ||
cdrator.subscribeProductOptions({ id: '201305302066666666' }, { id: '201305302066666667' }) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { | ||
productOptions: {'id': '201305302066666667'}, | ||
subscriptionId: {'id': '201305302066666666'} | ||
productOptions: { 'id': '201305302066666667' }, | ||
subscriptionId: { 'id': '201305302066666666' } | ||
}) | ||
@@ -122,7 +164,7 @@ }) | ||
const hookpoint = 'SOAP_UNSUBSCRIBE_PRODUCT_OPTIONS' | ||
cdrator.unsubscribeProductOptions({id: '201305302066666666'}, {id: '201305302066666667'}) | ||
cdrator.unsubscribeProductOptions({ id: '201305302066666666' }, { id: '201305302066666667' }) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { | ||
productOptionIds: {'id': '201305302066666667'}, | ||
subscriptionId: {'id': '201305302066666666'} | ||
productOptionIds: { 'id': '201305302066666667' }, | ||
subscriptionId: { 'id': '201305302066666666' } | ||
}) | ||
@@ -156,6 +198,41 @@ }) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, {personalId: '197001010101'}) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { personalId: '197001010101' }) | ||
}) | ||
}) | ||
describe('terminateSubscription', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_TERMINATE_SUBSCRIPTION' | ||
const subscriptionId = 'subscriptionId' | ||
const terminationRequest = { | ||
expectedTerminationDate: new Date('2019-06-17'), | ||
endBillingDate: new Date('2019-06-17') | ||
} | ||
cdrator.terminateSubscription(subscriptionId, terminationRequest) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { subscriptionId, terminationRequest }) | ||
}) | ||
}) | ||
describe('blockSim', () => { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_BLOCK_SIMCARD' | ||
const icc = 'icc' | ||
const blockType = 'hard' | ||
cdrator.blockSim(icc, blockType) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { icc, blockType }) | ||
}) | ||
}) | ||
describe('payInvoiceUsingRechargeTicket', () => { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_PAY_INVOICE_USING_RECHARGETICKET' | ||
const invoiceId = 'invoiceId' | ||
cdrator.payInvoiceUsingRechargeTicket(invoiceId) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { invoiceId }) | ||
}) | ||
}) | ||
describe('createFullSubscription', function () { | ||
@@ -185,2 +262,14 @@ it('calls send with the correct parameters', function () { | ||
describe('reservePhoneNumber', function () { | ||
it('calls send with the correct parameters', function () { | ||
const hookpoint = 'SOAP_RESERVE_PHONE_NUMBER' | ||
const phoneNumber = '0706829100' | ||
const reserveTime = '12345' | ||
cdrator.reservePhoneNumber(phoneNumber, reserveTime) | ||
expect(invoker.send).calledOnce.calledWith(config, context, hookpoint, { phoneNumber, reserveTime }) | ||
}) | ||
}) | ||
describe('startSwTelcoMigration', function () { | ||
@@ -187,0 +276,0 @@ it('calls send with the correct parameters', function () { |
@@ -166,5 +166,5 @@ const chai = require('chai') | ||
} | ||
expect(dto.get({language: 'EN'})).to.eql(expected) | ||
expect(dto.get({ language: 'EN' })).to.eql(expected) | ||
}) | ||
}) | ||
}) |
@@ -17,3 +17,3 @@ const chai = require('chai') | ||
} | ||
defaultContext = {prop: 'bar'} | ||
defaultContext = { prop: 'bar' } | ||
http = { | ||
@@ -44,3 +44,3 @@ request: sinon.stub() | ||
it('assigns the default context to the data and calls buildEnvelope', function () { | ||
invoker.send(config, defaultContext, 'SOAP_DO_STUFF', {param: 'foo'}) | ||
invoker.send(config, defaultContext, 'SOAP_DO_STUFF', { param: 'foo' }) | ||
expect(soaper.buildEnvelope) | ||
@@ -50,7 +50,7 @@ .calledOnce | ||
param: 'foo', | ||
context: {prop: 'bar'} | ||
context: { prop: 'bar' } | ||
}) | ||
}) | ||
it('adds a custom context if one is passed', function () { | ||
invoker.send(config, defaultContext, 'SOAP_DO_STUFF', {param: 'foo'}, {prop: 'herp'}) | ||
invoker.send(config, defaultContext, 'SOAP_DO_STUFF', { param: 'foo' }, { prop: 'herp' }) | ||
expect(soaper.buildEnvelope) | ||
@@ -60,7 +60,7 @@ .calledOnce | ||
param: 'foo', | ||
context: {prop: 'herp'} | ||
context: { prop: 'herp' } | ||
}) | ||
}) | ||
it('does not add a context if null is passed', function () { | ||
invoker.send(config, defaultContext, 'SOAP_DO_STUFF', {param: 'foo'}, null) | ||
invoker.send(config, defaultContext, 'SOAP_DO_STUFF', { param: 'foo' }, null) | ||
expect(soaper.buildEnvelope) | ||
@@ -75,5 +75,5 @@ .calledOnce | ||
beforeEach(function () { | ||
parsedResult = {values: {foo: 'bar'}} | ||
parsedResult = { values: { foo: 'bar' } } | ||
soaper.parse.yields(null, parsedResult) | ||
promise = invoker.send(config, defaultContext, 'SOAP_DO_STUFF', {param: 'foo'}) | ||
promise = invoker.send(config, defaultContext, 'SOAP_DO_STUFF', { param: 'foo' }) | ||
res.emit('data', '<?xml version="1.0" encoding="UTF-8"?>') | ||
@@ -126,6 +126,6 @@ res.emit('data', '<S:Envelope />') | ||
soaper.parse.yields(null, {status: 1, errorCode: 101}) | ||
soaper.parse.yields(null, { status: 1, errorCode: 101 }) | ||
return promise | ||
.catch(function (err) { | ||
expect(err).to.eql(error) | ||
expect(err.toString()).to.equal(error.toString()) | ||
}) | ||
@@ -137,6 +137,6 @@ }) | ||
soaper.parse.yields(null, {status: 1, errorCode: 42}) | ||
soaper.parse.yields(null, { status: 1, errorCode: 42 }) | ||
return promise | ||
.catch(function (err) { | ||
expect(err).to.eql(error) | ||
expect(err.toString()).to.equal(error.toString()) | ||
}) | ||
@@ -143,0 +143,0 @@ }) |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
773499
14
2607
85
1
+ 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