Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:35 +09:00
commit d641ec3923
2315 changed files with 250301 additions and 0 deletions

55
node_modules/pinterest-node-api/lib/Error.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
'use strict';
var debug = require('debug')('pinterest:Error');
var utils = require('./utils');
module.exports = _Error;
/**
* Generic Error Class to wrap any errors returned by pinterest-node-api
*/
function _Error() {
this.populate.apply(this, arguments);
var stack = (new Error(this.message)).stack;
debug('stack ', stack);
}
// Extend Native Error
_Error.prototype = Object.create(Error.prototype);
_Error.prototype.type = 'GenericError';
_Error.prototype.populate = function (type, message) {
this.Type = type;
this.Message = message;
};
_Error.extend = utils.protoExtend;
/**
* Create subclass of internal Error class
* (Specifically for errors returned from pinterest's REST API)
*/
var pinterestError = _Error.pinterestError = _Error.extend({
Type: 'pinterestError',
Message: '',
populate: function (raw) {
this.Type = this.type || 'unknown';
this.Code = raw.Code || 'GenericError';
this.Message = raw.message || raw.error || 'unknown';
this.StatusCode = raw.StatusCode || 'unknown';
}
});
/**
* Helper factory which takes raw pinterest errors and outputs wrapping instances
*/
pinterestError.generate = function () {
return new _Error('Generic', 'Unknown Error');
};
// Specific pinterest Error types:
_Error.pinterestInvalidRequestError = pinterestError.extend({ type: 'pinterestInvalidRequestError' });
_Error.pinterestAPIError = pinterestError.extend({ type: 'pinterestAPIError' });
_Error.pinterestPermissionError = pinterestError.extend({ type: 'pinterestPermissionError' });
_Error.pinterestRateLimitError = pinterestError.extend({ type: 'pinterestRateLimitError' });
_Error.pinterestConnectionError = pinterestError.extend({ type: 'pinterestConnectionError' });

View File

@@ -0,0 +1,43 @@
'use strict';
// Method for formatting HTTP body for the multipart/form-data specification
// Mostly taken from Fermata.js
function formDataDataGenerator(method, data, headers) {
var segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString();
headers['Content-Type'] = ('multipart/form-data; boundary=' + segno);
var buffer = new Buffer(0);
function push(l) {
var prevBuffer = buffer;
var newBuffer = (l instanceof Buffer) ? l : new Buffer(l);
buffer = new Buffer(prevBuffer.length + newBuffer.length + 2);
prevBuffer.copy(buffer);
newBuffer.copy(buffer, prevBuffer.length);
buffer.write('\r\n', buffer.length - 2);
}
function q(s) {
return '"' + s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ') + '"';
}
for (var k in data) {
var v = data[k];
push('--' + segno);
if (v.hasOwnProperty('data')) {
push('Content-Disposition: form-data; name=' + q(k) + '; filename=' + q(v.name || 'blob'));
push('Content-Type: ' + (v.type || 'application/octet-stream'));
push('');
push(v.data);
} else {
push('Content-Disposition: form-data; name=' + q(k));
push('');
push(v);
}
}
push('--' + segno + '--');
return buffer;
}
module.exports = formDataDataGenerator;

View File

