Skip to content

Commit 16672b9

Browse files
committed
Removes duplicate method and make changes to simplify testing
1 parent 76af12f commit 16672b9

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

lib/index.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ FilePreviews = function(options) {
99
this.debug = options.debug || false;
1010
this.apiKey = options.apiKey;
1111
this.apiSecret = options.apiSecret;
12+
this._request = request;
1213

1314
if (!this.apiKey) {
1415
throw new Error('Missing required apiKey.');
@@ -27,19 +28,6 @@ FilePreviews.prototype.log = function(msg) {
2728
return this;
2829
};
2930

30-
FilePreviews.prototype.generate = function(url, options, callback) {
31-
if (arguments.length === 2) {
32-
if (Object.prototype.toString.call(options) === '[object Function]') {
33-
callback = options;
34-
}
35-
}
36-
37-
this.submitJobToAPI(url, options, function(err, result) {
38-
callback(err, result);
39-
this._log('Processing done :)');
40-
}.bind(this));
41-
};
42-
4331
FilePreviews.prototype.generate = function(url, options, callback) {
4432
if (arguments.length === 2) {
4533
if (Object.prototype.toString.call(options) === '[object Function]') {
@@ -109,7 +97,7 @@ FilePreviews.prototype.request = function(url, options, callback) {
10997

11098
this.log('API request to: ' + url);
11199

112-
request(requestOptions, function (error, response, body) {
100+
this._request(requestOptions, function(error, response, body) {
113101
if (error) {
114102
onError(error, response, body);
115103
} else {
@@ -143,6 +131,7 @@ FilePreviews.prototype.getAPIRequestData = function(url, options) {
143131
size = size + 'x' + options.size.height;
144132
}
145133

134+
delete options.size;
146135
options.sizes = [size];
147136
}
148137
}

0 commit comments

Comments
 (0)