@dawntech/blip-tools 0.5.1 → 0.6.1
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/dist/helpers/create-uri.d.ts +1 -0
- package/dist/index.cjs +96 -2
- package/dist/index.mjs +96 -2
- package/dist/modules/blip-analytics.d.ts +22 -0
- package/dist/modules/blip-main.d.ts +2 -0
- package/dist/modules/blip-monitoring.d.ts +2 -1
- package/dist/modules/blip-ticket.d.ts +4 -2
- package/dist/types/analytics.d.ts +21 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/monitoring.d.ts +9 -0
- package/dist/types/ticket-search-result.d.ts +16 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function createUri(url: string, params: Record<string, unknown>): string;
|
package/dist/index.cjs
CHANGED
|
@@ -493,12 +493,20 @@ class BlipInteraction {
|
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
+
function createUri(url, params) {
|
|
497
|
+
const encodedParams = encodeBlipParams(params);
|
|
498
|
+
if (encodedParams) {
|
|
499
|
+
return `${url}?${encodedParams}`;
|
|
500
|
+
}
|
|
501
|
+
return url;
|
|
502
|
+
}
|
|
503
|
+
|
|
496
504
|
class BlipTicket {
|
|
497
505
|
api;
|
|
498
506
|
constructor(context) {
|
|
499
507
|
this.api = context.api;
|
|
500
508
|
}
|
|
501
|
-
async search({ filter, skip, take }) {
|
|
509
|
+
async search({ filter, skip, take } = {}) {
|
|
502
510
|
try {
|
|
503
511
|
const params = {
|
|
504
512
|
$filter: filter,
|
|
@@ -509,7 +517,7 @@ class BlipTicket {
|
|
|
509
517
|
id: crypto.randomUUID(),
|
|
510
518
|
to: 'postmaster@desk.msging.net',
|
|
511
519
|
method: 'get',
|
|
512
|
-
uri:
|
|
520
|
+
uri: createUri('/tickets', params),
|
|
513
521
|
};
|
|
514
522
|
const response = await this.api.post('/commands', body);
|
|
515
523
|
validateResponse(response);
|
|
@@ -519,6 +527,22 @@ class BlipTicket {
|
|
|
519
527
|
throw handleError(error);
|
|
520
528
|
}
|
|
521
529
|
}
|
|
530
|
+
async getTicket(ticketId) {
|
|
531
|
+
try {
|
|
532
|
+
const body = {
|
|
533
|
+
id: crypto.randomUUID(),
|
|
534
|
+
to: 'postmaster@desk.msging.net',
|
|
535
|
+
method: 'get',
|
|
536
|
+
uri: `/ticket/${ticketId}`,
|
|
537
|
+
};
|
|
538
|
+
const response = await this.api.post('/commands', body);
|
|
539
|
+
validateResponse(response);
|
|
540
|
+
return response.data.resource;
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
throw handleError(error);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
522
546
|
}
|
|
523
547
|
|
|
524
548
|
class BlipWhatsapp {
|
|
@@ -631,6 +655,74 @@ class BlipMonitoring {
|
|
|
631
655
|
throw handleError(error);
|
|
632
656
|
}
|
|
633
657
|
}
|
|
658
|
+
async getWaitingTicketsMetrics() {
|
|
659
|
+
try {
|
|
660
|
+
const response = await this.api.post('/commands', {
|
|
661
|
+
id: crypto.randomUUID(),
|
|
662
|
+
to: 'postmaster@desk.msging.net',
|
|
663
|
+
method: 'get',
|
|
664
|
+
uri: '/monitoring/waiting-tickets',
|
|
665
|
+
});
|
|
666
|
+
validateResponse(response);
|
|
667
|
+
return response.data.resource.items;
|
|
668
|
+
}
|
|
669
|
+
catch (error) {
|
|
670
|
+
throw handleError(error);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
class BlipAnalytics {
|
|
676
|
+
api;
|
|
677
|
+
constructor(context) {
|
|
678
|
+
this.api = context.api;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Returns a list of reports by day with tickets status. Ommiting dates will return only the last report. Dates are expected to be in yyyy-mm-dd format.
|
|
682
|
+
*/
|
|
683
|
+
async getTicketReports({ beginDate, endDate } = {}) {
|
|
684
|
+
try {
|
|
685
|
+
const params = {
|
|
686
|
+
beginDate,
|
|
687
|
+
endDate,
|
|
688
|
+
};
|
|
689
|
+
const body = {
|
|
690
|
+
id: crypto.randomUUID(),
|
|
691
|
+
to: 'postmaster@desk.msging.net',
|
|
692
|
+
method: 'get',
|
|
693
|
+
uri: `/analytics/reports/tickets?${encodeBlipParams(params)}`,
|
|
694
|
+
};
|
|
695
|
+
const response = await this.api.post('/commands', body);
|
|
696
|
+
validateResponse(response);
|
|
697
|
+
return response.data.resource.items;
|
|
698
|
+
}
|
|
699
|
+
catch (error) {
|
|
700
|
+
throw handleError(error);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Returns ticket timings metrics. Dates are expected to be in yyyy-mm-dd format.
|
|
705
|
+
*/
|
|
706
|
+
async getTicketTimings({ beginDate, endDate } = {}) {
|
|
707
|
+
try {
|
|
708
|
+
const params = {
|
|
709
|
+
beginDate,
|
|
710
|
+
endDate,
|
|
711
|
+
};
|
|
712
|
+
const body = {
|
|
713
|
+
id: crypto.randomUUID(),
|
|
714
|
+
to: 'postmaster@desk.msging.net',
|
|
715
|
+
method: 'get',
|
|
716
|
+
uri: ['/analytics/reports/timings', encodeBlipParams(params)].filter((p) => p).join('?'),
|
|
717
|
+
};
|
|
718
|
+
const response = await this.api.post('/commands', body);
|
|
719
|
+
validateResponse(response);
|
|
720
|
+
return response.data.resource;
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
throw handleError(error);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
634
726
|
}
|
|
635
727
|
|
|
636
728
|
class Blip {
|
|
@@ -646,6 +738,7 @@ class Blip {
|
|
|
646
738
|
ticket;
|
|
647
739
|
whatsapp;
|
|
648
740
|
monitoring;
|
|
741
|
+
analytics;
|
|
649
742
|
constructor(params) {
|
|
650
743
|
validateInstance(params);
|
|
651
744
|
this.api = axios.create({
|
|
@@ -666,6 +759,7 @@ class Blip {
|
|
|
666
759
|
this.ticket = new BlipTicket({ api: this.api });
|
|
667
760
|
this.whatsapp = new BlipWhatsapp({ api: this.api });
|
|
668
761
|
this.monitoring = new BlipMonitoring({ api: this.api });
|
|
762
|
+
this.analytics = new BlipAnalytics({ api: this.api });
|
|
669
763
|
}
|
|
670
764
|
}
|
|
671
765
|
|
package/dist/index.mjs
CHANGED
|
@@ -491,12 +491,20 @@ class BlipInteraction {
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
function createUri(url, params) {
|
|
495
|
+
const encodedParams = encodeBlipParams(params);
|
|
496
|
+
if (encodedParams) {
|
|
497
|
+
return `${url}?${encodedParams}`;
|
|
498
|
+
}
|
|
499
|
+
return url;
|
|
500
|
+
}
|
|
501
|
+
|
|
494
502
|
class BlipTicket {
|
|
495
503
|
api;
|
|
496
504
|
constructor(context) {
|
|
497
505
|
this.api = context.api;
|
|
498
506
|
}
|
|
499
|
-
async search({ filter, skip, take }) {
|
|
507
|
+
async search({ filter, skip, take } = {}) {
|
|
500
508
|
try {
|
|
501
509
|
const params = {
|
|
502
510
|
$filter: filter,
|
|
@@ -507,7 +515,7 @@ class BlipTicket {
|
|
|
507
515
|
id: randomUUID(),
|
|
508
516
|
to: 'postmaster@desk.msging.net',
|
|
509
517
|
method: 'get',
|
|
510
|
-
uri:
|
|
518
|
+
uri: createUri('/tickets', params),
|
|
511
519
|
};
|
|
512
520
|
const response = await this.api.post('/commands', body);
|
|
513
521
|
validateResponse(response);
|
|
@@ -517,6 +525,22 @@ class BlipTicket {
|
|
|
517
525
|
throw handleError(error);
|
|
518
526
|
}
|
|
519
527
|
}
|
|
528
|
+
async getTicket(ticketId) {
|
|
529
|
+
try {
|
|
530
|
+
const body = {
|
|
531
|
+
id: randomUUID(),
|
|
532
|
+
to: 'postmaster@desk.msging.net',
|
|
533
|
+
method: 'get',
|
|
534
|
+
uri: `/ticket/${ticketId}`,
|
|
535
|
+
};
|
|
536
|
+
const response = await this.api.post('/commands', body);
|
|
537
|
+
validateResponse(response);
|
|
538
|
+
return response.data.resource;
|
|
539
|
+
}
|
|
540
|
+
catch (error) {
|
|
541
|
+
throw handleError(error);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
520
544
|
}
|
|
521
545
|
|
|
522
546
|
class BlipWhatsapp {
|
|
@@ -629,6 +653,74 @@ class BlipMonitoring {
|
|
|
629
653
|
throw handleError(error);
|
|
630
654
|
}
|
|
631
655
|
}
|
|
656
|
+
async getWaitingTicketsMetrics() {
|
|
657
|
+
try {
|
|
658
|
+
const response = await this.api.post('/commands', {
|
|
659
|
+
id: randomUUID(),
|
|
660
|
+
to: 'postmaster@desk.msging.net',
|
|
661
|
+
method: 'get',
|
|
662
|
+
uri: '/monitoring/waiting-tickets',
|
|
663
|
+
});
|
|
664
|
+
validateResponse(response);
|
|
665
|
+
return response.data.resource.items;
|
|
666
|
+
}
|
|
667
|
+
catch (error) {
|
|
668
|
+
throw handleError(error);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
class BlipAnalytics {
|
|
674
|
+
api;
|
|
675
|
+
constructor(context) {
|
|
676
|
+
this.api = context.api;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Returns a list of reports by day with tickets status. Ommiting dates will return only the last report. Dates are expected to be in yyyy-mm-dd format.
|
|
680
|
+
*/
|
|
681
|
+
async getTicketReports({ beginDate, endDate } = {}) {
|
|
682
|
+
try {
|
|
683
|
+
const params = {
|
|
684
|
+
beginDate,
|
|
685
|
+
endDate,
|
|
686
|
+
};
|
|
687
|
+
const body = {
|
|
688
|
+
id: randomUUID(),
|
|
689
|
+
to: 'postmaster@desk.msging.net',
|
|
690
|
+
method: 'get',
|
|
691
|
+
uri: `/analytics/reports/tickets?${encodeBlipParams(params)}`,
|
|
692
|
+
};
|
|
693
|
+
const response = await this.api.post('/commands', body);
|
|
694
|
+
validateResponse(response);
|
|
695
|
+
return response.data.resource.items;
|
|
696
|
+
}
|
|
697
|
+
catch (error) {
|
|
698
|
+
throw handleError(error);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Returns ticket timings metrics. Dates are expected to be in yyyy-mm-dd format.
|
|
703
|
+
*/
|
|
704
|
+
async getTicketTimings({ beginDate, endDate } = {}) {
|
|
705
|
+
try {
|
|
706
|
+
const params = {
|
|
707
|
+
beginDate,
|
|
708
|
+
endDate,
|
|
709
|
+
};
|
|
710
|
+
const body = {
|
|
711
|
+
id: randomUUID(),
|
|
712
|
+
to: 'postmaster@desk.msging.net',
|
|
713
|
+
method: 'get',
|
|
714
|
+
uri: ['/analytics/reports/timings', encodeBlipParams(params)].filter((p) => p).join('?'),
|
|
715
|
+
};
|
|
716
|
+
const response = await this.api.post('/commands', body);
|
|
717
|
+
validateResponse(response);
|
|
718
|
+
return response.data.resource;
|
|
719
|
+
}
|
|
720
|
+
catch (error) {
|
|
721
|
+
throw handleError(error);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
632
724
|
}
|
|
633
725
|
|
|
634
726
|
class Blip {
|
|
@@ -644,6 +736,7 @@ class Blip {
|
|
|
644
736
|
ticket;
|
|
645
737
|
whatsapp;
|
|
646
738
|
monitoring;
|
|
739
|
+
analytics;
|
|
647
740
|
constructor(params) {
|
|
648
741
|
validateInstance(params);
|
|
649
742
|
this.api = axios.create({
|
|
@@ -664,6 +757,7 @@ class Blip {
|
|
|
664
757
|
this.ticket = new BlipTicket({ api: this.api });
|
|
665
758
|
this.whatsapp = new BlipWhatsapp({ api: this.api });
|
|
666
759
|
this.monitoring = new BlipMonitoring({ api: this.api });
|
|
760
|
+
this.analytics = new BlipAnalytics({ api: this.api });
|
|
667
761
|
}
|
|
668
762
|
}
|
|
669
763
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TicketAnalyticsReport, TicketAnalyticsTimings } from '../types/analytics';
|
|
3
|
+
export default class BlipAnalytics {
|
|
4
|
+
private api;
|
|
5
|
+
constructor(context: {
|
|
6
|
+
api: AxiosInstance;
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Returns a list of reports by day with tickets status. Ommiting dates will return only the last report. Dates are expected to be in yyyy-mm-dd format.
|
|
10
|
+
*/
|
|
11
|
+
getTicketReports({ beginDate, endDate }?: {
|
|
12
|
+
beginDate?: string;
|
|
13
|
+
endDate?: string;
|
|
14
|
+
}): Promise<TicketAnalyticsReport[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns ticket timings metrics. Dates are expected to be in yyyy-mm-dd format.
|
|
17
|
+
*/
|
|
18
|
+
getTicketTimings({ beginDate, endDate }?: {
|
|
19
|
+
beginDate?: string;
|
|
20
|
+
endDate?: string;
|
|
21
|
+
}): Promise<TicketAnalyticsTimings>;
|
|
22
|
+
}
|
|
@@ -10,6 +10,7 @@ import BlipTicket from './blip-ticket';
|
|
|
10
10
|
import BlipWhatsapp from './blip-whatsapp';
|
|
11
11
|
import BlipContact from './blip-contact';
|
|
12
12
|
import BlipMonitoring from './blip-monitoring';
|
|
13
|
+
import BlipAnalytics from './blip-analytics';
|
|
13
14
|
export declare class Blip {
|
|
14
15
|
private api;
|
|
15
16
|
bucket: BlipBucket;
|
|
@@ -23,5 +24,6 @@ export declare class Blip {
|
|
|
23
24
|
ticket: BlipTicket;
|
|
24
25
|
whatsapp: BlipWhatsapp;
|
|
25
26
|
monitoring: BlipMonitoring;
|
|
27
|
+
analytics: BlipAnalytics;
|
|
26
28
|
constructor(params: BlipConstructor);
|
|
27
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { MonitoredAttendantStatusMetrics, MonitoredTicketMetrics, MonitoredTickets } from '../types/monitoring';
|
|
2
|
+
import { MonitoredAttendantStatusMetrics, MonitoredTicketMetrics, MonitoredTickets, MonitoredWaitingTicketsMetrics } from '../types/monitoring';
|
|
3
3
|
export default class BlipMonitoring {
|
|
4
4
|
private api;
|
|
5
5
|
constructor(context: {
|
|
@@ -8,4 +8,5 @@ export default class BlipMonitoring {
|
|
|
8
8
|
getTickets(): Promise<MonitoredTickets>;
|
|
9
9
|
getTicketMetrics(): Promise<MonitoredTicketMetrics>;
|
|
10
10
|
getAttendantStatusMetrics(): Promise<MonitoredAttendantStatusMetrics>;
|
|
11
|
+
getWaitingTicketsMetrics(): Promise<MonitoredWaitingTicketsMetrics[]>;
|
|
11
12
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TicketSearchResult } from '../types/ticket-search-result';
|
|
2
3
|
export default class BlipTicket {
|
|
3
4
|
private api;
|
|
4
5
|
constructor(context: {
|
|
5
6
|
api: AxiosInstance;
|
|
6
7
|
});
|
|
7
|
-
search({ filter, skip, take }
|
|
8
|
+
search({ filter, skip, take }?: {
|
|
8
9
|
filter?: string;
|
|
9
10
|
skip?: number;
|
|
10
11
|
take?: number;
|
|
11
|
-
}): Promise<import("../types").Ticket[]>;
|
|
12
|
+
}): Promise<import("../types/ticket-search-result").Ticket[]>;
|
|
13
|
+
getTicket(ticketId: string): Promise<TicketSearchResult>;
|
|
12
14
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface TicketAnalyticsReport {
|
|
2
|
+
date: string;
|
|
3
|
+
waiting: number;
|
|
4
|
+
open: number;
|
|
5
|
+
closed: number;
|
|
6
|
+
closedAttendant: number;
|
|
7
|
+
closedClient: number;
|
|
8
|
+
transferred: number;
|
|
9
|
+
missed: number;
|
|
10
|
+
inAttendance: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TicketAnalyticsTimings {
|
|
13
|
+
maxQueueTime: string;
|
|
14
|
+
maxFirstResponseTime: string;
|
|
15
|
+
maxWithoutFirstResponseTime: string;
|
|
16
|
+
avgQueueTime: string;
|
|
17
|
+
avgFirstResponseTime: string;
|
|
18
|
+
avgWaitTime: string;
|
|
19
|
+
avgResponseTime: string;
|
|
20
|
+
avgAttendanceTime: string;
|
|
21
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ import { BlipRequestBody, BlipResponse, BlipArrayBody } from './blip';
|
|
|
4
4
|
import { Parameter, Component, Template } from './template';
|
|
5
5
|
import { TicketSearchResult } from './ticket-search-result';
|
|
6
6
|
import { Ticket } from './ticket';
|
|
7
|
-
|
|
7
|
+
import { MonitoredTickets, MonitoredTicketMetrics, MonitoredAttendantStatusMetrics } from './monitoring';
|
|
8
|
+
import { TicketAnalyticsReport, TicketAnalyticsTimings } from './analytics';
|
|
9
|
+
export { AttendanceHourContainer, BlipConstructor, BlipRequestBody, BlipResponse, BlipArrayBody, Parameter, Component, Template, TicketAnalyticsReport, MonitoredTickets, MonitoredTicketMetrics, MonitoredAttendantStatusMetrics, TicketSearchResult, TicketAnalyticsTimings, Ticket, };
|
|
@@ -25,3 +25,12 @@ export interface MonitoredAttendantStatusMetrics {
|
|
|
25
25
|
invisible: number;
|
|
26
26
|
offline: number;
|
|
27
27
|
}
|
|
28
|
+
export interface MonitoredWaitingTicketsMetrics {
|
|
29
|
+
id: string;
|
|
30
|
+
sequentialId: number;
|
|
31
|
+
customerIdentity: string;
|
|
32
|
+
customerName: string;
|
|
33
|
+
team: string;
|
|
34
|
+
queueTime: string;
|
|
35
|
+
priority: number;
|
|
36
|
+
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import { Ticket } from './ticket';
|
|
2
1
|
export interface TicketSearchResult {
|
|
3
2
|
total: number;
|
|
4
3
|
itemType: string;
|
|
5
4
|
items: Ticket[];
|
|
6
5
|
}
|
|
6
|
+
export interface Ticket {
|
|
7
|
+
closed: boolean;
|
|
8
|
+
customerDomain: string;
|
|
9
|
+
customerIdentity: string;
|
|
10
|
+
externalId: string;
|
|
11
|
+
id: string;
|
|
12
|
+
ownerIdentity: string;
|
|
13
|
+
priority: number;
|
|
14
|
+
provider: string;
|
|
15
|
+
rating: number;
|
|
16
|
+
sequentialId: number;
|
|
17
|
+
status: string;
|
|
18
|
+
storageDate: string;
|
|
19
|
+
team: string;
|
|
20
|
+
unreadMessages: number;
|
|
21
|
+
}
|