@@ -0,0 +1,172 @@
'use strict';
// var debug = require('debug')('pinterest:PinterestHttpClient');
var Promise = require('bluebird');
var utils = require('./utils');
var OPTIONAL_REGEX = /^optional!/;
var _ = require('lodash');
/**
* Create an API method from the declared spec.
*
* @param [spec.method='GET'] Request Method (POST, GET, DELETE, PUT)
* @param [spec.path=''] Path to be appended to the API BASE_PATH, joined with
* the instance's path (e.g. 'users' or 'boards')
* @param [spec.required=[]] Array of required arguments in the order that they
* must be passed by the consumer of the API. Subsequent optional arguments are
* optionally passed through a hash (Object) as the penultimate argument
* (preceding the also-optional callback argument
* @param [spec.encode] Function for mutating input parameters to a method.
* Usefully for applying transforms to data on a per-method basis.
*/
module.exports = {
pinterestMethod: function (spec) {
var commandPath = typeof spec.path === 'function' ? spec.path
: utils.makeURLInterpolator(spec.path || '');
var requestMethod = (spec.method || 'GET').toUpperCase();
var urlParams = spec.urlParams || [];
var encode = spec.encode || function (data) {
return data;
};
return function () {
var self = this;
var args = [].slice.call(arguments);
var callback = typeof args[args.length - 1] === 'function' && args.pop();
var urlData = this.createUrlData();
return this.wrapTimeout(new Promise((function (resolve, reject) {
for (var i = 0, l = urlParams.length; i < l; ++i) {
// Note that we shift the args array after every iteration so this just
// grabs the "next" argument for use as a URL parameter.
var arg = args[0];
var param = urlParams[i];
var isOptional = OPTIONAL_REGEX.test(param);
param = param.replace(OPTIONAL_REGEX, '');
if (!arg) {
if (isOptional) {
urlData[param] = '';
continue;
}
return reject(new Error(
'pinterest: Argument "' + urlParams[i] + '" required, but got: ' + arg +
' (on API request to ' + requestMethod + ' ' + commandPath + ')'
));
}
urlData[param] = args.shift();
}
var data = encode(utils.getDataFromArgs(args));
var opts = utils.getOptionsFromArgs(args);
if (args.length) {
var err = new Error('pinterest: Unknown arguments (' + args + ').');
return reject(err);
}
var requestPath = this.createFullPath(commandPath, urlData);
function requestCallback(err, response) {
if (err) {
reject(err);
} else {
resolve(
spec.transformResponseData ?
spec.transformResponseData(response) :
response
);
}
}
var options = { headers: Object.assign(opts.headers, spec.headers) };
options.useBody = spec.useBody || false;
options.authorization = spec.authorization || '';
options.contentType = spec.contentType || '';
self._request(requestMethod, requestPath, data, opts.auth, options, requestCallback);
}).bind(this)), callback);
};
},
setMetadata: function (id, key, value, auth, cb) {
var self = this;
var data = key;
var isObject = _.isPlainObject(key);
// We assume null for an empty object
var isNull = data === null || (isObject && !Object.keys(data).length);
// Allow optional passing of auth & cb:
if ((isNull || isObject) && typeof value === 'string') {
auth = value;
} else if (typeof auth !== 'string') {
if (!cb && typeof auth === 'function') {
cb = auth;
}
auth = null;
}
var urlData = this.createUrlData();
var path = this.createFullPath('/' + id, urlData);
return this.wrapTimeout(new Promise((function (resolve, reject) {
if (isNull) {
// Reset metadata:
sendMetadata(null, auth);
} else if (!isObject) {
// Set individual metadata property:
var metadata = {};
metadata[key] = value;
sendMetadata(metadata, auth);
} else {
// Set entire metadata object after resetting it:
this._request('POST', path, {
metadata: null
}, auth, {}, function (err) {
if (err) {
return reject(err);
}
sendMetadata(data, auth);
});
}
function sendMetadata(metadata, auth) {
self._request('POST', path, {
metadata: metadata
}, auth, {}, function (err, response) {
if (err) {
reject(err);
} else {
resolve(response.metadata);
}
});
}
}).bind(this)), cb);
},
getMetadata: function (id, auth, cb) {
if (!cb && typeof auth === 'function') {
cb = auth;
auth = null;
}
var urlData = this.createUrlData();
var path = this.createFullPath('/' + id, urlData);
return this.wrapTimeout(new Promise((function (resolve, reject) {
this._request('GET', path, {}, auth, {}, function (err, response) {
if (err) {
reject(err);
} else {
resolve(response.metadata);
}
});
}).bind(this)), cb);
}
};

358
node_modules/pinterest-node-api/lib/Resource.js generated vendored Normal file
View File

