From 8c2f0010dd653b1f6421e9721b5bb0f761d3e192 Mon Sep 17 00:00:00 2001 From: Brendan Lane Date: Mon, 21 Dec 2020 10:09:46 -0500 Subject: [PATCH] Stocks Fixes #14 Co-authored-by: Bryce Bauer --- src/modules/Stock.ts | 45 ++++++++++++++++++++++++++++++++++++++ src/modules/types/Types.ts | 4 +++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/modules/Stock.ts b/src/modules/Stock.ts index f526a77..1d7eebf 100644 --- a/src/modules/Stock.ts +++ b/src/modules/Stock.ts @@ -2,6 +2,7 @@ // Written by Bryce Bauer and Brendan Lane - https://github.com/bluebeargreen-2 and https://brndnln.dev/ import axios from 'axios' +import { QueueType } from './types/Types' const ecoURL = 'https://api.spookvooper.com/eco' class Stock { @@ -50,6 +51,50 @@ class Stock { }) }) } + + public async getQueueInfo (type: QueueType): Promise { + switch (type.toUpperCase()) { + case 'BUY': + break + + case 'SELL': + break + + default: + throw new Error('Parameter \'type\' must be \'BUY\' or \'SELL\'') + } + + return await new Promise((resolve, reject) => { + axios.get(`${ecoURL}/getQueueInfo`, { + params: { + ticker: this.stockTicker, + type: type.toUpperCase() + } + }) + .then((response) => { + resolve(response.data) + }) + .catch((error) => { + reject(error) + }) + }) + } + + public async getOwnerData (): Promise { + return await new Promise((resolve, reject) => { + axios.get(`${ecoURL}/getOwnerData`, { + params: { + ticker: this.stockTicker + } + }) + .then((response) => { + resolve(response.data) + }) + .catch((error) => { + reject(error) + }) + }) + } } export default Stock diff --git a/src/modules/types/Types.ts b/src/modules/types/Types.ts index 2168d96..bc866a0 100644 --- a/src/modules/types/Types.ts +++ b/src/modules/types/Types.ts @@ -11,6 +11,7 @@ type AuthConfig = ConfigAuth type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula' type DistrictWealthType = 'ALL' | 'USER' | 'GROUP' type SenatorDistrict = District | 'ALL' +type QueueType = 'BUY' | 'SELL' export { CreditAmount, @@ -20,5 +21,6 @@ export { AuthConfig, District, DistrictWealthType, - SenatorDistrict + SenatorDistrict, + QueueType }