UNPKG

gopro-js

Version:

A Promise based JavaScript GoPro Controller/API Wrapper (Unofficial)

85 lines (56 loc) 3.58 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var PromiseError = exports.PromiseError = function (_Error) { _inherits(PromiseError, _Error); function PromiseError() { var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'PromiseError'; var _ret; var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400; _classCallCheck(this, PromiseError); var _this = _possibleConstructorReturn(this, (PromiseError.__proto__ || Object.getPrototypeOf(PromiseError)).call(this, message)); _this.name = _this.constructor.name; _this.status = status; if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(_this, _this.constructor); } else _this.stack = new Error(message).stack; return _ret = Promise.reject(_this), _possibleConstructorReturn(_this, _ret); } return PromiseError; }(Error); var NotFoundError = exports.NotFoundError = function (_PromiseError) { _inherits(NotFoundError, _PromiseError); function NotFoundError() { _classCallCheck(this, NotFoundError); return _possibleConstructorReturn(this, (NotFoundError.__proto__ || Object.getPrototypeOf(NotFoundError)).call(this, 'GoPro not found.', 404)); } return NotFoundError; }(PromiseError); var UnsupportedError = exports.UnsupportedError = function (_PromiseError2) { _inherits(UnsupportedError, _PromiseError2); function UnsupportedError() { _classCallCheck(this, UnsupportedError); return _possibleConstructorReturn(this, (UnsupportedError.__proto__ || Object.getPrototypeOf(UnsupportedError)).call(this, 'Unsupported GoPro.', 415)); } return UnsupportedError; }(PromiseError); var ForbiddenMethodError = exports.ForbiddenMethodError = function (_PromiseError3) { _inherits(ForbiddenMethodError, _PromiseError3); function ForbiddenMethodError(property) { _classCallCheck(this, ForbiddenMethodError); return _possibleConstructorReturn(this, (ForbiddenMethodError.__proto__ || Object.getPrototypeOf(ForbiddenMethodError)).call(this, property + ' not allowed on this interface.', 403)); } return ForbiddenMethodError; }(PromiseError); var UndefinedMethodError = exports.UndefinedMethodError = function (_PromiseError4) { _inherits(UndefinedMethodError, _PromiseError4); function UndefinedMethodError(property) { _classCallCheck(this, UndefinedMethodError); return _possibleConstructorReturn(this, (UndefinedMethodError.__proto__ || Object.getPrototypeOf(UndefinedMethodError)).call(this, property + ' not defined for current API.', 403)); } return UndefinedMethodError; }(PromiseError);