react-stickerpipe
Version:
React Component for StickerPipe API
64 lines (52 loc) • 2.36 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _superagent = require('superagent');
var _superagent2 = _interopRequireDefault(_superagent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var StickerPipeClient = function () {
function StickerPipeClient(apiKey, userId, baseUrl) {
_classCallCheck(this, StickerPipeClient);
Object.assign(this, { apiKey: apiKey, userId: userId, baseUrl: baseUrl });
}
_createClass(StickerPipeClient, [{
key: 'performRequest',
value: function performRequest(method, url, callback) {
var options = {
url: url,
headers: {
ApiKey: this.apiKey,
Platform: 'JS',
UserId: this.userId
}
};
_superagent2.default[method](options.url).set(options.headers).end(callback);
}
}, {
key: 'getMyPacks',
value: function getMyPacks(callback) {
this.performRequest('get', this.baseUrl + '/shop/my', callback);
}
}, {
key: 'getShop',
value: function getShop(callback) {
this.performRequest('get', this.baseUrl + '/shop', callback);
}
}, {
key: 'getPackPreview',
value: function getPackPreview(packName, callback) {
this.performRequest('get', this.baseUrl + '/packs/' + packName, callback);
}
}, {
key: 'purchasePack',
value: function purchasePack(packName, callback) {
this.performRequest('post', this.baseUrl + '/packs/' + packName, callback);
}
}]);
return StickerPipeClient;
}();
exports.default = StickerPipeClient;
module.exports = exports['default'];
;