💻 Sync with local
This commit is contained in:
parent
b9b7b267f4
commit
e92873f2d5
|
@ -7,11 +7,11 @@
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Program",
|
"name": "Launch Test File",
|
||||||
"skipFiles": [
|
"skipFiles": [
|
||||||
"<node_internals>/**"
|
"<node_internals>/**"
|
||||||
],
|
],
|
||||||
"program": "${workspaceFolder}\\dist\\main.js",
|
"program": "${workspaceFolder}\\dist\\test.js",
|
||||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||||
"outFiles": [
|
"outFiles": [
|
||||||
"${workspaceFolder}/dist/**/*.js"
|
"${workspaceFolder}/dist/**/*.js"
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
import User from './modules/User'
|
import User from './modules/User'
|
||||||
import Group from './modules/Group'
|
import Group from './modules/Group'
|
||||||
import Auth from './modules/Auth'
|
import Auth from './modules/Auth'
|
||||||
|
import District from './modules/District'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
User,
|
User,
|
||||||
Group,
|
Group,
|
||||||
Auth
|
Auth,
|
||||||
|
District
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
// SpookVooper API - modules/District.ts
|
||||||
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
import axios from 'axios'
|
||||||
|
import { District as DistrictType, DistrictWealthType, SenatorDistrict } from './types/Types'
|
||||||
|
import { ReturnedUser } from './interfaces/Interfaces'
|
||||||
|
|
||||||
|
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||||
|
const userURL = 'https://api.spookvooper.com/user'
|
||||||
|
const Districts = [
|
||||||
|
'Voopmont',
|
||||||
|
'New Yam',
|
||||||
|
'San Vooperisco',
|
||||||
|
'Medievala',
|
||||||
|
'Landing Cove',
|
||||||
|
'New Spudland',
|
||||||
|
'Vooperia City',
|
||||||
|
'Corgi',
|
||||||
|
'Old Yam',
|
||||||
|
'New Vooperis',
|
||||||
|
'The Netherlands',
|
||||||
|
'Queensland',
|
||||||
|
'Servers Past',
|
||||||
|
'Los Vooperis',
|
||||||
|
'Old King Peninsula'
|
||||||
|
]
|
||||||
|
|
||||||
|
class District {
|
||||||
|
private districtName: DistrictType
|
||||||
|
|
||||||
|
public get name (): DistrictType {
|
||||||
|
return this.districtName
|
||||||
|
}
|
||||||
|
|
||||||
|
public set name (name: DistrictType) {
|
||||||
|
if (!Districts.includes(name)) {
|
||||||
|
throw new Error('The district must exist! To get a list of districts, please visit https://spookvooper.com/Government/Map')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.districtName = name
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor (name: DistrictType) {
|
||||||
|
if (!Districts.includes(name)) {
|
||||||
|
throw new Error('The district must exist! To get a list of districts, please visit https://spookvooper.com/Government/Map')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.districtName = name
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getWealth (type: DistrictWealthType): Promise<any> {
|
||||||
|
switch (type.toUpperCase()) {
|
||||||
|
case 'ALL':
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getDistrictWealth`, {
|
||||||
|
params: {
|
||||||
|
id: this.districtName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
case 'USER':
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getDistrictUserWealth`, {
|
||||||
|
params: {
|
||||||
|
id: this.districtName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
case 'GROUP':
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getDistrictGroupWealth`, {
|
||||||
|
params: {
|
||||||
|
id: this.districtName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error('Must use either \'ALL\', \'USER\', or \'GROUP\'!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getSenator (district?: SenatorDistrict): Promise<ReturnedUser> {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${userURL}/getSenators`)
|
||||||
|
.then((response) => {
|
||||||
|
const data: any[] = response.data
|
||||||
|
if (district !== undefined) {
|
||||||
|
const found = data.find(user => user.district === district)
|
||||||
|
resolve(found)
|
||||||
|
} else if (district === 'ALL') {
|
||||||
|
resolve(response.data)
|
||||||
|
} else {
|
||||||
|
const found = data.find(user => user.district === this.districtName)
|
||||||
|
resolve(found)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default District
|
|
@ -2,11 +2,11 @@
|
||||||
// Written by Brendan Lane - https://brndnln.dev
|
// Written by Brendan Lane - https://brndnln.dev
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { CreditAmount, PaymentEntity, SVStockTicker } from './types/Types'
|
import { CreditAmount, PaymentEntity } from './types/Types'
|
||||||
import { ConfigUser } from './interfaces/Interfaces'
|
import { ConfigUser } from './interfaces/Interfaces'
|
||||||
|
|
||||||
const userURL: string = 'https://api.spookvooper.com/user'
|
const userURL = 'https://api.spookvooper.com/user'
|
||||||
const ecoURL: string = 'https://api.spookvooper.com/eco'
|
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
private accountid: string
|
private accountid: string
|
||||||
|
@ -146,7 +146,7 @@ class User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getStockOffers (ticker: SVStockTicker): Promise<any> {
|
public async getStockOffers (ticker: string): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/getUserStockOffers`, {
|
axios.get(`${ecoURL}/getUserStockOffers`, {
|
||||||
params: {
|
params: {
|
||||||
|
@ -163,7 +163,7 @@ class User {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buyStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise<any> {
|
public async buyStock (ticker: string, amount: number, price: CreditAmount): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/submitStockBuy`, {
|
axios.get(`${ecoURL}/submitStockBuy`, {
|
||||||
params: {
|
params: {
|
||||||
|
@ -183,7 +183,7 @@ class User {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sellStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise<any> {
|
public async sellStock (ticker: string, amount: number, price: CreditAmount): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/submitStockSell`, {
|
axios.get(`${ecoURL}/submitStockSell`, {
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SpookVooper API - modules/interfaces/Interfaces.ts
|
// SpookVooper API - modules/interfaces/Interfaces.ts
|
||||||
// Written by Brendan Lane - https://brndnln.dev/
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
export interface EntityUser {
|
interface EntityUser {
|
||||||
getUser: () => Promise<any>
|
getUser: () => Promise<any>
|
||||||
getUsername: () => Promise<any>
|
getUsername: () => Promise<any>
|
||||||
getBalance: () => Promise<any>
|
getBalance: () => Promise<any>
|
||||||
|
@ -15,16 +15,55 @@ export interface EntityUser {
|
||||||
apikey: string
|
apikey: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigUser {
|
interface ConfigUser {
|
||||||
svid: string
|
svid: string
|
||||||
apikey?: string
|
apikey?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntityGroup {
|
interface EntityGroup {
|
||||||
svid: string
|
svid: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthConfig {
|
interface AuthConfig {
|
||||||
clientid: string
|
clientid: string
|
||||||
clientsecret: string
|
clientsecret: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ReturnedUser {
|
||||||
|
userName: string
|
||||||
|
twitch_id: string | null
|
||||||
|
discord_id: number | null
|
||||||
|
post_likes: number
|
||||||
|
comment_likes: number
|
||||||
|
nationstate: string | null
|
||||||
|
description: string | null
|
||||||
|
api_use_count: number
|
||||||
|
minecraft_id: string | null
|
||||||
|
twitch_last_message_minute: number
|
||||||
|
twitch_message_xp: number
|
||||||
|
twitch_messages: number
|
||||||
|
discord_commends: number
|
||||||
|
discord_commends_sent: number
|
||||||
|
discord_last_commend_hour: number
|
||||||
|
discord_last_commend_message: number
|
||||||
|
discord_message_xp: number
|
||||||
|
discord_message_count: number
|
||||||
|
discord_last_message_minute: number
|
||||||
|
discord_warning_count: number
|
||||||
|
discord_ban_count: number
|
||||||
|
discord_kick_count: number
|
||||||
|
discord_game_xp: number
|
||||||
|
district: string | null
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
credits: number
|
||||||
|
image_Url: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
EntityUser,
|
||||||
|
EntityGroup,
|
||||||
|
ConfigUser,
|
||||||
|
AuthConfig,
|
||||||
|
ReturnedUser
|
||||||
|
}
|
||||||
|
|
|
@ -3,9 +3,22 @@
|
||||||
|
|
||||||
import { EntityUser, AuthConfig as AuthConfigInt } from './../interfaces/Interfaces'
|
import { EntityUser, AuthConfig as AuthConfigInt } from './../interfaces/Interfaces'
|
||||||
|
|
||||||
export type CreditAmount = string | number
|
type CreditAmount = string | number
|
||||||
export type PaymentEntity = string | EntityUser
|
type PaymentEntity = string | EntityUser
|
||||||
export type SVStockTicker = 'B' | 'IDE' | 'NEWS' | 'POT' | 'TECH' | 'TYCO' | 'VC' | 'VNB' | 'VU' | 'X'
|
type AuthEntity = EntityUser
|
||||||
export type AuthEntity = EntityUser
|
type GroupMember = string | EntityUser
|
||||||
export type GroupMember = string | EntityUser
|
type AuthConfig = AuthConfigInt
|
||||||
export type AuthConfig = AuthConfigInt
|
type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula'
|
||||||
|
type DistrictWealthType = 'ALL' | 'USER' | 'GROUP'
|
||||||
|
type SenatorDistrict = District | 'ALL'
|
||||||
|
|
||||||
|
export {
|
||||||
|
CreditAmount,
|
||||||
|
PaymentEntity,
|
||||||
|
AuthEntity,
|
||||||
|
GroupMember,
|
||||||
|
AuthConfig,
|
||||||
|
District,
|
||||||
|
DistrictWealthType,
|
||||||
|
SenatorDistrict
|
||||||
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
"ESNext.Symbol",
|
"ESNext.Symbol",
|
||||||
"DOM"
|
"DOM"
|
||||||
],
|
],
|
||||||
"sourceMap": true,
|
"sourceMap": false,
|
||||||
"inlineSourceMap": false,
|
"inlineSourceMap": true,
|
||||||
"inlineSources": true,
|
"inlineSources": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|
Loading…
Reference in New Issue