🩹 Start patch
This commit is contained in:
parent
e25a0672a5
commit
d013dfefa8
|
@ -2,6 +2,7 @@
|
||||||
// Written by Brendan Lane - https://brndnln.dev/
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { EntityUser } from './interfaces/Interfaces'
|
||||||
import { AuthEntity, CreditAmount, GroupMember, PaymentEntity } from './types/Types'
|
import { AuthEntity, CreditAmount, GroupMember, PaymentEntity } from './types/Types'
|
||||||
|
|
||||||
const groupURL = 'https://api.spookvooper.com/group'
|
const groupURL = 'https://api.spookvooper.com/group'
|
||||||
|
@ -34,7 +35,7 @@ class Group {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: AuthEntity): Promise<any> {
|
public async sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: EntityUser): Promise<any> {
|
||||||
if (typeof to === 'string') {
|
if (typeof to === 'string') {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/sendTransactionByIds`, {
|
axios.get(`${ecoURL}/sendTransactionByIds`, {
|
||||||
|
@ -157,6 +158,81 @@ class Group {
|
||||||
|
|
||||||
this.accountid = svid
|
this.accountid = svid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getStockOffers (ticker: string): Promise<any> {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/getUserStockOffers`, {
|
||||||
|
params: {
|
||||||
|
ticker: ticker,
|
||||||
|
svid: this.accountid
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async buyStock (ticker: string, amount: number, price: CreditAmount, auth: AuthEntity): Promise<any> {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/submitStockBuy`, {
|
||||||
|
params: {
|
||||||
|
ticker: ticker,
|
||||||
|
count: amount,
|
||||||
|
price: price,
|
||||||
|
accountid: this.accountid,
|
||||||
|
auth: auth.apikey
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sellStock (ticker: string, amount: number, price: CreditAmount, auth: AuthEntity): Promise<any> {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/submitStockSell`, {
|
||||||
|
params: {
|
||||||
|
ticker: ticker,
|
||||||
|
count: amount,
|
||||||
|
price: price,
|
||||||
|
accountid: this.accountid,
|
||||||
|
auth: auth.apikey
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async cancelOffer (orderid: number, auth: AuthEntity): Promise<any> {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${ecoURL}/cancelOrder`, {
|
||||||
|
params: {
|
||||||
|
orderid: orderid,
|
||||||
|
accountid: this.accountid,
|
||||||
|
auth: auth.apikey
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Group
|
export default Group
|
||||||
|
|
|
@ -23,6 +23,9 @@ class TransactionHub {
|
||||||
public fromAccount: string
|
public fromAccount: string
|
||||||
public toAccount: string
|
public toAccount: string
|
||||||
|
|
||||||
|
public fromType: string
|
||||||
|
public toType: string
|
||||||
|
|
||||||
public event = new Observable((observer) => {
|
public event = new Observable((observer) => {
|
||||||
this.connection.on('NotifyTransaction', (recieved: string) => {
|
this.connection.on('NotifyTransaction', (recieved: string) => {
|
||||||
this.val = JSON.parse(recieved)
|
this.val = JSON.parse(recieved)
|
||||||
|
|
|
@ -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/
|
||||||
|
|
||||||
import { DistrictWealthType, SenatorDistrict } from '../types/Types'
|
import { CreditAmount, DistrictWealthType, PaymentEntity, SenatorDistrict } from '../types/Types'
|
||||||
|
|
||||||
interface EntityUser {
|
interface EntityUser {
|
||||||
svid: string
|
svid: string
|
||||||
|
@ -9,12 +9,12 @@ interface EntityUser {
|
||||||
getUser: () => Promise<any>
|
getUser: () => Promise<any>
|
||||||
getUsername: () => Promise<any>
|
getUsername: () => Promise<any>
|
||||||
getBalance: () => Promise<any>
|
getBalance: () => Promise<any>
|
||||||
hasDiscordRole: () => Promise<any>
|
hasDiscordRole: (role: string) => Promise<any>
|
||||||
getDiscordRoles: () => Promise<any>
|
getDiscordRoles: () => Promise<any>
|
||||||
sendCredits: () => Promise<any>
|
sendCredits: (amount: CreditAmount, to: PaymentEntity, reason: string) => Promise<any>
|
||||||
getStockOffers: () => Promise<any>
|
getStockOffers: (ticker: string) => Promise<any>
|
||||||
buyStock: () => Promise<any>
|
buyStock: (ticker: string, amount: number, price: CreditAmount) => Promise<any>
|
||||||
sellStock: () => Promise<any>
|
sellStock: (ticker: string, amount: number, price: CreditAmount) => Promise<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EntityGroup {
|
interface EntityGroup {
|
||||||
|
|
Loading…
Reference in New Issue