king-coin-api
Advanced tools
Comparing version 1.0.4 to 1.0.5
21
index.js
const { post } = require('axios') | ||
const url = 'https://kcbot.ru/server/api/' | ||
exports.KingCoinApi = class { | ||
constructor({ token } = {}) { | ||
constructor({token} = this) { | ||
this.token = token | ||
} | ||
callApi(data = {}) { | ||
return post(url, data).then(data => data?.data).catch((err) => err) | ||
callApi(data, token = this.token) { | ||
return post("https://kcbot.ru/server/api/", {token, ...data}).then(({data}) => data) | ||
} | ||
getMyBalance({ action = 'myBalance', token = this.token } = {}) { | ||
return this.callApi({ action, token }) | ||
getMyBalance(action = 'myBalance') { | ||
return this.callApi({ action }) | ||
} | ||
getUserBalance({ action = 'balance', token = this.token, user_ids = this.user_ids } = {}) { | ||
return this.callApi({ action, token, user_ids }) | ||
getUserBalance({action = 'balance', user_ids = this.user_ids} = this) { | ||
return this.callApi({ action, user_ids }) | ||
} | ||
getHistory({ action = 'tx', token = this.token, filter = this.filter, count = this.count, offset = this.offset } = {}) { | ||
getHistory({ action = 'tx', filter = this.filter, count = this.count, offset = this.offset } = this) { | ||
return this.callApi({ | ||
action, | ||
token, | ||
filter: !filter ? 'ALL' : filter, | ||
@@ -30,6 +28,5 @@ count: !count ? 20 : count, | ||
sendCoins({ action = 'transfer', token = this.token, receiver = this.receiver, amount = this.amount, payload = this.payload } = {}) { | ||
sendCoins({action = 'transfer', receiver = this.receiver, amount = this.amount, payload = this.payload} = this) { | ||
return this.callApi({ | ||
action, | ||
token, | ||
receiver, | ||
@@ -36,0 +33,0 @@ amount, |
{ | ||
"name": "king-coin-api", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Модуль для удобного использования KingCoin API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
5867
30