@@ -0,0 +1,358 @@
'use strict';
var debug = require('debug')('pinterest:Resource');
var http = require('http');
var https = require('https');
var path = require('path');
var xml2js = require('xml2js');
var qs = require('qs');
var iconv = require('iconv-lite');
var utils = require('./utils');
var Error = require('./Error');
var hasOwn = {}.hasOwnProperty;
var RESPONSE_CONTENT_TYPE = ['text/xml', 'text/xml;charset=utf-8', 'application/xml'];
// Provide extension mechanism for pinterest Resource Sub-Classes
pinterestResource.extend = utils.protoExtend;
// Expose method-creator & prepared (basic) methods
pinterestResource.methods = require('./PinterestHttpClient');
/**
* Encapsulates request logic for a pinterest Resource
*/
function pinterestResource(pinterest, urlData) {
this._pinterest = pinterest;
this._urlData = urlData || {};
this.basePath = utils.makeURLInterpolator(pinterest.getApiField('basePath'));
this.path = utils.makeURLInterpolator(this.path);
if (this.includeBasic) {
this.includeBasic.forEach(function (methodName) {
this[methodName] = pinterestResource.methods[methodName];
}, this);
}
this.initialize.apply(this, arguments);
}
pinterestResource.prototype = {
path: '',
requestBody: {},
requestParamsJSON: {},
initialize: function () {
},
// Function to override the default data processor. This allows full control
// over how a pinterestResource's request data will get converted into an HTTP
// body. This is useful for non-standard HTTP requests. The function should
// take method name, data, and headers as arguments.
requestDataProcessor: null,
// String that overrides the base API endpoint. If `overrideHost` is not null
// then all requests for a particular resource will be sent to a base API
// endpoint as defined by `overrideHost`.
overrideHost: null,
createFullPath: function (commandPath, urlData) {
return path.join(
this.basePath(urlData),
this.path(urlData),
typeof commandPath === 'function' ?
commandPath(urlData) : commandPath
).replace(/\\/g, '/'); // ugly workaround for Windows
},
createUrlData: function () {
var urlData = {};
// Merge in baseData
for (var i in this._urlData) {
if (hasOwn.call(this._urlData, i)) {
urlData[i] = this._urlData[i];
}
}
return urlData;
},
wrapTimeout: function (promise, callback) {
if (callback) {
// Ensure callback is called outside of promise stack.
return promise.then(function (res) {
setTimeout(function () {
callback(null, res);
}, 0);
}, function (err) {
setTimeout(function () {
callback(err, null);
}, 0);
});
}
return promise;
},
_timeoutHandler: function (timeout, req, callback) {
var self = this;
return function () {
var timeoutErr = new Error('ETIMEDOUT');
timeoutErr.code = 'ETIMEDOUT';
req._isAborted = true;
req.abort();
callback.call(self, new Error.pinterestConnectionError({
message: 'Request aborted due to timeout being reached (' + timeout + 'ms)'
}), null);
};
},
_responseHandler: function (requestParamsJSONCopy, req, userOptions, callback) {
var self = this;
function processResponseType(res, responseString, callback) {
//debug('res %o ', res);
//debug('res.headers %o ', res.headers);
if (RESPONSE_CONTENT_TYPE.indexOf(res.headers['content-type'].toLowerCase()) > -1) {
debug('It is XML Response');
var parser = new xml2js.Parser({
explicitArray: false,
ignoreAttrs: true
});
parser.parseString(responseString, function (err, response) {
//debug('response after parsing JSON %o ', response);
return callback(null, response);
});
} else {
debug('It is NON-XML Response');
try {
var response = JSON.parse(responseString);
return callback(null, response);
} catch (exception) {
debug('exception ', exception);
return callback(callback, responseString);
}
}
}
return function (res) {
debug('----------- Received Response -------------');
var dbgResponseBuffer = [];
var headers = res.headers;
var statusCode = res.statusCode;
// debug('res ', res);
try {
statusCode = parseInt(statusCode, 10);
} catch (Exception) {
debug('Failed to parse statusCode as statusCode not provided in the response. ', statusCode);
}
var charset = '';
var content_type = '';
var responseString = '';
if (headers['content-type']) {
content_type = headers['content-type'].toLowerCase();
}
if (content_type && content_type.indexOf('charset') > -1 && content_type.split(';')[0] && content_type.split(';')[1]) {
if (content_type.split(';')[1] && content_type.split(';')[1].trim().match(/^((\b[^\s=]+)=(([^=]|\\=)+))*$/)[3]) {
charset = content_type.split(';')[1].trim().match(/^((\b[^\s=]+)=(([^=]|\\=)+))*$/)[3];
}
content_type = content_type.split(';')[0].toLowerCase();
}
var ResponseHeaders = headers;
res.on('data', function (chunk) {
dbgResponseBuffer.push(chunk);
});
res.on('end', function () {
var bufferString = Buffer.concat(dbgResponseBuffer);
/**
* You can use Either userRaw or userCharset.
* Both of them will not work together.
*/
if (userOptions.userRaw === true) {
var response = {
data: bufferString,
Headers: ResponseHeaders
};
return callback.call(self, null, response);
}
if (userOptions.userCharset && userOptions.userCharset.length > 0) {
debug('Inside user Charset option');
charset = userOptions.userCharset;
try {
var win1251String = iconv.decode(bufferString, 'win1251');
responseString = iconv.encode(win1251String, charset);
} catch (Exception) {
debug('Exception iconv ', Exception);
return callback.call(self, new Error.pinterestAPIError({
message: 'Failed to parse response received from the pinterest API',
StatusCode: statusCode || 'unknown'
}), null);
}
} else {
responseString = bufferString.toString('utf8');
}
debug('responseString ', responseString);
debug('content_type ', content_type);
debug('statusCode ', statusCode);
debug('x-ratelimit-remaining ', ResponseHeaders['x-ratelimit-remaining']);
try {
if (!responseString && statusCode < 400) {
Object.defineProperty({}, 'lastResponse', {
enumerable: false,
writable: false,
value: res
});
return callback.call(self, null, {});
}
processResponseType(res, responseString, function (error, response) {
if (response.errors) {
debug('It is ErrorResponse');
var errorResponse = response.errors;
errorResponse.Headers = ResponseHeaders;
errorResponse.StatusCode = statusCode || 'unknown';
return callback.call(self, errorResponse, null);
} else if (response.error) {
debug('It is ErrorResponse have a single error');
var errorDetail = response;
errorDetail.Headers = ResponseHeaders;
errorDetail.StatusCode = statusCode || 'unknown';
return callback.call(self, errorDetail, null);
} else if (error) {
return callback.call(self, new Error.pinterestAPIError({
message: 'Failed to parse response received from the pinterest API',
StatusCode: statusCode || 'unknown'
}), null);
}
debug('-----------------------------------------------------------------');
// debug('final response %o ', response);
// Expose res object
Object.defineProperty(response, 'lastResponse', {
enumerable: false,
writable: false,
value: res
});
return callback.call(self, null, response);
});
} catch (exception) {
return callback.call(self, new Error.pinterestAPIError({
message: 'Invalid response received from the pinterest API',
StatusCode: statusCode || 'unknown'
}), null);
}
});
};
},
_errorHandler: function (req, callback) {
var self = this;
return function (error) {
if (req._isAborted) {
// already handled
return;
}
callback.call(self, new Error.pinterestConnectionError({
message: 'An error occurred with our connection to pinterest',
error: error
}), null);
};
},
_request: function (method, path, data, auth, options, callback) {
var requestParamsJSONCopy = JSON.parse(JSON.stringify(data));
var self = this;
self.body = '';
var userRaw = '';
var userCharset = '';
/**custom option passed by user, a better way to do this would be nice */
if (data.__RAW__) {
userRaw = data.__RAW__;
delete data.__RAW__;
}
if (data.__CHARSET__) {
userCharset = data.__CHARSET__;
delete data.__CHARSET__;
}
var authorization = 'Bearer';
if (options.authorization === 'Basic') {
authorization = options.authorization;
var keySecret = self._pinterest.getApiField('key') + ':' + self._pinterest.getApiField('secret');
var buffer = new Buffer(keySecret);
var base64String = buffer.toString('base64');
authorization = authorization.concat(' ', base64String);
} else {
authorization = authorization.concat(' ', self._pinterest.getApiField('userToken'));
}
var headers = {
// 'Content-Type': 'application/json',
'Accept': 'application/json',
'cache-control': 'no-cache',
'Content-Language': 'en-US',
'Authorization': authorization
};
if (options.contentType && options.contentType === 'application/json') {
self.body = JSON.stringify(data);
headers['Content-Length'] = self.body.length;
} else if (['POST', 'PUT', 'PATCH'].indexOf(method) > -1) {
headers['Content-Type'] = 'application/json';
self.body = JSON.stringify(data);
headers['Content-Length'] = self.body.length;
} else if (['GET'].indexOf(method) > -1) {
path = path.concat('?', qs.stringify(data));
} else if (['DELETE'].indexOf(method) > -1) {
self.body = JSON.stringify(data);
}
makeRequest();
function makeRequest() {
var timeout = self._pinterest.getApiField('timeout');
var isInsecureConnection = self._pinterest.getApiField('protocol') === 'http';
var host = self.overrideHost || self._pinterest.getApiField('host');
var params = {
hostname: host,
port: self._pinterest.getApiField('port'),
path: path,
method: method,
headers: headers
};
debug('path ', path);
debug('params %o ', params);
debug('self.body %o ', self.body);
var req = (isInsecureConnection ? http : https).request(params);
req.setTimeout(timeout, self._timeoutHandler(timeout, req, callback));
var userOptions = {
userCharset: userCharset,
userRaw: userRaw
};
req.on('response', self._responseHandler(requestParamsJSONCopy, req, userOptions, callback));
req.on('error', self._errorHandler(req, callback));
req.on('socket', function (socket) {
socket.on((isInsecureConnection ? 'connect' : 'secureConnect'), function () {
// Send payload; we're safe:
req.write(self.body);
req.end();
});
});
}
}
};
module.exports = pinterestResource;

