💻 Sync with local
This commit is contained in:
parent
075dc25844
commit
7677ea0194
428
main.js
428
main.js
|
@ -1,426 +1,20 @@
|
||||||
// SpookVooper API - main.js
|
// SpookVooper API - main.js
|
||||||
// Written by Brendan Lane - https://brndnln.dev/
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
const userURL = "https://api.spookvooper.com/user";
|
const User = require('./modules/User.js')
|
||||||
const groupURL = "https://api.spookvooper.com/group";
|
const Stock = require('./modules/Stock.js')
|
||||||
const ecoURL = "https://api.spookvooper.com/eco";
|
const District = require('./modules/District.js')
|
||||||
const authURL = "https://spookvooper.com/oauth2";
|
const Group = require('./modules/Group.js')
|
||||||
|
const Auth = require('./modules/Auth.js')
|
||||||
const axios = require('axios');
|
const TransactionHub = require('./modules/TransactionHub.js')
|
||||||
let urlReturn;
|
const ExchangeHub = require('./modules/ExchangeHub.js')
|
||||||
|
|
||||||
class User {
|
|
||||||
#apikey = undefined;
|
|
||||||
|
|
||||||
constructor(svid) {
|
|
||||||
this.svid = svid
|
|
||||||
}
|
|
||||||
|
|
||||||
getUser() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${userURL}/getUser?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getUsername() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${userURL}/getUsername?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getBalance() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getBalance?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
hasDiscordRole(role) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${userURL}/hasDiscordRole?userid=${this.svid}&role=${role}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getDiscordRoles() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${userURL}/getDiscordRoles?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getDaysSinceLastMove() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${userURL}/getDaysSinceLastMove?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setApiKey(key) {
|
|
||||||
this.#apikey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendCredits(amount, to, reason) {
|
|
||||||
if (typeof to === "string") {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else if (typeof to === "object") {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to.svid}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw "The 'to' parameter must be a string or an object!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserStockOffers(ticker) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getUserStockOffers?ticker=${ticker}&svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
buyStock(ticker, amount, price) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/submitStockBuy?ticker=${ticker}&count=${amount}&price=${price}&accountid=${this.svid}&auth=${this.#apikey}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
sellStock(ticker, amount, price) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/submitStockSell?ticker=${ticker}&count=${amount}&price=${price}&accountid=${this.svid}&auth=${this.#apikey}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelStockOrder(orderid) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/cancelOrder?orderid=${orderid}&accountid=${this.svid}&auth=${this.#apikey}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Stock {
|
|
||||||
constructor(ticker) {
|
|
||||||
this.ticker = ticker;
|
|
||||||
}
|
|
||||||
|
|
||||||
getValue() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getStockValue?ticker=${this.ticker}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getStockBuyPrice() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getStockBuyPrice?ticker=${this.ticker}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getQueueInfo(type) {
|
|
||||||
switch (type) {
|
|
||||||
case "BUY":
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "SELL":
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw "Parameter 'type' must be 'BUY' or 'SELL'"
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getQueueInfo?ticker=${this.ticker}&type=${type}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getOwner() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getOwnerData?ticker=${this.ticker}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class District {
|
|
||||||
constructor(name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
getWealth(type) {
|
|
||||||
switch (type) {
|
|
||||||
case "ALL":
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getDistrictWealth?id=${this.name}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
case "USER":
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getDistrictUserWealth?id=${this.name}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
case "GROUP":
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/getDistrictGroupWealth?id=${this.name}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw "Parameter 'type' must be 'ALL', 'USER', or 'GROUP'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Group {
|
|
||||||
#apikey = undefined;
|
|
||||||
|
|
||||||
constructor(name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
getGroup() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${groupURL}/getGroup?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setApiKey(key) {
|
|
||||||
this.#apikey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendCredits(amount, to, reason) {
|
|
||||||
if (typeof to === "string") {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else if (typeof to === "object") {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to.svid}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw "The 'to' parameter must be a string or an object!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doesGroupExist() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${groupURL}/doesGroupExist?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getGroupMembers() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${groupURL}/getGroupMembers?svid=${this.svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
hasGroupPermission(user, permission) {
|
|
||||||
if (typeof to === "string") {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${groupURL}/hasGroupPermission?svid=${this.svid}&usersvid=${user}&permission=${permission}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else if (typeof to === "object") {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${groupURL}/hasGroupPermission?svid=${this.svid}&usersvid=${user.svid}&permission=${permission}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Auth {
|
|
||||||
#clientsecret = undefined;
|
|
||||||
#authcode = undefined;
|
|
||||||
|
|
||||||
constructor(clientid, clientsecret) {
|
|
||||||
this.clientid = clientid;
|
|
||||||
this.#clientsecret = clientsecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
genLink(redirect, scope, state) {
|
|
||||||
if (redirect === undefined || scope === undefined) {
|
|
||||||
throw "Both parameters 'redirect' and 'scope' must be defined!"
|
|
||||||
} else if (state === undefined) {
|
|
||||||
state = "";
|
|
||||||
urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`;
|
|
||||||
urlReturn = urlReturn.split(" ").join("%20");
|
|
||||||
return urlReturn;
|
|
||||||
} else {
|
|
||||||
urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`;
|
|
||||||
urlReturn = urlReturn.split(" ").join("%20");
|
|
||||||
return urlReturn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setAuthCode(authcode) {
|
|
||||||
this.#authcode = authcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestToken(redirect) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${authURL}/requestToken?grant_type=authorization_code&code=${this.#authcode}&redirect_uri=${redirect}&client_id=${this.clientid}&client_secret=${this.#clientsecret}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
User,
|
User,
|
||||||
Stock,
|
Stock,
|
||||||
District,
|
District,
|
||||||
Group,
|
Group,
|
||||||
Auth
|
Auth,
|
||||||
}
|
TransactionHub,
|
||||||
|
ExchangeHub
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
// SpookVooper API - modules/District.js
|
||||||
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
const axios = require('axios')
|
||||||
|
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||||
|
|
||||||
|
class District {
|
||||||
|
constructor(name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
getWealth(type) {
|
||||||
|
switch (type) {
|
||||||
|
case "ALL":
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getDistrictWealth?id=${this.name}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
case "USER":
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getDistrictUserWealth?id=${this.name}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
case "GROUP":
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getDistrictGroupWealth?id=${this.name}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw "Parameter 'type' must be 'ALL', 'USER', or 'GROUP'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = District
|
|
@ -0,0 +1,104 @@
|
||||||
|
// SpookVooper API - modules/ExchangeHub.js
|
||||||
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
const signalR = require('@microsoft/signalr')
|
||||||
|
const EventEmitter = require('events')
|
||||||
|
|
||||||
|
class ExchangeEmitter extends EventEmitter {}
|
||||||
|
|
||||||
|
class ExchangeHub {
|
||||||
|
#connection = new signalR.HubConnectionBuilder()
|
||||||
|
.withUrl('https://spookvooper.com/ExchangeHub')
|
||||||
|
.withAutomaticReconnect()
|
||||||
|
.configureLogging(signalR.LogLevel.Information)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
exchangeEvent = new ExchangeEmitter()
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
// Event Handlers
|
||||||
|
this.#connection.on('StockOffer', (offer) => {
|
||||||
|
this.exchangeEvent.emit('NewOffer', offer)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.#connection.on('StockOfferCancel', (offer) => {
|
||||||
|
this.exchangeEvent.emit('OfferCancelled', offer)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.#connection.on('StockTrade', (trade) => {
|
||||||
|
this.exchangeEvent.emit('StockTrade', trade)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.#connection.on('RecieveMessage', (message, mode) => {
|
||||||
|
this.exchangeEvent.emit('RecieveMessage', message, mode)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.#connection.on('RecieveMessageHistory', (messages, modes) => {
|
||||||
|
this.exchangeEvent.emit('RevieveMessageHistory', messages, modes)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Start of connection logic
|
||||||
|
this.#connection.onclose(async (e) => {
|
||||||
|
await this.onClosed(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.#connection.on()
|
||||||
|
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
async start() {
|
||||||
|
console.log("Starting ExchangeHub Connection...")
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.#connection.start()
|
||||||
|
console.log("Connected to ExchangeHub")
|
||||||
|
} catch (e) {
|
||||||
|
console.error("ExchangeHub Error: Connection failed while trying to establish a connnection\n", e)
|
||||||
|
console.log("Retrying in 5 seconds")
|
||||||
|
setTimeout(() => {
|
||||||
|
this.start()
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClosed(e) {
|
||||||
|
console.error("ExchangeHub Error: Connection closed unexpectedly\n", e)
|
||||||
|
await this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
sendChatMessage(message, accountid, apikey, ticker, tradeState) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (message === undefined || accountid === undefined || apikey === undefined || ticker === undefined || tradeState === undefined) {
|
||||||
|
throw "All variables are needed for this to work."
|
||||||
|
}
|
||||||
|
|
||||||
|
tradeState = tradeState.toUpperCase()
|
||||||
|
if (tradeState !== "BUY" && tradeState !== "SELL") {
|
||||||
|
throw "The tradeState argument must either be 'BUY' or 'SELL'";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#connection.invoke("SendMessage", accountid, apikey, message, ticker, tradeState)
|
||||||
|
.then(function () {
|
||||||
|
resolve(true)
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getMessageHistory() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.#connection.invoke('RequestHistory')
|
||||||
|
.then(function (val) {
|
||||||
|
resolve(val)
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ExchangeHub
|
|
@ -0,0 +1,72 @@
|
||||||
|
// SpookVooper API - modules/Stock.js
|
||||||
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
const axios = require('axios');
|
||||||
|
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||||
|
|
||||||
|
class Stock {
|
||||||
|
constructor(ticker) {
|
||||||
|
this.ticker = ticker.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
getValue() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getStockValue?ticker=${this.ticker}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getStockBuyPrice() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getStockBuyPrice?ticker=${this.ticker}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getQueueInfo(type) {
|
||||||
|
switch (type) {
|
||||||
|
case "BUY":
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "SELL":
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw "Parameter 'type' must be 'BUY' or 'SELL'"
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getQueueInfo?ticker=${this.ticker}&type=${type}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getOwner() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getOwnerData?ticker=${this.ticker}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Stock
|
|
@ -0,0 +1,65 @@
|
||||||
|
// SpookVooper API - modules/TransactionHub.js
|
||||||
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
const signalR = require('@microsoft/signalr')
|
||||||
|
const EventEmitter = require('events')
|
||||||
|
|
||||||
|
class TransactionEmitter extends EventEmitter {}
|
||||||
|
|
||||||
|
class TransactionHub {
|
||||||
|
#connection = new signalR.HubConnectionBuilder()
|
||||||
|
.withUrl('https://spookvooper.com/TransactionHub')
|
||||||
|
.withAutomaticReconnect()
|
||||||
|
.configureLogging(signalR.LogLevel.Information)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
transactionEvent = new TransactionEmitter()
|
||||||
|
|
||||||
|
#val = undefined;
|
||||||
|
|
||||||
|
fromAccount = undefined
|
||||||
|
toAccount = undefined
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
// Event Handlers
|
||||||
|
this.#connection.on('NotifyTransaction', (recieved) => {
|
||||||
|
this.#val = JSON.parse(recieved);
|
||||||
|
this.fromAccount = this.#val.FromAccount;
|
||||||
|
this.toAccount = this.#val.ToAccount;
|
||||||
|
|
||||||
|
this.transactionEvent.emit('NewTransaction', recieved);
|
||||||
|
})
|
||||||
|
|
||||||
|
// Start connection logic
|
||||||
|
this.#connection.onclose(async (e) => {
|
||||||
|
await this.onClosed(e)
|
||||||
|
});
|
||||||
|
|
||||||
|
this.#connection.on();
|
||||||
|
|
||||||
|
this.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
async start() {
|
||||||
|
console.log("Starting TransactionHub Connection...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.#connection.start();
|
||||||
|
console.log("Connected to TransactionHub");
|
||||||
|
} catch (e) {
|
||||||
|
console.error("TransactionHub Error: Connection failed while trying to establish a connection\n", e)
|
||||||
|
console.log("Retrying in 5 seconds")
|
||||||
|
setTimeout(() => {
|
||||||
|
this.start();
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClosed(e) {
|
||||||
|
console.error("TransactionHub Error: Connection closed unexpectedly\n", e);
|
||||||
|
await this.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = TransactionHub
|
|
@ -1,65 +1,49 @@
|
||||||
// SpookVooper API - modules/auth.js
|
// SpookVooper API - modules/Auth.js
|
||||||
// Written by Brendan Lane
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
/** @module modules/auth */
|
const axios = require('axios')
|
||||||
import axios from 'axios'
|
const authURL = 'https://spookvooper.com/oauth2'
|
||||||
|
let urlReturn;
|
||||||
|
|
||||||
const baseURL = 'https://spookvooper.com/oauth2'
|
class Auth {
|
||||||
let urlReturn
|
#clientsecret = undefined;
|
||||||
|
#authcode = undefined;
|
||||||
|
|
||||||
/**
|
constructor(clientid, clientsecret) {
|
||||||
* Generates a Oauth2 URL for you. This just builds a string and DOES NOT need a promise. For any updates on how this works, check #sv-developer in the discord server. https://discord.gg/spookvooper. Get more information at the wiki. https://github.com/bowlingballindustries/spookvooper-api/wiki/Auth#authorize
|
this.clientid = clientid;
|
||||||
* @function authorize
|
this.#clientsecret = clientsecret;
|
||||||
* @param {string} response_type The type of response you get back. Currently the only one that is supported is "code". This parameter is requried.
|
}
|
||||||
* @param {string} client_id The client ID of your Oauth2 app. To get your client ID, go to https://spookvooper.com/oauth2. This parameter is requried.
|
|
||||||
* @param {string} redirect_uri Where to redirect to once authorization has been granted. Will return a "code" and "state" parameter if successful. This parameter is requried.
|
|
||||||
* @param {string} scope The scope of what you want to be able to receive. All scopes are allowed. This parameter is requried.
|
|
||||||
* @param {string} state The state parameter can have anything here. Will be returned to the server upon completion. This parameter is optional.
|
|
||||||
* @returns {string} Will return a string containing a link to the Oauth2 authorization page. If there is an error, it will return "ERROR: Oauth2 URL Builder - A required variable is undefined or is missing."
|
|
||||||
*/
|
|
||||||
function authorize (response_type, client_id, redirect_uri, scope, state) {
|
|
||||||
if (response_type === undefined || client_id === undefined || redirect_uri === undefined || scope === undefined) {
|
|
||||||
return 'ERROR: Oauth2 URL Builder - A required variable is undefined or is missing.'
|
|
||||||
} else if (state === undefined) {
|
|
||||||
state = ''
|
|
||||||
urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`
|
|
||||||
urlReturn = urlReturn.split(' ').join('%20')
|
|
||||||
return urlReturn
|
|
||||||
} else {
|
|
||||||
urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`
|
|
||||||
urlReturn = urlReturn.split(' ').join('%20')
|
|
||||||
return urlReturn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
genLink(redirect, scope, state) {
|
||||||
* Gets a token that you can use for Oauth2. For any updates on how this works, check #sv-developer in the discord server. https://discord.gg/spookvooper
|
if (redirect === undefined || scope === undefined) {
|
||||||
* @function requestToken
|
throw "Both parameters 'redirect' and 'scope' must be defined!"
|
||||||
* @param {string} grant_type The type of response you get back. Currently the one that is supported is "authorization_code"
|
} else if (state === undefined) {
|
||||||
* @param {string} code The code that was returned from the authorization.
|
state = "";
|
||||||
* @param {string} redirect_uri Where to redirect to once authorization has been granted. Will return a "code" and "state" parameter if successful.
|
urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`;
|
||||||
* @param {string} client_id The client ID of your Oauth2 app. To get your client ID, go to https://spookvooper.com/oauth2.
|
urlReturn = urlReturn.split(" ").join("%20");
|
||||||
* @param {string} client_secret The client secret of your Oauth2 app. To get your client ID, go to https://spookvooper.com/oauth2. This WILL NOT get shared with anything other than the function it is in, and will not get sent anywhere other than https://spookvooper.com/. We take privacy very seriously. You must keep this safe.
|
return urlReturn;
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object containing the token, expire time in seconds, and the svid of the authorized user).
|
|
||||||
*/
|
|
||||||
function requestToken (grant_type, code, redirect_uri, client_id, client_secret, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/requestToken?grant_type=${grant_type}&code=${code}&redirect_uri=${redirect_uri}&client_id=${client_id}&client_secret=${client_secret}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`;
|
||||||
|
urlReturn = urlReturn.split(" ").join("%20");
|
||||||
|
return urlReturn;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
|
||||||
|
setAuthCode(authcode) {
|
||||||
|
this.#authcode = authcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
requestToken(redirect) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${authURL}/requestToken?grant_type=authorization_code&code=${this.#authcode}&redirect_uri=${redirect}&client_id=${this.clientid}&client_secret=${this.#clientsecret}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
module.exports = Auth
|
||||||
authorize,
|
|
||||||
requestToken
|
|
||||||
}
|
|
||||||
|
|
238
modules/group.js
238
modules/group.js
|
@ -1,137 +1,113 @@
|
||||||
// SpookVooper API - modules/group.js
|
// SpookVooper API - modules/Group.js
|
||||||
// Written by Brendan Lane
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
/** @module modules/group */
|
const axios = require('axios');
|
||||||
import axios from 'axios'
|
const groupURL = 'https://api.spookvooper.com/group'
|
||||||
|
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||||
|
|
||||||
const baseURL = 'https://api.spookvooper.com/group'
|
class Group {
|
||||||
|
svid = undefined;
|
||||||
|
#apikey = undefined;
|
||||||
|
|
||||||
/**
|
constructor(svid) {
|
||||||
* Checks if a group exists.
|
this.svid = svid;
|
||||||
* @function doesGroupExist
|
|
||||||
* @param {string} svid The svid of the group in question.
|
if (!this.svid.startsWith('g-')) {
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
throw "Error: A group must have a 'g-' or else it is not a group!"
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function doesGroupExist (svid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/doesGroupExist?svid=${svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
|
||||||
|
getGroup() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${groupURL}/getGroup?svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
set setApiKey(key) {
|
||||||
|
this.#apikey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendCredits(amount, to, reason) {
|
||||||
|
if (typeof to === "string") {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (typeof to === "object") {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to.svid}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw "The 'to' parameter must be a string or an object!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doesGroupExist() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${groupURL}/doesGroupExist?svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getGroupMembers() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${groupURL}/getGroupMembers?svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hasGroupPermission(user, permission) {
|
||||||
|
if (typeof to === "string") {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${groupURL}/hasGroupPermission?svid=${this.svid}&usersvid=${user}&permission=${permission}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (typeof to === "object") {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${groupURL}/hasGroupPermission?svid=${this.svid}&usersvid=${user.svid}&permission=${permission}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw "Argument user must either be a string or an object"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
module.exports = Group
|
||||||
* Gets all members of a group.
|
|
||||||
* @function getGroupMembers
|
|
||||||
* @param {string} svid The svid of the group in question.
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getGroupMembers (svid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getGroupMembers?svid=${svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all members of a group.
|
|
||||||
* @function hasGroupPermission
|
|
||||||
* @param {string} svid The svid of the group in question.
|
|
||||||
* @param {string} usersvid The svid of the user you want to check
|
|
||||||
* @param {string} permission The permission you want to search for
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function hasGroupPermission (svid, usersvid, permission, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/hasGroupPermission?svid=${svid}&usersvid=${usersvid}&permission=${permission}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the SVID from a name
|
|
||||||
* @function getSvidFromName
|
|
||||||
* @param {string} name The name of the group
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getSvidFromName (name, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getSvidFromName?name=${name}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the name of the group
|
|
||||||
* @function getGroupMembers
|
|
||||||
* @param {string} svid The svid of the group in question.
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getName (svid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getName?svid=${svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
doesGroupExist,
|
|
||||||
getGroupMembers,
|
|
||||||
hasGroupPermission,
|
|
||||||
getSvidFromName,
|
|
||||||
getName
|
|
||||||
}
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
// SpookVooper API - modules/auth.js
|
||||||
|
// Written by Brendan Lane
|
||||||
|
|
||||||
|
/** @module modules/auth */
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const baseURL = 'https://spookvooper.com/oauth2'
|
||||||
|
let urlReturn
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a Oauth2 URL for you. This just builds a string and DOES NOT need a promise. For any updates on how this works, check #sv-developer in the discord server. https://discord.gg/spookvooper. Get more information at the wiki. https://github.com/bowlingballindustries/spookvooper-api/wiki/Auth#authorize
|
||||||
|
* @function authorize
|
||||||
|
* @param {string} response_type The type of response you get back. Currently the only one that is supported is "code". This parameter is requried.
|
||||||
|
* @param {string} client_id The client ID of your Oauth2 app. To get your client ID, go to https://spookvooper.com/oauth2. This parameter is requried.
|
||||||
|
* @param {string} redirect_uri Where to redirect to once authorization has been granted. Will return a "code" and "state" parameter if successful. This parameter is requried.
|
||||||
|
* @param {string} scope The scope of what you want to be able to receive. All scopes are allowed. This parameter is requried.
|
||||||
|
* @param {string} state The state parameter can have anything here. Will be returned to the server upon completion. This parameter is optional.
|
||||||
|
* @returns {string} Will return a string containing a link to the Oauth2 authorization page. If there is an error, it will return "ERROR: Oauth2 URL Builder - A required variable is undefined or is missing."
|
||||||
|
*/
|
||||||
|
function authorize (response_type, client_id, redirect_uri, scope, state) {
|
||||||
|
if (response_type === undefined || client_id === undefined || redirect_uri === undefined || scope === undefined) {
|
||||||
|
return 'ERROR: Oauth2 URL Builder - A required variable is undefined or is missing.'
|
||||||
|
} else if (state === undefined) {
|
||||||
|
state = ''
|
||||||
|
urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`
|
||||||
|
urlReturn = urlReturn.split(' ').join('%20')
|
||||||
|
return urlReturn
|
||||||
|
} else {
|
||||||
|
urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`
|
||||||
|
urlReturn = urlReturn.split(' ').join('%20')
|
||||||
|
return urlReturn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a token that you can use for Oauth2. For any updates on how this works, check #sv-developer in the discord server. https://discord.gg/spookvooper
|
||||||
|
* @function requestToken
|
||||||
|
* @param {string} grant_type The type of response you get back. Currently the one that is supported is "authorization_code"
|
||||||
|
* @param {string} code The code that was returned from the authorization.
|
||||||
|
* @param {string} redirect_uri Where to redirect to once authorization has been granted. Will return a "code" and "state" parameter if successful.
|
||||||
|
* @param {string} client_id The client ID of your Oauth2 app. To get your client ID, go to https://spookvooper.com/oauth2.
|
||||||
|
* @param {string} client_secret The client secret of your Oauth2 app. To get your client ID, go to https://spookvooper.com/oauth2. This WILL NOT get shared with anything other than the function it is in, and will not get sent anywhere other than https://spookvooper.com/. We take privacy very seriously. You must keep this safe.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object containing the token, expire time in seconds, and the svid of the authorized user).
|
||||||
|
*/
|
||||||
|
function requestToken (grant_type, code, redirect_uri, client_id, client_secret, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/requestToken?grant_type=${grant_type}&code=${code}&redirect_uri=${redirect_uri}&client_id=${client_id}&client_secret=${client_secret}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
authorize,
|
||||||
|
requestToken
|
||||||
|
}
|
|
@ -1,378 +1,378 @@
|
||||||
// SpookVooper API - modules/eco.js
|
// SpookVooper API - modules/eco.js
|
||||||
// Written by Brendan Lane
|
// Written by Brendan Lane
|
||||||
|
|
||||||
/** @module modules/eco */
|
/** @module modules/eco */
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
const baseURL = 'https://api.spookvooper.com/eco'
|
const baseURL = 'https://api.spookvooper.com/eco'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the balance of a user, given their svid.
|
* Gets the balance of a user, given their svid.
|
||||||
* @function getBalance
|
* @function getBalance
|
||||||
* @param {string} svid The svid of the user in question.
|
* @param {string} svid The svid of the user in question.
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getBalance (svid, errToConsole) {
|
function getBalance (svid, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getBalance?svid=${svid}`)
|
axios.get(`${baseURL}/getBalance?svid=${svid}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a payment to and from accounts
|
* Makes a payment to and from accounts
|
||||||
* @function sendTransactionByIDs
|
* @function sendTransactionByIDs
|
||||||
* @param {string} to The svid of the user/group you want to send the payment to
|
* @param {string} to The svid of the user/group you want to send the payment to
|
||||||
* @param {string} from The svid of the user/group you want to send the payment from
|
* @param {string} from The svid of the user/group you want to send the payment from
|
||||||
* @param {string} amount The amount of money to be sent
|
* @param {string} amount The amount of money to be sent
|
||||||
* @param {string} auth An api key which has permission to use funds from the sender or use oauthkey|app_secret formula for Oauth2.
|
* @param {string} auth An api key which has permission to use funds from the sender or use oauthkey|app_secret formula for Oauth2.
|
||||||
* @param {string} detail A short detail of why the payment happened. Must include "sale" if it was a sale.
|
* @param {string} detail A short detail of why the payment happened. Must include "sale" if it was a sale.
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function sendTransactionByIDs (to, from, amount, auth, detail, errToConsole) {
|
function sendTransactionByIDs (to, from, amount, auth, detail, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/sendTransactionByIDs?to=${to}&from=${from}&amount=${amount}&auth=${auth}&detail=${detail}`)
|
axios.get(`${baseURL}/sendTransactionByIDs?to=${to}&from=${from}&amount=${amount}&auth=${auth}&detail=${detail}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of a stock ticker.
|
* Gets the value of a stock ticker.
|
||||||
* @function getStockValue
|
* @function getStockValue
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getStockValue (ticker, errToConsole) {
|
function getStockValue (ticker, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getStockValue?ticker=${ticker}`)
|
axios.get(`${baseURL}/getStockValue?ticker=${ticker}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the history of a stock ticker.
|
* Gets the history of a stock ticker.
|
||||||
* @function getStockHistory
|
* @function getStockHistory
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {string} type Can be "MINUTE", "HOUR", or "DAY"
|
* @param {string} type Can be "MINUTE", "HOUR", or "DAY"
|
||||||
* @param {string} count How far back to go. Don't use a count over 60!
|
* @param {string} count How far back to go. Don't use a count over 60!
|
||||||
* @param {string} interval Set the time interval beteen data points
|
* @param {string} interval Set the time interval beteen data points
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an array).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an array).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getStockHistory (ticker, type, count, interval, errToConsole) {
|
function getStockHistory (ticker, type, count, interval, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getStockHistory?ticker=${ticker}&type=${type}&count=${count}&interval=${interval}`)
|
axios.get(`${baseURL}/getStockHistory?ticker=${ticker}&type=${type}&count=${count}&interval=${interval}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purchases Stocks
|
* Purchases Stocks
|
||||||
* @function submitStockBuy
|
* @function submitStockBuy
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {string} count How many stocks you want to purchase
|
* @param {string} count How many stocks you want to purchase
|
||||||
* @param {string} price How much you want to pay for each stock
|
* @param {string} price How much you want to pay for each stock
|
||||||
* @param {string} accountid The SVID of the account (user or group) you'd like to purchase from.
|
* @param {string} accountid The SVID of the account (user or group) you'd like to purchase from.
|
||||||
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
|
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a tesult).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a tesult).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function submitStockBuy (ticker, count, price, accountid, auth, errToConsole) {
|
function submitStockBuy (ticker, count, price, accountid, auth, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/submitStockBuy?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
|
axios.get(`${baseURL}/submitStockBuy?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sells Stocks
|
* Sells Stocks
|
||||||
* @function submitStockSell
|
* @function submitStockSell
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {string} count How many stocks you want to sell
|
* @param {string} count How many stocks you want to sell
|
||||||
* @param {string} price How much you want to sell each stock for
|
* @param {string} price How much you want to sell each stock for
|
||||||
* @param {string} accountid The SVID of the account (user or group) you'd like to sell from.
|
* @param {string} accountid The SVID of the account (user or group) you'd like to sell from.
|
||||||
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
|
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function submitStockSell (ticker, count, price, accountid, auth, errToConsole) {
|
function submitStockSell (ticker, count, price, accountid, auth, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/submitStockSell?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
|
axios.get(`${baseURL}/submitStockSell?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels an ongoing order.
|
* Cancels an ongoing order.
|
||||||
* @function cancelOrder
|
* @function cancelOrder
|
||||||
* @param {string} orderid The ID of the order you'd like to cancel.
|
* @param {string} orderid The ID of the order you'd like to cancel.
|
||||||
* @param {string} accountid The SVID of the account (user or group) you'd like to purchase from.
|
* @param {string} accountid The SVID of the account (user or group) you'd like to purchase from.
|
||||||
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
|
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function cancelOrder (orderid, accountid, auth, errToConsole) {
|
function cancelOrder (orderid, accountid, auth, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/submitStockBuy?orderid=${orderid}&accountid=${accountid}&auth=${auth}`)
|
axios.get(`${baseURL}/submitStockBuy?orderid=${orderid}&accountid=${accountid}&auth=${auth}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current buy price of the ticker
|
* Gets the current buy price of the ticker
|
||||||
* @function getStockBuyPrice
|
* @function getStockBuyPrice
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getStockBuyPrice (ticker, errToConsole) {
|
function getStockBuyPrice (ticker, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getStockBuyPrice?ticker=${ticker}`)
|
axios.get(`${baseURL}/getStockBuyPrice?ticker=${ticker}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current buy price of the ticker
|
* Gets the current buy price of the ticker
|
||||||
* @function getStockBuyPrice
|
* @function getStockBuyPrice
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {string} type The type of queue. Can either be "BUY" or "SELL"
|
* @param {string} type The type of queue. Can either be "BUY" or "SELL"
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getQueueInfo (ticker, type, errToConsole) {
|
function getQueueInfo (ticker, type, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getQueueInfo?ticker=${ticker}&type=${type}`)
|
axios.get(`${baseURL}/getQueueInfo?ticker=${ticker}&type=${type}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets stock offer data for a user.
|
* Gets stock offer data for a user.
|
||||||
* @function getUserStockOffers
|
* @function getUserStockOffers
|
||||||
* @param {string} ticker The ticker id
|
* @param {string} ticker The ticker id
|
||||||
* @param {string} svid The SVID of the user you want to look up
|
* @param {string} svid The SVID of the user you want to look up
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an array).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an array).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getUserStockOffers (ticker, svid, errToConsole) {
|
function getUserStockOffers (ticker, svid, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getUserStockOffers?ticker=${ticker}&svid=${svid}`)
|
axios.get(`${baseURL}/getUserStockOffers?ticker=${ticker}&svid=${svid}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets total wealth of a district
|
* Gets total wealth of a district
|
||||||
* @function getDistrictWealth
|
* @function getDistrictWealth
|
||||||
* @param {string} id The name of the district
|
* @param {string} id The name of the district
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getDistrictWealth (id, errToConsole) {
|
function getDistrictWealth (id, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getDistrictWealth?id=${id}`)
|
axios.get(`${baseURL}/getDistrictWealth?id=${id}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets total wealth of users in a district
|
* Gets total wealth of users in a district
|
||||||
* @function getDistrictUserWealth
|
* @function getDistrictUserWealth
|
||||||
* @param {string} id The name of the district
|
* @param {string} id The name of the district
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getDistrictUserWealth (id, errToConsole) {
|
function getDistrictUserWealth (id, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getDistrictUserWealth?id=${id}`)
|
axios.get(`${baseURL}/getDistrictUserWealth?id=${id}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets total wealth of groups in a district
|
* Gets total wealth of groups in a district
|
||||||
* @function getDistrictGroupWealth
|
* @function getDistrictGroupWealth
|
||||||
* @param {string} id The name of the district
|
* @param {string} id The name of the district
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getDistrictGroupWealth (id, errToConsole) {
|
function getDistrictGroupWealth (id, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getDistrictGroupWealth?id=${id}`)
|
axios.get(`${baseURL}/getDistrictGroupWealth?id=${id}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function getOwnerData
|
* @function getOwnerData
|
||||||
* @param {string} ticker The stock ticker you want to query
|
* @param {string} ticker The stock ticker you want to query
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object).
|
||||||
* @author Brendan Lane <me@imbl.me>
|
* @author Brendan Lane <me@imbl.me>
|
||||||
*/
|
*/
|
||||||
function getOwnerData (ticker, errToConsole) {
|
function getOwnerData (ticker, errToConsole) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(`${baseURL}/getOwnerData?ticker=${ticker}`)
|
axios.get(`${baseURL}/getOwnerData?ticker=${ticker}`)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
resolve(response.data)
|
resolve(response.data)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (errToConsole) {
|
if (errToConsole) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getBalance,
|
getBalance,
|
||||||
sendTransactionByIDs,
|
sendTransactionByIDs,
|
||||||
getStockValue,
|
getStockValue,
|
||||||
getStockHistory,
|
getStockHistory,
|
||||||
submitStockBuy,
|
submitStockBuy,
|
||||||
submitStockSell,
|
submitStockSell,
|
||||||
cancelOrder,
|
cancelOrder,
|
||||||
getStockBuyPrice,
|
getStockBuyPrice,
|
||||||
getQueueInfo,
|
getQueueInfo,
|
||||||
getUserStockOffers,
|
getUserStockOffers,
|
||||||
getDistrictWealth,
|
getDistrictWealth,
|
||||||
getDistrictUserWealth,
|
getDistrictUserWealth,
|
||||||
getDistrictGroupWealth,
|
getDistrictGroupWealth,
|
||||||
getOwnerData
|
getOwnerData
|
||||||
}
|
}
|
|
@ -0,0 +1,137 @@
|
||||||
|
// SpookVooper API - modules/group.js
|
||||||
|
// Written by Brendan Lane
|
||||||
|
|
||||||
|
/** @module modules/group */
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const baseURL = 'https://api.spookvooper.com/group'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a group exists.
|
||||||
|
* @function doesGroupExist
|
||||||
|
* @param {string} svid The svid of the group in question.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function doesGroupExist (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/doesGroupExist?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all members of a group.
|
||||||
|
* @function getGroupMembers
|
||||||
|
* @param {string} svid The svid of the group in question.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getGroupMembers (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getGroupMembers?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all members of a group.
|
||||||
|
* @function hasGroupPermission
|
||||||
|
* @param {string} svid The svid of the group in question.
|
||||||
|
* @param {string} usersvid The svid of the user you want to check
|
||||||
|
* @param {string} permission The permission you want to search for
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function hasGroupPermission (svid, usersvid, permission, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/hasGroupPermission?svid=${svid}&usersvid=${usersvid}&permission=${permission}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the SVID from a name
|
||||||
|
* @function getSvidFromName
|
||||||
|
* @param {string} name The name of the group
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getSvidFromName (name, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getSvidFromName?name=${name}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the group
|
||||||
|
* @function getGroupMembers
|
||||||
|
* @param {string} svid The svid of the group in question.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getName (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getName?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
doesGroupExist,
|
||||||
|
getGroupMembers,
|
||||||
|
hasGroupPermission,
|
||||||
|
getSvidFromName,
|
||||||
|
getName
|
||||||
|
}
|
|
@ -1,42 +1,42 @@
|
||||||
// SpookVooper API - modules/premade.js
|
// SpookVooper API - modules/premade.js
|
||||||
// Written by Brendan Lane
|
// Written by Brendan Lane
|
||||||
|
|
||||||
/** @module modules/premade */
|
/** @module modules/premade */
|
||||||
import user from './user.js'
|
import user from './user.js'
|
||||||
import eco from './eco.js'
|
import eco from './eco.js'
|
||||||
|
|
||||||
let StockOwnerAmount
|
let StockOwnerAmount
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total XP of a user
|
* Gets the total XP of a user
|
||||||
* @function getTotalXP
|
* @function getTotalXP
|
||||||
* @param {string} svid The svid of the user you want to lookup.
|
* @param {string} svid The svid of the user you want to lookup.
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an integer).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an integer).
|
||||||
*/
|
*/
|
||||||
function getTotalXP (svid) {
|
function getTotalXP (svid) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
user.getUser(svid, true).then(value => {
|
user.getUser(svid, true).then(value => {
|
||||||
resolve(value.post_likes + value.comment_likes + (value.twitch_message_xp * 4) + (value.discord_commends * 5) + (value.discord_message_xp * 2) + (value.discord_game_xp / 100))
|
resolve(value.post_likes + value.comment_likes + (value.twitch_message_xp * 4) + (value.discord_commends * 5) + (value.discord_message_xp * 2) + (value.discord_game_xp / 100))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the stock owner and the amount they own.
|
* Gets the name of the stock owner and the amount they own.
|
||||||
* @function getStockOwner
|
* @function getStockOwner
|
||||||
* @param {string} ticker The ticker you want to lookup.
|
* @param {string} ticker The ticker you want to lookup.
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an Object).
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an Object).
|
||||||
*/
|
*/
|
||||||
function getStockOwner (ticker) {
|
function getStockOwner (ticker) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
eco.getOwnerData(ticker, true).then(value => {
|
eco.getOwnerData(ticker, true).then(value => {
|
||||||
StockOwnerAmount = value.length - 1
|
StockOwnerAmount = value.length - 1
|
||||||
resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount })
|
resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getTotalXP,
|
getTotalXP,
|
||||||
getStockOwner
|
getStockOwner
|
||||||
}
|
}
|
|
@ -0,0 +1,261 @@
|
||||||
|
// SpookVooper API - modules/user.js
|
||||||
|
// Written by Brendan Lane
|
||||||
|
|
||||||
|
/** @module modules/user */
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const baseURL = 'https://api.spookvooper.com/user'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets information on the user
|
||||||
|
* @function getUser
|
||||||
|
* @param {string} svid The svid for the user.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getUser (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getUser?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the username of a user
|
||||||
|
* @function getUsername
|
||||||
|
* @param {string} svid The svid for the user lookup.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getUsername (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getUsername?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the svid of a user from their username
|
||||||
|
* @function getSvidFromUsername
|
||||||
|
* @param {string} username The username of the user
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getSvidFromUsername (username, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getSvidFromUsername?username=${username}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the username from their linked discord account
|
||||||
|
* @function getUsernameFromDiscord
|
||||||
|
* @param {string} discordid The discord User ID for the user account.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getUsernameFromDiscord (discordid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getUsernameFromDiscord?discordid=${discordid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the SVID of a user who has their discord account linked.
|
||||||
|
* @function getSvidFromDiscord
|
||||||
|
* @param {string} discordid The discord user ID
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getSvidFromDiscord (discordid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getSvidFromDiscord?discordid=${discordid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the username from the minecraft UUID.
|
||||||
|
* @function getUsernameFromMinecraft
|
||||||
|
* @param {string} minecraftid The UUID of the minecraft user.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getUsernameFromMinecraft (minecraftid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getUsernameFromMinecraft?minecraftid=${minecraftid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the SVID from the minecraft UUID.
|
||||||
|
* @function getSvidFromMinecraft
|
||||||
|
* @param {string} minecraftid The UUID of the minecraft user.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getSvidFromMinecraft (minecraftid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getSvidFromMinecraft?minecraftid=${minecraftid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the user has a discord role
|
||||||
|
* @function hasDiscordRole
|
||||||
|
* @param {string} userid The SVID of the user you want to lookup
|
||||||
|
* @param {string} role The name of the role you want to lookup.
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function hasDiscordRole (userid, role, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/hasDiscordRole?userid=${userid}&role=${role}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the discord roles of a user
|
||||||
|
* @function getDiscordRoles
|
||||||
|
* @param {string} svid The svid of the user you want to lookup
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getDiscordRoles (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getDiscordRoles?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the days since the last move of a user
|
||||||
|
* @function getDiscordRoles
|
||||||
|
* @param {string} svid The svid of the user you want to lookup
|
||||||
|
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
||||||
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a integer).
|
||||||
|
* @author Brendan Lane <me@imbl.me>
|
||||||
|
*/
|
||||||
|
function getDaysSinceLastMove (svid, errToConsole) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${baseURL}/getDaysSinceLastMove?svid=${svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
if (errToConsole) {
|
||||||
|
console.warn(error)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getUser,
|
||||||
|
getUsername,
|
||||||
|
getSvidFromUsername,
|
||||||
|
getUsernameFromDiscord,
|
||||||
|
getSvidFromDiscord,
|
||||||
|
getUsernameFromMinecraft,
|
||||||
|
getSvidFromMinecraft,
|
||||||
|
hasDiscordRole,
|
||||||
|
getDiscordRoles,
|
||||||
|
getDaysSinceLastMove
|
||||||
|
}
|
413
modules/user.js
413
modules/user.js
|
@ -1,261 +1,170 @@
|
||||||
// SpookVooper API - modules/user.js
|
// SpookVooper API - modules/User.js
|
||||||
// Written by Brendan Lane
|
// Written by Brendan Lane - https://brndnln.dev
|
||||||
|
|
||||||
/** @module modules/user */
|
const axios = require('axios')
|
||||||
import axios from 'axios'
|
const userURL = "https://api.spookvooper.com/user"
|
||||||
|
const ecoURL = "https://api.spookvooper.com/eco"
|
||||||
|
|
||||||
const baseURL = 'https://api.spookvooper.com/user'
|
class User {
|
||||||
|
#apikey = undefined;
|
||||||
|
|
||||||
/**
|
constructor(svid) {
|
||||||
* Gets information on the user
|
this.svid = svid
|
||||||
* @function getUser
|
|
||||||
* @param {string} svid The svid for the user.
|
if (!this.svid.startsWith('u-')) {
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
throw "Error: A user must have a 'u-' or else it is not a user!"
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getUser (svid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getUser?svid=${svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
getUser() {
|
||||||
* Gets the username of a user
|
return new Promise((resolve, reject) => {
|
||||||
* @function getUsername
|
axios.get(`${userURL}/getUser?svid=${this.svid}`)
|
||||||
* @param {string} svid The svid for the user lookup.
|
.then(function (response) {
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
resolve(response.data);
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
})
|
||||||
* @author Brendan Lane <me@imbl.me>
|
.catch(function (error) {
|
||||||
*/
|
reject(error);
|
||||||
function getUsername (svid, errToConsole) {
|
});
|
||||||
return new Promise((resolve, reject) => {
|
});
|
||||||
axios.get(`${baseURL}/getUsername?svid=${svid}`)
|
}
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
getUsername() {
|
||||||
})
|
return new Promise((resolve, reject) => {
|
||||||
.catch(function (error) {
|
axios.get(`${userURL}/getUsername?svid=${this.svid}`)
|
||||||
if (errToConsole) {
|
.then(function (response) {
|
||||||
console.warn(error)
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getBalance() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getBalance?svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hasDiscordRole(role) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${userURL}/hasDiscordRole?userid=${this.svid}&role=${role}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getDiscordRoles() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${userURL}/getDiscordRoles?svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getDaysSinceLastMove() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${userURL}/getDaysSinceLastMove?svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
set setApiKey(key) {
|
||||||
|
this.#apikey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendCredits(amount, to, reason) {
|
||||||
|
if (typeof to === "string") {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (typeof to === "object") {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to.svid}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
throw "The 'to' parameter must be a string or an object!";
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
|
||||||
|
getUserStockOffers(ticker) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getUserStockOffers?ticker=${ticker}&svid=${this.svid}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
buyStock(ticker, amount, price) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/submitStockBuy?ticker=${ticker}&count=${amount}&price=${price}&accountid=${this.svid}&auth=${this.#apikey}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sellStock(ticker, amount, price) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/submitStockSell?ticker=${ticker}&count=${amount}&price=${price}&accountid=${this.svid}&auth=${this.#apikey}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelStockOrder(orderid) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/cancelOrder?orderid=${orderid}&accountid=${this.svid}&auth=${this.#apikey}`)
|
||||||
|
.then(function (response) {
|
||||||
|
resolve(response.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
module.exports = User
|
||||||
* Gets the svid of a user from their username
|
|
||||||
* @function getSvidFromUsername
|
|
||||||
* @param {string} username The username of the user
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getSvidFromUsername (username, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getSvidFromUsername?username=${username}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the username from their linked discord account
|
|
||||||
* @function getUsernameFromDiscord
|
|
||||||
* @param {string} discordid The discord User ID for the user account.
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getUsernameFromDiscord (discordid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getUsernameFromDiscord?discordid=${discordid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the SVID of a user who has their discord account linked.
|
|
||||||
* @function getSvidFromDiscord
|
|
||||||
* @param {string} discordid The discord user ID
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getSvidFromDiscord (discordid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getSvidFromDiscord?discordid=${discordid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the username from the minecraft UUID.
|
|
||||||
* @function getUsernameFromMinecraft
|
|
||||||
* @param {string} minecraftid The UUID of the minecraft user.
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getUsernameFromMinecraft (minecraftid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getUsernameFromMinecraft?minecraftid=${minecraftid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the SVID from the minecraft UUID.
|
|
||||||
* @function getSvidFromMinecraft
|
|
||||||
* @param {string} minecraftid The UUID of the minecraft user.
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getSvidFromMinecraft (minecraftid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getSvidFromMinecraft?minecraftid=${minecraftid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the user has a discord role
|
|
||||||
* @function hasDiscordRole
|
|
||||||
* @param {string} userid The SVID of the user you want to lookup
|
|
||||||
* @param {string} role The name of the role you want to lookup.
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function hasDiscordRole (userid, role, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/hasDiscordRole?userid=${userid}&role=${role}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the discord roles of a user
|
|
||||||
* @function getDiscordRoles
|
|
||||||
* @param {string} svid The svid of the user you want to lookup
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getDiscordRoles (svid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getDiscordRoles?svid=${svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the days since the last move of a user
|
|
||||||
* @function getDiscordRoles
|
|
||||||
* @param {string} svid The svid of the user you want to lookup
|
|
||||||
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
|
|
||||||
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a integer).
|
|
||||||
* @author Brendan Lane <me@imbl.me>
|
|
||||||
*/
|
|
||||||
function getDaysSinceLastMove (svid, errToConsole) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.get(`${baseURL}/getDaysSinceLastMove?svid=${svid}`)
|
|
||||||
.then(function (response) {
|
|
||||||
resolve(response.data)
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
if (errToConsole) {
|
|
||||||
console.warn(error)
|
|
||||||
} else {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
getUser,
|
|
||||||
getUsername,
|
|
||||||
getSvidFromUsername,
|
|
||||||
getUsernameFromDiscord,
|
|
||||||
getSvidFromDiscord,
|
|
||||||
getUsernameFromMinecraft,
|
|
||||||
getSvidFromMinecraft,
|
|
||||||
hasDiscordRole,
|
|
||||||
getDiscordRoles,
|
|
||||||
getDaysSinceLastMove
|
|
||||||
}
|
|
|
@ -1,14 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "spookvooperapi",
|
"name": "@vexico/spookvooperapi",
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "spookvooperapi",
|
"name": "@vexico/spookvooperapi",
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@microsoft/signalr": "^5.0.0",
|
||||||
"axios": "^0.20.0"
|
"axios": "^0.20.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -178,12 +179,35 @@
|
||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@microsoft/signalr": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-AsbU1ZB4Q9JsZ77W13VGT8gi/cVrFn3XbvVfULSwrC9DVCXF2JpkBDh0cCmRaYs9M3kqKohiVM1WPqNeAGil/g==",
|
||||||
|
"dependencies": {
|
||||||
|
"abort-controller": "^3.0.0",
|
||||||
|
"eventsource": "^1.0.7",
|
||||||
|
"fetch-cookie": "^0.7.3",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
|
"ws": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/color-name": {
|
"node_modules/@types/color-name": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/abort-controller": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
|
||||||
|
"dependencies": {
|
||||||
|
"event-target-shim": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "7.4.0",
|
"version": "7.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
|
||||||
|
@ -262,6 +286,11 @@
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/async-limiter": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||||
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "0.20.0",
|
"version": "0.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
|
||||||
|
@ -460,6 +489,11 @@
|
||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/es6-denodeify": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-denodeify/-/es6-denodeify-0.1.5.tgz",
|
||||||
|
"integrity": "sha1-MdTV/pxVA+ElRgQ5MQ4WoqPznB8="
|
||||||
|
},
|
||||||
"node_modules/escape-string-regexp": {
|
"node_modules/escape-string-regexp": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||||
|
@ -641,6 +675,25 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/event-target-shim": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eventsource": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-4Ln17+vVT0k8aWq+t/bF5arcS3EpT9gYtW66EPacdj/mAFevznsnyoHLPy2BA8gbIQeIHoPsvwmfBftfcG//BQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"original": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fast-deep-equal": {
|
"node_modules/fast-deep-equal": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||||
|
@ -659,6 +712,15 @@
|
||||||
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/fetch-cookie": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.7.3.tgz",
|
||||||
|
"integrity": "sha512-rZPkLnI8x5V+zYAiz8QonAHsTb4BY+iFowFBI1RFn0zrO343AVp9X7/yUj/9wL6Ef/8fLls8b/vGtzUvmyAUGA==",
|
||||||
|
"dependencies": {
|
||||||
|
"es6-denodeify": "^0.1.1",
|
||||||
|
"tough-cookie": "^2.3.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/file-entry-cache": {
|
"node_modules/file-entry-cache": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
|
||||||
|
@ -978,6 +1040,14 @@
|
||||||
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/node-fetch": {
|
||||||
|
"version": "2.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||||
|
"engines": {
|
||||||
|
"node": "4.x || >=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/once": {
|
"node_modules/once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
|
@ -1004,6 +1074,14 @@
|
||||||
"node": ">= 0.8.0"
|
"node": ">= 0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/original": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg==",
|
||||||
|
"dependencies": {
|
||||||
|
"url-parse": "^1.4.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/parent-module": {
|
"node_modules/parent-module": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||||
|
@ -1070,15 +1148,24 @@
|
||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/psl": {
|
||||||
|
"version": "1.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
|
||||||
|
"integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ=="
|
||||||
|
},
|
||||||
"node_modules/punycode": {
|
"node_modules/punycode": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/querystringify": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
|
||||||
|
},
|
||||||
"node_modules/regexpp": {
|
"node_modules/regexpp": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
|
||||||
|
@ -1088,6 +1175,11 @@
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/requires-port": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
|
},
|
||||||
"node_modules/resolve": {
|
"node_modules/resolve": {
|
||||||
"version": "1.19.0",
|
"version": "1.19.0",
|
||||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
|
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
|
||||||
|
@ -1282,6 +1374,18 @@
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tough-cookie": {
|
||||||
|
"version": "2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
|
||||||
|
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
|
||||||
|
"dependencies": {
|
||||||
|
"psl": "^1.1.28",
|
||||||
|
"punycode": "^2.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/type-check": {
|
"node_modules/type-check": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||||
|
@ -1312,6 +1416,15 @@
|
||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/url-parse": {
|
||||||
|
"version": "1.4.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz",
|
||||||
|
"integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==",
|
||||||
|
"dependencies": {
|
||||||
|
"querystringify": "^2.1.1",
|
||||||
|
"requires-port": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/v8-compile-cache": {
|
"node_modules/v8-compile-cache": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
|
||||||
|
@ -1359,6 +1472,14 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ws": {
|
||||||
|
"version": "6.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
|
||||||
|
"integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
|
||||||
|
"dependencies": {
|
||||||
|
"async-limiter": "~1.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1512,12 +1633,32 @@
|
||||||
"strip-json-comments": "^3.1.1"
|
"strip-json-comments": "^3.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@microsoft/signalr": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-AsbU1ZB4Q9JsZ77W13VGT8gi/cVrFn3XbvVfULSwrC9DVCXF2JpkBDh0cCmRaYs9M3kqKohiVM1WPqNeAGil/g==",
|
||||||
|
"requires": {
|
||||||
|
"abort-controller": "^3.0.0",
|
||||||
|
"eventsource": "^1.0.7",
|
||||||
|
"fetch-cookie": "^0.7.3",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
|
"ws": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/color-name": {
|
"@types/color-name": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"abort-controller": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
|
||||||
|
"requires": {
|
||||||
|
"event-target-shim": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "7.4.0",
|
"version": "7.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
|
||||||
|
@ -1578,6 +1719,11 @@
|
||||||
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
|
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"async-limiter": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||||
|
},
|
||||||
"axios": {
|
"axios": {
|
||||||
"version": "0.20.0",
|
"version": "0.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
|
||||||
|
@ -1745,6 +1891,11 @@
|
||||||
"ansi-colors": "^4.1.1"
|
"ansi-colors": "^4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"es6-denodeify": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-denodeify/-/es6-denodeify-0.1.5.tgz",
|
||||||
|
"integrity": "sha1-MdTV/pxVA+ElRgQ5MQ4WoqPznB8="
|
||||||
|
},
|
||||||
"escape-string-regexp": {
|
"escape-string-regexp": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||||
|
@ -1884,6 +2035,19 @@
|
||||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"event-target-shim": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
|
||||||
|
},
|
||||||
|
"eventsource": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-4Ln17+vVT0k8aWq+t/bF5arcS3EpT9gYtW66EPacdj/mAFevznsnyoHLPy2BA8gbIQeIHoPsvwmfBftfcG//BQ==",
|
||||||
|
"requires": {
|
||||||
|
"original": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"fast-deep-equal": {
|
"fast-deep-equal": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||||
|
@ -1902,6 +2066,15 @@
|
||||||
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"fetch-cookie": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.7.3.tgz",
|
||||||
|
"integrity": "sha512-rZPkLnI8x5V+zYAiz8QonAHsTb4BY+iFowFBI1RFn0zrO343AVp9X7/yUj/9wL6Ef/8fLls8b/vGtzUvmyAUGA==",
|
||||||
|
"requires": {
|
||||||
|
"es6-denodeify": "^0.1.1",
|
||||||
|
"tough-cookie": "^2.3.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"file-entry-cache": {
|
"file-entry-cache": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
|
||||||
|
@ -2158,6 +2331,11 @@
|
||||||
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node-fetch": {
|
||||||
|
"version": "2.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||||
|
},
|
||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
|
@ -2181,6 +2359,14 @@
|
||||||
"word-wrap": "^1.2.3"
|
"word-wrap": "^1.2.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"original": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg==",
|
||||||
|
"requires": {
|
||||||
|
"url-parse": "^1.4.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"parent-module": {
|
"parent-module": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||||
|
@ -2226,11 +2412,20 @@
|
||||||
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
|
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"psl": {
|
||||||
|
"version": "1.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
|
||||||
|
"integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ=="
|
||||||
|
},
|
||||||
"punycode": {
|
"punycode": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||||
"dev": true
|
},
|
||||||
|
"querystringify": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
|
||||||
},
|
},
|
||||||
"regexpp": {
|
"regexpp": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
|
@ -2238,6 +2433,11 @@
|
||||||
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
|
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"requires-port": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
|
},
|
||||||
"resolve": {
|
"resolve": {
|
||||||
"version": "1.19.0",
|
"version": "1.19.0",
|
||||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
|
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
|
||||||
|
@ -2383,6 +2583,15 @@
|
||||||
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
|
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"tough-cookie": {
|
||||||
|
"version": "2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
|
||||||
|
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
|
||||||
|
"requires": {
|
||||||
|
"psl": "^1.1.28",
|
||||||
|
"punycode": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"type-check": {
|
"type-check": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||||
|
@ -2407,6 +2616,15 @@
|
||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"url-parse": {
|
||||||
|
"version": "1.4.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz",
|
||||||
|
"integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==",
|
||||||
|
"requires": {
|
||||||
|
"querystringify": "^2.1.1",
|
||||||
|
"requires-port": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"v8-compile-cache": {
|
"v8-compile-cache": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
|
||||||
|
@ -2442,6 +2660,14 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"mkdirp": "^0.5.1"
|
"mkdirp": "^0.5.1"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ws": {
|
||||||
|
"version": "6.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
|
||||||
|
"integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
|
||||||
|
"requires": {
|
||||||
|
"async-limiter": "~1.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "spookvooperapi",
|
"name": "@vexico/spookvooperapi",
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"description": "Easy to use library for the SpookVooper API",
|
"description": "Easy to use library for the SpookVooper API",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
|
@ -7,6 +7,9 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node main.js"
|
"test": "node main.js"
|
||||||
},
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://npm.pkg.github.com/"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/vexico/spookvooper-api.git"
|
"url": "git+https://github.com/vexico/spookvooper-api.git"
|
||||||
|
@ -24,6 +27,7 @@
|
||||||
"prettier": "^2.1.1"
|
"prettier": "^2.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@microsoft/signalr": "^5.0.0",
|
||||||
"axios": "^0.20.0"
|
"axios": "^0.20.0"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
Loading…
Reference in New Issue