Skip to content

Commit

Permalink
support multi image size parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1277 committed Nov 13, 2014
1 parent e4e6b00 commit 33fcbff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
18 changes: 4 additions & 14 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

var https = require('https'),
querystring = require('querystring'),
Request = function Request(consumer_key) {
this._configure(consumer_key);
};
Expand All @@ -14,26 +15,15 @@ Request.prototype._configure = function(consumer_key) {
};

Request.prototype.executeRequest = function(method, parameters, callback) {
var parameterString = '',
operator = '?';

if (parameters === undefined) {
parameters = {};
}

parameters.consumer_key = this.consumer_key;

for (var key in parameters) { // jshint ignore:line
if (key) {
parameterString += (operator + key + '=' + parameters[key]);
if (operator === '?') {
operator = '&';
}
}
}

https.get(
{'host': this.host, 'path': this.baseUrl + method + parameterString },
https.get({
'host': this.host,
'path': this.baseUrl + method + '?' + querystring.stringify(parameters) },
function(res) {
var chunks = '';
res.on('data', function(resultData) {
Expand Down
16 changes: 16 additions & 0 deletions test/photos-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,20 @@ describe('Testing GET photos:', function() {
});
});
});

describe('#searchWithMultiImageSize()', function() {
it('should return a json with photos', function(done) {
photos.searchByGeo('37,126,100km', {
'rpp': 7, 'image_size[]': [1, 4]
}, function(err, result) {
should.not.exist(err);
should.exist(result);
result.should.have.property('photos');
result.photos.should.have.lengthOf(7);
result.photos[0].images.should.have.lengthOf(2);

done();
});
});
});
});

0 comments on commit 33fcbff

Please sign in to comment.