bkper 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/model/Account.js +1 -1
- package/lib/service/HttpApiRequest.js +4 -4
- package/lib/service/account-service.js +5 -5
- package/lib/service/app-service.js +3 -3
- package/lib/service/balances-service.js +1 -1
- package/lib/service/book-service.js +3 -3
- package/lib/service/file-service.js +2 -2
- package/lib/service/group-service.js +8 -8
- package/lib/service/transaction-service.js +10 -10
- package/package.json +2 -2
package/lib/model/Account.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.HttpBooksApiV5Request = exports.HttpBooksApiV2Request = exports.HttpApiRequest = void 0;
|
|
16
16
|
const local_auth_service_1 = require("../auth/local-auth-service");
|
|
17
17
|
const gaxios_1 = require("gaxios");
|
|
18
18
|
const https_1 = __importDefault(require("https"));
|
|
@@ -122,10 +122,10 @@ class HttpBooksApiV2Request extends HttpApiRequest {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
exports.HttpBooksApiV2Request = HttpBooksApiV2Request;
|
|
125
|
-
class
|
|
125
|
+
class HttpBooksApiV5Request extends HttpApiRequest {
|
|
126
126
|
constructor(service) {
|
|
127
|
-
super(`
|
|
127
|
+
super(`v5/books/${service}`);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
exports.
|
|
130
|
+
exports.HttpBooksApiV5Request = HttpBooksApiV5Request;
|
|
131
131
|
//# sourceMappingURL=HttpApiRequest.js.map
|
|
@@ -14,7 +14,7 @@ const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
|
14
14
|
function createAccount(bookId, account) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var payload = JSON.stringify(account);
|
|
17
|
-
var response = yield new HttpApiRequest_1.
|
|
17
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('POST').setPayload(payload).fetch();
|
|
18
18
|
return response.data;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -22,14 +22,14 @@ exports.createAccount = createAccount;
|
|
|
22
22
|
function updateAccount(bookId, account) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
var payload = JSON.stringify(account);
|
|
25
|
-
var response = yield new HttpApiRequest_1.
|
|
25
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('PUT').setPayload(payload).fetch();
|
|
26
26
|
return response.data;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
exports.updateAccount = updateAccount;
|
|
30
30
|
function deleteAccount(bookId, account) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
var response = yield new HttpApiRequest_1.
|
|
32
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`).setMethod('DELETE').fetch();
|
|
33
33
|
return response.data;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -40,7 +40,7 @@ function createAccounts(bookId, accounts) {
|
|
|
40
40
|
items: accounts
|
|
41
41
|
};
|
|
42
42
|
var accountSaveBatchJSON = JSON.stringify(accountList);
|
|
43
|
-
var response = yield new HttpApiRequest_1.
|
|
43
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/batch`).setMethod('POST').setPayload(accountSaveBatchJSON).fetch();
|
|
44
44
|
var accountsPlain = yield response.data;
|
|
45
45
|
if (accountsPlain.items == null) {
|
|
46
46
|
return [];
|
|
@@ -52,7 +52,7 @@ exports.createAccounts = createAccounts;
|
|
|
52
52
|
function getAccount(bookId, idOrName) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
try {
|
|
55
|
-
var response = yield new HttpApiRequest_1.
|
|
55
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
|
|
56
56
|
return response.data;
|
|
57
57
|
}
|
|
58
58
|
catch (error) {
|
|
@@ -14,7 +14,7 @@ const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
|
14
14
|
function createApp(app) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var payload = JSON.stringify(app);
|
|
17
|
-
var response = yield new HttpApiRequest_1.HttpApiRequest(`
|
|
17
|
+
var response = yield new HttpApiRequest_1.HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(payload).fetch();
|
|
18
18
|
return response.data;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -22,7 +22,7 @@ exports.createApp = createApp;
|
|
|
22
22
|
function updateApp(app) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
var payload = JSON.stringify(app);
|
|
25
|
-
var response = yield new HttpApiRequest_1.HttpApiRequest(`
|
|
25
|
+
var response = yield new HttpApiRequest_1.HttpApiRequest(`v5/apps`).setMethod('PUT').setPayload(payload).fetch();
|
|
26
26
|
return response.data;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@ exports.updateApp = updateApp;
|
|
|
30
30
|
function patchApp(app) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
var payload = JSON.stringify(app);
|
|
33
|
-
var response = yield new HttpApiRequest_1.HttpApiRequest(`
|
|
33
|
+
var response = yield new HttpApiRequest_1.HttpApiRequest(`v5/apps`).setMethod('PATCH').setPayload(payload).fetch();
|
|
34
34
|
return response.data;
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -13,7 +13,7 @@ exports.getBalances = void 0;
|
|
|
13
13
|
const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
14
14
|
function getBalances(bookId, query) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var response = yield new HttpApiRequest_1.
|
|
16
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/balances`).addParam('query', query).addParam('time', Date.now()).fetch();
|
|
17
17
|
return response.data;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -16,7 +16,7 @@ function loadBook(bookId) {
|
|
|
16
16
|
if (bookId == null) {
|
|
17
17
|
throw new Error("Book id null!");
|
|
18
18
|
}
|
|
19
|
-
let response = yield new HttpApiRequest_1.
|
|
19
|
+
let response = yield new HttpApiRequest_1.HttpBooksApiV5Request(bookId).fetch();
|
|
20
20
|
return response.data;
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -24,14 +24,14 @@ exports.loadBook = loadBook;
|
|
|
24
24
|
function updateBook(bookId, book) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
var payload = JSON.stringify(book);
|
|
27
|
-
var response = yield new HttpApiRequest_1.
|
|
27
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}`).setMethod('PUT').setPayload(payload).fetch();
|
|
28
28
|
return response.data;
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
exports.updateBook = updateBook;
|
|
32
32
|
function audit(bookId) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
new HttpApiRequest_1.
|
|
34
|
+
new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/audit`).setMethod('PATCH').fetch();
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
exports.audit = audit;
|
|
@@ -14,14 +14,14 @@ const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
|
14
14
|
function createFile(bookId, file) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var payload = JSON.stringify(file);
|
|
17
|
-
var response = yield new HttpApiRequest_1.
|
|
17
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/files`).setMethod('POST').setPayload(payload).fetch();
|
|
18
18
|
return response.data;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
exports.createFile = createFile;
|
|
22
22
|
function getFile(bookId, id) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
var response = yield new HttpApiRequest_1.
|
|
24
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/files/${id}`).setMethod('GET').fetch();
|
|
25
25
|
return response.data;
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -14,7 +14,7 @@ const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
|
14
14
|
function createGroup(bookId, group) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var payload = JSON.stringify(group);
|
|
17
|
-
var response = yield new HttpApiRequest_1.
|
|
17
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('POST').setPayload(payload).fetch();
|
|
18
18
|
return response.data;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -22,14 +22,14 @@ exports.createGroup = createGroup;
|
|
|
22
22
|
function updateGroup(bookId, group) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
var payload = JSON.stringify(group);
|
|
25
|
-
var response = yield new HttpApiRequest_1.
|
|
25
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('PUT').setPayload(payload).fetch();
|
|
26
26
|
return response.data;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
exports.updateGroup = updateGroup;
|
|
30
30
|
function deleteGroup(bookId, group) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
var response = yield new HttpApiRequest_1.
|
|
32
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/${group.id}`).setMethod('DELETE').fetch();
|
|
33
33
|
return response.data;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -40,7 +40,7 @@ function createGroups(bookId, groups) {
|
|
|
40
40
|
items: groups
|
|
41
41
|
};
|
|
42
42
|
var groupsBatchJSON = JSON.stringify(groupList);
|
|
43
|
-
var response = yield new HttpApiRequest_1.
|
|
43
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/batch`).setMethod('POST').setPayload(groupsBatchJSON).fetch();
|
|
44
44
|
if (response == null) {
|
|
45
45
|
return [];
|
|
46
46
|
}
|
|
@@ -54,7 +54,7 @@ function createGroups(bookId, groups) {
|
|
|
54
54
|
exports.createGroups = createGroups;
|
|
55
55
|
function getGroupsByAccountId(bookId, accountId) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
var response = yield new HttpApiRequest_1.
|
|
57
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${accountId}/groups`).setMethod('GET').fetch();
|
|
58
58
|
var groupsPlain = response.data;
|
|
59
59
|
if (groupsPlain.items == null) {
|
|
60
60
|
return [];
|
|
@@ -65,7 +65,7 @@ function getGroupsByAccountId(bookId, accountId) {
|
|
|
65
65
|
exports.getGroupsByAccountId = getGroupsByAccountId;
|
|
66
66
|
function getGroups(bookId) {
|
|
67
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
var response = yield new HttpApiRequest_1.
|
|
68
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('GET').fetch();
|
|
69
69
|
var groupsPlain = response.data;
|
|
70
70
|
if (groupsPlain.items == null) {
|
|
71
71
|
return [];
|
|
@@ -77,7 +77,7 @@ exports.getGroups = getGroups;
|
|
|
77
77
|
function getGroup(bookId, idOrName) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
79
|
try {
|
|
80
|
-
var response = yield new HttpApiRequest_1.
|
|
80
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
|
|
81
81
|
return response.data;
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
@@ -88,7 +88,7 @@ function getGroup(bookId, idOrName) {
|
|
|
88
88
|
exports.getGroup = getGroup;
|
|
89
89
|
function getAccounts(bookId, idOrName) {
|
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
var response = yield new HttpApiRequest_1.
|
|
91
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}/accounts`).setMethod('GET').fetch();
|
|
92
92
|
var accountsPlain = response.data;
|
|
93
93
|
if (accountsPlain.items == null) {
|
|
94
94
|
return [];
|
|
@@ -14,7 +14,7 @@ const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
|
14
14
|
function createTransaction(bookId, transaction) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var payload = JSON.stringify(transaction);
|
|
17
|
-
var response = yield new HttpApiRequest_1.
|
|
17
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions`).setMethod('POST').setPayload(payload).fetch();
|
|
18
18
|
return response.data;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -25,7 +25,7 @@ function createTransactionsBatch(bookId, transactions) {
|
|
|
25
25
|
items: transactions
|
|
26
26
|
};
|
|
27
27
|
var payload = JSON.stringify(transactionList);
|
|
28
|
-
let response = yield new HttpApiRequest_1.
|
|
28
|
+
let response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/batch`)
|
|
29
29
|
.setMethod('POST')
|
|
30
30
|
.setPayload(payload)
|
|
31
31
|
.fetch();
|
|
@@ -37,7 +37,7 @@ exports.createTransactionsBatch = createTransactionsBatch;
|
|
|
37
37
|
function updateTransaction(bookId, transaction) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
39
|
var payload = JSON.stringify(transaction);
|
|
40
|
-
var response = yield new HttpApiRequest_1.
|
|
40
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions`).setMethod('PUT').setPayload(payload).fetch();
|
|
41
41
|
return response.data;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ exports.updateTransaction = updateTransaction;
|
|
|
45
45
|
function postTransaction(bookId, transaction) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
47
|
var payload = JSON.stringify(transaction);
|
|
48
|
-
var response = yield new HttpApiRequest_1.
|
|
48
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/post`).setMethod('PATCH').setPayload(payload).fetch();
|
|
49
49
|
return response.data;
|
|
50
50
|
});
|
|
51
51
|
}
|
|
@@ -53,7 +53,7 @@ exports.postTransaction = postTransaction;
|
|
|
53
53
|
function checkTransaction(bookId, transaction) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
var payload = JSON.stringify(transaction);
|
|
56
|
-
var response = yield new HttpApiRequest_1.
|
|
56
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/check`).setMethod('PATCH').setPayload(payload).fetch();
|
|
57
57
|
return response.data;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -61,7 +61,7 @@ exports.checkTransaction = checkTransaction;
|
|
|
61
61
|
function uncheckTransaction(bookId, transaction) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
var payload = JSON.stringify(transaction);
|
|
64
|
-
var response = yield new HttpApiRequest_1.
|
|
64
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/uncheck`).setMethod('PATCH').setPayload(payload).fetch();
|
|
65
65
|
return response.data;
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -69,7 +69,7 @@ exports.uncheckTransaction = uncheckTransaction;
|
|
|
69
69
|
function removeTransaction(bookId, transaction) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
71
|
var payload = JSON.stringify(transaction);
|
|
72
|
-
var response = yield new HttpApiRequest_1.
|
|
72
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/remove`).setMethod('PATCH').setPayload(payload).fetch();
|
|
73
73
|
return response.data;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -77,14 +77,14 @@ exports.removeTransaction = removeTransaction;
|
|
|
77
77
|
function restoreTransaction(bookId, transaction) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
79
|
var payload = JSON.stringify(transaction);
|
|
80
|
-
var response = yield new HttpApiRequest_1.
|
|
80
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/restore`).setMethod('PATCH').setPayload(payload).fetch();
|
|
81
81
|
return response.data;
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
exports.restoreTransaction = restoreTransaction;
|
|
85
85
|
function getTransaction(bookId, id) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
var response = yield new HttpApiRequest_1.
|
|
87
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions/${id}`).setMethod('GET').fetch();
|
|
88
88
|
return response.data;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -94,7 +94,7 @@ function searchTransactions(bookId, query, limit, cursor) {
|
|
|
94
94
|
if (query == null) {
|
|
95
95
|
query = "";
|
|
96
96
|
}
|
|
97
|
-
var request = new HttpApiRequest_1.
|
|
97
|
+
var request = new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/transactions`);
|
|
98
98
|
request.addParam('query', query);
|
|
99
99
|
request.addParam('limit', limit);
|
|
100
100
|
if (cursor != null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Node.js client for Bkper REST API",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"open": "^7.3.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@bkper/bkper-api-types": "^
|
|
49
|
+
"@bkper/bkper-api-types": "^5.0.0",
|
|
50
50
|
"@microsoft/api-extractor": "^7.12.1",
|
|
51
51
|
"@types/big.js": "^6.0.2",
|
|
52
52
|
"@types/chai": "^4.2.14",
|