bkper 2.7.1 → 3.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.
Files changed (41) hide show
  1. package/README.md +8 -8
  2. package/bun.lockb +0 -0
  3. package/package.json +10 -33
  4. package/src/auth/keys.json +12 -0
  5. package/src/auth/local-auth-service.ts +73 -0
  6. package/src/cli.ts +57 -0
  7. package/tsconfig.json +25 -0
  8. package/lib/auth/keys.json +0 -12
  9. package/lib/auth/local-auth-service.js +0 -80
  10. package/lib/cli.js +0 -64
  11. package/lib/index.d.ts +0 -1775
  12. package/lib/index.js +0 -42
  13. package/lib/model/Account.js +0 -381
  14. package/lib/model/Amount.js +0 -295
  15. package/lib/model/App.js +0 -95
  16. package/lib/model/Bkper.js +0 -101
  17. package/lib/model/Book.js +0 -713
  18. package/lib/model/Collection.js +0 -43
  19. package/lib/model/Config.js +0 -3
  20. package/lib/model/Connection.js +0 -257
  21. package/lib/model/Enums.js +0 -138
  22. package/lib/model/File.js +0 -124
  23. package/lib/model/Group.js +0 -244
  24. package/lib/model/Integration.js +0 -112
  25. package/lib/model/Transaction.js +0 -715
  26. package/lib/model/TransactionIterator.js +0 -154
  27. package/lib/model/TransactionPage.js +0 -93
  28. package/lib/model/User.js +0 -93
  29. package/lib/service/HttpApiRequest.js +0 -170
  30. package/lib/service/account-service.js +0 -43
  31. package/lib/service/app-service.js +0 -35
  32. package/lib/service/balances-service.js +0 -21
  33. package/lib/service/book-service.js +0 -37
  34. package/lib/service/connection-service.js +0 -72
  35. package/lib/service/file-service.js +0 -28
  36. package/lib/service/group-service.js +0 -72
  37. package/lib/service/integration-service.js +0 -53
  38. package/lib/service/transaction-service.js +0 -115
  39. package/lib/service/user-service.js +0 -21
  40. package/lib/tsdoc-metadata.json +0 -11
  41. package/lib/utils.js +0 -341
