bkper-js 1.5.1 → 1.7.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/lib/index.d.ts +85 -3
- package/lib/index.js +6 -5
- package/lib/model/App.js +6 -0
- package/lib/model/Bkper.js +25 -0
- package/lib/model/Template.js +85 -0
- package/lib/service/app-service.js +14 -0
- package/lib/service/template-service.js +25 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -366,6 +366,10 @@ export declare class App {
|
|
|
366
366
|
* Perform update App, applying pending changes.
|
|
367
367
|
*/
|
|
368
368
|
update(): Promise<App>;
|
|
369
|
+
/**
|
|
370
|
+
* @returns The wrapped plain json object
|
|
371
|
+
*/
|
|
372
|
+
json(): bkper.App;
|
|
369
373
|
}
|
|
370
374
|
|
|
371
375
|
/**
|
|
@@ -414,6 +418,18 @@ export declare class Bkper {
|
|
|
414
418
|
* @returns The retrieved list of Books
|
|
415
419
|
*/
|
|
416
420
|
static getBooks(): Promise<Book[]>;
|
|
421
|
+
/**
|
|
422
|
+
* Gets all [[Apps]] available for the user.
|
|
423
|
+
*
|
|
424
|
+
* @returns The retrieved list of Apps
|
|
425
|
+
*/
|
|
426
|
+
static getApps(): Promise<App[]>;
|
|
427
|
+
/**
|
|
428
|
+
* Gets all [[Templates]] available for the user.
|
|
429
|
+
*
|
|
430
|
+
* @returns The retrieved list of Templates
|
|
431
|
+
*/
|
|
432
|
+
static getTemplates(): Promise<Template[]>;
|
|
417
433
|
/**
|
|
418
434
|
* Gets the current logged [[User]].
|
|
419
435
|
*
|
|
@@ -1357,7 +1373,7 @@ export declare class Integration {
|
|
|
1357
1373
|
*
|
|
1358
1374
|
* @public
|
|
1359
1375
|
*/
|
|
1360
|
-
declare enum Month {
|
|
1376
|
+
export declare enum Month {
|
|
1361
1377
|
JANUARY = "JANUARY",
|
|
1362
1378
|
FEBRUARY = "FEBRUARY",
|
|
1363
1379
|
MARCH = "MARCH",
|
|
@@ -1377,7 +1393,7 @@ declare enum Month {
|
|
|
1377
1393
|
*
|
|
1378
1394
|
* @public
|
|
1379
1395
|
*/
|
|
1380
|
-
declare enum Period {
|
|
1396
|
+
export declare enum Period {
|
|
1381
1397
|
/**
|
|
1382
1398
|
* Monthly period
|
|
1383
1399
|
*/
|
|
@@ -1446,6 +1462,72 @@ export declare enum Permission {
|
|
|
1446
1462
|
OWNER = "OWNER"
|
|
1447
1463
|
}
|
|
1448
1464
|
|
|
1465
|
+
/**
|
|
1466
|
+
* This class defines a Template.
|
|
1467
|
+
*
|
|
1468
|
+
* A Template is a pre-configured setup for [[Books]] and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.
|
|
1469
|
+
*
|
|
1470
|
+
* @public
|
|
1471
|
+
*/
|
|
1472
|
+
export declare class Template {
|
|
1473
|
+
|
|
1474
|
+
constructor(json?: bkper.Template);
|
|
1475
|
+
/**
|
|
1476
|
+
* Gets the name of the Template.
|
|
1477
|
+
*
|
|
1478
|
+
* @returns The Template's name
|
|
1479
|
+
*/
|
|
1480
|
+
getName(): string | undefined;
|
|
1481
|
+
/**
|
|
1482
|
+
* Gets the description of the Template.
|
|
1483
|
+
*
|
|
1484
|
+
* @returns The Template's description
|
|
1485
|
+
*/
|
|
1486
|
+
getDescription(): string | undefined;
|
|
1487
|
+
/**
|
|
1488
|
+
* Gets the url of the image of the Template.
|
|
1489
|
+
*
|
|
1490
|
+
* @returns The url of the Template's image
|
|
1491
|
+
*/
|
|
1492
|
+
getImageUrl(): string | undefined;
|
|
1493
|
+
/**
|
|
1494
|
+
* Gets the category of the Template.
|
|
1495
|
+
*
|
|
1496
|
+
* @returns The Template's category. Example: "PERSONAL", "BUSINESS", etc
|
|
1497
|
+
*/
|
|
1498
|
+
getCategory(): string | undefined;
|
|
1499
|
+
/**
|
|
1500
|
+
* Gets the times the Template has been used.
|
|
1501
|
+
*
|
|
1502
|
+
* @returns The number of times the Template has been used
|
|
1503
|
+
*/
|
|
1504
|
+
getTimesUsed(): number;
|
|
1505
|
+
/**
|
|
1506
|
+
* Gets the bookId of the [[Book]] associated with the Template.
|
|
1507
|
+
*
|
|
1508
|
+
* @returns The bookId of the Book associated with the Template
|
|
1509
|
+
*/
|
|
1510
|
+
getBookId(): string | undefined;
|
|
1511
|
+
/**
|
|
1512
|
+
* Gets the link of the [[Book]] associated with the Template.
|
|
1513
|
+
*
|
|
1514
|
+
* @returns The link of the Book associated with the Template
|
|
1515
|
+
*/
|
|
1516
|
+
getBookLink(): string | undefined;
|
|
1517
|
+
/**
|
|
1518
|
+
* Gets the link of the Google Sheets spreadsheet associated with the Template.
|
|
1519
|
+
*
|
|
1520
|
+
* @returns The link of the Google Sheets spreadsheet associated with the Template
|
|
1521
|
+
*/
|
|
1522
|
+
getSheetsLink(): string | undefined;
|
|
1523
|
+
/**
|
|
1524
|
+
* Gets the wrapped plain json object of the Template.
|
|
1525
|
+
*
|
|
1526
|
+
* @returns The Template wrapped plain json object
|
|
1527
|
+
*/
|
|
1528
|
+
json(): bkper.Template;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1449
1531
|
/**
|
|
1450
1532
|
*
|
|
1451
1533
|
* This class defines a Transaction between [credit and debit](http://en.wikipedia.org/wiki/Debits_and_credits) [[Accounts]].
|
|
@@ -1922,7 +2004,7 @@ export declare class User {
|
|
|
1922
2004
|
*
|
|
1923
2005
|
* @public
|
|
1924
2006
|
*/
|
|
1925
|
-
declare enum Visibility {
|
|
2007
|
+
export declare enum Visibility {
|
|
1926
2008
|
/**
|
|
1927
2009
|
* The book can be accessed by anyone with the link
|
|
1928
2010
|
*/
|
package/lib/index.js
CHANGED
|
@@ -5,18 +5,19 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
8
|
+
export { Account } from './model/Account.js';
|
|
9
9
|
export { Amount } from "./model/Amount.js";
|
|
10
|
+
export { App } from './model/App.js';
|
|
10
11
|
export { Bkper } from './model/Bkper.js';
|
|
11
|
-
export { Account } from './model/Account.js';
|
|
12
12
|
export { Book } from './model/Book.js';
|
|
13
13
|
export { Collection } from './model/Collection.js';
|
|
14
|
+
export { Connection } from './model/Connection.js';
|
|
14
15
|
export { File } from './model/File.js';
|
|
15
16
|
export { Group } from './model/Group.js';
|
|
17
|
+
export { Integration } from './model/Integration.js';
|
|
18
|
+
export { Template } from './model/Template.js';
|
|
16
19
|
export { Transaction } from './model/Transaction.js';
|
|
17
20
|
export { TransactionIterator } from './model/TransactionIterator.js';
|
|
18
21
|
export { User } from './model/User.js';
|
|
19
|
-
export {
|
|
20
|
-
export { Connection } from './model/Connection.js';
|
|
21
|
-
export { Periodicity, AccountType, DecimalSeparator, Permission } from './model/Enums.js';
|
|
22
|
+
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month } from './model/Enums.js';
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/lib/model/App.js
CHANGED
package/lib/model/Bkper.js
CHANGED
|
@@ -9,10 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Book } from "./Book.js";
|
|
11
11
|
import { App } from "./App.js";
|
|
12
|
+
import * as AppService from '../service/app-service.js';
|
|
12
13
|
import * as BookService from '../service/book-service.js';
|
|
13
14
|
import * as UserService from '../service/user-service.js';
|
|
15
|
+
import * as TemplateService from '../service/template-service.js';
|
|
14
16
|
import { HttpApiRequest } from '../service/http-api-request.js';
|
|
15
17
|
import { User } from "./User.js";
|
|
18
|
+
import { Template } from "./Template.js";
|
|
16
19
|
/**
|
|
17
20
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
18
21
|
*
|
|
@@ -71,6 +74,28 @@ export class Bkper {
|
|
|
71
74
|
return books.map(book => new Book(book));
|
|
72
75
|
});
|
|
73
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets all [[Apps]] available for the user.
|
|
79
|
+
*
|
|
80
|
+
* @returns The retrieved list of Apps
|
|
81
|
+
*/
|
|
82
|
+
static getApps() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
let apps = yield AppService.getApps();
|
|
85
|
+
return apps.map(app => new App(app));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets all [[Templates]] available for the user.
|
|
90
|
+
*
|
|
91
|
+
* @returns The retrieved list of Templates
|
|
92
|
+
*/
|
|
93
|
+
static getTemplates() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
let templates = yield TemplateService.getTemplates();
|
|
96
|
+
return templates.map(template => new Template(template));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
74
99
|
/**
|
|
75
100
|
* Gets the current logged [[User]].
|
|
76
101
|
*
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class defines a Template.
|
|
3
|
+
*
|
|
4
|
+
* A Template is a pre-configured setup for [[Books]] and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class Template {
|
|
9
|
+
constructor(json) {
|
|
10
|
+
this.wrapped = json || {};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Gets the name of the Template.
|
|
14
|
+
*
|
|
15
|
+
* @returns The Template's name
|
|
16
|
+
*/
|
|
17
|
+
getName() {
|
|
18
|
+
return this.wrapped.name;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets the description of the Template.
|
|
22
|
+
*
|
|
23
|
+
* @returns The Template's description
|
|
24
|
+
*/
|
|
25
|
+
getDescription() {
|
|
26
|
+
return this.wrapped.description;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Gets the url of the image of the Template.
|
|
30
|
+
*
|
|
31
|
+
* @returns The url of the Template's image
|
|
32
|
+
*/
|
|
33
|
+
getImageUrl() {
|
|
34
|
+
return this.wrapped.imageUrl;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets the category of the Template.
|
|
38
|
+
*
|
|
39
|
+
* @returns The Template's category. Example: "PERSONAL", "BUSINESS", etc
|
|
40
|
+
*/
|
|
41
|
+
getCategory() {
|
|
42
|
+
return this.wrapped.category;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the times the Template has been used.
|
|
46
|
+
*
|
|
47
|
+
* @returns The number of times the Template has been used
|
|
48
|
+
*/
|
|
49
|
+
getTimesUsed() {
|
|
50
|
+
return this.wrapped.timesUsed || 0;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the bookId of the [[Book]] associated with the Template.
|
|
54
|
+
*
|
|
55
|
+
* @returns The bookId of the Book associated with the Template
|
|
56
|
+
*/
|
|
57
|
+
getBookId() {
|
|
58
|
+
return this.wrapped.bookId;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the link of the [[Book]] associated with the Template.
|
|
62
|
+
*
|
|
63
|
+
* @returns The link of the Book associated with the Template
|
|
64
|
+
*/
|
|
65
|
+
getBookLink() {
|
|
66
|
+
return this.wrapped.bookLink;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the link of the Google Sheets spreadsheet associated with the Template.
|
|
70
|
+
*
|
|
71
|
+
* @returns The link of the Google Sheets spreadsheet associated with the Template
|
|
72
|
+
*/
|
|
73
|
+
getSheetsLink() {
|
|
74
|
+
return this.wrapped.sheetsLink;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the wrapped plain json object of the Template.
|
|
78
|
+
*
|
|
79
|
+
* @returns The Template wrapped plain json object
|
|
80
|
+
*/
|
|
81
|
+
json() {
|
|
82
|
+
return this.wrapped;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=Template.js.map
|
|
@@ -8,6 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { HttpApiRequest } from "./http-api-request.js";
|
|
11
|
+
export function getApps() {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let response = yield new HttpApiRequest(`v5/apps`).setMethod('GET').fetch();
|
|
14
|
+
if (response.data == null) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
let appListPlain = response.data;
|
|
18
|
+
let appsJson = appListPlain.items;
|
|
19
|
+
if (appsJson == null) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return appsJson;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
11
25
|
export function createApp(app) {
|
|
12
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
27
|
var response = yield new HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { HttpApiRequest } from "./http-api-request.js";
|
|
11
|
+
export function getTemplates() {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let response = yield new HttpApiRequest(`v5/templates`).setMethod('GET').fetch();
|
|
14
|
+
if (response.data == null) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
let templateListPlain = response.data;
|
|
18
|
+
let templatesJson = templateListPlain.items;
|
|
19
|
+
if (templatesJson == null) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return templatesJson;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=template-service.js.map
|