95
node_modules/pinterest-node-api/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
'use strict';
// var debug = require('debug')('pinterest:pinterest-node-api-index');
pinterest.DEFAULT_HOST = 'api.pinterest.com';
pinterest.DEFAULT_PORT = '443';
pinterest.DEFAULT_BASE_PATH = '/';
pinterest.DEFAULT_RESPONSE_FORMAT = '.json';
pinterest.DEFAULT_API_VERSION = null;
// Use node's default timeout:
pinterest.DEFAULT_TIMEOUT = require('http').createServer().timeout;
pinterest.PACKAGE_VERSION = require('../package.json').version;
var resources = {
users: require('./resources/users'),
boards: require('./resources/boards'),
pins: require('./resources/pins'),
sections: require('./resources/sections')
};
pinterest.pinterestResource = require('./Resource');
pinterest.resources = resources;
function pinterest(clientAccessToken) {
if (!(this instanceof pinterest)) {
return new pinterest(clientAccessToken);
}
this._api = {
auth: null,
host: pinterest.DEFAULT_HOST,
port: pinterest.DEFAULT_PORT,
basePath: pinterest.DEFAULT_BASE_PATH,
version: pinterest.DEFAULT_API_VERSION,
timeout: pinterest.DEFAULT_TIMEOUT
};
this._prepResources();
this.setUserToken(clientAccessToken);
this.setResponseFormat(pinterest.DEFAULT_RESPONSE_FORMAT);
}
pinterest.prototype = {
setHost: function (host, port, protocol) {
this._setApiField('host', host);
if (port) {
this.setPort(port);
}
if (protocol) {
this.setProtocol(protocol);
}
},
setProtocol: function (protocol) {
this._setApiField('protocol', protocol.toLowerCase());
},
setPort: function (port) {
this._setApiField('port', port);
},
setResponseFormat: function (format) {
this._setApiField('format', format);
},
setUserToken: function (token) {
if (token) {
this._setApiField('userToken', token);
}
},
setTimeout: function (timeout) {
this._setApiField('timeout', timeout === null ? pinterest.DEFAULT_TIMEOUT : timeout);
},
_setApiField: function (key, value) {
this._api[key] = value;
},
getApiField: function (key) {
return this._api[key];
},
_prepResources: function () {
for (var name in resources) {
this[name[0].toLowerCase() + name.substring(1)] = new resources[name](this);
}
}
};
module.exports = pinterest;
module.exports.pinterest = pinterest;

