💻 Sync with local

This commit is contained in:
Brendan Lane 2020-12-03 01:43:50 -05:00
parent 075dc25844
commit 7677ea0194
15 changed files with 1733 additions and 1283 deletions

428
main.js
View File

@ -1,426 +1,20 @@
// SpookVooper API - main.js
// Written by Brendan Lane - https://brndnln.dev/
const userURL = "https://api.spookvooper.com/user";
const groupURL = "https://api.spookvooper.com/group";
const ecoURL = "https://api.spookvooper.com/eco";
const authURL = "https://spookvooper.com/oauth2";
const axios = require('axios');
let urlReturn;
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);
});
});
}
}
const User = require('./modules/User.js')
const Stock = require('./modules/Stock.js')
const District = require('./modules/District.js')
const Group = require('./modules/Group.js')
const Auth = require('./modules/Auth.js')
const TransactionHub = require('./modules/TransactionHub.js')
const ExchangeHub = require('./modules/ExchangeHub.js')
module.exports = {
User,
Stock,
District,
Group,
Auth
}
Auth,
TransactionHub,
ExchangeHub
}

53
modules/District.js Normal file
View File

@ -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

104
modules/ExchangeHub.js Normal file
View File

@ -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

72
modules/Stock.js Normal file
View File

@ -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

65
modules/TransactionHub.js Normal file
View File

@ -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

View File

