Socket
Socket
Sign inDemoInstall

vkpoint-api

Package Overview
Dependencies
123
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

.github/FUNDING.yml

10

docs/README.md

@@ -51,3 +51,3 @@ # Начало работы с VK Point

|Опция |Тип |Необходимость |Описание |
|- |- | |- |
|- |- |- |- |
|method|String|true |Название метода, как оно указано в [документации к API](https://vk.com/@vposter-metody-api-vk-point).|

@@ -71,3 +71,3 @@ |params|Object|false |Параметры, необходимые для метода. (по умолчанию {}) |

|Опция |Тип |Необходимость |Описание |
|- |- | |- |
|- |- |- |- |
|toId |Number|true |ID пользователя, которму необходимо отправить VK Coins.|

@@ -91,3 +91,3 @@ |amount|Number|true |Количество VK Point, необходимое для отправки. |

|Опция |Тип |Необходимость |Описание |
|- |- | |- |
|- |- |- |- |
|targetId|Number|true |ID пользователя, о котором нужно получить данные.|

@@ -110,3 +110,3 @@

|Опция |Тип |Необходимость |Описание |
|- |- | |- |
|- |- |- |- |
|count |Number |false |Количество пользователей (по умолчанию 50) |

@@ -130,4 +130,4 @@ |vip |Boolean|false |Возвращает топ VIP пользователей, если true (по умолчанию false)|

|Опция |Тип |Необходимость |Описание |
|- |- | |- |
|- |- |- |- |
|amount |Number |false |Количество VK Point для перевода. (по умолчанию не указано)|
|fixation|Boolean|false |Является ли фиксированной ссылка. (по умолчанию false) |

@@ -6,6 +6,2 @@ const Koa = require('koa')

class Updates {
/**
* @param {String} token - VK Point Token
* @param {Number} userId - VK User ID
*/
constructor (token, userId) {

@@ -20,22 +16,6 @@ this.token = token

/**
*
* @param {Object} options - Callback API options
* @param {String} options.url - Callback API URL (Ex: 255.255.255.255)
* @param {Number} options.port - Callback API Port (Ex: 3000)
* @param {String} options.path - Callback API Path (Ex: /)
* @default options.path '/'
*/
async start (options) {
let { url, port, path } = options
async start ({ url, port = 8181, path = '/' }) {
if (!url) {
return new Error('Specify an URL.')
return new Error('param `url` is required')
}
if (!port) {
port = 8181
}
if (!path) {
path = '/'
}

@@ -50,3 +30,3 @@ this.app = new Koa()

await request('https://vkpoint.vposter.ru/api/method/account.changeSettings',
let result = await request('https://vkpoint.vposter.ru/api/method/account.changeSettings',
{

@@ -87,18 +67,7 @@ user_id: this.userId,

/**
* @async
* @param {String} method - VK Point API method
* @param {Object} params - VK Point API parameters
* @default param {}
*/
async call (method, params = {}) {
if (!method) {
throw new Error('method is undefined!')
throw new Error('param `method` is required')
}
if (!params) {
throw new Error('params is undefined!')
}
params = Object.assign({ access_token: this.token }, params)

@@ -108,3 +77,3 @@

if (result && result.error) {
if (result.error) {
throw new Error(result.error)

@@ -116,14 +85,9 @@ }

/**
* @async
* @param {Number} toId - target id
* @param {Number} amount - amount of VK Points
*/
async sendPayment (toId, amount) {
if (typeof toId !== 'number') {
throw new Error('toId must be a number!')
throw new Error(`expected \`toId\` to be number, got ${typeof toId}`)
}
if (typeof amount !== 'number') {
throw new Error('amount must be a number!')
throw new Error(`expected \`amount\` to be number, got ${typeof amount}`)
}

@@ -139,3 +103,3 @@

if (result && result.error) {
if (result.error) {
throw new Error(result.error)

@@ -147,9 +111,5 @@ }

/**
* @async
* @param {Number} targetId - target id
*/
async getUserData (targetId) {
if (typeof targetId !== 'number') {
throw new Error('toId must be a number!')
throw new Error(`expected \`targetId\` to be number, got ${typeof targetId}`)
}

@@ -163,3 +123,3 @@

if (result && result.error) {
if (result.error) {
throw new Error(result.error)

@@ -171,12 +131,5 @@ }

/**
* @async
* @param {Number} count - amount of users
* @param {Boolean} vip - is top vip?
* @default count 50
* @default vip false
*/
async getUsersTop (count = 50, vip = false) {
if (typeof targetId !== 'number') {
throw new Error('toId must be a number!')
throw new Error(`expected \`targetId\` to be number, got ${typeof targetId}`)
}

@@ -188,5 +141,6 @@

let result = vip ? await this.call('users.getTopVip', params) : await this.call('users.getTop', params)
let method = vip ? 'getTopVip' : 'getTop';
let result = await this.call(`users.${method}`, params)
if (result && result.error) {
if (result.error) {
throw new Error(result.error)

@@ -205,3 +159,3 @@ }

if (typeof amount !== 'number') {
throw new Error('amount isn\'t number!')
throw new Error(`expected \`amount\` to be number, got ${typeof amount}`)
}

@@ -214,11 +168,5 @@

module.exports = class VKPoint {
/**
* @param {Object} options - Options
* @param {String} options.token - VK Point API Key
* @param {Number} options.userId - VK User ID
*/
constructor (options) {
if (!options.token) throw new Error('VK Point Token is invalid!')
if (!options.userId) throw new Error('VK User ID is invalid!')
if (!options.token) throw new Error('param `token` is required')
if (!options.userId) throw new Error('param `userId` is required')

@@ -225,0 +173,0 @@ this.token = options.token

{
"name": "vkpoint-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "VK Point API",

@@ -47,3 +47,4 @@ "main": "index.js",

},
"homepage": "https://github.com/aeonixlegit/vkpoint-api#readme"
"homepage": "https://github.com/aeonixlegit/vkpoint-api#readme",
"typings": "./typings"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc