1036 lines
43 KiB
JavaScript
1036 lines
43 KiB
JavaScript
|
/**
|
|||
|
* mixin user
|
|||
|
*
|
|||
|
* Copyright 2012 Cloud9 IDE, Inc.
|
|||
|
*
|
|||
|
* This product includes software developed by
|
|||
|
* Cloud9 IDE, Inc (http://c9.io).
|
|||
|
*
|
|||
|
* Author: Mike de Boer <info@mikedeboer.nl>
|
|||
|
**/
|
|||
|
|
|||
|
"use strict";
|
|||
|
|
|||
|
var error = require("./../../error");
|
|||
|
var Util = require("./../../util");
|
|||
|
|
|||
|
var user = module.exports = {
|
|||
|
user: {}
|
|||
|
};
|
|||
|
|
|||
|
(function() {
|
|||
|
/** section: github
|
|||
|
* user#getAll(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - since (Number): Optional. The integer ID of the last User that you’ve seen.
|
|||
|
**/
|
|||
|
this.getAll = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getFrom(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
**/
|
|||
|
this.getFrom = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#get(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* No other params, simply pass an empty Object literal `{}`
|
|||
|
**/
|
|||
|
this.get = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#update(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - name (String): Optional.
|
|||
|
* - email (String): Optional.
|
|||
|
* - blog (String): Optional.
|
|||
|
* - company (String): Optional.
|
|||
|
* - location (String): Optional.
|
|||
|
* - hireable (Boolean): Optional.
|
|||
|
* - bio (String): Optional.
|
|||
|
**/
|
|||
|
this.update = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getOrgs(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getOrgs = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#editOrganizationMembership(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - org (String): Required.
|
|||
|
* - state (String): Required. Validation rule: ` ^(open|closed|active)$ `.
|
|||
|
**/
|
|||
|
this.editOrganizationMembership = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getTeams(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getTeams = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getEmails(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getEmails = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#addEmails(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* No other params, simply pass an empty Object literal `{}`
|
|||
|
**/
|
|||
|
this.addEmails = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#deleteEmails(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* No other params, simply pass an empty Object literal `{}`
|
|||
|
**/
|
|||
|
this.deleteEmails = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getFollowers(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getFollowers = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getFollowingFromUser(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getFollowingFromUser = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getFollowing(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getFollowing = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getFollowUser(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getFollowUser = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#followUser(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
**/
|
|||
|
this.followUser = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#unFollowUser(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
**/
|
|||
|
this.unFollowUser = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getKeys(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getKeys = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getKeysFromUser(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - user (String): Required.
|
|||
|
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
|
|||
|
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
|
|||
|
**/
|
|||
|
this.getKeysFromUser = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#getKey(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - id (String): Required.
|
|||
|
**/
|
|||
|
this.getKey = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#createKey(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - title (String): Required.
|
|||
|
* - key (String): Required.
|
|||
|
**/
|
|||
|
this.createKey = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#updateKey(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - id (String): Required.
|
|||
|
* - title (String): Required.
|
|||
|
* - key (String): Required.
|
|||
|
**/
|
|||
|
this.updateKey = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
/** section: github
|
|||
|
* user#deleteKey(msg, callback) -> null
|
|||
|
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
|
|||
|
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
|
|||
|
*
|
|||
|
* ##### Params on the `msg` object:
|
|||
|
*
|
|||
|
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
|
|||
|
* - id (String): Required.
|
|||
|
**/
|
|||
|
this.deleteKey = function(msg, block, callback) {
|
|||
|
var self = this;
|
|||
|
this.client.httpSend(msg, block, function(err, res) {
|
|||
|
if (err)
|
|||
|
return self.sendError(err, null, msg, callback);
|
|||
|
|
|||
|
var ret;
|
|||
|
try {
|
|||
|
ret = res.data;
|
|||
|
var contentType = res.headers["content-type"];
|
|||
|
if (contentType && contentType.indexOf("application/json") !== -1)
|
|||
|
ret = JSON.parse(ret);
|
|||
|
}
|
|||
|
catch (ex) {
|
|||
|
if (callback)
|
|||
|
callback(new error.InternalServerError(ex.message), res);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!ret)
|
|||
|
ret = {};
|
|||
|
if (typeof ret == "object") {
|
|||
|
if (!ret.meta)
|
|||
|
ret.meta = {};
|
|||
|
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
|
|||
|
if (res.headers[header])
|
|||
|
ret.meta[header] = res.headers[header];
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (callback)
|
|||
|
callback(null, ret);
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
}).call(user.user);
|