@ -1,65 +1,49 @@
// SpookVooper API - modules/auth.js
// Written by Brendan Lane
// SpookVooper API - modules/Auth.js
// Written by Brendan Lane - https://brndnln.dev/
/** @module modules/auth */
import axios from 'axios'
const axios = require('axios')
const authURL = 'https://spookvooper.com/oauth2'
let urlReturn;
const baseURL = 'https://spookvooper.com/oauth2'
let urlReturn
class Auth {
#clientsecret = undefined;
#authcode = undefined;
/**
* 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
}
}
constructor(clientid, clientsecret) {
this.clientid = clientid;
this.#clientsecret = clientsecret;
}
/**
* 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)
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 {
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 {
authorize,
requestToken
}
module.exports = Auth

View File

@ -1,137 +1,113 @@
// SpookVooper API - modules/group.js
// Written by Brendan Lane
// SpookVooper API - modules/Group.js
// Written by Brendan Lane - https://brndnln.dev/
/** @module modules/group */
import axios from 'axios'
const axios = require('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;
/**
* 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)
constructor(svid) {
this.svid = svid;
if (!this.svid.startsWith('g-')) {
throw "Error: A group must have a 'g-' or else it is not a group!"
}
})
})
}
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"
}
}
}
/**
* 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
}
module.exports = Group

65
modules/old/auth.js Normal file
View File

@ -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
}

View File

@ -1,378 +1,378 @@
// SpookVooper API - modules/eco.js
// Written by Brendan Lane
/** @module modules/eco */
import axios from 'axios'
const baseURL = 'https://api.spookvooper.com/eco'
/**
* Gets the balance of a user, given their svid.
* @function getBalance
* @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
* @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>
*/
function getBalance (svid, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getBalance?svid=${svid}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Makes a payment to and from accounts
* @function sendTransactionByIDs
* @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} 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} 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
* @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 sendTransactionByIDs (to, from, amount, auth, detail, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/sendTransactionByIDs?to=${to}&from=${from}&amount=${amount}&auth=${auth}&detail=${detail}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the value of a stock ticker.
* @function getStockValue
* @param {string} ticker The ticker 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 decimal).
* @author Brendan Lane <me@imbl.me>
*/
function getStockValue (ticker, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockValue?ticker=${ticker}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the history of a stock ticker.
* @function getStockHistory
* @param {string} ticker The ticker id
* @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} 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
* @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>
*/
function getStockHistory (ticker, type, count, interval, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockHistory?ticker=${ticker}&type=${type}&count=${count}&interval=${interval}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Purchases Stocks
* @function submitStockBuy
* @param {string} ticker The ticker id
* @param {string} count How many stocks you want to purchase
* @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} 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
* @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>
*/
function submitStockBuy (ticker, count, price, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockBuy?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Sells Stocks
* @function submitStockSell
* @param {string} ticker The ticker id
* @param {string} count How many stocks you want to sell
* @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} 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
* @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>
*/
function submitStockSell (ticker, count, price, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockSell?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Cancels an ongoing order.
* @function cancelOrder
* @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} 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
* @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>
*/
function cancelOrder (orderid, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockBuy?orderid=${orderid}&accountid=${accountid}&auth=${auth}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the current buy price of the ticker
* @function getStockBuyPrice
* @param {string} ticker The ticker 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 decimal).
* @author Brendan Lane <me@imbl.me>
*/
function getStockBuyPrice (ticker, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockBuyPrice?ticker=${ticker}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the current buy price of the ticker
* @function getStockBuyPrice
* @param {string} ticker The ticker id
* @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
* @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>
*/
function getQueueInfo (ticker, type, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getQueueInfo?ticker=${ticker}&type=${type}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets stock offer data for a user.
* @function getUserStockOffers
* @param {string} ticker The ticker id
* @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
* @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>
*/
function getUserStockOffers (ticker, svid, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUserStockOffers?ticker=${ticker}&svid=${svid}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets total wealth of a district
* @function getDistrictWealth
* @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
* @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>
*/
function getDistrictWealth (id, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictWealth?id=${id}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets total wealth of users in a district
* @function getDistrictUserWealth
* @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
* @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>
*/
function getDistrictUserWealth (id, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictUserWealth?id=${id}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets total wealth of groups in a district
* @function getDistrictGroupWealth
* @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
* @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>
*/
function getDistrictGroupWealth (id, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictGroupWealth?id=${id}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* @function getOwnerData
* @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
* @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 getOwnerData (ticker, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getOwnerData?ticker=${ticker}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
export default {
getBalance,
sendTransactionByIDs,
getStockValue,
getStockHistory,
submitStockBuy,
submitStockSell,
cancelOrder,
getStockBuyPrice,
getQueueInfo,
getUserStockOffers,
getDistrictWealth,
getDistrictUserWealth,
getDistrictGroupWealth,
getOwnerData
}
// SpookVooper API - modules/eco.js
// Written by Brendan Lane
/** @module modules/eco */
import axios from 'axios'
const baseURL = 'https://api.spookvooper.com/eco'
/**
* Gets the balance of a user, given their svid.
* @function getBalance
* @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
* @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>
*/
function getBalance (svid, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getBalance?svid=${svid}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Makes a payment to and from accounts
* @function sendTransactionByIDs
* @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} 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} 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
* @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 sendTransactionByIDs (to, from, amount, auth, detail, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/sendTransactionByIDs?to=${to}&from=${from}&amount=${amount}&auth=${auth}&detail=${detail}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the value of a stock ticker.
* @function getStockValue
* @param {string} ticker The ticker 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 decimal).
* @author Brendan Lane <me@imbl.me>
*/
function getStockValue (ticker, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockValue?ticker=${ticker}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the history of a stock ticker.
* @function getStockHistory
* @param {string} ticker The ticker id
* @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} 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
* @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>
*/
function getStockHistory (ticker, type, count, interval, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockHistory?ticker=${ticker}&type=${type}&count=${count}&interval=${interval}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Purchases Stocks
* @function submitStockBuy
* @param {string} ticker The ticker id
* @param {string} count How many stocks you want to purchase
* @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} 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
* @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>
*/
function submitStockBuy (ticker, count, price, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockBuy?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Sells Stocks
* @function submitStockSell
* @param {string} ticker The ticker id
* @param {string} count How many stocks you want to sell
* @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} 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
* @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>
*/
function submitStockSell (ticker, count, price, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockSell?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Cancels an ongoing order.
* @function cancelOrder
* @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} 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
* @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>
*/
function cancelOrder (orderid, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockBuy?orderid=${orderid}&accountid=${accountid}&auth=${auth}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the current buy price of the ticker
* @function getStockBuyPrice
* @param {string} ticker The ticker 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 decimal).
* @author Brendan Lane <me@imbl.me>
*/
function getStockBuyPrice (ticker, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockBuyPrice?ticker=${ticker}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets the current buy price of the ticker
* @function getStockBuyPrice
* @param {string} ticker The ticker id
* @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
* @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>
*/
function getQueueInfo (ticker, type, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getQueueInfo?ticker=${ticker}&type=${type}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets stock offer data for a user.
* @function getUserStockOffers
* @param {string} ticker The ticker id
* @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
* @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>
*/
function getUserStockOffers (ticker, svid, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUserStockOffers?ticker=${ticker}&svid=${svid}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets total wealth of a district
* @function getDistrictWealth
* @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
* @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>
*/
function getDistrictWealth (id, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictWealth?id=${id}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets total wealth of users in a district
* @function getDistrictUserWealth
* @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
* @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>
*/
function getDistrictUserWealth (id, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictUserWealth?id=${id}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* Gets total wealth of groups in a district
* @function getDistrictGroupWealth
* @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
* @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>
*/
function getDistrictGroupWealth (id, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictGroupWealth?id=${id}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
/**
* @function getOwnerData
* @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
* @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 getOwnerData (ticker, errToConsole) {
return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getOwnerData?ticker=${ticker}`)
.then(function (response) {
resolve(response.data)
})
.catch(function (error) {
if (errToConsole) {
console.warn(error)
} else {
reject(error)
}
})
})
}
export default {
getBalance,
sendTransactionByIDs,
getStockValue,
getStockHistory,
submitStockBuy,
submitStockSell,
cancelOrder,
getStockBuyPrice,
getQueueInfo,
getUserStockOffers,
getDistrictWealth,
getDistrictUserWealth,
getDistrictGroupWealth,
getOwnerData
}

137
modules/old/group.js Normal file
View File

@ -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
}

View File

@ -1,42 +1,42 @@
// SpookVooper API - modules/premade.js
// Written by Brendan Lane
/** @module modules/premade */
import user from './user.js'
import eco from './eco.js'
let StockOwnerAmount
/**
* Gets the total XP of a user
* @function getTotalXP
* @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).
*/
function getTotalXP (svid) {
return new Promise((resolve) => {
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))
})
})
}
/**
* Gets the name of the stock owner and the amount they own.
* @function getStockOwner
* @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).
*/
function getStockOwner (ticker) {
return new Promise((resolve) => {
eco.getOwnerData(ticker, true).then(value => {
StockOwnerAmount = value.length - 1
resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount })
})
})
}
export default {
getTotalXP,
getStockOwner
}
// SpookVooper API - modules/premade.js
// Written by Brendan Lane
/** @module modules/premade */
import user from './user.js'
import eco from './eco.js'
let StockOwnerAmount
/**
* Gets the total XP of a user
* @function getTotalXP
* @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).
*/
function getTotalXP (svid) {
return new Promise((resolve) => {
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))
})
})
}
/**
* Gets the name of the stock owner and the amount they own.
* @function getStockOwner
* @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).
*/
function getStockOwner (ticker) {
return new Promise((resolve) => {
eco.getOwnerData(ticker, true).then(value => {
StockOwnerAmount = value.length - 1
resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount })
})
})
}
export default {
getTotalXP,
getStockOwner
}

261
modules/old/user.js Normal file
View File

@ -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
}

