rez_core 3.1.105 → 3.1.106

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "3.1.105",
3
+ "version": "3.1.106",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,7 +1,10 @@
1
1
  import { Injectable, Logger } from '@nestjs/common';
2
- import axios from 'axios';
2
+ import axios, { AxiosResponse } from 'axios';
3
3
  import { randomUUID } from 'crypto';
4
- import { IntegrationResult, IntegrationStrategy } from '../integration.strategy';
4
+ import {
5
+ IntegrationResult,
6
+ IntegrationStrategy,
7
+ } from '../integration.strategy';
5
8
 
6
9
  interface TubelightWhatsAppConfig {
7
10
  userName: string;
@@ -48,29 +51,29 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
48
51
  throw new Error('Failed to authenticate with Tubelight');
49
52
  }
50
53
 
51
- const baseUrl = tubelightConfig.baseUrl || this.defaultBaseUrl;
54
+ const baseUrl = this.defaultBaseUrl;
52
55
  const url = `${baseUrl}/bulk/send`;
53
56
 
54
57
  const payload = [this.prepareMessagePayload(to, message, config)];
55
58
 
56
- console.log(payload);
59
+ console.log(payload)
57
60
 
58
- const response = await fetch(url, {
59
- method: 'POST',
60
- headers: {
61
- 'Content-Type': 'application/json',
62
- Authorization: `Bearer ${token}`,
61
+ const response = await axios.post(
62
+ url,
63
+ JSON.stringify(payload),
64
+ {
65
+ headers: {
66
+ 'Content-Type': 'application/json',
67
+ Authorization: `Bearer ${token}`,
68
+ },
69
+ timeout: 30000,
63
70
  },
64
- body: JSON.stringify(payload),
65
- signal: AbortSignal.timeout(30000),
66
- });
67
-
68
- const data = await response.json();
71
+ );
69
72
 
70
73
  if (
71
74
  response.status === 200
72
75
  ) {
73
- const messageId = data.messageId || data.id;
76
+ const messageId = response.data.messageId || response.data.id;
74
77
  this.logger.log(
75
78
  `Tubelight WhatsApp message sent successfully to ${to}, messageId: ${messageId}`,
76
79
  );
@@ -84,8 +87,8 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
84
87
  };
85
88
  } else {
86
89
  throw new Error(
87
- data?.error ||
88
- data?.message ||
90
+ response.data?.error ||
91
+ response.data?.message ||
89
92
  'Invalid response from Tubelight API',
90
93
  );
91
94
  }
@@ -171,7 +174,7 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
171
174
 
172
175
  // Add body_params if provided
173
176
  if (config.variables) {
174
- console.log('variables', config.variables);
177
+ console.log("variables", config.variables)
175
178
  try {
176
179
  // Parse JSON string
177
180
  const parsedVariables = typeof config.variables === 'string'