Skip to content

Commit

Permalink
Added new helper with more info
Browse files Browse the repository at this point in the history
Add helper to mocha tests
  • Loading branch information
SpiralArm Consulting Ltd committed Apr 17, 2019
1 parent 87e3365 commit a6d1b15
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 7 deletions.
54 changes: 54 additions & 0 deletions LDBWSOperationInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';
/**
* LDBWSOperationInfo.js
* This is a helper that defines information for specific LDBWS Operation Requests.
*/

const OperationInfo = {
"GetDepartureBoard": {
"key": "GetStationBoardResult",
"type": "board"
},
"GetDepBoardWithDetails": {
"key": "GetStationBoardResult",
"type": "board"
},
"GetArrivalBoard": {
"key": "GetStationBoardResult",
"type": "board"
},
"GetArrBoardWithDetails": {
"key": "GetStationBoardResult",
"type": "board"
},
"GetArrivalDepartureBoard": {
"key": "GetStationBoardResult",
"type": "board"
},
"GetArrDepBoardWithDetails": {
"key": "GetStationBoardResult",
"type": "board"
},
"GetNextDepartures": {
"key": "DeparturesBoard",
"type": "departure"
},
"GetNextDeparturesWithDetails": {
"key": "DeparturesBoard",
"type": "departure"
},
"GetFastestDepartures": {
"key": "DeparturesBoard",
"type": "departure"
},
"GetFastestDeparturesWithDetails":{
"key": "DeparturesBoard",
"type": "departure"
},
"GetServiceDetails": {
"key": "GetServiceDetailsResult",
"type": "service"
},
}

module.exports = OperationInfo;
1 change: 1 addition & 0 deletions LDBWSReturn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* LDBWSReturn.js
* This is a helper that defines the return key for the LDBWS Operation Requests.
* @deprecated LDBWSOperationInfo supercedes this
*/

const ReturnKey = {
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "ldbws-json",
"version": "1.0.1",
"version": "1.0.2",
"engines": {
"node": ">=7.6"
},
"description": "JSON Interface for the National Rail Enquiries Darwin OpenLDBWS SOAP service. Requires a valid token to access services.",
"author": "Steve Rogers <srogers.uk@gmail.com>",
"author": {
"name": "SpiralArm Consulting ltd",
"email": "srogers.uk@gmail.com"
},
"license": "MIT",
"homepage": "https://github.com/magnatronus/ldbws-json",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ Then, for example, to get the Departure Board Information for London Victoria (
const openLDBWS = require('ldbws-json');
const operation = require('ldbws-json/LDBWSOperation');
const requestData = require('ldbws-json/LDBWSRequestData');
const resultKeys = require('ldbws-json/LDBWSReturn');
const operationInfo = require('ldbws-json/LDBWSOperationInfo');
// Put a valid Token here
const token = "{PUT_YOUR_ASSIGNED_TOKEN_HERE}";
// Select the operation method we will call and use the helper to extract the result
// use of resultkeys is optional and provided for convienience only
const method = operation.GET_DEPARTURE_BOARD;
const key = resultKeys[method];
const key = operationInfo[method].key;
// populate the required data structure here we use the CRS code for London Victoria
const options = Object.assign({}, requestData.Board);
Expand Down
1 change: 0 additions & 1 deletion test/departuresoap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('SOAP Departures Test', function() {
options.filterList = ['EDB', 'LET'];
const envelope = `<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header><AccessToken xmlns="http://thalesgroup.com/RTTI/2013-11-28/Token/types"><TokenValue>${token}</TokenValue></AccessToken></Header><Body><GetNextDeparturesRequest xmlns="http://thalesgroup.com/RTTI/2017-02-02/ldb/"><crs>KGX</crs><filterList><crs>EDB</crs><crs>LET</crs></filterList><timeOffset>0</timeOffset><timeWindow>0</timeWindow></GetNextDeparturesRequest></Body></Envelope>`;
const soapCall = new LDBWSSoap(token, method, options).generateCall();
console.log(soapCall);
it('should equal the hardcoded envelope', function() {
assert.equal(soapCall, envelope);
});
Expand Down
2 changes: 1 addition & 1 deletion test/jsonboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('JSON Board Test', function() {
describe('#Departure Board JSON for Kings Cross', function() {
it('should have London Kings Cross as locationName', async function() {
const method = require('../LDBWSOperation').GET_DEPARTURE_BOARD;
const resultKey = require('../LDBWSReturn')[method];
const resultKey = require('../LDBWSOperationInfo')[method].key;
const options = Object.assign({}, require('../LDBWSRequestData').Board);
options.crs = "KGX";

Expand Down
2 changes: 1 addition & 1 deletion test/jsondeparture.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('JSON Departure Test', function() {
describe('#Next Departures JSON for Kings Cross', function() {
it('should have London Kings Cross as locationName', async function() {
const method = require('../LDBWSOperation').GET_NEXT_DEPARTURES;
const resultKey = require('../LDBWSReturn')[method];
const resultKey = require('../LDBWSOperationInfo')[method].key;
const options = Object.assign({}, require('../LDBWSRequestData').Departure);
options.crs = "KGX";
options.filterList = ['EDB', 'LET'];
Expand Down

0 comments on commit a6d1b15

Please sign in to comment.