Skip to content

Commit 40cf4fc

Browse files
committed
add more API calls
1 parent 7c91c3e commit 40cf4fc

File tree

7 files changed

+227
-39
lines changed

7 files changed

+227
-39
lines changed

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ module.exports = {
8585
"lines-around-directive": "error",
8686
"max-depth": "error",
8787
"max-len": "off",
88-
"max-lines": "error",
88+
"max-lines": "off",
8989
"max-nested-callbacks": "error",
90-
"max-params": "error",
90+
"max-params": "off",
9191
"max-statements": "off",
9292
"max-statements-per-line": "error",
9393
"multiline-ternary": [
@@ -200,7 +200,7 @@ module.exports = {
200200
"no-warning-comments": "error",
201201
"no-whitespace-before-property": "error",
202202
"no-with": "error",
203-
"object-curly-newline": "error",
203+
"object-curly-newline": "off",
204204
"object-curly-spacing": [
205205
"error",
206206
"always"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/
2+
package-lock.json

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) TestingBot.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[![npm version](https://img.shields.io/npm/v/testingbot-api.svg?style=flat-square)](https://www.npmjs.com/package/testingbot-api)
22
[![npm downloads](https://img.shields.io/npm/dm/testingbot-api.svg?style=flat-square)](https://www.npmjs.com/package/testingbot-api)
33
[![Build Status](https://travis-ci.org/testingbot/testingbot-api.svg?branch=master)](https://travis-ci.org/testingbot/testingbot-api)
4-
[![dependencies Status](https://david-dm.org/testingbot/testingbot-api/status.svg)](https://david-dm.org/testingbot/testingbot-api)
5-
[![devDependencies Status](https://david-dm.org/testingbot/testingbot-api/dev-status.svg)](https://david-dm.org/testingbot/testingbot-api?type=dev)
4+
[![dependencies Status](https://status.david-dm.org/gh/testingbot/testingbot-api.svg)](https://david-dm.org/testingbot/testingbot-api)
5+
[![devDependencies Status](https://status.david-dm.org/gh/testingbot/testingbot-api.svg?type=dev)](https://david-dm.org/testingbot/testingbot-api?type=dev)
66

77
# testingbot-api
88

9-
Wrapper around the TestingBot REST API for [Node.js](http://nodejs.org/).
9+
Wrapper around the TestingBot REST API for [Node.js](https://nodejs.org/).
1010

1111
## Install
1212

@@ -16,7 +16,7 @@ npm install testingbot-api
1616

1717
## Credentials
1818
You can use environment variables `TESTINGBOT_KEY` and `TESTINGBOT_SECRET` to pass your TestingBot key and secret to the API client.
19-
The key and secret can be obtained from [TestingBot](https://testingbot.com/members/user/edit) .
19+
The key and secret can be obtained from [TestingBot](https://testingbot.com/members/user/edit)
2020

2121
## Using the wrapper
2222

@@ -36,6 +36,27 @@ Gets a list of browsers you can test on
3636
api.getBrowsers(function(error, browsers) {});
3737
```
3838

39+
### getDevices
40+
Gets a list of physical mobile devices you can test on
41+
42+
```javascript
43+
api.getDevices(function(error, devices) {});
44+
```
45+
46+
### getAvailableDevices
47+
Gets a list of available physical mobile devices for your account
48+
49+
```javascript
50+
api.getAvailableDevices(function(error, availableDevices) {});
51+
```
52+
53+
### getDevice
54+
Gets details for a specific physical device
55+
56+
```javascript
57+
api.getDevice(deviceId, function(error, deviceDetails) {});
58+
```
59+
3960

4061
### getUserInfo
4162
Gets your user information
@@ -129,6 +150,27 @@ Uploads a remote file to TestingBot Storage
129150
api.uploadFile(remoteFileUrl, function(error, appUrl) {});
130151
```
131152

153+
### getStorageFile
154+
Retrieve data from a previously uploaded file
155+
156+
```javascript
157+
api.getStorageFile(remoteFileUrl, function(error, fileDetails) {});
158+
```
159+
160+
### getStorageFiles
161+
Retrieve list of previously uploaded files
162+
163+
```javascript
164+
api.getStorageFiles(function(error, fileDetails) {}, offset, limit);
165+
```
166+
167+
### deleteStorageFile
168+
Delete a previously uploaded file
169+
170+
```javascript
171+
api.deleteStorageFile(appId, function(error, success) {});
172+
```
173+
132174
### getAuthenticationHashForSharing
133175
Calculates the authentication hash for sharing, pass the WebDriver's SessionID.
134176
This is used to [share a test's detail page on TestingBot](https://testingbot.com/support/other/sharing)
@@ -137,34 +179,31 @@ This is used to [share a test's detail page on TestingBot](https://testingbot.co
137179
api.getAuthenticationHashForSharing(sessionId);
138180
```
139181

140-
## Tests
182+
### takeScreenshot
183+
Takes screenshots for the specific browsers
141184

142-
``npm test``
185+
```javascript
186+
api.getUserInfo(function(error, screenshots) {}, url, browsers, waitTime, resolution, fullPage, callbackURL);
187+
```
143188

144-
## More documentation
189+
### retrieveScreenshots
190+
Retrieves screenshots for a specific `takeScreenshot` call
145191

146-
Check out the [TestingBot REST API](https://testingbot.com/support/api) for more information.
192+
```javascript
193+
api.getUserInfo(screenshotId, function(error, screenshots) {});
194+
```
147195

148-
## License
196+
### getScreenshotList
197+
Retrieves all screenshots previously generate with your account
149198

150-
The MIT License (MIT)
199+
```javascript
200+
api.getScreenshotList(function(error, screenshots) {}, offset, limit);
201+
```
151202

152-
Copyright (c) TestingBot.com
203+
## Tests
153204

154-
Permission is hereby granted, free of charge, to any person obtaining a copy
155-
of this software and associated documentation files (the "Software"), to deal
156-
in the Software without restriction, including without limitation the rights
157-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
158-
copies of the Software, and to permit persons to whom the Software is
159-
furnished to do so, subject to the following conditions:
205+
``npm test``
160206

161-
The above copyright notice and this permission notice shall be included in
162-
all copies or substantial portions of the Software.
207+
## More documentation
163208

164-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
165-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
166-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
167-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
168-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
169-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
170-
THE SOFTWARE.
209+
Check out the [TestingBot REST API](https://testingbot.com/support/api) for more information.

lib/api.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,89 @@ function TestingBot(options) {
2828
}
2929
}
3030

31+
TestingBot.prototype.getDevices = function(callback) {
32+
var data = {};
33+
this.request({
34+
method: 'GET',
35+
url: '/devices',
36+
data: data
37+
}, callback);
38+
};
39+
40+
TestingBot.prototype.getAvailableDevices = function(callback) {
41+
var data = {};
42+
this.request({
43+
method: 'GET',
44+
url: '/devices/available',
45+
data: data
46+
}, callback);
47+
};
48+
49+
TestingBot.prototype.getDevice = function(deviceId, callback) {
50+
var data = {};
51+
if (deviceId) {
52+
data.deviceId = deviceId;
53+
}
54+
this.request({
55+
method: 'GET',
56+
url: '/devices/',
57+
data: data
58+
}, callback);
59+
};
60+
61+
TestingBot.prototype.takeScreenshot = function(callback, url, browsers, waitTime, resolution, fullPage, callbackURL) {
62+
var data = {};
63+
if (url) {
64+
data.url = url;
65+
}
66+
if (browsers) {
67+
data.browsers = browsers;
68+
}
69+
if (waitTime) {
70+
data.waitTime = waitTime;
71+
}
72+
if (resolution) {
73+
data.resolution = resolution;
74+
}
75+
if (fullPage) {
76+
data.fullPage = fullPage;
77+
}
78+
if (callbackURL) {
79+
data.callbackURL = callbackURL;
80+
}
81+
this.request({
82+
method: 'POST',
83+
url: '/screenshots',
84+
data: data
85+
}, callback);
86+
};
87+
88+
TestingBot.prototype.retrieveScreenshots = function(screenshotId, callback) {
89+
var data = {};
90+
if (screenshotId) {
91+
data.screenshotId = screenshotId;
92+
}
93+
this.request({
94+
method: 'GET',
95+
url: '/screenshots',
96+
data: data
97+
}, callback);
98+
};
99+
100+
TestingBot.prototype.getScreenshotList = function(callback, offset, limit) {
101+
if (!offset) {
102+
offset = 0;
103+
}
104+
if (!limit) {
105+
limit = 10;
106+
}
107+
this.request({
108+
method: 'GET',
109+
url: '/screenshots',
110+
data: { offset: offset, limit: limit }
111+
}, callback);
112+
};
113+
31114
TestingBot.prototype.getBrowsers = function(callback, type) {
32115
var data = {};
33116
if (type) {
@@ -209,6 +292,35 @@ TestingBot.prototype.uploadFile = function(localFilePath, callback) {
209292
});
210293
};
211294

295+
TestingBot.prototype.getStorageFile = function(appUrl, callback) {
296+
this.request({
297+
method: 'GET',
298+
url: '/storage/' + appUrl
299+
}, callback);
300+
};
301+
302+
TestingBot.prototype.getStorageFiles = function(callback, offset, limit) {
303+
if (!offset) {
304+
offset = 0;
305+
}
306+
if (!limit) {
307+
limit = 10;
308+
}
309+
310+
this.request({
311+
method: 'GET',
312+
url: '/storage',
313+
data: { offset: offset, limit: limit }
314+
}, callback);
315+
};
316+
317+
TestingBot.prototype.deleteStorageFile = function(appUrl, callback) {
318+
this.request({
319+
method: 'DELETE',
320+
url: '/storage/' + appUrl
321+
}, callback);
322+
};
323+
212324
TestingBot.prototype.uploadRemoteFile = function(remoteUrl, callback) {
213325
this.request({
214326
method: 'POST',

package.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "TestingBot <info@testingbot.com> (testingbot.com)",
33
"name": "testingbot-api",
44
"description": "A wrapper around TestingBot's REST API",
5-
"version": "1.0.7",
5+
"version": "1.0.8",
66
"scripts": {
77
"lint": "eslint lib/",
88
"test": "make test"
@@ -12,20 +12,28 @@
1212
"type": "git",
1313
"url": "git://github.com/testingbot/testingbot-api.git"
1414
},
15+
"bugs": {
16+
"url" : "https://github.com/testingbot/testingbot-api/issues",
17+
},
18+
"keywords": [
19+
"testingbot-api",
20+
"testingbot-nodejs",
21+
"nodejs api"
22+
],
1523
"devDependencies": {
16-
"eslint": "^5.12.1",
17-
"eslint-config-airbnb-base": "^13.1.0",
18-
"eslint-config-standard": "^12.0.0",
19-
"eslint-plugin-import": "^2.16.0",
20-
"eslint-plugin-promise": "^4.0.1",
21-
"eslint-plugin-standard": "^4.0.0",
22-
"mocha": "^5.2.0"
24+
"eslint": "^7.25.0",
25+
"eslint-config-airbnb-base": "^14.2.1",
26+
"eslint-config-standard": "^16.0.2",
27+
"eslint-plugin-import": "^2.22.1",
28+
"eslint-plugin-promise": "^5.1.0",
29+
"eslint-plugin-standard": "^5.0.0",
30+
"mocha": "^8.3.2"
2331
},
2432
"engines": {
2533
"node": "*"
2634
},
2735
"dependencies": {
28-
"qs": "^6.7.0",
29-
"request": "^2.88.0"
36+
"qs": "^6.10.1",
37+
"request": "^2.88.2"
3038
}
3139
}

test/api_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ describe('Api Tests', function() {
3434
});
3535
});
3636

37+
it('should list devices', function(done) {
38+
this.api.getDevices(function(err, response) {
39+
assert.equal(response && response.length > 0, true);
40+
done();
41+
});
42+
});
43+
3744
it('should error when not test is found', function(done) {
3845
this.api.getTestDetails(324234234324, function(err, response) {
3946
assert.equal(null, response);

0 commit comments

Comments
 (0)