API generation

This commit is contained in:
delvedor
2018-12-12 16:46:44 +01:00
parent 230b08ab86
commit ab90797b65
238 changed files with 4268 additions and 1661 deletions

View File

@ -8,15 +8,21 @@ function buildCcrGetAutoFollowPattern (opts) {
*
* @param {string} name - The name of the auto follow pattern.
*/
return function ccrGetAutoFollowPattern (params, callback) {
return function ccrGetAutoFollowPattern (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
ccrGetAutoFollowPattern(params, (err, body) => {
ccrGetAutoFollowPattern(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
@ -58,7 +64,7 @@ function buildCcrGetAutoFollowPattern (opts) {
)
}
var ignore = params.ignore || null
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
@ -70,12 +76,17 @@ function buildCcrGetAutoFollowPattern (opts) {
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
querystring,
body: null,
headers: params.headers || null,
ignore,
requestTimeout: params.requestTimeout || null
headers: params.headers || null
}
return makeRequest(request, callback)
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false
}
return makeRequest(request, requestOptions, callback)
}
}