@jaketb/node-fred
Version:
Another nodejs wrapper for the st louis fed
120 lines (99 loc) • 4.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _api = _interopRequireDefault(require("../api"));
var _tagsBuilder = _interopRequireDefault(require("./Builders/tagsBuilder"));
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"); } }
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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Tags =
/*#__PURE__*/
function () {
function Tags(apiKey, returnType) {
_classCallCheck(this, Tags);
this.apiKey = apiKey;
this.returnType = returnType;
this.tagsBuilder = new _tagsBuilder["default"]();
}
/**
* Gets all tags, search for tags, or get tags by name.
* @param {Object} params
* @returns {Promise} Resolves with a set of tags or errors out
*/
_createClass(Tags, [{
key: "getAllTags",
value: function getAllTags() {
var _this = this;
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return new Promise(function (resolve, reject) {
try {
var url = _this.tagsBuilder.setAPIKey(_this.apiKey).setFileType(_this.returnType).setRealTimeStart(params).setRealTimeEnd(params).setLimit(params).setOffset(params).setOrderBy(params).setSortOrder(params).setTagNames(params).setTagGroupId(params).setSearchText(params).getUrl();
_api["default"].get("tags?".concat(url)).then(function (res) {
resolve(res.data);
})["catch"](function (err) {
reject(err);
});
} catch (e) {
reject(e);
}
});
}
/**
* Get the related tags for one or more tags.
* @param {string} tagNames
* @param {Object} params
* @returns {Promise} Resolves with the related tags for one or more tags or errors out
*/
}, {
key: "getAllRelatedTags",
value: function getAllRelatedTags(tagNames) {
var _this2 = this;
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return new Promise(function (resolve, reject) {
try {
var url = _this2.tagsBuilder.setAPIKey(_this2.apiKey).setFileType(_this2.returnType).setRealTimeStart(params).setRealTimeEnd(params).setLimit(params).setOffset(params).setOrderBy(params).setSortOrder(params).setTagNames(tagNames).setExcludeTagNames(params).setTagGroupId(params).setSearchText(params).getUrl();
_api["default"].get("related_tags?".concat(url)).then(function (res) {
resolve(res.data);
})["catch"](function (err) {
reject(err);
});
} catch (e) {
reject(e);
}
});
}
/**
* Gets the series matching tags.
* @param {string} tagNames
* @param {Object} params
* @returns {Promise} Resolves with the series matching tags or errors out
*/
}, {
key: "getAllSeriesMatchingTags",
value: function getAllSeriesMatchingTags(tagNames) {
var _this3 = this;
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return new Promise(function (resolve, reject) {
try {
var url = _this3.tagsBuilder.setAPIKey(_this3.apiKey).setFileType(_this3.returnType).setRealTimeStart(params).setRealTimeEnd(params).setLimit(params).setOffset(params).setOrderBy(params).setSortOrder(params).setTagNames({
tag_names: tagNames
}).setExcludeTagNames(params).getUrl();
_api["default"].get("tags/series?".concat(url)).then(function (res) {
resolve(res.data);
})["catch"](function (err) {
reject(err);
});
} catch (e) {
reject(e);
}
});
}
}]);
return Tags;
}();
var _default = Tags;
exports["default"] = _default;
//# sourceMappingURL=tags.js.map