@parcl-finance/product-sdk
Version:
TypeScript SDK for interacting with Parcl's product APIs
115 lines • 3.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RealEstateData = void 0;
const constants_1 = require("./constants");
const httpClient_1 = require("./httpClient");
const utils_1 = require("./utils");
class RealEstateData {
baseUrl;
headers;
client;
expressClient;
constructor(baseUrl, accessToken, env) {
const headers = {};
if (accessToken !== undefined) {
headers["Authorization"] = "Bearer " + accessToken;
}
this.headers = headers;
this.baseUrl = baseUrl.concat("/real-estate-data");
this.client = new httpClient_1.HttpClient(this.baseUrl, this.headers);
this.expressClient = new httpClient_1.HttpClient((0, constants_1.getDefaultExpressApiUrl)(env), this.headers);
}
async getParclIds() {
const { ids } = await this.client.get({ path: "/parcl-ids" });
return ids;
}
async getParclInfo(id) {
const { info } = await this.client.get({
path: "/parcl-info",
params: { id },
});
return (0, utils_1.formatParclInfo)(info);
}
async getParclInfos(ids) {
if (ids.length > constants_1.MAX_PARCL_IDS_PER_INFOS_REQUEST) {
throw new Error(`Too many parcl ids supplied. ${ids.length} ids supplied, but the max amount is ${constants_1.MAX_PARCL_IDS_PER_INFOS_REQUEST}`);
}
const { infos } = await this.client.post({
path: "/parcl-infos",
body: { ids },
});
return infos.map((info) => (0, utils_1.formatParclInfo)(info));
}
async getPriceFeed(id, window) {
const { priceFeed } = await this.client.get({
path: `/price-feed`,
params: {
id,
window,
},
});
return (0, utils_1.formatPriceFeed)(priceFeed);
}
async getPriceFeedBySymbol(symbol, window) {
const { priceFeed } = await this.expressClient.get({
path: `/market/${symbol}/price-feed`,
params: {
window,
},
});
return priceFeed;
}
async getPriceFeedStatsBySymbol(symbol) {
const { priceFeedStats } = await this.expressClient.get({
path: `/market/${symbol}/price-feed-stats`,
});
return priceFeedStats;
}
async getFinancialsBySymbol(symbol) {
const { financials } = await this.expressClient.get({
path: `/market/${symbol}/financials`,
});
return financials;
}
async getAbsorptionRateHistoryBySymbol(symbol, window) {
const { absorptionRateHistory } = await this.expressClient.get({
path: `/market/${symbol}/absorption-rate-history`,
params: {
window,
},
});
return absorptionRateHistory;
}
async getSalesHistoryBySymbol(symbol, window) {
const { salesHistory } = await this.expressClient.get({
path: `/market/${symbol}/sales-history`,
params: {
window,
},
});
return salesHistory;
}
async getListingsHistoryBySymbol(symbol, window) {
const { listingsHistory } = await this.expressClient.get({
path: `/market/${symbol}/listings-history`,
params: {
window,
},
});
return listingsHistory;
}
async getCurrentInventoryBySymbol(symbol) {
const { currentInventory } = await this.expressClient.get({
path: `/market/${symbol}/current-inventory`,
});
return currentInventory;
}
async getDemographicsBySymbol(symbol) {
const { demographics } = await this.expressClient.get({
path: `/market/${symbol}/demographics`,
});
return demographics;
}
}
exports.RealEstateData = RealEstateData;
//# sourceMappingURL=realEstateData.js.map