diff --git a/src/api-wrapper.ts b/src/api-wrapper.ts index fba756f..6a28789 100644 --- a/src/api-wrapper.ts +++ b/src/api-wrapper.ts @@ -69,29 +69,29 @@ export const mapping = async (options: { useragent: string }): Promise => { const { timestamp, useragent } = options || {}; - let { interval } = options || {}; + let { timestep } = options || {}; if (!useragent) throw new Error("useragent is required"); - if (interval) interval.toLowerCase(); + if (timestep) timestep.toLowerCase(); - if (interval !== "5m" && interval !== "1h") + if (timestep !== "5m" && timestep !== "1h") console.error("interval must be '5m' or '1h'. Falling back to 5min, in future, this will be an error."); - interval = interval ?? "5m"; + timestep = timestep ?? "5m"; const url = timestamp - ? `https://prices.runescape.wiki/api/v1/osrs/${interval}?timestamp=${timestamp}` - : `https://prices.runescape.wiki/api/v1/osrs/${interval}`; + ? `https://prices.runescape.wiki/api/v1/osrs/${timestep}?timestamp=${timestamp}` + : `https://prices.runescape.wiki/api/v1/osrs/${timestep}`; const response = ( await axios.get<{ data: any } & { timestamp: number }>(url, { diff --git a/tests/api.test.ts b/tests/api.test.ts index d26ae7d..a6c2d46 100644 --- a/tests/api.test.ts +++ b/tests/api.test.ts @@ -33,14 +33,14 @@ describe("/mapping endpoint", () => { describe("prices /5m endpoint", () => { it("resolves the 5min data", async () => { - const minData = await API.prices({ useragent, interval: "5m" }); + const minData = await API.prices({ useragent, timestep: "5m" }); chai.expect(minData).to.have.property("4151"); }); }); describe("prices /1h endpoint", () => { it("resolves the 1hour data", async () => { - const minData = await API.prices({ useragent, interval: "1h" }); + const minData = await API.prices({ useragent, timestep: "1h" }); chai.expect(minData).to.have.property("4151"); }); });