@dawntech/blip-tools 0.6.2 → 0.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/dist/index.cjs CHANGED
@@ -418,7 +418,7 @@ class BlipDispatch {
418
418
  /**
419
419
  * Sends a simple text message to an active user. For sending messages to clients who have never interacted or are inactive, use `sendTemplate` instead.
420
420
  */
421
- async sendSimpleMessage({ identity, content, metadata }) {
421
+ async sendSimpleMessage({ identity, content, metadata, }) {
422
422
  try {
423
423
  const response = await this.api.post('/messages', {
424
424
  id: crypto.randomUUID(),
@@ -805,6 +805,36 @@ class BlipAnalytics {
805
805
  }
806
806
  }
807
807
 
808
+ class BlipThreads {
809
+ api;
810
+ constructor(context) {
811
+ this.api = context.api;
812
+ }
813
+ async getThread({ identity, refreshExpiredMedia, skip, take, messageId, storageDate, direction, getFromOriginator, }) {
814
+ const params = {
815
+ refreshExpiredMedia: refreshExpiredMedia ? 'true' : 'false',
816
+ $skip: skip,
817
+ $take: take,
818
+ messageId,
819
+ storageDate,
820
+ direction,
821
+ getFromOriginator,
822
+ };
823
+ try {
824
+ const response = await this.api.post('/commands', {
825
+ id: crypto.randomUUID(),
826
+ method: 'get',
827
+ uri: createUri(`/threads/${identity}`, params),
828
+ });
829
+ validateResponse(response);
830
+ return response.data.resource.items;
831
+ }
832
+ catch (error) {
833
+ throw handleError(error);
834
+ }
835
+ }
836
+ }
837
+
808
838
  class Blip {
809
839
  api;
810
840
  bucket;
@@ -820,6 +850,7 @@ class Blip {
820
850
  monitoring;
821
851
  analytics;
822
852
  campaign;
853
+ threads;
823
854
  constructor(params) {
824
855
  validateInstance(params);
825
856
  this.api = axios.create({
@@ -842,6 +873,7 @@ class Blip {
842
873
  this.monitoring = new BlipMonitoring({ api: this.api });
843
874
  this.analytics = new BlipAnalytics({ api: this.api });
844
875
  this.campaign = new BlipCampaign({ api: this.api });
876
+ this.threads = new BlipThreads({ api: this.api });
845
877
  }
846
878
  }
847
879
 
package/dist/index.mjs CHANGED
@@ -416,7 +416,7 @@ class BlipDispatch {
416
416
  /**
417
417
  * Sends a simple text message to an active user. For sending messages to clients who have never interacted or are inactive, use `sendTemplate` instead.
418
418
  */
419
- async sendSimpleMessage({ identity, content, metadata }) {
419
+ async sendSimpleMessage({ identity, content, metadata, }) {
420
420
  try {
421
421
  const response = await this.api.post('/messages', {
422
422
  id: randomUUID(),
@@ -803,6 +803,36 @@ class BlipAnalytics {
803
803
  }
804
804
  }
805
805
 
806
+ class BlipThreads {
807
+ api;
808
+ constructor(context) {
809
+ this.api = context.api;
810
+ }
811
+ async getThread({ identity, refreshExpiredMedia, skip, take, messageId, storageDate, direction, getFromOriginator, }) {
812
+ const params = {
813
+ refreshExpiredMedia: refreshExpiredMedia ? 'true' : 'false',
814
+ $skip: skip,
815
+ $take: take,
816
+ messageId,
817
+ storageDate,
818
+ direction,
819
+ getFromOriginator,
820
+ };
821
+ try {
822
+ const response = await this.api.post('/commands', {
823
+ id: randomUUID(),
824
+ method: 'get',
825
+ uri: createUri(`/threads/${identity}`, params),
826
+ });
827
+ validateResponse(response);
828
+ return response.data.resource.items;
829
+ }
830
+ catch (error) {
831
+ throw handleError(error);
832
+ }
833
+ }
834
+ }
835
+
806
836
  class Blip {
807
837
  api;
808
838
  bucket;
@@ -818,6 +848,7 @@ class Blip {
818
848
  monitoring;
819
849
  analytics;
820
850
  campaign;
851
+ threads;
821
852
  constructor(params) {
822
853
  validateInstance(params);
823
854
  this.api = axios.create({
@@ -840,6 +871,7 @@ class Blip {
840
871
  this.monitoring = new BlipMonitoring({ api: this.api });
841
872
  this.analytics = new BlipAnalytics({ api: this.api });
842
873
  this.campaign = new BlipCampaign({ api: this.api });
874
+ this.threads = new BlipThreads({ api: this.api });
843
875
  }
844
876
  }
845
877
 
@@ -30,15 +30,15 @@ export default class BlipDispatch {
30
30
  sendTemplateMessage({ identity, template, metadata, }: {
31
31
  identity: string;
32
32
  template: Template;
33
- metadata?: string;
33
+ metadata?: Record<string, string>;
34
34
  }): Promise<void>;
35
35
  /**
36
36
  * Sends a simple text message to an active user. For sending messages to clients who have never interacted or are inactive, use `sendTemplate` instead.
37
37
  */
38
- sendSimpleMessage({ identity, content, metadata }: {
38
+ sendSimpleMessage({ identity, content, metadata, }: {
39
39
  identity: string;
40
40
  content: string;
41
- metadata?: string;
41
+ metadata?: Record<string, string>;
42
42
  }): Promise<void>;
43
43
  /**
44
44
  * Sends a text message to an active user with a midia. For sending messages to clients who have never interacted or are inactive, use `sendTemplate` instead.
@@ -48,7 +48,7 @@ export default class BlipDispatch {
48
48
  uri: string;
49
49
  identity: string;
50
50
  text: string;
51
- metadata?: string;
51
+ metadata?: Record<string, string>;
52
52
  title: string;
53
53
  aspectRatio?: string;
54
54
  size?: number;
@@ -59,6 +59,6 @@ export default class BlipDispatch {
59
59
  identity: string;
60
60
  message: string;
61
61
  buttons: string[];
62
- metadata?: string;
62
+ metadata?: Record<string, string>;
63
63
  }): Promise<void>;
64
64
  }
@@ -12,6 +12,7 @@ import BlipContact from './blip-contact';
12
12
  import BlipMonitoring from './blip-monitoring';
13
13
  import BlipAnalytics from './blip-analytics';
14
14
  import BlipCampaign from './blip-campaign';
15
+ import BlipThreads from './blip-threads';
15
16
  export declare class Blip {
16
17
  private api;
17
18
  bucket: BlipBucket;
@@ -27,5 +28,6 @@ export declare class Blip {
27
28
  monitoring: BlipMonitoring;
28
29
  analytics: BlipAnalytics;
29
30
  campaign: BlipCampaign;
31
+ threads: BlipThreads;
30
32
  constructor(params: BlipConstructor);
31
33
  }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ThreadItem } from '../types/threads';
3
+ export default class BlipThreads {
4
+ private api;
5
+ constructor(context: {
6
+ api: AxiosInstance;
7
+ });
8
+ getThread({ identity, refreshExpiredMedia, skip, take, messageId, storageDate, direction, getFromOriginator, }: {
9
+ identity: string;
10
+ refreshExpiredMedia?: boolean;
11
+ skip?: number;
12
+ take?: number;
13
+ messageId?: string;
14
+ storageDate?: string;
15
+ direction?: 'asc' | 'desc';
16
+ getFromOriginator?: string;
17
+ }): Promise<ThreadItem[]>;
18
+ }
@@ -0,0 +1,13 @@
1
+ export interface ThreadItem {
2
+ id: string;
3
+ direction: string;
4
+ type: string;
5
+ content: unknown;
6
+ date: string;
7
+ status: string;
8
+ metadata: Record<string, string>;
9
+ reason?: {
10
+ code: number;
11
+ description: string;
12
+ };
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawntech/blip-tools",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Node package for Blip API",
5
5
  "exports": {
6
6
  ".": {