Merge pull request #14322 from Archcry/master

Added ns-api typings
This commit is contained in:
Daniel Rosenwasser
2017-01-28 21:07:02 -08:00
committed by GitHub
4 changed files with 143 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
// Type definitions for ns-api 2.0
// Project: https://github.com/fvdm/nodejs-ns-api#readme
// Definitions by: Sander Koenders <https://github.com/Archcry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = nsApi;
declare function nsApi(conf: nsApi.Configuration): nsApi;
interface nsApi {
/**
* Vertrektijden - departure times
*
* @callback callback
* @param station {string} - Station ID
* @param callback {function} - `function (err, data) {}`
* @returns {void}
*/
vertrektijden(station: string, callback: (err: string, data: {}) => void): void;
/**
* Reisadvies - travel advise
*
* @callback callback
* @param params {object} - Parameters
* @param callback {function} - `function (err, data) {}`
* @returns {void}
*/
reisadvies(params: {}, callback: (err: string, data: {}) => void): void;
/**
* Prijzen - tariffs
*
* @callback callback
* @param params {object} - Parameters
* @param callback {function} - `function (err, data) {}`
* @returns {void}
*/
prijzen(params: {}, callback: (err: any, data: {}) => void): void;
/**
* List available stations
*
* @callback callback
* @param [treeKey] {string} - Group by this key
* @param callback {function} - `function (err, data) {}`
*/
stations(treeKey: string, callback: (err: string, data: {}) => void): void;
stations(callback: (err: string, data: {}) => void): void;
/**
* List disruptions
*
* @callback callback
* @param params {object} - Parameters
* @param callback {function} - `function (err, data) {}`
*/
storingen(params: {}, callback: (err: string, data: {}) => void): void;
}
declare namespace nsApi {
interface Configuration {
username: string;
password: string;
timeout?: number;
}
}
+56
View File
@@ -0,0 +1,56 @@
import * as NsApi from "ns-api";
let ns: NsApi = NsApi({
username: "",
password: "",
timeout: 1500
});
ns.vertrektijden("", (err: any, data: Object) => {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
// Get travel advise
ns.reisadvies ({}, (err: any, data: Object) => {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
ns.prijzen({}, (err: any, data: Object) => {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
ns.stations("code", (err: any, data: Object) => {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
ns.stations((err: any, data: Object) => {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
ns.storingen({}, (err: any, data: Object) => {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ns-api-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }