Module: utils

SDK Utilities, used internally.
Source:

Methods

(inner) addQueries(uri, params, toExcludeopt) → {URIjs}

Append querystring using key-value pairs from an object. If a key exists both in the uri object and params, the one in the uri object will be replaced. Any camelcased key is automatically converted to lowercase with underscore separators. Some keys can be excluded automatically. They include: secret.
Parameters:
Name Type Attributes Default Description
uri URI an instance of URIjs
params Object object with parameters
toExclude Boolean <optional>
true whether to exclude keys automatically
Source:
Returns:
the uri with the queries appended
Type
URIjs

(inner) allowOptionalParams(params, callbackopt) → {Object|function|function}

Allow 'params' to be optional, thus user can pass 'callback' in its place.
Parameters:
Name Type Attributes Description
params * user's params
callback function <optional>
user's callback
Source:
Returns:
  • args
    Type
    Object
  • args.callback
    Type
    function
  • args.params
    Type
    function

(inner) createTimestamp() → {Number}

Generate a UNIX timestamp
Source:
Returns:
UNIX timestamp
Type
Number

(inner) getAuthOptions(sources, destopt) → {Object}

Return an object with authentication options from an object
Parameters:
Name Type Attributes Description
sources Object | Array.<Object> objects to look for the properties
dest Object <optional>
destination object
Source:
Returns:
options
Type
Object

(inner) getOptions(sources, keys, destopt) → {Object}

Return an object with key-value pairs, using keys, from an object
Parameters:
Name Type Attributes Description
sources Object | Array.<Object> object(s) to look for the properties
keys Array an array of keys of the properties to look up
dest Object <optional>
destination object
Source:
Returns:
options
Type
Object

(inner) getPollerOptions(sources, destopt) → {Object}

Return an object with poller options from sources
Parameters:
Name Type Attributes Description
sources Object | Array.<Object>
dest Object <optional>
Source:
Returns:
options
Type
Object

(inner) getProxy() → {String}

Return the currently set proxy
Source:
Returns:
the set proxy url
Type
String

(inner) getURIOptions(sources, destopt) → {Object}

Return an object with options required to instantiate URI.
Parameters:
Name Type Attributes Description
sources Object | Array.<Object> objects to look for the properties
dest Object <optional>
destination object
Source:
Returns:
options
Type
Object

(inner) passResponse(callback, optionsopt) → {function}

Parse response then pass to callback
Parameters:
Name Type Attributes Description
callback function user's callback
options Object <optional>
Properties
Name Type Attributes Description
post Boolean <optional>
callback is for a POST request
put Boolean <optional>
callback is for a PUT request
Source:
Returns:
function to handle responses from `request` calls
Type
function

(inner) pickParams(params) → {Object}

Pick out parameters
Parameters:
Name Type Description
params Object
Source:
Returns:
cleaner params
Type
Object

(inner) removeAuthOptions(…objects)

Remove all options applicable for signing requests
Parameters:
Name Type Attributes Description
objects Object <repeatable>
objects to modify
Source:

(inner) removeOptions(args, keys)

Delete keys from objects
Parameters:
Name Type Description
args Array.<Object>
keys String | Array.<String>
Source:

(inner) removeURIOptions(…objects)

Remove all options applicable for creating a new URI instance
Parameters:
Name Type Attributes Description
objects Object <repeatable>
objects to modify
Source:

(inner) request() → {Object}

Return a custom request object
Source:
Returns:
request object
Type
Object

(inner) setProxy(proxy)

Setting up proxy for the whole SDK
Parameters:
Name Type Description
proxy String a valid url
Source:

(inner) setup(settings) → {Object}

Set the SDK settings
Parameters:
Name Type Description
settings SETTINGS new SDK settings
Source:
Returns:
the newly-set SDK settings
Type
Object

(inner) shuffleArray(array) → {Array}

Shuffles items in an array Operation takes O(n) time. The array passed is operated on as its reference, rather than value, is passed to the function.
Parameters:
Name Type Description
array Array an array of items
Source:
Returns:
array with the the items shuffled
Type
Array

(inner) sortKeys(object) → {Array}

Return a sorted array of an object's keys
Parameters:
Name Type Description
object Object an object
Source:
Returns:
array of sorted keys
Type
Array

(inner) url(labelopt, optionsopt) → {URI}

Return an URI object (from URI.js) for easier URL building.
Parameters:
Name Type Attributes Description
label String <optional>
label - identifying the URL.
options Object <optional>
options - options to be used
Source:
See:
Returns:
an instance of URI.js
Type
URI