diff --git a/package.json b/package.json index 321e0d5..611a586 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/CreditsManager.ts b/src/CreditsManager.ts index 94edfdf..115705b 100644 --- a/src/CreditsManager.ts +++ b/src/CreditsManager.ts @@ -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"); + } } \ No newline at end of file diff --git a/src/IAManager.ts b/src/IAManager.ts index b352465..a2fbbfc 100644 --- a/src/IAManager.ts +++ b/src/IAManager.ts @@ -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;