bkper-js 1.30.0 → 1.31.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 +96 -1
- package/lib/index.js +2 -0
- package/lib/model/Bkper.js +12 -0
- package/lib/model/Conversation.js +73 -0
- package/lib/model/Event.js +1 -1
- package/lib/model/Message.js +57 -0
- package/lib/service/app-service.js +7 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -634,6 +634,12 @@ export declare class Bkper {
|
|
|
634
634
|
* @returns The retrieved list of Apps
|
|
635
635
|
*/
|
|
636
636
|
static getApps(): Promise<App[]>;
|
|
637
|
+
/**
|
|
638
|
+
* Gets all [[Conversations]] available for the user.
|
|
639
|
+
*
|
|
640
|
+
* @returns The retrieved list of Conversations
|
|
641
|
+
*/
|
|
642
|
+
static getConversations(): Promise<Conversation[]>;
|
|
637
643
|
/**
|
|
638
644
|
* Gets all [[Templates]] available for the user.
|
|
639
645
|
*
|
|
@@ -1425,6 +1431,53 @@ export declare class Connection {
|
|
|
1425
1431
|
remove(): Promise<Connection>;
|
|
1426
1432
|
}
|
|
1427
1433
|
|
|
1434
|
+
/**
|
|
1435
|
+
* Defines a Conversation on Bkper.
|
|
1436
|
+
*
|
|
1437
|
+
* A Conversation represents an interaction between [[Users]] and [[Apps]].
|
|
1438
|
+
*
|
|
1439
|
+
* @public
|
|
1440
|
+
*/
|
|
1441
|
+
export declare class Conversation {
|
|
1442
|
+
payload: bkper.Conversation;
|
|
1443
|
+
|
|
1444
|
+
constructor(payload?: bkper.Conversation);
|
|
1445
|
+
/**
|
|
1446
|
+
* @returns The wrapped plain json object
|
|
1447
|
+
*/
|
|
1448
|
+
json(): bkper.Conversation;
|
|
1449
|
+
/**
|
|
1450
|
+
*
|
|
1451
|
+
* @returns The Conversation universal identifier
|
|
1452
|
+
*/
|
|
1453
|
+
getId(): string | undefined;
|
|
1454
|
+
/**
|
|
1455
|
+
*
|
|
1456
|
+
* @returns The title of the Conversation
|
|
1457
|
+
*/
|
|
1458
|
+
getTitle(): string | undefined;
|
|
1459
|
+
/**
|
|
1460
|
+
*
|
|
1461
|
+
* @returns The Agent associated to this Conversation
|
|
1462
|
+
*/
|
|
1463
|
+
getAgent(): Agent | undefined;
|
|
1464
|
+
/**
|
|
1465
|
+
*
|
|
1466
|
+
* @returns The Date the Conversation was created
|
|
1467
|
+
*/
|
|
1468
|
+
getCreatedAt(): Date | undefined;
|
|
1469
|
+
/**
|
|
1470
|
+
*
|
|
1471
|
+
* @returns The Date the Conversation was last updated
|
|
1472
|
+
*/
|
|
1473
|
+
getUpdatedAt(): Date | undefined;
|
|
1474
|
+
/**
|
|
1475
|
+
*
|
|
1476
|
+
* @returns The Messages associated to this Conversation
|
|
1477
|
+
*/
|
|
1478
|
+
getMessages(): Message[];
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1428
1481
|
/**
|
|
1429
1482
|
* Decimal separator of numbers on book
|
|
1430
1483
|
*
|
|
@@ -1471,7 +1524,7 @@ export declare class Event {
|
|
|
1471
1524
|
*/
|
|
1472
1525
|
getUser(): User | undefined;
|
|
1473
1526
|
/**
|
|
1474
|
-
* @returns The
|
|
1527
|
+
* @returns The Agent who performed the Event
|
|
1475
1528
|
*/
|
|
1476
1529
|
getAgent(): Agent | undefined;
|
|
1477
1530
|
/**
|
|
@@ -1931,6 +1984,48 @@ export declare class Integration {
|
|
|
1931
1984
|
remove(): Promise<Integration>;
|
|
1932
1985
|
}
|
|
1933
1986
|
|
|
1987
|
+
/**
|
|
1988
|
+
* Defines a Message on Bkper.
|
|
1989
|
+
*
|
|
1990
|
+
* A Message is a building block of a [[Conversation]].
|
|
1991
|
+
*
|
|
1992
|
+
* @public
|
|
1993
|
+
*/
|
|
1994
|
+
export declare class Message {
|
|
1995
|
+
payload: bkper.Message;
|
|
1996
|
+
|
|
1997
|
+
constructor(conversation: Conversation, payload?: bkper.Message);
|
|
1998
|
+
/**
|
|
1999
|
+
* @returns The wrapped plain json object
|
|
2000
|
+
*/
|
|
2001
|
+
json(): bkper.Message;
|
|
2002
|
+
/**
|
|
2003
|
+
*
|
|
2004
|
+
* @returns The Message universal identifier
|
|
2005
|
+
*/
|
|
2006
|
+
getId(): string | undefined;
|
|
2007
|
+
/**
|
|
2008
|
+
*
|
|
2009
|
+
* @returns The Agent who created the Message, if any
|
|
2010
|
+
*/
|
|
2011
|
+
getAgent(): Agent | undefined;
|
|
2012
|
+
/**
|
|
2013
|
+
*
|
|
2014
|
+
* @returns The User who created the Message, if any
|
|
2015
|
+
*/
|
|
2016
|
+
getUser(): User | undefined;
|
|
2017
|
+
/**
|
|
2018
|
+
*
|
|
2019
|
+
* @returns The Date the Message was created
|
|
2020
|
+
*/
|
|
2021
|
+
getCreatedAt(): Date | undefined;
|
|
2022
|
+
/**
|
|
2023
|
+
*
|
|
2024
|
+
* @returns The content text of the Message
|
|
2025
|
+
*/
|
|
2026
|
+
getContent(): string | undefined;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
1934
2029
|
/**
|
|
1935
2030
|
* Enum that represents a Month.
|
|
1936
2031
|
*
|
package/lib/index.js
CHANGED
|
@@ -14,9 +14,11 @@ export { Bkper } from './model/Bkper.js';
|
|
|
14
14
|
export { Book } from './model/Book.js';
|
|
15
15
|
export { Collection } from './model/Collection.js';
|
|
16
16
|
export { Connection } from './model/Connection.js';
|
|
17
|
+
export { Conversation } from './model/Conversation.js';
|
|
17
18
|
export { File } from './model/File.js';
|
|
18
19
|
export { Group } from './model/Group.js';
|
|
19
20
|
export { Integration } from './model/Integration.js';
|
|
21
|
+
export { Message } from './model/Message.js';
|
|
20
22
|
export { Template } from './model/Template.js';
|
|
21
23
|
export { Transaction } from './model/Transaction.js';
|
|
22
24
|
export { TransactionList } from './model/TransactionList.js';
|
package/lib/model/Bkper.js
CHANGED
|
@@ -18,6 +18,7 @@ import { HttpApiRequest } from '../service/http-api-request.js';
|
|
|
18
18
|
import { User } from "./User.js";
|
|
19
19
|
import { Template } from "./Template.js";
|
|
20
20
|
import { Collection } from "./Collection.js";
|
|
21
|
+
import { Conversation } from "./Conversation.js";
|
|
21
22
|
/**
|
|
22
23
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
23
24
|
*
|
|
@@ -84,6 +85,17 @@ export class Bkper {
|
|
|
84
85
|
return apps.map(app => new App(app));
|
|
85
86
|
});
|
|
86
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets all [[Conversations]] available for the user.
|
|
90
|
+
*
|
|
91
|
+
* @returns The retrieved list of Conversations
|
|
92
|
+
*/
|
|
93
|
+
static getConversations() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
let conversations = yield AppService.getConversations();
|
|
96
|
+
return conversations.map(c => new Conversation(c));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
87
99
|
/**
|
|
88
100
|
* Gets all [[Templates]] available for the user.
|
|
89
101
|
*
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Agent } from "./Agent.js";
|
|
2
|
+
import { Message } from "./Message.js";
|
|
3
|
+
/**
|
|
4
|
+
* Defines a Conversation on Bkper.
|
|
5
|
+
*
|
|
6
|
+
* A Conversation represents an interaction between [[Users]] and [[Apps]].
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class Conversation {
|
|
11
|
+
constructor(payload) {
|
|
12
|
+
this.payload = payload || {};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @returns The wrapped plain json object
|
|
16
|
+
*/
|
|
17
|
+
json() {
|
|
18
|
+
return Object.assign({}, this.payload);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @returns The Conversation universal identifier
|
|
23
|
+
*/
|
|
24
|
+
getId() {
|
|
25
|
+
return this.payload.id;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @returns The title of the Conversation
|
|
30
|
+
*/
|
|
31
|
+
getTitle() {
|
|
32
|
+
return this.payload.title;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @returns The Agent associated to this Conversation
|
|
37
|
+
*/
|
|
38
|
+
getAgent() {
|
|
39
|
+
return this.payload.agent ? new Agent(this.payload.agent) : undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @returns The Date the Conversation was created
|
|
44
|
+
*/
|
|
45
|
+
getCreatedAt() {
|
|
46
|
+
return this.payload.createdAt ? new Date(this.payload.createdAt) : undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @returns The Date the Conversation was last updated
|
|
51
|
+
*/
|
|
52
|
+
getUpdatedAt() {
|
|
53
|
+
return this.payload.updatedAt ? new Date(this.payload.updatedAt) : undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @returns The Messages associated to this Conversation
|
|
58
|
+
*/
|
|
59
|
+
getMessages() {
|
|
60
|
+
if (this.messages !== undefined) {
|
|
61
|
+
return this.messages;
|
|
62
|
+
}
|
|
63
|
+
let messages = [];
|
|
64
|
+
if (this.payload.messages) {
|
|
65
|
+
for (const message of this.payload.messages) {
|
|
66
|
+
messages.push(new Message(this, message));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this.messages = messages;
|
|
70
|
+
return this.messages;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=Conversation.js.map
|
package/lib/model/Event.js
CHANGED
|
@@ -40,7 +40,7 @@ export class Event {
|
|
|
40
40
|
return this.payload.user ? new User(this.payload.user) : undefined;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* @returns The
|
|
43
|
+
* @returns The Agent who performed the Event
|
|
44
44
|
*/
|
|
45
45
|
getAgent() {
|
|
46
46
|
return this.payload.agent ? new Agent(this.payload.agent) : undefined;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Agent } from "./Agent.js";
|
|
2
|
+
import { User } from "./User.js";
|
|
3
|
+
/**
|
|
4
|
+
* Defines a Message on Bkper.
|
|
5
|
+
*
|
|
6
|
+
* A Message is a building block of a [[Conversation]].
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class Message {
|
|
11
|
+
constructor(conversation, payload) {
|
|
12
|
+
this.conversation = conversation;
|
|
13
|
+
this.payload = payload || {};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @returns The wrapped plain json object
|
|
17
|
+
*/
|
|
18
|
+
json() {
|
|
19
|
+
return Object.assign({}, this.payload);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @returns The Message universal identifier
|
|
24
|
+
*/
|
|
25
|
+
getId() {
|
|
26
|
+
return this.payload.id;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @returns The Agent who created the Message, if any
|
|
31
|
+
*/
|
|
32
|
+
getAgent() {
|
|
33
|
+
return this.payload.agent ? new Agent(this.payload.agent) : undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @returns The User who created the Message, if any
|
|
38
|
+
*/
|
|
39
|
+
getUser() {
|
|
40
|
+
return this.payload.user ? new User(this.payload.user) : undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @returns The Date the Message was created
|
|
45
|
+
*/
|
|
46
|
+
getCreatedAt() {
|
|
47
|
+
return this.payload.createdAt ? new Date(this.payload.createdAt) : undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @returns The content text of the Message
|
|
52
|
+
*/
|
|
53
|
+
getContent() {
|
|
54
|
+
return this.payload.content;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=Message.js.map
|
|
@@ -22,6 +22,13 @@ export function getApps() {
|
|
|
22
22
|
return appsJson;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
export function getConversations() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a;
|
|
28
|
+
const response = yield new HttpApiRequest(`v5/apps/conversations`).setMethod('GET').fetch();
|
|
29
|
+
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
30
|
+
});
|
|
31
|
+
}
|
|
25
32
|
export function createApp(app) {
|
|
26
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
34
|
var response = yield new HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "Javascript client for Bkper REST API",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@bkper/bkper-api-types": "^5.15.
|
|
37
|
+
"@bkper/bkper-api-types": "^5.15.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@google-cloud/local-auth": "^3.0.1",
|