View File

@ -1,261 +1,170 @@
// SpookVooper API - modules/user.js
// Written by Brendan Lane
// SpookVooper API - modules/User.js
// Written by Brendan Lane - https://brndnln.dev
/** @module modules/user */
import axios from 'axios'
const axios = require('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;
/**
* 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)
constructor(svid) {
this.svid = svid
if (!this.svid.startsWith('u-')) {
throw "Error: A user must have a 'u-' or else it is not a user!"
}
})
})
}
}
/**
* 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)
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);
});
});
}
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 {
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);
});
});
}
}
/**
* 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
}
module.exports = User

236
package-lock.json generated
View File

@ -1,14 +1,15 @@
{
"name": "spookvooperapi",
"name": "@vexico/spookvooperapi",
"version": "1.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "spookvooperapi",
"name": "@vexico/spookvooperapi",
"version": "1.3.0",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@microsoft/signalr": "^5.0.0",
"axios": "^0.20.0"
},
"devDependencies": {
@ -178,12 +179,35 @@
"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": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"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": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
@ -262,6 +286,11 @@
"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": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
@ -460,6 +489,11 @@
"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": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
@ -641,6 +675,25 @@
"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": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@ -659,6 +712,15 @@
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
"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": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
@ -978,6 +1040,14 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"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": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@ -1004,6 +1074,14 @@
"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": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@ -1070,15 +1148,24 @@
"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": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true,
"engines": {
"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": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
@ -1088,6 +1175,11 @@
"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": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
@ -1282,6 +1374,18 @@
"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": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@ -1312,6 +1416,15 @@
"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": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
@ -1359,6 +1472,14 @@
"engines": {
"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": {
@ -1512,12 +1633,32 @@
"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": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"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": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
@ -1578,6 +1719,11 @@
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"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": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
@ -1745,6 +1891,11 @@
"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": {
"version": "1.0.5",
"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==",
"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": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@ -1902,6 +2066,15 @@
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
"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": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
@ -2158,6 +2331,11 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"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": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@ -2181,6 +2359,14 @@
"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": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@ -2226,11 +2412,20 @@
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
"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": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
},
"regexpp": {
"version": "3.1.0",
@ -2238,6 +2433,11 @@
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
"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": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
@ -2383,6 +2583,15 @@
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
"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": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@ -2407,6 +2616,15 @@
"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": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
@ -2442,6 +2660,14 @@
"requires": {
"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"
}
}
}
}

View File

@ -1,5 +1,5 @@
{
"name": "spookvooperapi",
"name": "@vexico/spookvooperapi",
"version": "1.3.0",
"description": "Easy to use library for the SpookVooper API",
"main": "main.js",
@ -7,6 +7,9 @@
"scripts": {
"test": "node main.js"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vexico/spookvooper-api.git"
@ -24,6 +27,7 @@
"prettier": "^2.1.1"
},
"dependencies": {
"@microsoft/signalr": "^5.0.0",
"axios": "^0.20.0"
},
"bugs": {