lib/generate.js
function newPostOne(endpoint, options) {
    // for backwards-compatibility <= 0.11.1
    if (_.isArray(options)) {
        options = { allowable: options };
    }
    options = _.defaultsDeep({}, options, {
        allowable: [],
        method: "post",
    });

    return function(body, callback) {
        // get and remove/detach URI options
        var uriOptions = utils.getURIOptions([utils.setup(), options, this, body]);
        utils.removeURIOptions(body);
        // create a URI
        var uri = utils.url(endpoint, uriOptions);
        // get auth options
        var authOptions = utils.getAuthOptions([utils.setup(), this, body]);
        utils.removeAuthOptions(body);
        // remove params that are not allowed
        body = utils.pickParams(body, options.allowable);
        // sign the URI (automatically removes the secret param from body)
        try {
            auth.sign(authOptions.key, authOptions.secret, uri, body, {
                apiVersion: uriOptions.apiVersion,
            });
        } catch(err) {
            return callback(err);
        }

        var url = uri.toString();
        var method;
        var resOpts = {};
        switch (options.method) {
        case "put":
            method = "put";
            resOpts.put = true;
            break;
        case "post":
        default:
            method = "post";
            resOpts.post = true;
        }

        debug("[%s] /%s (%s) [%j]", method.toUpperCase(), endpoint, url, body);
        return utils.request()[method]({
            url: url,
            body: body,
        }, utils.passResponse(callback, resOpts));
    };
}
function newPostOne(endpoint, options) {
    // for backwards-compatibility <= 0.11.1
    if (_.isArray(options)) {
        options = { allowable: options };
    }
    options = _.defaultsDeep({}, options, {
        allowable: [],
        method: "post",
    });

    return function(body, callback) {
        // get and remove/detach URI options
        var uriOptions = utils.getURIOptions([utils.setup(), options, this, body]);
        utils.removeURIOptions(body);
        // create a URI
        var uri = utils.url(endpoint, uriOptions);
        // get auth options
        var authOptions = utils.getAuthOptions([utils.setup(), this, body]);
        utils.removeAuthOptions(body);
        // remove params that are not allowed
        body = utils.pickParams(body, options.allowable);
        // sign the URI (automatically removes the secret param from body)
        try {
            auth.sign(authOptions.key, authOptions.secret, uri, body, {
                apiVersion: uriOptions.apiVersion,
            });
        } catch(err) {
            return callback(err);
        }

        var url = uri.toString();
        var method;
        var resOpts = {};
        switch (options.method) {
        case "put":
            method = "put";
            resOpts.put = true;
            break;
        case "post":
        default:
            method = "post";
            resOpts.post = true;
        }

        debug("[%s] /%s (%s) [%j]", method.toUpperCase(), endpoint, url, body);
        return utils.request()[method]({
            url: url,
            body: body,
        }, utils.passResponse(callback, resOpts));
    };
}
function newPostOne ( endpoint , options ) { // for backwards-compatibility <= 0.11.1 if ( _ . isArray ( options ) ) { options = { allowable : options } ; } options = _ . defaultsDeep ( { } , options , { allowable : [ ] , method : "post" , } ) ; return function ( body , callback ) { // get and remove/detach URI options var uriOptions = utils . getURIOptions ( [ utils . setup ( ) , options , this , body ] ) ; utils . removeURIOptions ( body ) ; // create a URI var uri = utils . url ( endpoint , uriOptions ) ; // get auth options var authOptions = utils . getAuthOptions ( [ utils . setup ( ) , this , body ] ) ; utils . removeAuthOptions ( body ) ; // remove params that are not allowed body = utils . pickParams ( body , options . allowable ) ; // sign the URI (automatically removes the secret param from body) try { auth . sign ( authOptions . key , authOptions . secret , uri , body , { apiVersion : uriOptions . apiVersion , } ) ; } catch ( err ) { return callback ( err ) ; } var url = uri . toString ( ) ; var method ; var resOpts = { } ; switch ( options . method ) { case "put" : method = "put" ; resOpts . put = true ; break ; case "post" : default : method = "post" ; resOpts . post = true ; } debug ( "[%s] /%s (%s) [%j]" , method . toUpperCase ( ) , endpoint , url , body ) ; return utils . request ( ) [ method ] ( { url : url , body : body , } , utils . passResponse ( callback , resOpts ) ) ; } ; }
Return a function for posting items

@param  {Endpoint} endpoint
@param  {Object} [options]
@param  {String[]} [options.allowable]
@param  {String} [options.method=post]
@param  {Number} [options.apiVersion=2] API version used
@return {itemsPostOneRequest}
Return a function for posting items