View File

@@ -0,0 +1,45 @@
'use strict';
var pinterestResource = require('../Resource');
var pinterestMethod = pinterestResource.methods.pinterestMethod;
module.exports = pinterestResource.extend({
createBoard: pinterestMethod({
method: 'POST',
path: 'v1/boards/'
}),
getBoard: pinterestMethod({
method: 'GET',
path: 'v1/boards/{board}/',
urlParams: ['board'],
required: ['board']
}),
getBoardPins: pinterestMethod({
method: 'GET',
path: 'v1/boards/{board}/pins/',
urlParams: ['board'],
required: ['board']
}),
getUserBoards: pinterestMethod({
method: 'GET',
path: 'v1/me/boards/'
}),
updateBoard: pinterestMethod({
method: 'PATCH',
path: 'v1/boards/{board}/',
urlParams: ['board'],
required: ['board']
}),
deleteBoard: pinterestMethod({
method: 'DELETE',
path: 'v1/boards/{board}/',
urlParams: ['board'],
required: ['board']
})
});

45
node_modules/pinterest-node-api/lib/resources/pins.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
'use strict';
var pinterestResource = require('../Resource');
var pinterestMethod = pinterestResource.methods.pinterestMethod;
module.exports = pinterestResource.extend({
createPin: pinterestMethod({
method: 'POST',
path: 'v1/pins/'
}),
getPin: pinterestMethod({
method: 'GET',
path: 'v1/pins/{pin}/',
urlParams: ['pin'],
required: ['pin']
}),
getBoardPins: pinterestMethod({
method: 'GET',
path: 'v1/boards/{board}/pins/',
urlParams: ['board'],
required: ['board']
}),
getUserPins: pinterestMethod({
method: 'GET',
path: 'v1/me/pins/'
}),
updatePin: pinterestMethod({
method: 'PATCH',
path: 'v1/pins/{pin}/',
urlParams: ['pin'],
required: ['pin']
}),
deletePin: pinterestMethod({
method: 'DELETE',
path: 'v1/pins/{pin}/',
urlParams: ['pin'],
required: ['pin']
})
});

