bkper-js 1.6.0 → 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 +75 -3
- package/lib/index.js +6 -5
- package/lib/model/Bkper.js +13 -0
- package/lib/model/Template.js +85 -0
- package/lib/service/template-service.js +25 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -424,6 +424,12 @@ export declare class Bkper {
|
|
|
424
424
|
* @returns The retrieved list of Apps
|
|
425
425
|
*/
|
|
426
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[]>;
|
|
427
433
|
/**
|
|
428
434
|
* Gets the current logged [[User]].
|
|
429
435
|
*
|
|
@@ -1367,7 +1373,7 @@ export declare class Integration {
|
|
|
1367
1373
|
*
|
|
1368
1374
|
* @public
|
|
1369
1375
|
*/
|
|
1370
|
-
declare enum Month {
|
|
1376
|
+
export declare enum Month {
|
|
1371
1377
|
JANUARY = "JANUARY",
|
|
1372
1378
|
FEBRUARY = "FEBRUARY",
|
|
1373
1379
|
MARCH = "MARCH",
|
|
@@ -1387,7 +1393,7 @@ declare enum Month {
|
|
|
1387
1393
|
*
|
|
1388
1394
|
* @public
|
|
1389
1395
|
*/
|
|
1390
|
-
declare enum Period {
|
|
1396
|
+
export declare enum Period {
|
|
1391
1397
|
/**
|
|
1392
1398
|
* Monthly period
|
|
1393
1399
|
*/
|
|
@@ -1456,6 +1462,72 @@ export declare enum Permission {
|
|
|
1456
1462
|
OWNER = "OWNER"
|
|
1457
1463
|
}
|
|
1458
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
|
+
|
|
1459
1531
|
/**
|
|
1460
1532
|
*
|
|
1461
1533
|
* This class defines a Transaction between [credit and debit](http://en.wikipedia.org/wiki/Debits_and_credits) [[Accounts]].
|
|
@@ -1932,7 +2004,7 @@ export declare class User {
|
|
|
1932
2004
|
*
|
|
1933
2005
|
* @public
|
|
1934
2006
|
*/
|
|
1935
|
-
declare enum Visibility {
|
|
2007
|
+
export declare enum Visibility {
|
|
1936
2008
|
/**
|
|
1937
2009
|
* The book can be accessed by anyone with the link
|
|
1938
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/Bkper.js
CHANGED
|
@@ -12,8 +12,10 @@ import { App } from "./App.js";
|
|
|
12
12
|
import * as AppService from '../service/app-service.js';
|
|
13
13
|
import * as BookService from '../service/book-service.js';
|
|
14
14
|
import * as UserService from '../service/user-service.js';
|
|
15
|
+
import * as TemplateService from '../service/template-service.js';
|
|
15
16
|
import { HttpApiRequest } from '../service/http-api-request.js';
|
|
16
17
|
import { User } from "./User.js";
|
|
18
|
+
import { Template } from "./Template.js";
|
|
17
19
|
/**
|
|
18
20
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
19
21
|
*
|
|
@@ -83,6 +85,17 @@ export class Bkper {
|
|
|
83
85
|
return apps.map(app => new App(app));
|
|
84
86
|
});
|
|
85
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
|
+
}
|
|
86
99
|
/**
|
|
87
100
|
* Gets the current logged [[User]].
|
|
88
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
|
|
@@ -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
|