🩹 Start patch

This commit is contained in:
Brendan Lane 2020-12-23 01:12:43 -05:00
parent e25a0672a5
commit d013dfefa8
No known key found for this signature in database
GPG Key ID: 906880739CCF90C9
3 changed files with 86 additions and 7 deletions

View File

@ -2,6 +2,7 @@
// Written by Brendan Lane - https://brndnln.dev/
import axios from 'axios'
import { EntityUser } from './interfaces/Interfaces'
import { AuthEntity, CreditAmount, GroupMember, PaymentEntity } from './types/Types'
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') {
return await new Promise((resolve, reject) => {
axios.get(`${ecoURL}/sendTransactionByIds`, {
@ -157,6 +158,81 @@ class Group {
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

View File

@ -23,6 +23,9 @@ class TransactionHub {
public fromAccount: string
public toAccount: string
public fromType: string
public toType: string
public event = new Observable((observer) => {
this.connection.on('NotifyTransaction', (recieved: string) => {
this.val = JSON.parse(recieved)

View File

@ -1,7 +1,7 @@
// SpookVooper API - modules/interfaces/Interfaces.ts
// Written by Brendan Lane - https://brndnln.dev/
import { DistrictWealthType, SenatorDistrict } from '../types/Types'
import { CreditAmount, DistrictWealthType, PaymentEntity, SenatorDistrict } from '../types/Types'
interface EntityUser {
svid: string
@ -9,12 +9,12 @@ interface EntityUser {
getUser: () => Promise<any>
getUsername: () => Promise<any>
getBalance: () => Promise<any>
hasDiscordRole: () => Promise<any>
hasDiscordRole: (role: string) => Promise<any>
getDiscordRoles: () => Promise<any>
sendCredits: () => Promise<any>
getStockOffers: () => Promise<any>
buyStock: () => Promise<any>
sellStock: () => Promise<any>
sendCredits: (amount: CreditAmount, to: PaymentEntity, reason: string) => Promise<any>
getStockOffers: (ticker: string) => Promise<any>
buyStock: (ticker: string, amount: number, price: CreditAmount) => Promise<any>
sellStock: (ticker: string, amount: number, price: CreditAmount) => Promise<any>
}
interface EntityGroup {