💻 Sync with local
This commit is contained in:
parent
b9b7b267f4
commit
e92873f2d5
|
@ -7,11 +7,11 @@
|
|||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"name": "Launch Test File",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\dist\\main.js",
|
||||
"program": "${workspaceFolder}\\dist\\test.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js"
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
import User from './modules/User'
|
||||
import Group from './modules/Group'
|
||||
import Auth from './modules/Auth'
|
||||
import District from './modules/District'
|
||||
|
||||
export {
|
||||
User,
|
||||
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
|
||||
|
||||
import axios from 'axios'
|
||||
import { CreditAmount, PaymentEntity, SVStockTicker } from './types/Types'
|
||||
import { CreditAmount, PaymentEntity } from './types/Types'
|
||||
import { ConfigUser } from './interfaces/Interfaces'
|
||||
|
||||
const userURL: string = 'https://api.spookvooper.com/user'
|
||||
const ecoURL: string = 'https://api.spookvooper.com/eco'
|
||||
const userURL = 'https://api.spookvooper.com/user'
|
||||
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||
|
||||
class User {
|
||||
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) => {
|
||||
axios.get(`${ecoURL}/getUserStockOffers`, {
|
||||
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) => {
|
||||
axios.get(`${ecoURL}/submitStockBuy`, {
|
||||
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) => {
|
||||
axios.get(`${ecoURL}/submitStockSell`, {
|
||||
params: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SpookVooper API - modules/interfaces/Interfaces.ts
|
||||
// Written by Brendan Lane - https://brndnln.dev/
|
||||
|
||||
export interface EntityUser {
|
||||
interface EntityUser {
|
||||
getUser: () => Promise<any>
|
||||
getUsername: () => Promise<any>
|
||||
getBalance: () => Promise<any>
|
||||
|
@ -15,16 +15,55 @@ export interface EntityUser {
|
|||
apikey: string
|
||||
}
|
||||
|
||||
export interface ConfigUser {
|
||||
interface ConfigUser {
|
||||
svid: string
|
||||
apikey?: string
|
||||
}
|
||||
|
||||
export interface EntityGroup {
|
||||
interface EntityGroup {
|
||||
svid: string
|
||||
}
|
||||
|
||||
export interface AuthConfig {
|
||||
interface AuthConfig {
|
||||
clientid: 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'
|
||||
|
||||
export type CreditAmount = string | number
|
||||
export type PaymentEntity = string | EntityUser
|
||||
export type SVStockTicker = 'B' | 'IDE' | 'NEWS' | 'POT' | 'TECH' | 'TYCO' | 'VC' | 'VNB' | 'VU' | 'X'
|
||||
export type AuthEntity = EntityUser
|
||||
export type GroupMember = string | EntityUser
|
||||
export type AuthConfig = AuthConfigInt
|
||||
type CreditAmount = string | number
|
||||
type PaymentEntity = string | EntityUser
|
||||
type AuthEntity = EntityUser
|
||||
type GroupMember = string | EntityUser
|
||||
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",
|
||||
"DOM"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"inlineSourceMap": false,
|
||||
"sourceMap": false,
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"incremental": true,
|
||||
"esModuleInterop": true,
|
||||
|
|
Loading…
Reference in New Issue