@hellotext/hellotext 2.4.53 → 2.5.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/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface HellotextConfig {
6
6
  successMessage?: boolean | string
7
7
  }
8
8
  webchat?: false | HellotextWebchatConfig
9
+ whatsappWidget?: false | HellotextWhatsAppWidgetConfig
9
10
  session?: string
10
11
  autoGenerateSession?: boolean
11
12
  }
@@ -51,6 +52,21 @@ export interface HellotextWebchatConfig {
51
52
  strategy?: HellotextWebchatStrategy
52
53
  }
53
54
 
55
+ export interface HellotextWhatsAppWidgetAppearance {
56
+ launcher?: {
57
+ iconUrl?: string | null
58
+ }
59
+ }
60
+
61
+ export interface HellotextWhatsAppWidgetConfig {
62
+ id?: string
63
+ container?: string
64
+ placement?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
65
+ number?: string | null
66
+ body?: string | null
67
+ appearance?: HellotextWhatsAppWidgetAppearance
68
+ }
69
+
54
70
  export interface HellotextBusinessCountry {
55
71
  code?: string
56
72
  prefix?: string
@@ -64,6 +80,7 @@ export interface HellotextBusinessData {
64
80
  locale?: string
65
81
  style_url?: string
66
82
  webchat?: HellotextWebchatConfig | null
83
+ whatsapp?: HellotextWhatsAppWidgetConfig | null
67
84
  whitelist?: string | string[] | null
68
85
  subscription?: string | null
69
86
  [key: string]: any
@@ -124,6 +141,7 @@ declare class Hellotext {
124
141
  static forms: any
125
142
  static business: HellotextBusiness
126
143
  static webchat: any
144
+ static whatsapp: any
127
145
  }
128
146
 
129
147
  export declare class User {
package/lib/api/index.cjs CHANGED
@@ -16,6 +16,7 @@ var _events = _interopRequireDefault(require("./events"));
16
16
  var _forms = _interopRequireDefault(require("./forms"));
17
17
  var _identifications = _interopRequireDefault(require("./identifications"));
18
18
  var _webchats = _interopRequireDefault(require("./webchats"));
19
+ var _whatsapp_widgets = _interopRequireDefault(require("./whatsapp_widgets"));
19
20
  var _acks = _interopRequireDefault(require("./acks"));
20
21
  var _response = require("./response");
21
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -68,6 +69,11 @@ let API = /*#__PURE__*/function () {
68
69
  get: function () {
69
70
  return _webchats.default;
70
71
  }
72
+ }, {
73
+ key: "whatsappWidgets",
74
+ get: function () {
75
+ return _whatsapp_widgets.default;
76
+ }
71
77
  }, {
72
78
  key: "identifications",
73
79
  get: function () {
package/lib/api/index.js CHANGED
@@ -8,6 +8,7 @@ import EventsAPI from './events';
8
8
  import FormsAPI from './forms';
9
9
  import IdentificationsAPI from './identifications';
10
10
  import WebchatsAPI from './webchats';
11
+ import WhatsAppWidgetsAPI from './whatsapp_widgets';
11
12
  import AcksAPI from './acks';
12
13
 
13
14
  // Browsers keep `fetch(..., { keepalive: true })` requests alive during page
@@ -54,6 +55,11 @@ var API = /*#__PURE__*/function () {
54
55
  get: function get() {
55
56
  return WebchatsAPI;
56
57
  }
58
+ }, {
59
+ key: "whatsappWidgets",
60
+ get: function get() {
61
+ return WhatsAppWidgetsAPI;
62
+ }
57
63
  }, {
58
64
  key: "identifications",
59
65
  get: function get() {
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _core = require("../core");
8
+ var _hellotext = _interopRequireDefault(require("../hellotext"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ let WhatsAppWidgetsAPI = /*#__PURE__*/function () {
16
+ function WhatsAppWidgetsAPI() {
17
+ _classCallCheck(this, WhatsAppWidgetsAPI);
18
+ }
19
+ _createClass(WhatsAppWidgetsAPI, null, [{
20
+ key: "endpoint",
21
+ get: function () {
22
+ return _core.Configuration.endpoint('public/widgets/whatsapp');
23
+ }
24
+ }, {
25
+ key: "get",
26
+ value: async function get(id) {
27
+ const url = new URL(`${this.endpoint}/${id}`);
28
+ url.searchParams.append('locale', _core.Locale.toString());
29
+ url.searchParams.append('placement', _core.Configuration.whatsapp.placement);
30
+ this.appendWhatsAppOverrides(url);
31
+ const response = await this.fetchWidget(url);
32
+ if (!response.ok) return null;
33
+ const data = await this.parseWidgetResponse(response);
34
+ if (!data) return null;
35
+ if (!_hellotext.default.business.data) {
36
+ _hellotext.default.business.setData(data.business);
37
+ _hellotext.default.business.setLocale(data.locale);
38
+ }
39
+ return new DOMParser().parseFromString(data.html, 'text/html').querySelector('article');
40
+ }
41
+ }, {
42
+ key: "appendWhatsAppOverrides",
43
+ value: function appendWhatsAppOverrides(url) {
44
+ var _appearance$launcher;
45
+ const {
46
+ appearance,
47
+ body,
48
+ number
49
+ } = _core.Configuration.whatsapp;
50
+ this.appendIfSupplied(url, 'whatsapp[appearance][launcher][icon_url]', (_appearance$launcher = appearance.launcher) === null || _appearance$launcher === void 0 ? void 0 : _appearance$launcher.iconUrl);
51
+ this.appendIfSupplied(url, 'whatsapp[number]', number);
52
+ this.appendIfSupplied(url, 'whatsapp[body]', body);
53
+ }
54
+ }, {
55
+ key: "appendIfSupplied",
56
+ value: function appendIfSupplied(url, key, value) {
57
+ if (value === undefined || value === null) return;
58
+ url.searchParams.append(key, String(value));
59
+ }
60
+ }, {
61
+ key: "fetchWidget",
62
+ value: async function fetchWidget(url) {
63
+ try {
64
+ return await fetch(url, {
65
+ method: 'GET',
66
+ headers: _hellotext.default.headers
67
+ });
68
+ } catch (_) {
69
+ return {
70
+ ok: false
71
+ };
72
+ }
73
+ }
74
+ }, {
75
+ key: "parseWidgetResponse",
76
+ value: async function parseWidgetResponse(response) {
77
+ try {
78
+ return await response.json();
79
+ } catch (_) {
80
+ return null;
81
+ }
82
+ }
83
+ }]);
84
+ return WhatsAppWidgetsAPI;
85
+ }();
86
+ var _default = WhatsAppWidgetsAPI;
87
+ exports.default = _default;
@@ -0,0 +1,99 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ import { Configuration, Locale } from '../core';
9
+ import Hellotext from '../hellotext';
10
+ var WhatsAppWidgetsAPI = /*#__PURE__*/function () {
11
+ function WhatsAppWidgetsAPI() {
12
+ _classCallCheck(this, WhatsAppWidgetsAPI);
13
+ }
14
+ _createClass(WhatsAppWidgetsAPI, null, [{
15
+ key: "endpoint",
16
+ get: function get() {
17
+ return Configuration.endpoint('public/widgets/whatsapp');
18
+ }
19
+ }, {
20
+ key: "get",
21
+ value: function () {
22
+ var _get = _asyncToGenerator(function* (id) {
23
+ var url = new URL("".concat(this.endpoint, "/").concat(id));
24
+ url.searchParams.append('locale', Locale.toString());
25
+ url.searchParams.append('placement', Configuration.whatsapp.placement);
26
+ this.appendWhatsAppOverrides(url);
27
+ var response = yield this.fetchWidget(url);
28
+ if (!response.ok) return null;
29
+ var data = yield this.parseWidgetResponse(response);
30
+ if (!data) return null;
31
+ if (!Hellotext.business.data) {
32
+ Hellotext.business.setData(data.business);
33
+ Hellotext.business.setLocale(data.locale);
34
+ }
35
+ return new DOMParser().parseFromString(data.html, 'text/html').querySelector('article');
36
+ });
37
+ function get(_x) {
38
+ return _get.apply(this, arguments);
39
+ }
40
+ return get;
41
+ }()
42
+ }, {
43
+ key: "appendWhatsAppOverrides",
44
+ value: function appendWhatsAppOverrides(url) {
45
+ var _appearance$launcher;
46
+ var {
47
+ appearance,
48
+ body,
49
+ number
50
+ } = Configuration.whatsapp;
51
+ this.appendIfSupplied(url, 'whatsapp[appearance][launcher][icon_url]', (_appearance$launcher = appearance.launcher) === null || _appearance$launcher === void 0 ? void 0 : _appearance$launcher.iconUrl);
52
+ this.appendIfSupplied(url, 'whatsapp[number]', number);
53
+ this.appendIfSupplied(url, 'whatsapp[body]', body);
54
+ }
55
+ }, {
56
+ key: "appendIfSupplied",
57
+ value: function appendIfSupplied(url, key, value) {
58
+ if (value === undefined || value === null) return;
59
+ url.searchParams.append(key, String(value));
60
+ }
61
+ }, {
62
+ key: "fetchWidget",
63
+ value: function () {
64
+ var _fetchWidget = _asyncToGenerator(function* (url) {
65
+ try {
66
+ return yield fetch(url, {
67
+ method: 'GET',
68
+ headers: Hellotext.headers
69
+ });
70
+ } catch (_) {
71
+ return {
72
+ ok: false
73
+ };
74
+ }
75
+ });
76
+ function fetchWidget(_x2) {
77
+ return _fetchWidget.apply(this, arguments);
78
+ }
79
+ return fetchWidget;
80
+ }()
81
+ }, {
82
+ key: "parseWidgetResponse",
83
+ value: function () {
84
+ var _parseWidgetResponse = _asyncToGenerator(function* (response) {
85
+ try {
86
+ return yield response.json();
87
+ } catch (_) {
88
+ return null;
89
+ }
90
+ });
91
+ function parseWidgetResponse(_x3) {
92
+ return _parseWidgetResponse.apply(this, arguments);
93
+ }
94
+ return parseWidgetResponse;
95
+ }()
96
+ }]);
97
+ return WhatsAppWidgetsAPI;
98
+ }();
99
+ export default WhatsAppWidgetsAPI;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WhatsApp = void 0;
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ /**
13
+ * @typedef {'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'} Placement
14
+ * @description Valid placements for the WhatsApp widget.
15
+ */
16
+
17
+ /**
18
+ * @enum {Placement}
19
+ */
20
+ const placements = {
21
+ TOP_LEFT: 'top-left',
22
+ TOP_RIGHT: 'top-right',
23
+ BOTTOM_LEFT: 'bottom-left',
24
+ BOTTOM_RIGHT: 'bottom-right'
25
+ };
26
+
27
+ /**
28
+ * @typedef {Object} WhatsAppWidgetAppearance
29
+ * @property {Object} [launcher] - Launcher appearance overrides.
30
+ * @property {string} [launcher.iconUrl] - Image URL used for the launcher icon.
31
+ */
32
+
33
+ /**
34
+ * @class WhatsApp
35
+ * @classdesc Configuration for the standalone WhatsApp widget.
36
+ * @property {String} id - The id of the WhatsApp widget.
37
+ * @property {String} container - The container to append the widget to, defaults to 'body'.
38
+ * @property {Placement} placement - The placement of the widget, defaults to 'bottom-right'.
39
+ * @property {String} number - WhatsApp number used by the widget link.
40
+ * @property {String} body - Prefilled WhatsApp compose text.
41
+ * @property {WhatsAppWidgetAppearance} appearance - Appearance overrides.
42
+ */
43
+ let WhatsApp = /*#__PURE__*/function () {
44
+ function WhatsApp() {
45
+ _classCallCheck(this, WhatsApp);
46
+ }
47
+ _createClass(WhatsApp, null, [{
48
+ key: "id",
49
+ get: function () {
50
+ return this._id;
51
+ },
52
+ set: function (value) {
53
+ this._id = value;
54
+ }
55
+ }, {
56
+ key: "container",
57
+ get: function () {
58
+ return this._container;
59
+ },
60
+ set: function (value) {
61
+ this._container = value;
62
+ }
63
+ }, {
64
+ key: "placement",
65
+ get: function () {
66
+ return this._placement;
67
+ },
68
+ set: function (value) {
69
+ if (!Object.values(placements).includes(value)) {
70
+ throw new Error(`Invalid placement value: ${value}`);
71
+ }
72
+ this._placement = value;
73
+ }
74
+ }, {
75
+ key: "appearance",
76
+ get: function () {
77
+ return this._appearance;
78
+ },
79
+ set: function (value) {
80
+ if (!this.isPlainObject(value)) {
81
+ throw new Error('Appearance must be an object');
82
+ }
83
+ Object.entries(value).forEach(([key, nestedValue]) => {
84
+ if (key !== 'launcher') {
85
+ throw new Error(`Invalid appearance property: ${key}`);
86
+ }
87
+ if (!this.isPlainObject(nestedValue)) {
88
+ throw new Error(`Appearance ${key} must be an object`);
89
+ }
90
+ Object.entries(nestedValue).forEach(([nestedKey, propertyValue]) => {
91
+ if (nestedKey !== 'iconUrl') {
92
+ throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
93
+ }
94
+ if (propertyValue == null) {
95
+ return;
96
+ }
97
+ if (typeof propertyValue !== 'string') {
98
+ throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
99
+ }
100
+ });
101
+ });
102
+ this._appearance = value;
103
+ }
104
+ }, {
105
+ key: "number",
106
+ get: function () {
107
+ return this._number;
108
+ },
109
+ set: function (value) {
110
+ if (value != null && typeof value !== 'string') {
111
+ throw new Error(`Invalid number value: ${value}`);
112
+ }
113
+ this._number = value;
114
+ }
115
+ }, {
116
+ key: "body",
117
+ get: function () {
118
+ return this._body;
119
+ },
120
+ set: function (value) {
121
+ if (value != null && typeof value !== 'string') {
122
+ throw new Error(`Invalid body value: ${value}`);
123
+ }
124
+ this._body = value;
125
+ }
126
+ }, {
127
+ key: "assign",
128
+ value: function assign(props) {
129
+ if (props) {
130
+ Object.entries(props).forEach(([key, value]) => {
131
+ this[key] = value;
132
+ });
133
+ }
134
+ return this;
135
+ }
136
+ }, {
137
+ key: "isPlainObject",
138
+ value: function isPlainObject(value) {
139
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
140
+ }
141
+ }]);
142
+ return WhatsApp;
143
+ }();
144
+ exports.WhatsApp = WhatsApp;
145
+ WhatsApp._id = void 0;
146
+ WhatsApp._container = 'body';
147
+ WhatsApp._placement = 'bottom-right';
148
+ WhatsApp._appearance = {};
149
+ WhatsApp._number = null;
150
+ WhatsApp._body = null;
@@ -0,0 +1,147 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ /**
7
+ * @typedef {'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'} Placement
8
+ * @description Valid placements for the WhatsApp widget.
9
+ */
10
+
11
+ /**
12
+ * @enum {Placement}
13
+ */
14
+ var placements = {
15
+ TOP_LEFT: 'top-left',
16
+ TOP_RIGHT: 'top-right',
17
+ BOTTOM_LEFT: 'bottom-left',
18
+ BOTTOM_RIGHT: 'bottom-right'
19
+ };
20
+
21
+ /**
22
+ * @typedef {Object} WhatsAppWidgetAppearance
23
+ * @property {Object} [launcher] - Launcher appearance overrides.
24
+ * @property {string} [launcher.iconUrl] - Image URL used for the launcher icon.
25
+ */
26
+
27
+ /**
28
+ * @class WhatsApp
29
+ * @classdesc Configuration for the standalone WhatsApp widget.
30
+ * @property {String} id - The id of the WhatsApp widget.
31
+ * @property {String} container - The container to append the widget to, defaults to 'body'.
32
+ * @property {Placement} placement - The placement of the widget, defaults to 'bottom-right'.
33
+ * @property {String} number - WhatsApp number used by the widget link.
34
+ * @property {String} body - Prefilled WhatsApp compose text.
35
+ * @property {WhatsAppWidgetAppearance} appearance - Appearance overrides.
36
+ */
37
+ var WhatsApp = /*#__PURE__*/function () {
38
+ function WhatsApp() {
39
+ _classCallCheck(this, WhatsApp);
40
+ }
41
+ _createClass(WhatsApp, null, [{
42
+ key: "id",
43
+ get: function get() {
44
+ return this._id;
45
+ },
46
+ set: function set(value) {
47
+ this._id = value;
48
+ }
49
+ }, {
50
+ key: "container",
51
+ get: function get() {
52
+ return this._container;
53
+ },
54
+ set: function set(value) {
55
+ this._container = value;
56
+ }
57
+ }, {
58
+ key: "placement",
59
+ get: function get() {
60
+ return this._placement;
61
+ },
62
+ set: function set(value) {
63
+ if (!Object.values(placements).includes(value)) {
64
+ throw new Error("Invalid placement value: ".concat(value));
65
+ }
66
+ this._placement = value;
67
+ }
68
+ }, {
69
+ key: "appearance",
70
+ get: function get() {
71
+ return this._appearance;
72
+ },
73
+ set: function set(value) {
74
+ if (!this.isPlainObject(value)) {
75
+ throw new Error('Appearance must be an object');
76
+ }
77
+ Object.entries(value).forEach(_ref => {
78
+ var [key, nestedValue] = _ref;
79
+ if (key !== 'launcher') {
80
+ throw new Error("Invalid appearance property: ".concat(key));
81
+ }
82
+ if (!this.isPlainObject(nestedValue)) {
83
+ throw new Error("Appearance ".concat(key, " must be an object"));
84
+ }
85
+ Object.entries(nestedValue).forEach(_ref2 => {
86
+ var [nestedKey, propertyValue] = _ref2;
87
+ if (nestedKey !== 'iconUrl') {
88
+ throw new Error("Invalid appearance launcher property: ".concat(nestedKey));
89
+ }
90
+ if (propertyValue == null) {
91
+ return;
92
+ }
93
+ if (typeof propertyValue !== 'string') {
94
+ throw new Error("Invalid appearance ".concat(key, ".").concat(nestedKey, " value: ").concat(propertyValue));
95
+ }
96
+ });
97
+ });
98
+ this._appearance = value;
99
+ }
100
+ }, {
101
+ key: "number",
102
+ get: function get() {
103
+ return this._number;
104
+ },
105
+ set: function set(value) {
106
+ if (value != null && typeof value !== 'string') {
107
+ throw new Error("Invalid number value: ".concat(value));
108
+ }
109
+ this._number = value;
110
+ }
111
+ }, {
112
+ key: "body",
113
+ get: function get() {
114
+ return this._body;
115
+ },
116
+ set: function set(value) {
117
+ if (value != null && typeof value !== 'string') {
118
+ throw new Error("Invalid body value: ".concat(value));
119
+ }
120
+ this._body = value;
121
+ }
122
+ }, {
123
+ key: "assign",
124
+ value: function assign(props) {
125
+ if (props) {
126
+ Object.entries(props).forEach(_ref3 => {
127
+ var [key, value] = _ref3;
128
+ this[key] = value;
129
+ });
130
+ }
131
+ return this;
132
+ }
133
+ }, {
134
+ key: "isPlainObject",
135
+ value: function isPlainObject(value) {
136
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
137
+ }
138
+ }]);
139
+ return WhatsApp;
140
+ }();
141
+ WhatsApp._id = void 0;
142
+ WhatsApp._container = 'body';
143
+ WhatsApp._placement = 'bottom-right';
144
+ WhatsApp._appearance = {};
145
+ WhatsApp._number = null;
146
+ WhatsApp._body = null;
147
+ export { WhatsApp };
@@ -7,6 +7,7 @@ exports.Configuration = void 0;
7
7
  var _forms = require("./configuration/forms");
8
8
  var _locale = require("./configuration/locale");
9
9
  var _webchat = require("./configuration/webchat");
10
+ var _whatsapp = require("./configuration/whatsapp");
10
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
12
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -20,6 +21,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
20
21
  * @property {String} [session] - session id
21
22
  * @property {Forms} [forms] - form configuration
22
23
  * @property {Webchat} [webchat] - webchat configuration
24
+ * @property {WhatsApp} [whatsappWidget] - WhatsApp widget configuration
23
25
  * @property {Locale} [locale] - locale configuration
24
26
  */
25
27
  let Configuration = /*#__PURE__*/function () {
@@ -45,6 +47,8 @@ let Configuration = /*#__PURE__*/function () {
45
47
  this.forms = _forms.Forms.assign(value);
46
48
  } else if (key === 'webchat') {
47
49
  this.webchat = _webchat.Webchat.assign(value);
50
+ } else if (key === 'whatsappWidget') {
51
+ this.whatsapp = _whatsapp.WhatsApp.assign(value);
48
52
  } else {
49
53
  this[key] = value;
50
54
  }
@@ -92,4 +96,5 @@ Configuration.actionCableUrl = 'wss://www.hellotext.com/cable';
92
96
  Configuration.autoGenerateSession = true;
93
97
  Configuration.session = null;
94
98
  Configuration.forms = _forms.Forms;
95
- Configuration.webchat = _webchat.Webchat;
99
+ Configuration.webchat = _webchat.Webchat;
100
+ Configuration.whatsapp = _whatsapp.WhatsApp;
@@ -6,6 +6,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
6
6
  import { Forms } from './configuration/forms';
7
7
  import { Locale } from './configuration/locale';
8
8
  import { Webchat } from './configuration/webchat';
9
+ import { WhatsApp } from './configuration/whatsapp';
9
10
 
10
11
  /**
11
12
  * @class Configuration
@@ -15,6 +16,7 @@ import { Webchat } from './configuration/webchat';
15
16
  * @property {String} [session] - session id
16
17
  * @property {Forms} [forms] - form configuration
17
18
  * @property {Webchat} [webchat] - webchat configuration
19
+ * @property {WhatsApp} [whatsappWidget] - WhatsApp widget configuration
18
20
  * @property {Locale} [locale] - locale configuration
19
21
  */
20
22
  var Configuration = /*#__PURE__*/function () {
@@ -41,6 +43,8 @@ var Configuration = /*#__PURE__*/function () {
41
43
  this.forms = Forms.assign(value);
42
44
  } else if (key === 'webchat') {
43
45
  this.webchat = Webchat.assign(value);
46
+ } else if (key === 'whatsappWidget') {
47
+ this.whatsapp = WhatsApp.assign(value);
44
48
  } else {
45
49
  this[key] = value;
46
50
  }
@@ -88,4 +92,5 @@ Configuration.autoGenerateSession = true;
88
92
  Configuration.session = null;
89
93
  Configuration.forms = Forms;
90
94
  Configuration.webchat = Webchat;
95
+ Configuration.whatsapp = WhatsApp;
91
96
  export { Configuration };
@@ -27,8 +27,15 @@ Object.defineProperty(exports, "Webchat", {
27
27
  return _webchat.Webchat;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "WhatsApp", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _whatsapp.WhatsApp;
34
+ }
35
+ });
30
36
  var _configuration = require("./configuration");
31
37
  var _locale = require("./configuration/locale");
32
38
  var _webchat = require("./configuration/webchat");
39
+ var _whatsapp = require("./configuration/whatsapp");
33
40
  var _event = _interopRequireDefault(require("./event"));
34
41
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/lib/core/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Configuration } from './configuration';
2
2
  export { Locale } from './configuration/locale';
3
3
  export { Webchat } from './configuration/webchat';
4
+ export { WhatsApp } from './configuration/whatsapp';
4
5
  export { default as Event } from './event';