bkper-js 1.17.0 → 1.18.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 +57 -0
- package/lib/index.js +2 -0
- package/lib/model/Book.js +20 -0
- package/lib/model/Event.js +17 -0
- package/lib/model/EventList.js +43 -0
- package/lib/service/event-service.js +26 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -789,6 +789,19 @@ export declare class Book {
|
|
|
789
789
|
* @returns A TransactionPage object containing the list of transactions
|
|
790
790
|
*/
|
|
791
791
|
listTransactions(query?: string, limit?: number, cursor?: string): Promise<TransactionList>;
|
|
792
|
+
/**
|
|
793
|
+
* Lists events in the Book based on the provided parameters.
|
|
794
|
+
*
|
|
795
|
+
* @param afterDate - The start date (inclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format. Can be null.
|
|
796
|
+
* @param beforeDate - The end date (exclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format. Can be null.
|
|
797
|
+
* @param onError - True to search only for events on error.
|
|
798
|
+
* @param resourceId - The ID of the event's resource (Transaction, Account, or Group). Can be null.
|
|
799
|
+
* @param limit - The maximum number of events to return.
|
|
800
|
+
* @param cursor - The cursor for pagination. Can be null.
|
|
801
|
+
*
|
|
802
|
+
* @returns An EventList object containing the list of events.
|
|
803
|
+
*/
|
|
804
|
+
listEvents(afterDate: string | null, beforeDate: string | null, onError: boolean, resourceId: string | null, limit: number, cursor?: string): Promise<EventList>;
|
|
792
805
|
/**
|
|
793
806
|
* Retrieve a transaction by id
|
|
794
807
|
*/
|
|
@@ -1117,6 +1130,50 @@ export declare enum DecimalSeparator {
|
|
|
1117
1130
|
DOT = "DOT"
|
|
1118
1131
|
}
|
|
1119
1132
|
|
|
1133
|
+
/**
|
|
1134
|
+
* Represents an Event in the system.
|
|
1135
|
+
*
|
|
1136
|
+
* @public
|
|
1137
|
+
*/
|
|
1138
|
+
export declare class Event {
|
|
1139
|
+
payload: bkper.Event;
|
|
1140
|
+
constructor(payload?: bkper.Event);
|
|
1141
|
+
/**
|
|
1142
|
+
* @returns The wrapped plain json object
|
|
1143
|
+
*/
|
|
1144
|
+
json(): bkper.Event;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* A list associated with an event query.
|
|
1149
|
+
*/
|
|
1150
|
+
export declare class EventList {
|
|
1151
|
+
private payload;
|
|
1152
|
+
|
|
1153
|
+
constructor(book: Book, payload: bkper.EventList);
|
|
1154
|
+
/**
|
|
1155
|
+
* @returns The cursor associated with the query for pagination.
|
|
1156
|
+
*/
|
|
1157
|
+
getCursor(): string | undefined;
|
|
1158
|
+
/**
|
|
1159
|
+
* @returns The first Event in the list.
|
|
1160
|
+
*/
|
|
1161
|
+
getFirst(): Event | undefined;
|
|
1162
|
+
/**
|
|
1163
|
+
*
|
|
1164
|
+
* Get the total number of events in the list.
|
|
1165
|
+
*
|
|
1166
|
+
* @returns The total number of events.
|
|
1167
|
+
*/
|
|
1168
|
+
size(): number;
|
|
1169
|
+
/**
|
|
1170
|
+
* Get the events in the list.
|
|
1171
|
+
*
|
|
1172
|
+
* @returns An array of Event objects.
|
|
1173
|
+
*/
|
|
1174
|
+
getItems(): Event[];
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1120
1177
|
/**
|
|
1121
1178
|
*
|
|
1122
1179
|
* This class defines a File uploaded to a [[Book]].
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,8 @@ export { Integration } from './model/Integration.js';
|
|
|
18
18
|
export { Template } from './model/Template.js';
|
|
19
19
|
export { Transaction } from './model/Transaction.js';
|
|
20
20
|
export { TransactionList } from './model/TransactionList.js';
|
|
21
|
+
export { Event } from './model/Event.js';
|
|
22
|
+
export { EventList } from './model/EventList.js';
|
|
21
23
|
export { User } from './model/User.js';
|
|
22
24
|
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month } from './model/Enums.js';
|
|
23
25
|
//# sourceMappingURL=index.js.map
|
package/lib/model/Book.js
CHANGED
|
@@ -13,9 +13,11 @@ import * as FileService from '../service/file-service.js';
|
|
|
13
13
|
import * as GroupService from '../service/group-service.js';
|
|
14
14
|
import * as IntegrationService from '../service/integration-service.js';
|
|
15
15
|
import * as TransactionService from '../service/transaction-service.js';
|
|
16
|
+
import * as EventService from '../service/event-service.js';
|
|
16
17
|
import * as Utils from '../utils.js';
|
|
17
18
|
import { Account } from './Account.js';
|
|
18
19
|
import { Collection } from './Collection.js';
|
|
20
|
+
import { EventList } from './EventList.js';
|
|
19
21
|
import { File } from './File.js';
|
|
20
22
|
import { Group } from './Group.js';
|
|
21
23
|
import { Integration } from './Integration.js';
|
|
@@ -639,6 +641,24 @@ export class Book {
|
|
|
639
641
|
return new TransactionList(this, transactionsList);
|
|
640
642
|
});
|
|
641
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Lists events in the Book based on the provided parameters.
|
|
646
|
+
*
|
|
647
|
+
* @param afterDate - The start date (inclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format. Can be null.
|
|
648
|
+
* @param beforeDate - The end date (exclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format. Can be null.
|
|
649
|
+
* @param onError - True to search only for events on error.
|
|
650
|
+
* @param resourceId - The ID of the event's resource (Transaction, Account, or Group). Can be null.
|
|
651
|
+
* @param limit - The maximum number of events to return.
|
|
652
|
+
* @param cursor - The cursor for pagination. Can be null.
|
|
653
|
+
*
|
|
654
|
+
* @returns An EventList object containing the list of events.
|
|
655
|
+
*/
|
|
656
|
+
listEvents(afterDate, beforeDate, onError, resourceId, limit, cursor) {
|
|
657
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
658
|
+
const eventsList = yield EventService.listEvents(this, afterDate, beforeDate, onError, resourceId, limit, cursor);
|
|
659
|
+
return new EventList(this, eventsList);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
642
662
|
/**
|
|
643
663
|
* Retrieve a transaction by id
|
|
644
664
|
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an Event in the system.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class Event {
|
|
7
|
+
constructor(payload) {
|
|
8
|
+
this.payload = payload || {};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @returns The wrapped plain json object
|
|
12
|
+
*/
|
|
13
|
+
json() {
|
|
14
|
+
return Object.assign({}, this.payload);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Event.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Event } from "./Event.js";
|
|
2
|
+
/**
|
|
3
|
+
* A list associated with an event query.
|
|
4
|
+
*/
|
|
5
|
+
export class EventList {
|
|
6
|
+
constructor(book, payload) {
|
|
7
|
+
this.book = book;
|
|
8
|
+
this.payload = payload || {};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @returns The cursor associated with the query for pagination.
|
|
12
|
+
*/
|
|
13
|
+
getCursor() {
|
|
14
|
+
return this.payload.cursor;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @returns The first Event in the list.
|
|
18
|
+
*/
|
|
19
|
+
getFirst() {
|
|
20
|
+
const events = this.getItems();
|
|
21
|
+
return events.length > 0 ? events[0] : undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* Get the total number of events in the list.
|
|
26
|
+
*
|
|
27
|
+
* @returns The total number of events.
|
|
28
|
+
*/
|
|
29
|
+
size() {
|
|
30
|
+
var _a;
|
|
31
|
+
return ((_a = this.payload.items) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the events in the list.
|
|
35
|
+
*
|
|
36
|
+
* @returns An array of Event objects.
|
|
37
|
+
*/
|
|
38
|
+
getItems() {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = this.payload.items) === null || _a === void 0 ? void 0 : _a.map(event => new Event(event))) || [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=EventList.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { HttpBooksApiV5Request } from "./http-api-request.js";
|
|
11
|
+
export function listEvents(book, afterDate, beforeDate, onError, resourceId, limit, cursor) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let request = new HttpBooksApiV5Request(`${book.getId()}/events`);
|
|
14
|
+
request.addParam('after', afterDate);
|
|
15
|
+
request.addParam('before', beforeDate);
|
|
16
|
+
request.addParam('error', onError);
|
|
17
|
+
request.addParam('resoureId', resourceId);
|
|
18
|
+
request.addParam('limit', limit);
|
|
19
|
+
if (cursor != null) {
|
|
20
|
+
request.setHeader('cursor', cursor);
|
|
21
|
+
}
|
|
22
|
+
var response = yield request.fetch();
|
|
23
|
+
return response.data;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=event-service.js.map
|