0.5.0
This commit is contained in:
parent
afe9a66889
commit
bfc9e0c6c1
3 changed files with 16 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tn-api.js",
|
||||
"version": "0.4.3",
|
||||
"version": "0.5.0",
|
||||
"description": "A Public Template for npm",
|
||||
"main": "build/index.js",
|
||||
"repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js",
|
||||
|
|
|
@ -56,4 +56,18 @@ export default class CreditsManager {
|
|||
if (req.status == 404) throw new Error("Transaction not Found");
|
||||
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");
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ export default class IAManager {
|
|||
this.token = token;
|
||||
}
|
||||
|
||||
async get(id: number) {
|
||||
async get(id: string|number) {
|
||||
let req = await axios.get(`${this.URL}/IA/${id}`);
|
||||
if (req.status == 404) throw new Error("User not Found");
|
||||
return req.data.user;
|
||||
|
|
Loading…
Reference in a new issue