client-aftermath-ts-sdk
Version:
Client Aftermath TypeScript SDK
52 lines (51 loc) • 2.38 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Prices = void 0;
const caller_1 = require("../utils/caller");
class Prices extends caller_1.Caller {
// =========================================================================
// Constructor
// =========================================================================
constructor(config) {
super(config, "price-info");
}
// =========================================================================
// Prices
// =========================================================================
getCoinPriceInfo(inputs) {
return __awaiter(this, void 0, void 0, function* () {
const coinsToPriceInfo = yield this.getCoinsToPriceInfo({
coins: [inputs.coin],
});
return Object.values(coinsToPriceInfo)[0];
});
}
getCoinsToPriceInfo(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.fetchApi("", inputs);
});
}
getCoinPrice(inputs) {
return __awaiter(this, void 0, void 0, function* () {
const priceInfo = yield this.getCoinPriceInfo(inputs);
return priceInfo.price;
});
}
getCoinsToPrice(inputs) {
return __awaiter(this, void 0, void 0, function* () {
const coinsToPriceInfo = yield this.getCoinsToPriceInfo(inputs);
const coinsToPrice = Object.entries(coinsToPriceInfo).reduce((acc, [coinType, info]) => (Object.assign(Object.assign({}, acc), { [coinType]: info.price })), {});
return coinsToPrice;
});
}
}
exports.Prices = Prices;