Skip to content

Commit

Permalink
upd licaense and .call method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Step committed Mar 15, 2021
1 parent 2e262dc commit 6c49758
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const stats = await nalogAPI.call('incomes/summary')

Пример расширенного добавления дохода
```javascript
const response = await nalogAPI.call('income', 'POST', {
const response = await nalogAPI.call('income', {
paymentType: 'CASH',
inn: null,
ignoreMaxTotalIncomeRestriction: false,
Expand Down
6 changes: 3 additions & 3 deletions docs/nalogAPIClass.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* [.createDeviceId()](#NalogAPI+createDeviceId)
* [.auth(username, password)](#NalogAPI+auth) ⇒ <code>Promise(object)</code>
* [.getToken()](#NalogAPI+getToken) ⇒ <code>Promise(string)</code>
* [.call(endpoint, method, payload)](#NalogAPI+call) ⇒ <code>Promise(object)</code>
* [.call(endpoint, payload, method)](#NalogAPI+call) ⇒ <code>Promise(object)</code>
* [.addIncome(date, name, amount)](#NalogAPI+addIncome) ⇒ <code>Promise({id,printUrl,jsonUrl,data,approvedReceiptUuid})</code>
* [.userInfo()](#NalogAPI+userInfo) ⇒ <code>Promise(object)</code>

Expand Down Expand Up @@ -73,7 +73,7 @@
**Kind**: instance method of [<code>NalogAPI</code>](#NalogAPI)
<a name="NalogAPI+call"></a>

### nalogAPI.call(endpoint, method, payload) ⇒ <code>Promise(object)</code>
### nalogAPI.call(endpoint, payload, method) ⇒ <code>Promise(object)</code>
Вызов метода api

**Kind**: instance method of [<code>NalogAPI</code>](#NalogAPI)
Expand All @@ -82,8 +82,8 @@
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| endpoint | <code>string</code> | | url метода без слэша в начале (например `user`) |
| method | <code>enum</code> | <code>&#x27;GET&#x27;</code> | |
| payload | <code>object</code> | | данные для отправки в body |
| method | <code>enum</code> | <code>&#x27;GET&#x27;</code> | |

<a name="NalogAPI+addIncome"></a>

Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ class NalogAPI {
/**
* Вызов метода api
* @param {string} endpoint - url метода без слэша в начале (например `user`)
* @param {enum} method='GET'
* @param {object} payload - данные для отправки в body
* @param {enum} method='GET'
* @returns {Promise(object)} - json ответа сервера
*/
async call (endpoint, method = 'GET', payload = {}) {
async call (endpoint, payload, method = 'GET') {
if (payload) { method = 'POST' }

const params = {
method: method,
headers: {
Expand Down Expand Up @@ -179,7 +181,7 @@ class NalogAPI {
* @returns {Promise({id,printUrl,jsonUrl,data,approvedReceiptUuid})} - информация о созданном чеке, либо об ошибке
*/
async addIncome ({ date = new Date(), name, quantity = 1, amount }) {
const response = await this.call('income', 'POST', {
const response = await this.call('income', {
paymentType: 'CASH',
inn: null,
ignoreMaxTotalIncomeRestriction: false,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moy-nalog",
"version": "1.0.2",
"version": "1.0.3",
"description": "Обёртка для API сервиса lknpd.nalog.ru",
"main": "index.js",
"scripts": {
Expand All @@ -13,7 +13,7 @@
},
"keywords": [],
"author": "",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/alexstep/moy-nalog/issues"
},
Expand Down

0 comments on commit 6c49758

Please sign in to comment.