Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addToMany and followMany API operations added.
- Loading branch information
Matthisk
authored and
Matthisk
committed
Oct 23, 2015
1 parent
8d7a594
commit ca61067
Showing
10 changed files
with
12,212 additions
and
7,729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var httpSignature = require('http-signature'); | ||
var request = require('request'); | ||
|
||
module.exports = { | ||
addToMany: function(activity, feeds, callback) { | ||
var req = this.makeSignedRequest({ | ||
url: 'feed/add_to_many/', | ||
body: { | ||
'activity': activity, | ||
'feeds': feeds | ||
} | ||
}, callback); | ||
|
||
return req; | ||
}, | ||
|
||
followMany: function(follows, callback) { | ||
var req = this.makeSignedRequest({ | ||
url: 'follow_many/', | ||
body: follows | ||
}, callback); | ||
|
||
return req; | ||
}, | ||
|
||
makeSignedRequest: function(kwargs, cb) { | ||
if(!this.apiSecret) { | ||
throw new errors.SiteError('Missing secret, which is needed to perform signed requests, use var client = stream.connect(key, secret);'); | ||
} | ||
|
||
this.send('request', 'post', kwargs, cb); | ||
|
||
kwargs.url = this.enrichUrl(kwargs.url); | ||
kwargs.json = true; | ||
kwargs.method = 'POST'; | ||
kwargs.headers = { 'X-Api-Key' : this.apiKey }; | ||
|
||
var callback = this.wrapCallback(cb); | ||
var req = request(kwargs, callback); | ||
|
||
httpSignature.sign(req, { | ||
algorithm: 'hmac-sha256', | ||
key: this.apiSecret, | ||
keyId: this.apiKey | ||
}); | ||
|
||
return request; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.