king-coin-api
Advanced tools
Comparing version 1.0.2 to 1.0.3
48
index.js
const axios = require('axios') | ||
const url = 'https://kcbot.ru/server/api/' | ||
class API { | ||
constructor({ token }) { | ||
exports.KingCoinApi = class { | ||
constructor({ token } = {}) { | ||
this.token = token | ||
} | ||
async getMyBalance(action = 'myBalance', token = this.token) { | ||
const data = await axios.post(url, { | ||
getMyBalance(action = 'myBalance', token = this.token) { | ||
return axios.post(url, { | ||
action, | ||
token | ||
}) | ||
.then(data => data?.data) | ||
.catch(console.error) | ||
return data | ||
}).then(data => data?.data).catch(console.error) | ||
} | ||
async getUserBalance({ action = 'balance', token = this.token, user_ids = this.user_ids } = {}) { | ||
const data = await axios.post(url, { | ||
getUserBalance({ action = 'balance', token = this.token, user_ids = this.user_ids } = {}) { | ||
return axios.post(url, { | ||
action, | ||
token, | ||
user_ids | ||
}) | ||
.then(data => data?.data) | ||
.catch(console.error) | ||
return data | ||
}).then(data => data?.data).catch(console.error) | ||
} | ||
async getHistory({ action = 'tx', token = this.token, filter = this.filter, count = this.count, offset = this.offset } = {}) { | ||
const data = await axios.post(url, { | ||
getHistory({ action = 'tx', token = this.token, filter = this.filter, count = this.count, offset = this.offset } = {}) { | ||
return axios.post(url, { | ||
action, | ||
@@ -38,11 +30,7 @@ token, | ||
offset: !offset ? 0 : offset | ||
}) | ||
.then(data => data?.data) | ||
.catch(console.error) | ||
return data | ||
}).then(data => data?.data).catch(console.error) | ||
} | ||
async sendCoins({ action = 'transfer', token = this.token, receiver = this.receiver, amount = this.amount, payload = this.payload } = {}) { | ||
const data = await axios.post(url, { | ||
sendCoins({ action = 'transfer', token = this.token, receiver = this.receiver, amount = this.amount, payload = this.payload } = {}) { | ||
return axios.post(url, { | ||
action, | ||
@@ -53,10 +41,4 @@ token, | ||
payload: !payload ? 0 : payload | ||
}) | ||
.then(data => data?.data) | ||
.catch(console.error) | ||
return data | ||
}).then(data => data?.data).catch(console.error) | ||
} | ||
} | ||
module.exports = { API } | ||
} |
{ | ||
"name": "king-coin-api", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Модуль для удобного использования KingCoin API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,4 +27,4 @@ <p align=center> | ||
```js | ||
const { API } = require('king-coin-api') | ||
const api = new API({ token: 'YOUR_TOKEN' }) // Ваш токен | ||
const { KingCoinApi } = require('king-coin-api') | ||
const api = new KingCoinApi({ token: 'YOUR_TOKEN' }) // Ваш токен | ||
@@ -37,3 +37,7 @@ // Получение баланса мерчанта | ||
getMyBalance() // Вызов функции | ||
``` | ||
## 💸 Получение баланса пользователей | ||
```js | ||
// Получение баланса пользователей | ||
@@ -46,4 +50,8 @@ async function getUserBalance() { | ||
getUserBalance() // Вызов функции | ||
``` | ||
// Получение историю переводов | ||
## 📄 Получение истории переводов | ||
```js | ||
// Получение истории переводов | ||
async function getHistory() { | ||
@@ -54,3 +62,6 @@ const history = await api.getHistory({ filter: "IN", count: 20 }) // Получаем 20 последних пополнений | ||
getHistory() // Вызов функции | ||
``` | ||
## 💳 Перевод коинов пользователю | ||
```js | ||
//Перевод коинов пользователю | ||
@@ -62,3 +73,2 @@ async function sendCoins() { | ||
sendCoins() // Вызов функции | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69
6175
37