View File

@@ -0,0 +1,35 @@
'use strict';
var pinterestResource = require('../Resource');
var pinterestMethod = pinterestResource.methods.pinterestMethod;
module.exports = pinterestResource.extend({
createBoardSection: pinterestMethod({
method: 'PUT',
path: 'v1/board/{board}/sections/',
urlParams: ['board'],
required: ['board']
}),
getBoardSections: pinterestMethod({
method: 'GET',
path: 'v1/board/{board}/sections/',
urlParams: ['board'],
required: ['board']
}),
getBoardSectionPins: pinterestMethod({
method: 'GET',
path: 'v1/board/sections/{section}/pins/',
urlParams: ['section'],
required: ['section']
}),
deleteBoardSection: pinterestMethod({
method: 'DELETE',
path: 'v1/board/sections/{section}/',
urlParams: ['section'],
required: ['section']
})
});

88
node_modules/pinterest-node-api/lib/resources/users.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
'use strict';
var pinterestResource = require('../Resource');
var pinterestMethod = pinterestResource.methods.pinterestMethod;
module.exports = pinterestResource.extend({
getUserOwnInfo: pinterestMethod({
method: 'GET',
path: 'v1/me/'
}),
getUserBoards: pinterestMethod({
method: 'GET',
path: 'v1/me/boards/'
}),
getUserBoardSuggestions: pinterestMethod({
method: 'GET',
path: 'v1/me/boards/suggested/'
}),
getUserPins: pinterestMethod({
method: 'GET',
path: 'v1/me/pins/'
}),
searchUserBoards: pinterestMethod({
method: 'GET',
path: 'v1/me/search/boards/'
}),
searchUserPins: pinterestMethod({
method: 'GET',
path: 'v1/me/search/pins/'
}),
followBoard: pinterestMethod({
method: 'POST',
path: 'v1/me/following/boards/'
}),
followUser: pinterestMethod({
method: 'POST',
path: 'v1/me/following/users/'
}),
getUserFollowers: pinterestMethod({
method: 'GET',
path: 'v1/me/followers/'
}),
getUserFollowingBoards: pinterestMethod({
method: 'GET',
path: 'v1/me/following/boards/'
}),
getUserFollowingInterests: pinterestMethod({
method: 'GET',
path: 'v1/me/following/interests/'
}),
getUserFollowingUsers: pinterestMethod({
method: 'GET',
path: 'v1/me/following/users/'
}),
unfollowBoard: pinterestMethod({
method: 'DELETE',
path: 'v1/me/following/boards/{board}/',
urlParams: ['board'],
required: ['board']
}),
unfollowUser: pinterestMethod({
method: 'DELETE',
path: 'v1/me/following/users/{user}/',
urlParams: ['user'],
required: ['user']
}),
getUserInfo: pinterestMethod({
method: 'GET',
path: 'v1/users/{user}/',
urlParams: ['user'],
required: ['user']
})
});

