This commit is contained in:
KillerBossOriginal 2023-12-09 20:20:30 +01:00
parent afe9a66889
commit bfc9e0c6c1
3 changed files with 16 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "tn-api.js", "name": "tn-api.js",
"version": "0.4.3", "version": "0.5.0",
"description": "A Public Template for npm", "description": "A Public Template for npm",
"main": "build/index.js", "main": "build/index.js",
"repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js", "repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js",

View file

@ -56,4 +56,18 @@ export default class CreditsManager {
if (req.status == 404) throw new Error("Transaction not Found"); if (req.status == 404) throw new Error("Transaction not Found");
return req.data.transaction; return req.data.transaction;
} }
/**
* Sends a payment request to the specified user.
*
* @param {number} id - The ID of the user making the payment.
* @param {number} toPayID - The ID of the user to whom the payment is being made.
* @param {number} amount - The amount of the payment.
* @return {void}
*/
async pay(id: number, toPayID: number, amount: number) {
let req = await axios.post(`${this.URL}/credits/${id}`, { amount, to: toPayID }, { headers: { Authorization: `Bearer ${this.token}` } });
if (req.status == 403) throw new Error("No Permission");
if (req.status == 404) throw new Error("User not Found");
}
} }

View file

@ -9,7 +9,7 @@ export default class IAManager {
this.token = token; this.token = token;
} }
async get(id: number) { async get(id: string|number) {
let req = await axios.get(`${this.URL}/IA/${id}`); let req = await axios.get(`${this.URL}/IA/${id}`);
if (req.status == 404) throw new Error("User not Found"); if (req.status == 404) throw new Error("User not Found");
return req.data.user; return req.data.user;