screenshot.js 908 B

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