|
|
@ -1,7 +1,8 @@ |
|
|
const _ = require('lodash') |
|
|
|
|
|
const api = require("./api").api; |
|
|
|
|
|
|
|
|
const _ = require('lodash'); |
|
|
|
|
|
const api = require("./api"); |
|
|
const Client = require("./client"); |
|
|
const Client = require("./client"); |
|
|
|
|
|
|
|
|
|
|
|
const initialClient = new Client({}) |
|
|
/*section: dogapi |
|
|
/*section: dogapi |
|
|
*comment: configure the dogapi client with your app/api keys |
|
|
*comment: configure the dogapi client with your app/api keys |
|
|
*params: |
|
|
*params: |
|
|
@ -41,8 +42,8 @@ const Client = require("./client"); |
|
|
function initialize(options){ |
|
|
function initialize(options){ |
|
|
options = options || {}; |
|
|
options = options || {}; |
|
|
for(var key in options){ |
|
|
for(var key in options){ |
|
|
if(module.exports.client.hasOwnProperty(key)){ |
|
|
|
|
|
module.exports.client[key] = options[key]; |
|
|
|
|
|
|
|
|
if(initialClient.hasOwnProperty(key)){ |
|
|
|
|
|
initialClient[key] = options[key]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
@ -50,10 +51,15 @@ function initialize(options){ |
|
|
function DogApi(options) { |
|
|
function DogApi(options) { |
|
|
const client = new Client(options || {}); |
|
|
const client = new Client(options || {}); |
|
|
_.forEach(api, (value, key) => { |
|
|
_.forEach(api, (value, key) => { |
|
|
this[key] = value(client) |
|
|
|
|
|
|
|
|
this[key] = value(client); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DogApi.initialize = initialize; |
|
|
|
|
|
_.forEach(api, (value, key) => { |
|
|
|
|
|
DogApi[key] = value(initialClient); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
/*section: dogapi |
|
|
/*section: dogapi |
|
|
*comment: get the current POSIX timestamp |
|
|
*comment: get the current POSIX timestamp |
|
|
*example: | |
|
|
*example: | |
|
|
@ -67,8 +73,7 @@ function DogApi(options) { |
|
|
function now(){ |
|
|
function now(){ |
|
|
return parseInt(new Date().getTime() / 1000); |
|
|
return parseInt(new Date().getTime() / 1000); |
|
|
}; |
|
|
}; |
|
|
module.exports = DogApi |
|
|
|
|
|
module.exports.initialize = initialize; |
|
|
|
|
|
|
|
|
module.exports = DogApi; |
|
|
module.exports.now = now; |
|
|
module.exports.now = now; |
|
|
module.exports.OK = 0; |
|
|
module.exports.OK = 0; |
|
|
module.exports.WARNING = 1; |
|
|
module.exports.WARNING = 1; |
|
|
|