@wildix/xbees-connect 1.3.17-alpha.1 → 1.3.17-alpha.2

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/README.md CHANGED
@@ -518,10 +518,10 @@ client.setChatToOpen('chat_id');
518
518
 
519
519
  #### `getChannelsByEmailOrPhone(payload: IPayloadGetChannelsByEmailOrPhone): Promise<ResponseMessage>`
520
520
 
521
- Asks x-bees to look up chat channels for an email address or phone number. The integration sends `ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE` (`xBeesGetChannelsByEmailOrPhone`) with payload `{ id, type }`, where `type` is `'email'` or `'phone'`. Resolves with a `ResponseMessage` whose payload contains the matching channels returned by x-bees.
521
+ Asks x-bees to look up chat channels for an email address or phone number. The integration sends `ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE` (`xBeesGetChannelsByEmailOrPhone`) with payload `{ value, type }`, where `type` is `'email'` or `'phone'`. Resolves with a `ResponseMessage` whose payload contains the matching channels returned by x-bees.
522
522
 
523
523
  ```ts
524
- const { payload } = await client.getChannelsByEmailOrPhone({ id: 'user@example.com', type: 'email' });
524
+ const { payload } = await client.getChannelsByEmailOrPhone({ value: 'user@example.com', type: 'email' });
525
525
  ```
526
526
 
527
527
  ---
@@ -547,6 +547,12 @@ class Client {
547
547
  });
548
548
  }
549
549
  getChannelsByEmailOrPhone(payload) {
550
+ if (!payload?.value?.trim()) {
551
+ return Promise.reject(new Error('`value` is required'));
552
+ }
553
+ if (payload.type !== 'email' && payload.type !== 'phone') {
554
+ return Promise.reject(new Error('`type` must be "email" or "phone"'));
555
+ }
550
556
  return this.sendAsync({
551
557
  type: enums_1.ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE,
552
558
  payload,
@@ -541,6 +541,12 @@ export class Client {
541
541
  });
542
542
  }
543
543
  getChannelsByEmailOrPhone(payload) {
544
+ if (!payload?.value?.trim()) {
545
+ return Promise.reject(new Error('`value` is required'));
546
+ }
547
+ if (payload.type !== 'email' && payload.type !== 'phone') {
548
+ return Promise.reject(new Error('`type` must be "email" or "phone"'));
549
+ }
544
550
  return this.sendAsync({
545
551
  type: ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE,
546
552
  payload,
@@ -236,7 +236,7 @@ export interface ConnectClient {
236
236
  setChatToOpen: (chatId: string) => void;
237
237
  /**
238
238
  * Asks x-bees to look up chat channels for an email address or phone number.
239
- * @param payload - Contact identifier: `id` (email or phone value) and `type` (`'email'` or `'phone'`).
239
+ * @param payload - Contact identifier: `value` (email or phone value) and `type` (`'email'` or `'phone'`).
240
240
  */
241
241
  getChannelsByEmailOrPhone: (payload: IPayloadGetChannelsByEmailOrPhone) => Promise<ResponseMessage>;
242
242
  /**
@@ -101,7 +101,7 @@ export interface IPayloadSetChatToOpen {
101
101
  chatId: string;
102
102
  }
103
103
  export interface IPayloadGetChannelsByEmailOrPhone {
104
- id: string;
104
+ value: string;
105
105
  type: 'email' | 'phone';
106
106
  }
107
107
  export interface IPayloadContactWeightUpdate {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.3.17-alpha.1",
3
+ "version": "1.3.17-alpha.2",
4
4
  "description": "This library provides easy communication between x-bees and integrated web applications",
5
5
  "author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
6
6
  "homepage": "",