92
node_modules/pinterest-node-api/lib/utils/index.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
'use strict';
var hasOwn = {}.hasOwnProperty;
var _ = require('lodash');
var utils = module.exports = {
isAuthKey: function (key) {
return typeof key === 'string' && /^(?:[a-z]{2}_)?[A-z0-9]{32}$/.test(key);
},
isOptionsHash: function (o) {
o = JSON.parse(JSON.stringify(o));
return _.isPlainObject(o) && ['api_key'].some(function (key) {
return o.hasOwnProperty(key);
});
},
/**
* Outputs a new function with interpolated object property values.
* Use like so:
* var fn = makeURLInterpolator('some/url/{param1}/{param2}');
* fn({ param1: 123, param2: 456 }); // => 'some/url/123/456'
*/
makeURLInterpolator: (function () {
var rc = {
'\n': '\\n', '\"': '\\\"',
'\u2028': '\\u2028', '\u2029': '\\u2029'
};
return function makeURLInterpolator(str) {
var cleanString = str.replace(/["\n\r\u2028\u2029]/g, function ($0) {
return rc[$0];
});
return function (outputs) {
return cleanString.replace(/\{([\s\S]+?)\}/g, function ($0, $1) {
return encodeURIComponent(outputs[$1] || '');
});
};
};
}()),
/**
* Return the data argument from a list of arguments
*/
getDataFromArgs: function (args) {
if (args.length > 0) {
if (_.isPlainObject(args[0]) && !utils.isOptionsHash(args[0])) {
return args.shift();
}
}
return {};
},
/**
* Return the options hash from a list of arguments
*/
getOptionsFromArgs: function (args) {
var opts = {
auth: null,
headers: {}
};
if (args.length > 0) {
var arg = args[args.length - 1];
if (utils.isAuthKey(arg)) {
opts.auth = args.pop();
}
}
return opts;
},
/**
* Provide simple "Class" extension mechanism
*/
protoExtend: function (sub) {
var Super = this;
var Constructor = hasOwn.call(sub, 'constructor') ? sub.constructor : function () {
Super.apply(this, arguments);
};
Constructor.prototype = Object.create(Super.prototype);
for (var i in sub) {
if (hasOwn.call(sub, i)) {
Constructor.prototype[i] = sub[i];
}
}
for (i in Super) {
if (hasOwn.call(Super, i)) {
Constructor[i] = Super[i];
}
}
return Constructor;
}
};