UNPKG

908 BJavaScriptView Raw
1var util = require("util");
2var BaseClient = require("./client");
3var extend = require("./extend");
4
5function ScreenshotClient(settings) {
6 this.server = {
7 host: "www.browserstack.com"
8 };
9 BaseClient.call(this, settings);
10}
11
12util.inherits(ScreenshotClient, BaseClient);
13
14// public API
15extend(ScreenshotClient.prototype, {
16 getBrowsers: function(fn) {
17 this.request({
18 path: this.path("/browsers.json")
19 }, fn);
20 },
21
22 generateScreenshots: function(options, fn) {
23 var data = JSON.stringify(options);
24 this.request({
25 method: "POST",
26 path: this.path("")
27 }, data, fn);
28 },
29
30 getJob: function(id, fn) {
31 this.request({
32 path: this.path("/" + id + ".json")
33 }, fn);
34 }
35});
36
37// internal API
38extend(ScreenshotClient.prototype, {
39 path: function(path) {
40 return "/screenshots" + path;
41 }
42});
43
44module.exports = {
45 createClient: function(settings) {
46 return new ScreenshotClient(settings);
47 }
48};