bkper-js 1.0.0
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/LICENSE +201 -0
- package/README.md +27 -0
- package/lib/index.d.ts +1804 -0
- package/lib/index.js +42 -0
- package/lib/model/Account.js +385 -0
- package/lib/model/Amount.js +295 -0
- package/lib/model/App.js +114 -0
- package/lib/model/Bkper.js +105 -0
- package/lib/model/Book.js +717 -0
- package/lib/model/Collection.js +43 -0
- package/lib/model/Config.js +3 -0
- package/lib/model/Connection.js +261 -0
- package/lib/model/Enums.js +138 -0
- package/lib/model/File.js +128 -0
- package/lib/model/Group.js +248 -0
- package/lib/model/Integration.js +112 -0
- package/lib/model/Transaction.js +719 -0
- package/lib/model/TransactionIterator.js +154 -0
- package/lib/model/TransactionPage.js +97 -0
- package/lib/model/User.js +97 -0
- package/lib/service/account-service.js +42 -0
- package/lib/service/app-service.js +34 -0
- package/lib/service/balances-service.js +20 -0
- package/lib/service/book-service.js +36 -0
- package/lib/service/connection-service.js +71 -0
- package/lib/service/file-service.js +27 -0
- package/lib/service/group-service.js +71 -0
- package/lib/service/http-api-request.js +165 -0
- package/lib/service/integration-service.js +52 -0
- package/lib/service/transaction-service.js +114 -0
- package/lib/service/user-service.js +20 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/utils.js +341 -0
- package/package.json +58 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TransactionIterator = void 0;
|
|
13
|
+
const TransactionPage_1 = require("./TransactionPage");
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* An iterator that allows scripts to iterate over a potentially large collection of transactions.
|
|
17
|
+
*
|
|
18
|
+
* Example:
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
|
|
22
|
+
*
|
|
23
|
+
* var transactionIterator = book.getTransactions("account:CreditCard after:28/01/2013 before:29/01/2013");
|
|
24
|
+
*
|
|
25
|
+
* while (transactionIterator.hasNext()) {
|
|
26
|
+
* var transaction = transactions.next();
|
|
27
|
+
* Logger.log(transaction.getDescription());
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
class TransactionIterator {
|
|
34
|
+
/** @internal */
|
|
35
|
+
constructor(book, query) {
|
|
36
|
+
this.book = book;
|
|
37
|
+
this.query = query;
|
|
38
|
+
if (this.query == null) {
|
|
39
|
+
this.query = "";
|
|
40
|
+
}
|
|
41
|
+
this.currentPage = null;
|
|
42
|
+
this.nextPage = null;
|
|
43
|
+
this.lastCursor = null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the Book that originate the iterator
|
|
47
|
+
*/
|
|
48
|
+
getBook() {
|
|
49
|
+
return this.book;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets a token that can be used to resume this iteration at a later time.
|
|
53
|
+
*
|
|
54
|
+
* This method is useful if processing an iterator in one execution would exceed the maximum execution time.
|
|
55
|
+
*
|
|
56
|
+
* Continuation tokens are generally valid short period of time.
|
|
57
|
+
*/
|
|
58
|
+
getContinuationToken() {
|
|
59
|
+
if (this.currentPage == null) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
var cursor = this.lastCursor;
|
|
63
|
+
if (cursor == null) {
|
|
64
|
+
cursor = "null";
|
|
65
|
+
}
|
|
66
|
+
var continuationToken = cursor + "_bkperpageindex_" + this.currentPage.getIndex();
|
|
67
|
+
return continuationToken;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sets a continuation token from previous paused iteration
|
|
71
|
+
*/
|
|
72
|
+
setContinuationToken(continuationToken) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (continuationToken == null) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
var cursorIndexArray = continuationToken.split("_bkperpageindex_");
|
|
78
|
+
if (cursorIndexArray.length != 2) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
var cursor = cursorIndexArray[0];
|
|
82
|
+
var index = cursorIndexArray[1];
|
|
83
|
+
if ("null" != cursor) {
|
|
84
|
+
this.lastCursor = cursor;
|
|
85
|
+
}
|
|
86
|
+
let indexNum = new Number(index).valueOf();
|
|
87
|
+
this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
|
|
88
|
+
this.currentPage.setIndex(indexNum);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Determines whether calling next() will return a transaction.
|
|
93
|
+
*/
|
|
94
|
+
hasNext() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
if (this.currentPage == null) {
|
|
97
|
+
this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
|
|
98
|
+
}
|
|
99
|
+
if (this.currentPage.hasNext()) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
else if (!this.currentPage.hasReachEnd()) {
|
|
103
|
+
this.lastCursor = this.currentPage.getCursor();
|
|
104
|
+
if (this.nextPage == null) {
|
|
105
|
+
this.nextPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
|
|
106
|
+
}
|
|
107
|
+
return this.nextPage.hasNext();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Gets the next transaction in the collection of transactions.
|
|
116
|
+
*/
|
|
117
|
+
next() {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
if (this.currentPage == null) {
|
|
120
|
+
this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
|
|
121
|
+
}
|
|
122
|
+
if (this.currentPage.hasNext()) {
|
|
123
|
+
return this.currentPage.next();
|
|
124
|
+
}
|
|
125
|
+
else if (!this.currentPage.hasReachEnd()) {
|
|
126
|
+
this.lastCursor = this.currentPage.getCursor();
|
|
127
|
+
if (this.nextPage != null) {
|
|
128
|
+
this.currentPage = this.nextPage;
|
|
129
|
+
this.nextPage = null;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
|
|
133
|
+
}
|
|
134
|
+
return this.currentPage.next();
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @returns The account, when filtering by a single account.
|
|
143
|
+
*/
|
|
144
|
+
getAccount() {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
if (this.currentPage == null) {
|
|
147
|
+
this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
|
|
148
|
+
}
|
|
149
|
+
return this.currentPage.getAccount();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.TransactionIterator = TransactionIterator;
|
|
154
|
+
//# sourceMappingURL=TransactionIterator.js.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.TransactionPage = void 0;
|
|
36
|
+
const Transaction_1 = require("./Transaction");
|
|
37
|
+
const TransactionService = __importStar(require("../service/transaction-service"));
|
|
38
|
+
const utils_1 = require("../utils");
|
|
39
|
+
class TransactionPage {
|
|
40
|
+
init(book, query, lastCursor) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var transactionList = yield TransactionService.searchTransactions(book.getId(), query, 1000, lastCursor);
|
|
43
|
+
if (transactionList.items == null) {
|
|
44
|
+
transactionList.items = [];
|
|
45
|
+
}
|
|
46
|
+
this.transactions = (0, utils_1.wrapObjects)(new Transaction_1.Transaction(), transactionList.items);
|
|
47
|
+
book.configureTransactions_(this.transactions);
|
|
48
|
+
this.cursor = transactionList.cursor;
|
|
49
|
+
if (transactionList.account) {
|
|
50
|
+
this.account = yield book.getAccount(transactionList.account);
|
|
51
|
+
}
|
|
52
|
+
this.index = 0;
|
|
53
|
+
if (this.transactions == null || this.transactions.length == 0 || this.cursor == null || this.cursor == "") {
|
|
54
|
+
this.reachEnd = true;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.reachEnd = false;
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getCursor() {
|
|
63
|
+
return this.cursor;
|
|
64
|
+
}
|
|
65
|
+
hasNext() {
|
|
66
|
+
return this.index < this.transactions.length;
|
|
67
|
+
}
|
|
68
|
+
hasReachEnd() {
|
|
69
|
+
return this.reachEnd;
|
|
70
|
+
}
|
|
71
|
+
getIndex() {
|
|
72
|
+
if (this.index >= this.transactions.length) {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return this.index;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
setIndex(index) {
|
|
80
|
+
this.index = index;
|
|
81
|
+
}
|
|
82
|
+
getAccount() {
|
|
83
|
+
return this.account;
|
|
84
|
+
}
|
|
85
|
+
next() {
|
|
86
|
+
if (this.index < this.transactions.length) {
|
|
87
|
+
var transaction = this.transactions[this.index];
|
|
88
|
+
this.index++;
|
|
89
|
+
return transaction;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.TransactionPage = TransactionPage;
|
|
97
|
+
//# sourceMappingURL=TransactionPage.js.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.User = void 0;
|
|
36
|
+
const Connection_1 = require("./Connection");
|
|
37
|
+
const ConnectionService = __importStar(require("../service/connection-service"));
|
|
38
|
+
/**
|
|
39
|
+
* This class defines a User.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
class User {
|
|
44
|
+
constructor(wrapped) {
|
|
45
|
+
this.wrapped = wrapped;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets the id of the User.
|
|
49
|
+
*
|
|
50
|
+
* @returns The User's id
|
|
51
|
+
*/
|
|
52
|
+
getId() {
|
|
53
|
+
return this.wrapped.id;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the name of the User.
|
|
57
|
+
*
|
|
58
|
+
* @returns The User's name
|
|
59
|
+
*/
|
|
60
|
+
getName() {
|
|
61
|
+
return this.wrapped.name;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the full name of the User.
|
|
65
|
+
*
|
|
66
|
+
* @returns The User's full name
|
|
67
|
+
*/
|
|
68
|
+
getFullName() {
|
|
69
|
+
return this.wrapped.fullName;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets the [[Connections]] of the User.
|
|
73
|
+
*
|
|
74
|
+
* @returns The retrieved Connection objects
|
|
75
|
+
*/
|
|
76
|
+
getConnections() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const json = yield ConnectionService.listConnections();
|
|
79
|
+
return json.map(c => new Connection_1.Connection(c));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets a [[Connection]] of the User.
|
|
84
|
+
*
|
|
85
|
+
* @param id - The Connection's id
|
|
86
|
+
*
|
|
87
|
+
* @returns The retrieved Connection object
|
|
88
|
+
*/
|
|
89
|
+
getConnection(id) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const json = yield ConnectionService.getConnection(id);
|
|
92
|
+
return new Connection_1.Connection(json);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.User = User;
|
|
97
|
+
//# sourceMappingURL=User.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createAccount = createAccount;
|
|
13
|
+
exports.updateAccount = updateAccount;
|
|
14
|
+
exports.deleteAccount = deleteAccount;
|
|
15
|
+
exports.getAccount = getAccount;
|
|
16
|
+
const http_api_request_1 = require("./http-api-request");
|
|
17
|
+
function createAccount(bookId, account) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('POST').setPayload(account).fetch();
|
|
20
|
+
return response.data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function updateAccount(bookId, account) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
var payload = JSON.stringify(account);
|
|
26
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('PUT').setPayload(payload).fetch();
|
|
27
|
+
return response.data;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function deleteAccount(bookId, account) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`).setMethod('DELETE').fetch();
|
|
33
|
+
return response.data;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function getAccount(bookId, idOrName) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
|
|
39
|
+
return response.data;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=account-service.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createApp = createApp;
|
|
13
|
+
exports.updateApp = updateApp;
|
|
14
|
+
exports.patchApp = patchApp;
|
|
15
|
+
const http_api_request_1 = require("./http-api-request");
|
|
16
|
+
function createApp(app) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
var response = yield new http_api_request_1.HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
|
|
19
|
+
return response.data;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function updateApp(app) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var response = yield new http_api_request_1.HttpApiRequest(`v5/apps`).setMethod('PUT').setPayload(app).fetch();
|
|
25
|
+
return response.data;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function patchApp(app) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var response = yield new http_api_request_1.HttpApiRequest(`v5/apps`).setMethod('PATCH').setPayload(app).fetch();
|
|
31
|
+
return response.data;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=app-service.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getBalances = getBalances;
|
|
13
|
+
const http_api_request_1 = require("./http-api-request");
|
|
14
|
+
function getBalances(bookId, query) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/balances`).addParam('query', query).addParam('time', Date.now()).fetch();
|
|
17
|
+
return response.data;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=balances-service.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadBook = loadBook;
|
|
13
|
+
exports.updateBook = updateBook;
|
|
14
|
+
exports.audit = audit;
|
|
15
|
+
const http_api_request_1 = require("./http-api-request");
|
|
16
|
+
function loadBook(bookId) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (bookId == null) {
|
|
19
|
+
throw new Error("Book id null!");
|
|
20
|
+
}
|
|
21
|
+
let response = yield new http_api_request_1.HttpBooksApiV5Request(bookId).fetch();
|
|
22
|
+
return response.data;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function updateBook(bookId, book) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}`).setMethod('PUT').setPayload(book).fetch();
|
|
28
|
+
return response.data;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function audit(bookId) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
new http_api_request_1.HttpBooksApiV5Request(`${bookId}/audit`).setMethod('PATCH').fetch();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=book-service.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getConnection = getConnection;
|
|
13
|
+
exports.listConnections = listConnections;
|
|
14
|
+
exports.createConnection = createConnection;
|
|
15
|
+
exports.updateConnection = updateConnection;
|
|
16
|
+
exports.deleteConnection = deleteConnection;
|
|
17
|
+
exports.listIntegrations = listIntegrations;
|
|
18
|
+
const http_api_request_1 = require("./http-api-request");
|
|
19
|
+
function getConnection(id) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const res = yield new http_api_request_1.HttpApiV5Request(`user/connections/${id}`)
|
|
22
|
+
.setMethod('GET')
|
|
23
|
+
.fetch();
|
|
24
|
+
return res.data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function listConnections() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a;
|
|
30
|
+
const res = yield new http_api_request_1.HttpApiV5Request(`user/connections`)
|
|
31
|
+
.setMethod('GET')
|
|
32
|
+
.fetch();
|
|
33
|
+
return ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function createConnection(connection) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const res = yield new http_api_request_1.HttpApiV5Request(`user/connections`)
|
|
39
|
+
.setPayload(connection)
|
|
40
|
+
.setMethod('POST')
|
|
41
|
+
.fetch();
|
|
42
|
+
return res.data;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function updateConnection(connection) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const res = yield new http_api_request_1.HttpApiV5Request(`user/connections`)
|
|
48
|
+
.setPayload(connection)
|
|
49
|
+
.setMethod('PUT')
|
|
50
|
+
.fetch();
|
|
51
|
+
return res.data;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function deleteConnection(id) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const res = yield new http_api_request_1.HttpApiV5Request(`user/connections/${id}`)
|
|
57
|
+
.setMethod('DELETE')
|
|
58
|
+
.fetch();
|
|
59
|
+
return res.data;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function listIntegrations(connectionId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
var _a;
|
|
65
|
+
const res = yield new http_api_request_1.HttpApiV5Request(`user/connections/${connectionId}/integrations`)
|
|
66
|
+
.setMethod('GET')
|
|
67
|
+
.fetch();
|
|
68
|
+
return ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=connection-service.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createFile = createFile;
|
|
13
|
+
exports.getFile = getFile;
|
|
14
|
+
const http_api_request_1 = require("./http-api-request");
|
|
15
|
+
function createFile(bookId, file) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/files`).setMethod('POST').setPayload(file).fetch();
|
|
18
|
+
return response.data;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function getFile(bookId, id) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/files/${id}`).setMethod('GET').fetch();
|
|
24
|
+
return response.data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=file-service.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createGroup = createGroup;
|
|
13
|
+
exports.updateGroup = updateGroup;
|
|
14
|
+
exports.deleteGroup = deleteGroup;
|
|
15
|
+
exports.getGroupsByAccountId = getGroupsByAccountId;
|
|
16
|
+
exports.getGroups = getGroups;
|
|
17
|
+
exports.getGroup = getGroup;
|
|
18
|
+
exports.getAccounts = getAccounts;
|
|
19
|
+
const http_api_request_1 = require("./http-api-request");
|
|
20
|
+
function createGroup(bookId, group) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('POST').setPayload(group).fetch();
|
|
23
|
+
return response.data;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function updateGroup(bookId, group) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('PUT').setPayload(group).fetch();
|
|
29
|
+
return response.data;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function deleteGroup(bookId, group) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups/${group.id}`).setMethod('DELETE').fetch();
|
|
35
|
+
return response.data;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function getGroupsByAccountId(bookId, accountId) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
var _a;
|
|
41
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts/${accountId}/groups`).setMethod('GET').fetch();
|
|
42
|
+
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function getGroups(bookId) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('GET').fetch();
|
|
48
|
+
var groupsPlain = response.data;
|
|
49
|
+
if (!(groupsPlain === null || groupsPlain === void 0 ? void 0 : groupsPlain.items)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return groupsPlain.items;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function getGroup(bookId, idOrName) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
|
|
58
|
+
return response.data;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getAccounts(bookId, idOrName) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}/accounts`).setMethod('GET').fetch();
|
|
64
|
+
var accountsPlain = response.data;
|
|
65
|
+
if (!(accountsPlain === null || accountsPlain === void 0 ? void 0 : accountsPlain.items)) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
return accountsPlain.items;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=group-service.js.map
|