@@ -1,154 +0,0 @@
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
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.TransactionPage = void 0;
32
- const Transaction_1 = require("./Transaction");
33
- const TransactionService = __importStar(require("../service/transaction-service"));
34
- const utils_1 = require("../utils");
35
- class TransactionPage {
36
- init(book, query, lastCursor) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- var transactionList = yield TransactionService.searchTransactions(book.getId(), query, 1000, lastCursor);
39
- if (transactionList.items == null) {
40
- transactionList.items = [];
41
- }
42
- this.transactions = utils_1.wrapObjects(new Transaction_1.Transaction(), transactionList.items);
43
- book.configureTransactions_(this.transactions);
44
- this.cursor = transactionList.cursor;
45
- if (transactionList.account) {
46
- this.account = yield book.getAccount(transactionList.account);
47
- }
48
- this.index = 0;
49
- if (this.transactions == null || this.transactions.length == 0 || this.cursor == null || this.cursor == "") {
50
- this.reachEnd = true;
51
- }
52
- else {
53
- this.reachEnd = false;
54
- }
55
- return this;
56
- });
57
- }
58
- getCursor() {
59
- return this.cursor;
60
- }
61
- hasNext() {
62
- return this.index < this.transactions.length;
63
- }
64
- hasReachEnd() {
65
- return this.reachEnd;
66
- }
67
- getIndex() {
68
- if (this.index >= this.transactions.length) {
69
- return 0;
70
- }
71
- else {
72
- return this.index;
73
- }
74
- }
75
- setIndex(index) {
76
- this.index = index;
77
- }
78
- getAccount() {
79
- return this.account;
80
- }
81
- next() {
82
- if (this.index < this.transactions.length) {
83
- var transaction = this.transactions[this.index];
84
- this.index++;
85
- return transaction;
86
- }
87
- else {
88
- return null;
89
- }
90
- }
91
- }
92
- exports.TransactionPage = TransactionPage;
93
- //# sourceMappingURL=TransactionPage.js.map
package/lib/model/User.js DELETED
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.User = void 0;
32
- const Connection_1 = require("./Connection");
33
- const ConnectionService = __importStar(require("../service/connection-service"));
34
- /**
35
- * This class defines a User.
36
- *
37
- * @public
38
- */
39
- class User {
40
- constructor(wrapped) {
41
- this.wrapped = wrapped;
42
- }
43
- /**
44
- * Gets the id of the User.
45
- *
46
- * @returns The User's id
47
- */
48
- getId() {
49
- return this.wrapped.id;
50
- }
51
- /**
52
- * Gets the name of the User.
53
- *
54
- * @returns The User's name
55
- */
56
- getName() {
57
- return this.wrapped.name;
58
- }
59
- /**
60
- * Gets the full name of the User.
61
- *
62
- * @returns The User's full name
63
- */
64
- getFullName() {
65
- return this.wrapped.fullName;
66
- }
67
- /**
68
- * Gets the [[Connections]] of the User.
69
- *
70
- * @returns The retrieved Connection objects
71
- */
72
- getConnections() {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- const json = yield ConnectionService.listConnections();
75
- return json.map(c => new Connection_1.Connection(c));
76
- });
77
- }
78
- /**
79
- * Gets a [[Connection]] of the User.
80
- *
81
- * @param id - The Connection's id
82
- *
83
- * @returns The retrieved Connection object
84
- */
85
- getConnection(id) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const json = yield ConnectionService.getConnection(id);
88
- return new Connection_1.Connection(json);
89
- });
90
- }
91
- }
92
- exports.User = User;
93
- //# sourceMappingURL=User.js.map
@@ -1,170 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.HttpApiV5Request = exports.HttpBooksApiV5Request = exports.HttpApiRequest = void 0;
16
- const local_auth_service_1 = require("../auth/local-auth-service");
17
- const gaxios_1 = require("gaxios");
18
- const https_1 = __importDefault(require("https"));
19
- const utils_1 = require("../utils");
20
- const httpsAgent = new https_1.default.Agent({ keepAlive: true });
21
- class HttpApiRequest {
22
- constructor(path) {
23
- this.params = [];
24
- this.headers = {};
25
- this.method = 'GET';
26
- this.payload = null;
27
- this.url = `${HttpApiRequest.config.apiBaseUrl || "https://app.bkper.com/_ah/api/bkper"}/${path}`;
28
- }
29
- setMethod(method) {
30
- this.method = method;
31
- return this;
32
- }
33
- setHeader(name, value) {
34
- if (value) {
35
- this.headers[name] = value;
36
- }
37
- return this;
38
- }
39
- addParam(name, value) {
40
- if (value) {
41
- this.params.push({ name, value });
42
- }
43
- return this;
44
- }
45
- setPayload(payload) {
46
- this.payload = typeof payload === "string" ? payload : JSON.stringify(payload);
47
- return this;
48
- }
49
- /**
50
- * Gets the result url, with query params appended.
51
- */
52
- getUrl() {
53
- let url = this.url;
54
- if (this.params != null) {
55
- let i = 0;
56
- if (url.indexOf('?') < 0) {
57
- url += '?';
58
- }
59
- else {
60
- i++;
61
- }
62
- for (const param of this.params) {
63
- if (i > 0) {
64
- url += "&";
65
- }
66
- var key = param.name;
67
- var value = param.value;
68
- if (value != null) {
69
- url += key + "=" + encodeURIComponent(value);
70
- i++;
71
- }
72
- }
73
- }
74
- return url;
75
- }
76
- fetch() {
77
- var _a;
78
- return __awaiter(this, void 0, void 0, function* () {
79
- this.addCustomHeaders();
80
- this.headers['Authorization'] = `Bearer ${yield getAccessToken()}`;
81
- this.addParam('key', yield getApiKey());
82
- // this.httpRequest.setMuteHttpExceptions(true);
83
- const url = this.getUrl();
84
- try {
85
- return yield gaxios_1.request({
86
- url: url,
87
- method: this.method,
88
- headers: this.headers,
89
- body: this.payload,
90
- agent: url.startsWith('https') ? httpsAgent : null,
91
- retryConfig: {
92
- httpMethodsToRetry: ['GET', 'PUT', 'POST', 'PATCH', 'HEAD', 'OPTIONS', 'DELETE'],
93
- statusCodesToRetry: [[100, 199], [429, 429], [500, 599]],
94
- retry: process.env.NODE_ENV == utils_1.NODE_ENV_DEV ? 0 : 6,
95
- onRetryAttempt: (err) => { console.log(`${err.message} - Retrying... `); },
96
- retryDelay: 1000
97
- }
98
- });
99
- }
100
- catch (e) {
101
- const customError = HttpApiRequest.config.requestErrorHandler ? HttpApiRequest.config.requestErrorHandler(e) : undefined;
102
- if (customError) {
103
- throw customError;
104
- }
105
- else {
106
- //Default error handler
107
- let error = (_a = e.response.data) === null || _a === void 0 ? void 0 : _a.error;
108
- if (error) {
109
- if (error.code == 404) {
110
- return { data: null };
111
- }
112
- else {
113
- throw error.message;
114
- }
115
- }
116
- else {
117
- throw e.message;
118
- }
119
- }
120
- }
121
- });
122
- }
123
- addCustomHeaders() {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- if (HttpApiRequest.config.requestHeadersProvider) {
126
- const headers = yield HttpApiRequest.config.requestHeadersProvider();
127
- Object.entries(headers).forEach(([key, value]) => this.setHeader(key, value));
128
- }
129
- });
130
- }
131
- }
132
- exports.HttpApiRequest = HttpApiRequest;
133
- HttpApiRequest.config = {};
134
- function getApiKey() {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- if (HttpApiRequest.config.apiKeyProvider) {
137
- return yield HttpApiRequest.config.apiKeyProvider();
138
- }
139
- return null;
140
- });
141
- }
142
- function getAccessToken() {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- let token = null;
145
- if (HttpApiRequest.config.oauthTokenProvider) {
146
- token = yield HttpApiRequest.config.oauthTokenProvider();
147
- }
148
- if (local_auth_service_1.isLoggedIn() && token == null) {
149
- token = yield local_auth_service_1.getOAuthToken();
150
- }
151
- if (token) {
152
- token = token.replace('Bearer ', '');
153
- token = token.replace('bearer ', '');
154
- }
155
- return token;
156
- });
157
- }
158
- class HttpBooksApiV5Request extends HttpApiRequest {
159
- constructor(service) {
160
- super(`v5/books/${service}`);
161
- }
162
- }
163
- exports.HttpBooksApiV5Request = HttpBooksApiV5Request;
164
- class HttpApiV5Request extends HttpApiRequest {
165
- constructor(service) {
166
- super(`v5/${service}`);
167
- }
168
- }
169
- exports.HttpApiV5Request = HttpApiV5Request;
170
- //# sourceMappingURL=HttpApiRequest.js.map
@@ -1,43 +0,0 @@
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.getAccount = exports.deleteAccount = exports.updateAccount = exports.createAccount = void 0;
13
- const HttpApiRequest_1 = require("./HttpApiRequest");
14
- function createAccount(bookId, account) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('POST').setPayload(account).fetch();
17
- return response.data;
18
- });
19
- }
20
- exports.createAccount = createAccount;
21
- function updateAccount(bookId, account) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- var payload = JSON.stringify(account);
24
- var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('PUT').setPayload(payload).fetch();
25
- return response.data;
26
- });
27
- }
28
- exports.updateAccount = updateAccount;
29
- function deleteAccount(bookId, account) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`).setMethod('DELETE').fetch();
32
- return response.data;
33
- });
34
- }
35
- exports.deleteAccount = deleteAccount;
36
- function getAccount(bookId, idOrName) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
39
- return response.data;
40
- });
41
- }
42
- exports.getAccount = getAccount;
43
- //# sourceMappingURL=account-service.js.map
@@ -1,35 +0,0 @@
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.patchApp = exports.updateApp = exports.createApp = void 0;
13
- const HttpApiRequest_1 = require("./HttpApiRequest");
14
- function createApp(app) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- var response = yield new HttpApiRequest_1.HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
17
- return response.data;
18
- });
19
- }
20
- exports.createApp = createApp;
21
- function updateApp(app) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- var response = yield new HttpApiRequest_1.HttpApiRequest(`v5/apps`).setMethod('PUT').setPayload(app).fetch();
24
- return response.data;
25
- });
26
- }
27
- exports.updateApp = updateApp;
28
- function patchApp(app) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- var response = yield new HttpApiRequest_1.HttpApiRequest(`v5/apps`).setMethod('PATCH').setPayload(app).fetch();
31
- return response.data;
32
- });
33
- }
34
- exports.patchApp = patchApp;
35
- //# sourceMappingURL=app-service.js.map
@@ -1,21 +0,0 @@
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 = void 0;
13
- const HttpApiRequest_1 = require("./HttpApiRequest");
14
- function getBalances(bookId, query) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/balances`).addParam('query', query).addParam('time', Date.now()).fetch();
17
- return response.data;
18
- });
19
- }
20
- exports.getBalances = getBalances;
21
- //# sourceMappingURL=balances-service.js.map
@@ -1,37 +0,0 @@
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.audit = exports.updateBook = exports.loadBook = void 0;
13
- const HttpApiRequest_1 = require("./HttpApiRequest");
14
- function loadBook(bookId) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- if (bookId == null) {
17
- throw new Error("Book id null!");
18
- }
19
- let response = yield new HttpApiRequest_1.HttpBooksApiV5Request(bookId).fetch();
20
- return response.data;
21
- });
22
- }
23
- exports.loadBook = loadBook;
24
- function updateBook(bookId, book) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}`).setMethod('PUT').setPayload(book).fetch();
27
- return response.data;
28
- });
29
- }
30
- exports.updateBook = updateBook;
31
- function audit(bookId) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/audit`).setMethod('PATCH').fetch();
34
- });
35
- }
36
- exports.audit = audit;
37
- //# sourceMappingURL=book-service.js.map