@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.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.
Files changed (158) hide show
  1. package/README.md +38 -28
  2. package/builds/browser.js +4327 -7903
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +629 -102
  5. package/builds/lib.js +4319 -7904
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +27540 -41958
  8. package/builds/twilio-conversations.min.js +200 -1
  9. package/dist/aggregated-delivery-receipt.js +10 -1
  10. package/dist/aggregated-delivery-receipt.js.map +1 -1
  11. package/dist/channel-metadata-client.js +192 -0
  12. package/dist/channel-metadata-client.js.map +1 -0
  13. package/dist/client.js +75 -123
  14. package/dist/client.js.map +1 -1
  15. package/dist/command-executor.js +81 -20
  16. package/dist/command-executor.js.map +1 -1
  17. package/dist/configuration.js +14 -3
  18. package/dist/configuration.js.map +1 -1
  19. package/dist/content-client.js +184 -0
  20. package/dist/content-client.js.map +1 -0
  21. package/dist/content-template.js +310 -0
  22. package/dist/content-template.js.map +1 -0
  23. package/dist/conversation.js +105 -22
  24. package/dist/conversation.js.map +1 -1
  25. package/dist/data/conversations.js +43 -5
  26. package/dist/data/conversations.js.map +1 -1
  27. package/dist/data/messages.js +26 -19
  28. package/dist/data/messages.js.map +1 -1
  29. package/dist/data/participants.js +15 -4
  30. package/dist/data/participants.js.map +1 -1
  31. package/dist/data/users.js +11 -2
  32. package/dist/data/users.js.map +1 -1
  33. package/dist/detailed-delivery-receipt.js +9 -0
  34. package/dist/detailed-delivery-receipt.js.map +1 -1
  35. package/dist/index.js +20 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/interfaces/notification-types.js +9 -0
  38. package/dist/interfaces/notification-types.js.map +1 -1
  39. package/dist/interfaces/{attributes.js → rules.js} +26 -7
  40. package/dist/interfaces/rules.js.map +1 -0
  41. package/dist/logger.js +9 -0
  42. package/dist/logger.js.map +1 -1
  43. package/dist/media.js +9 -0
  44. package/dist/media.js.map +1 -1
  45. package/dist/message-builder.js +77 -6
  46. package/dist/message-builder.js.map +1 -1
  47. package/dist/message.js +115 -22
  48. package/dist/message.js.map +1 -1
  49. package/dist/node_modules/quick-lru/index.js +265 -0
  50. package/dist/node_modules/quick-lru/index.js.map +1 -0
  51. package/dist/node_modules/tslib/tslib.es6.js +9 -0
  52. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  53. package/dist/packages/conversations/package.json.js +10 -1
  54. package/dist/packages/conversations/package.json.js.map +1 -1
  55. package/dist/participant.js +45 -36
  56. package/dist/participant.js.map +1 -1
  57. package/dist/push-notification.js +9 -0
  58. package/dist/push-notification.js.map +1 -1
  59. package/dist/rest-paginator.js +20 -11
  60. package/dist/rest-paginator.js.map +1 -1
  61. package/dist/services/network.js +110 -11
  62. package/dist/services/network.js.map +1 -1
  63. package/dist/services/typing-indicator.js +22 -5
  64. package/dist/services/typing-indicator.js.map +1 -1
  65. package/dist/unsent-message.js +9 -0
  66. package/dist/unsent-message.js.map +1 -1
  67. package/dist/user.js +20 -3
  68. package/dist/user.js.map +1 -1
  69. package/dist/util/deferred.js +9 -0
  70. package/dist/util/deferred.js.map +1 -1
  71. package/dist/util/index.js +9 -0
  72. package/dist/util/index.js.map +1 -1
  73. package/docs/.nojekyll +1 -0
  74. package/docs/assets/highlight.css +113 -0
  75. package/docs/assets/main.js +58 -0
  76. package/docs/assets/search.js +1 -0
  77. package/docs/assets/style.css +1279 -0
  78. package/docs/classes/AggregatedDeliveryReceipt.html +144 -3182
  79. package/docs/classes/CancellablePromise.html +224 -3209
  80. package/docs/classes/CancellationError.html +112 -0
  81. package/docs/classes/ChannelMetadata.html +67 -0
  82. package/docs/classes/Client.html +701 -4237
  83. package/docs/classes/ContentTemplate.html +97 -0
  84. package/docs/classes/ContentTemplateVariable.html +90 -0
  85. package/docs/classes/Conversation.html +768 -4352
  86. package/docs/classes/DetailedDeliveryReceipt.html +116 -3162
  87. package/docs/classes/Media.html +119 -3165
  88. package/docs/classes/Message.html +417 -3730
  89. package/docs/classes/MessageBuilder.html +208 -3274
  90. package/docs/classes/Participant.html +258 -3442
  91. package/docs/classes/PushNotification.html +101 -3129
  92. package/docs/classes/RestPaginator.html +120 -3158
  93. package/docs/classes/UnsentMessage.html +63 -3040
  94. package/docs/classes/User.html +209 -3347
  95. package/docs/index.html +146 -3502
  96. package/docs/interfaces/ClientOptions.html +66 -3033
  97. package/docs/interfaces/ConversationBindings.html +109 -3000
  98. package/docs/interfaces/ConversationEmailBinding.html +109 -3000
  99. package/docs/interfaces/ConversationLimits.html +87 -3097
  100. package/docs/interfaces/ConversationState.html +66 -3049
  101. package/docs/interfaces/ConversationUpdatedEventArgs.html +109 -3000
  102. package/docs/interfaces/CreateConversationOptions.html +73 -3065
  103. package/docs/interfaces/LastMessage.html +66 -3049
  104. package/docs/interfaces/Paginator.html +110 -3139
  105. package/docs/interfaces/ParticipantBindingOptions.html +110 -0
  106. package/docs/interfaces/ParticipantBindings.html +109 -3000
  107. package/docs/interfaces/ParticipantEmailBinding.html +109 -3000
  108. package/docs/interfaces/PushNotificationData.html +94 -3113
  109. package/docs/interfaces/SendEmailOptions.html +59 -3033
  110. package/docs/interfaces/SendMediaOptions.html +75 -3067
  111. package/docs/modules.html +180 -3509
  112. package/docs/types/ChannelType.html +106 -0
  113. package/docs/types/ConnectionState.html +115 -0
  114. package/docs/types/ContentData.html +106 -0
  115. package/docs/types/ContentDataAction.html +107 -0
  116. package/docs/types/ContentDataActionOther.html +121 -0
  117. package/docs/types/ContentDataActionPhone.html +128 -0
  118. package/docs/types/ContentDataActionReply.html +133 -0
  119. package/docs/types/ContentDataActionUrl.html +128 -0
  120. package/docs/types/ContentDataCallToAction.html +131 -0
  121. package/docs/types/ContentDataCard.html +137 -0
  122. package/docs/types/ContentDataListItem.html +121 -0
  123. package/docs/types/ContentDataListPicker.html +134 -0
  124. package/docs/types/ContentDataLocation.html +134 -0
  125. package/docs/types/ContentDataMedia.html +129 -0
  126. package/docs/types/ContentDataOther.html +121 -0
  127. package/docs/types/ContentDataQuickReply.html +131 -0
  128. package/docs/types/ContentDataReply.html +119 -0
  129. package/docs/types/ContentDataText.html +125 -0
  130. package/docs/types/ConversationStatus.html +107 -0
  131. package/docs/types/ConversationUpdateReason.html +106 -0
  132. package/docs/types/DeliveryAmount.html +106 -0
  133. package/docs/types/DeliveryStatus.html +106 -0
  134. package/docs/types/JSONArray.html +106 -0
  135. package/docs/types/JSONObject.html +111 -0
  136. package/docs/types/JSONValue.html +106 -0
  137. package/docs/types/LogLevel.html +106 -0
  138. package/docs/types/MediaCategory.html +106 -0
  139. package/docs/types/MessageType.html +106 -0
  140. package/docs/types/MessageUpdateReason.html +106 -0
  141. package/docs/types/NotificationLevel.html +109 -0
  142. package/docs/types/NotificationsChannelType.html +110 -0
  143. package/docs/types/ParticipantEmailLevel.html +108 -0
  144. package/docs/types/ParticipantType.html +107 -0
  145. package/docs/types/ParticipantUpdateReason.html +106 -0
  146. package/docs/types/PushNotificationType.html +106 -0
  147. package/docs/types/State.html +110 -0
  148. package/docs/types/UserUpdateReason.html +106 -0
  149. package/package.json +22 -17
  150. package/CHANGELOG.md +0 -509
  151. package/dist/interfaces/attributes.js.map +0 -1
  152. package/docs/assets/css/main.css +0 -2660
  153. package/docs/assets/images/icons.png +0 -0
  154. package/docs/assets/images/icons@2x.png +0 -0
  155. package/docs/assets/images/widgets.png +0 -0
  156. package/docs/assets/images/widgets@2x.png +0 -0
  157. package/docs/assets/js/main.js +0 -248
  158. package/docs/assets/js/search.js +0 -1
@@ -0,0 +1,184 @@
1
+ /*
2
+ @license
3
+ The following license applies to all parts of this software except as
4
+ documented below.
5
+
6
+ Copyright (c) 2019, Twilio, inc.
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are
11
+ met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in
18
+ the documentation and/or other materials provided with the
19
+ distribution.
20
+
21
+ 3. Neither the name of Twilio nor the names of its contributors may
22
+ be used to endorse or promote products derived from this software
23
+ without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ This software includes javascript-state-machine under the following license.
38
+
39
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ of this software and associated documentation files (the "Software"), to deal
43
+ in the Software without restriction, including without limitation the rights
44
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ copies of the Software, and to permit persons to whom the Software is
46
+ furnished to do so, subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in all
49
+ copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57
+
58
+ This software includes loglevel under the following license.
59
+
60
+ Copyright (c) 2013 Tim Perry
61
+
62
+ Permission is hereby granted, free of charge, to any person
63
+ obtaining a copy of this software and associated documentation
64
+ files (the "Software"), to deal in the Software without
65
+ restriction, including without limitation the rights to use,
66
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
67
+ copies of the Software, and to permit persons to whom the
68
+ Software is furnished to do so, subject to the following
69
+ conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
76
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
78
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
81
+ OTHER DEALINGS IN THE SOFTWARE.
82
+
83
+ This software includes q under the following license.
84
+
85
+ Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to
88
+ deal in the Software without restriction, including without limitation the
89
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
90
+ sell copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
101
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
102
+ IN THE SOFTWARE.
103
+
104
+ This software includes platform.js under the following license.
105
+
106
+ Copyright 2014 Benjamin Tan <https://d10.github.io/>
107
+ Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining
110
+ a copy of this software and associated documentation files (the
111
+ "Software"), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, sublicense, and/or sell copies of the Software, and to
114
+ permit persons to whom the Software is furnished to do so, subject to
115
+ the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be
118
+ included in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
123
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
124
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
125
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
126
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
+
128
+ */
129
+ 'use strict';
130
+
131
+ var global =
132
+ typeof global !== "undefined"
133
+ ? global
134
+ : typeof self !== "undefined"
135
+ ? self
136
+ : typeof window !== "undefined"
137
+ ? window
138
+ : {};
139
+
140
+ Object.defineProperty(exports, '__esModule', { value: true });
141
+
142
+ var contentTemplate = require('./content-template.js');
143
+ var index = require('./util/index.js');
144
+
145
+ class ContentClient {
146
+ constructor(_services, _pageSize = 100, _cacheTtlMs = 5000) {
147
+ this._services = _services;
148
+ this._pageSize = _pageSize;
149
+ this._cacheTtlMs = _cacheTtlMs;
150
+ this._cachedTemplates = null;
151
+ }
152
+ async getContentTemplates() {
153
+ if (this._cachedTemplates !== null) {
154
+ return this._cachedTemplates;
155
+ }
156
+ let [templatesPage, nextToken] = await this._fetchContentTemplates();
157
+ let templates = templatesPage;
158
+ while (nextToken !== null) {
159
+ [templatesPage, nextToken] = await this._fetchContentTemplates(nextToken);
160
+ templates = [...templates, ...templatesPage];
161
+ }
162
+ this._cachedTemplates = Object.freeze(templates);
163
+ setTimeout(() => {
164
+ this._cachedTemplates = null;
165
+ }, this._cacheTtlMs);
166
+ return templates;
167
+ }
168
+ async _fetchContentTemplates(pageToken) {
169
+ const contentTemplatesUrl = "Client/v2/ContentTemplates";
170
+ const url = new index.UriBuilder(contentTemplatesUrl);
171
+ url.arg("PageSize", this._pageSize);
172
+ if (pageToken !== undefined) {
173
+ url.arg("PageToken", pageToken);
174
+ }
175
+ const response = await this._services.commandExecutor.fetchResource(url.build());
176
+ return [
177
+ response.templates.map((template) => new contentTemplate.ContentTemplate(template)),
178
+ response.meta.next_token,
179
+ ];
180
+ }
181
+ }
182
+
183
+ exports.ContentClient = ContentClient;
184
+ //# sourceMappingURL=content-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-client.js","sources":["../src/content-client.ts"],"sourcesContent":["import { CommandExecutor } from \"./command-executor\";\nimport { ContentTemplate } from \"./content-template\";\nimport { ContentTemplatesResponse } from \"./interfaces/commands/content-templates-response\";\nimport { UriBuilder } from \"./util\";\n\ntype ContentClientServices = {\n commandExecutor: CommandExecutor;\n};\n\nclass ContentClient {\n private _cachedTemplates: Readonly<ContentTemplate[]> | null = null;\n\n public constructor(\n private readonly _services: ContentClientServices,\n private readonly _pageSize: number = 100,\n private readonly _cacheTtlMs: number = 5_000\n ) {}\n\n public async getContentTemplates(): Promise<Readonly<ContentTemplate[]>> {\n if (this._cachedTemplates !== null) {\n return this._cachedTemplates;\n }\n\n let [templatesPage, nextToken] = await this._fetchContentTemplates();\n let templates = templatesPage;\n\n while (nextToken !== null) {\n [templatesPage, nextToken] = await this._fetchContentTemplates(nextToken);\n templates = [...templates, ...templatesPage];\n }\n\n this._cachedTemplates = Object.freeze(templates);\n\n setTimeout(() => {\n this._cachedTemplates = null;\n }, this._cacheTtlMs);\n\n return templates;\n }\n\n private async _fetchContentTemplates(\n pageToken?: string\n ): Promise<[ContentTemplate[], string?]> {\n const contentTemplatesUrl = \"Client/v2/ContentTemplates\";\n const url = new UriBuilder(contentTemplatesUrl);\n\n url.arg(\"PageSize\", this._pageSize);\n\n if (pageToken !== undefined) {\n url.arg(\"PageToken\", pageToken);\n }\n\n const response = await this._services.commandExecutor.fetchResource<\n void,\n ContentTemplatesResponse\n >(url.build());\n\n return [\n response.templates.map((template) => new ContentTemplate(template)),\n response.meta.next_token,\n ];\n }\n}\n\nexport { ContentClient };\n"],"names":["UriBuilder","ContentTemplate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,SAAS,CAAC,CAAC;QAEpC,IAAI,SAAS,KAAK,SAAS,EAAE;AAC3B,YAAA,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACjC,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,aAAa,CAGjE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QAEf,OAAO;AACL,YAAA,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,IAAIC,+BAAe,CAAC,QAAQ,CAAC,CAAC;YACnE,QAAQ,CAAC,IAAI,CAAC,UAAU;SACzB,CAAC;KACH;AACF;;;;"}
@@ -0,0 +1,310 @@
1
+ /*
2
+ @license
3
+ The following license applies to all parts of this software except as
4
+ documented below.
5
+
6
+ Copyright (c) 2019, Twilio, inc.
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are
11
+ met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in
18
+ the documentation and/or other materials provided with the
19
+ distribution.
20
+
21
+ 3. Neither the name of Twilio nor the names of its contributors may
22
+ be used to endorse or promote products derived from this software
23
+ without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ This software includes javascript-state-machine under the following license.
38
+
39
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ of this software and associated documentation files (the "Software"), to deal
43
+ in the Software without restriction, including without limitation the rights
44
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ copies of the Software, and to permit persons to whom the Software is
46
+ furnished to do so, subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in all
49
+ copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57
+
58
+ This software includes loglevel under the following license.
59
+
60
+ Copyright (c) 2013 Tim Perry
61
+
62
+ Permission is hereby granted, free of charge, to any person
63
+ obtaining a copy of this software and associated documentation
64
+ files (the "Software"), to deal in the Software without
65
+ restriction, including without limitation the rights to use,
66
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
67
+ copies of the Software, and to permit persons to whom the
68
+ Software is furnished to do so, subject to the following
69
+ conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
76
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
78
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
81
+ OTHER DEALINGS IN THE SOFTWARE.
82
+
83
+ This software includes q under the following license.
84
+
85
+ Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to
88
+ deal in the Software without restriction, including without limitation the
89
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
90
+ sell copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
101
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
102
+ IN THE SOFTWARE.
103
+
104
+ This software includes platform.js under the following license.
105
+
106
+ Copyright 2014 Benjamin Tan <https://d10.github.io/>
107
+ Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining
110
+ a copy of this software and associated documentation files (the
111
+ "Software"), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, sublicense, and/or sell copies of the Software, and to
114
+ permit persons to whom the Software is furnished to do so, subject to
115
+ the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be
118
+ included in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
123
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
124
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
125
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
126
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
+
128
+ */
129
+ 'use strict';
130
+
131
+ var global =
132
+ typeof global !== "undefined"
133
+ ? global
134
+ : typeof self !== "undefined"
135
+ ? self
136
+ : typeof window !== "undefined"
137
+ ? window
138
+ : {};
139
+
140
+ Object.defineProperty(exports, '__esModule', { value: true });
141
+
142
+ const collectActions = (actions) => {
143
+ return actions.map((action) => {
144
+ var _a, _b, _c, _d;
145
+ const rawData = JSON.stringify(action);
146
+ switch (action.type) {
147
+ case "QUICK_REPLY":
148
+ return {
149
+ type: "reply",
150
+ title: action.title,
151
+ id: (_a = action.id) !== null && _a !== void 0 ? _a : "",
152
+ index: (_b = action.index) !== null && _b !== void 0 ? _b : 0,
153
+ rawData,
154
+ };
155
+ case "PHONE_NUMBER":
156
+ return {
157
+ type: "phone",
158
+ title: action.title,
159
+ phone: (_c = action.phone) !== null && _c !== void 0 ? _c : "",
160
+ rawData,
161
+ };
162
+ case "URL":
163
+ return {
164
+ type: "url",
165
+ title: action.title,
166
+ url: (_d = action.url) !== null && _d !== void 0 ? _d : "",
167
+ rawData,
168
+ };
169
+ default:
170
+ return {
171
+ type: "other",
172
+ rawData,
173
+ };
174
+ }
175
+ });
176
+ };
177
+ const parseVariant = (type, data) => {
178
+ var _a, _b;
179
+ const rawData = JSON.stringify(data);
180
+ switch (type) {
181
+ case "twilio/text": {
182
+ const variant = data;
183
+ return {
184
+ type: "text",
185
+ body: variant.body,
186
+ rawData,
187
+ };
188
+ }
189
+ case "twilio/media": {
190
+ const variant = data;
191
+ return {
192
+ type: "media",
193
+ body: variant.body,
194
+ media: variant.media,
195
+ rawData,
196
+ };
197
+ }
198
+ case "twilio/location": {
199
+ const variant = data;
200
+ return {
201
+ type: "location",
202
+ longitude: variant.longitude,
203
+ latitude: variant.latitude,
204
+ label: variant.label,
205
+ rawData,
206
+ };
207
+ }
208
+ case "twilio/quick-reply": {
209
+ const variant = data;
210
+ return {
211
+ type: "quickReply",
212
+ body: variant.body,
213
+ replies: variant.actions,
214
+ rawData,
215
+ };
216
+ }
217
+ case "twilio/call-to-action": {
218
+ const variant = data;
219
+ return {
220
+ type: "callToAction",
221
+ body: variant.body,
222
+ actions: collectActions(variant.actions),
223
+ rawData,
224
+ };
225
+ }
226
+ case "twilio/list-picker": {
227
+ const variant = data;
228
+ return {
229
+ type: "listPicker",
230
+ body: variant.body,
231
+ button: variant.button,
232
+ items: variant.items,
233
+ rawData,
234
+ };
235
+ }
236
+ case "twilio/card": {
237
+ const variant = data;
238
+ return {
239
+ type: "card",
240
+ title: variant.title,
241
+ subtitle: variant.subtitle,
242
+ media: (_a = variant.media) !== null && _a !== void 0 ? _a : [],
243
+ actions: collectActions((_b = variant.actions) !== null && _b !== void 0 ? _b : []),
244
+ rawData,
245
+ };
246
+ }
247
+ default:
248
+ return {
249
+ type: "other",
250
+ rawData,
251
+ };
252
+ }
253
+ };
254
+ const collectVariants = (variants) => {
255
+ const variantsMap = new Map();
256
+ for (const [key, value] of Object.entries(variants)) {
257
+ variantsMap.set(key, parseVariant(key, value));
258
+ }
259
+ return variantsMap;
260
+ };
261
+ /**
262
+ * Represents a variable for a content template. See
263
+ * {@link ContentTemplate.variables}.
264
+ */
265
+ class ContentTemplateVariable {
266
+ constructor(
267
+ /**
268
+ * Name of the variable.
269
+ */
270
+ name,
271
+ /**
272
+ * Key of the variable
273
+ */
274
+ value) {
275
+ this.name = name;
276
+ this.value = value;
277
+ }
278
+ /**
279
+ * Copies the variable with a new value.
280
+ *
281
+ * @param value The new value for the variable.
282
+ */
283
+ copyWithValue(value) {
284
+ return new ContentTemplateVariable(this.name, value);
285
+ }
286
+ }
287
+ /**
288
+ * A rich content template.
289
+ *
290
+ * Use {@link Client.getContentTemplates} to request all the templates available
291
+ * for the current account.
292
+ */
293
+ class ContentTemplate {
294
+ /**
295
+ * @internal
296
+ */
297
+ constructor(contentTemplateResponse) {
298
+ this.sid = contentTemplateResponse.sid;
299
+ this.friendlyName = contentTemplateResponse.friendly_name;
300
+ this.variables = Object.entries(JSON.parse(contentTemplateResponse.variables)).map(([key, value]) => new ContentTemplateVariable(key, value));
301
+ this.variants = collectVariants(contentTemplateResponse.variants);
302
+ this.dateCreated = new Date(contentTemplateResponse.date_created);
303
+ this.dateUpdated = new Date(contentTemplateResponse.date_updated);
304
+ }
305
+ }
306
+
307
+ exports.ContentTemplate = ContentTemplate;
308
+ exports.ContentTemplateVariable = ContentTemplateVariable;
309
+ exports.parseVariant = parseVariant;
310
+ //# sourceMappingURL=content-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-template.js","sources":["../src/content-template.ts"],"sourcesContent":["import {\n ContentDataCallToActionResponse,\n ContentDataCardResponse,\n ContentDataListPickerResponse,\n ContentDataLocationResponse,\n ContentDataMediaResponse,\n ContentDataQuickReplyResponse,\n ContentDataTextResponse,\n ContentTemplateResponse,\n} from \"./interfaces/commands/content-templates-response\";\n\n/**\n * Shows a button that sends back a predefined text. Used in\n * {@link ContentDataQuickReply}.\n */\ntype ContentDataReply = {\n /**\n * Display value of the action. This is the message that will be sent back\n * when the user taps on the button.\n */\n readonly title: string;\n\n /**\n * Postback payload. This field is not visible to the end user.\n */\n readonly id?: string;\n};\n\n/**\n * Shows a button that redirects recipient to a predefined URL.\n */\ntype ContentDataActionUrl = {\n /**\n * The type discriminant.\n */\n readonly type: \"url\";\n\n /**\n * Display value for the action.\n */\n readonly title: string;\n\n /**\n * URL to direct to when the recipient taps the button.\n */\n readonly url: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a button that calls a phone number.\n */\ntype ContentDataActionPhone = {\n /**\n * The type discriminant.\n */\n readonly type: \"phone\";\n\n /**\n * Display value for the action.\n */\n readonly title: string;\n\n /**\n * Phone number to call when the recipient taps the button.\n */\n readonly phone: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a button that sends back a predefined text.\n */\ntype ContentDataActionReply = {\n /**\n * The type discriminant.\n */\n readonly type: \"reply\";\n\n /**\n * Display value for the action. This is the message that will be sent back\n * when the user taps on the button.\n */\n readonly title: string;\n\n /**\n * Postback payload. This field is not visible to the end user.\n */\n readonly id?: string;\n\n /**\n * Index for the action.\n */\n readonly index: number;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used for unknown action types which aren't present in the current version of\n * the Conversations SDK.\n */\ntype ContentDataActionOther = {\n /**\n * The type discriminant.\n */\n readonly type: \"other\";\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * A union of possible actions used in {@link ContentDataCallToAction} and\n * {@link ContentDataCard}.\n */\ntype ContentDataAction =\n | ContentDataActionUrl\n | ContentDataActionPhone\n | ContentDataActionReply\n | ContentDataActionOther;\n\n/**\n * Represents an item in the {@link ContentDataListPicker}.\n */\ntype ContentDataListItem = {\n /**\n * Unique item identifier. Not visible to the recipient.\n */\n readonly id: string;\n\n /**\n * Display value of the item.\n */\n readonly item: string;\n\n /**\n * Description of the item.\n */\n readonly description?: string;\n};\n\n/**\n * Contains only the plain text-based content. Represents the twilio/text\n * content type.\n */\ntype ContentDataText = {\n /**\n * The type discriminant.\n */\n readonly type: \"text\";\n\n /**\n * The text of the message you want to send.\n */\n readonly body: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used to send file attachments, or to send long texts via MMS in the US and\n * Canada. Represents the twilio/media content type.\n */\ntype ContentDataMedia = {\n /**\n * The type discriminant.\n */\n readonly type: \"media\";\n\n /**\n * The text of the message you want to send.\n */\n readonly body?: string;\n\n /**\n * URLs of the media you want to send.\n */\n readonly media: string[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Contains a location pin and an optional label, which can be used to enhance\n * delivery notifications or connect recipients to physical experiences you\n * offer. Represents the twilio/location content type.\n */\ntype ContentDataLocation = {\n /**\n * The type discriminant.\n */\n readonly type: \"location\";\n\n /**\n * The longitude value of the location pin you want to send.\n */\n readonly longitude: number;\n\n /**\n * The latitude value of the location pin you want to send.\n */\n readonly latitude: number;\n\n /**\n * The label to be displayed to the end user alongside the location pin.\n */\n readonly label?: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Let recipients tap, rather than type, to respond to the message. Represents\n * the twilio/quick-reply content type.\n */\ntype ContentDataQuickReply = {\n /**\n * The type discriminant.\n */\n readonly type: \"quickReply\";\n\n /**\n * The text of the message you want to send. This is included as a regular\n * text message.\n */\n readonly body: string;\n\n /**\n * Up to 3 buttons can be created for quick reply. See\n * {@link ContentDataReply}.\n */\n readonly replies: ContentDataReply[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Buttons that let recipients tap to trigger actions such as launching a\n * website or making a phone call. Represents the twilio/call-to-action content\n * type.\n */\ntype ContentDataCallToAction = {\n /**\n * The type discriminant.\n */\n readonly type: \"callToAction\";\n\n /**\n * The text of the message you want to send. This is included as a regular\n * text message.\n */\n readonly body: string;\n\n /**\n * Buttons that recipients can tap on to act on the message.\n */\n readonly actions: ContentDataAction[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a menu of up to 10 options, which offers a simple way for users to make\n * a selection. Represents the twilio/list-picker content type.\n */\ntype ContentDataListPicker = {\n /**\n * The type discriminant.\n */\n readonly type: \"listPicker\";\n\n /**\n * The text of the message you want to send. This is rendered as the body of\n * the message.\n */\n readonly body: string;\n\n /**\n * Display value of the primary button.\n */\n readonly button: string;\n\n /**\n * List item objects displayed in the list. See {@link ContentDataListItem}.\n */\n readonly items: ContentDataListItem[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a menu of up to 10 options, which offers a simple way for users to make\n * a selection. Represents the twilio/card content type.\n */\ntype ContentDataCard = {\n /**\n * The type discriminant.\n */\n readonly type: \"card\";\n\n /**\n * Title of the card.\n */\n readonly title: string;\n\n /**\n * Subtitle of the card.\n */\n readonly subtitle?: string;\n\n /**\n * URLs of the media to send with the message.\n */\n readonly media: string[];\n\n /**\n * Buttons that the recipients can tap on to act on the message.\n */\n readonly actions: ContentDataAction[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used for unknown content types which aren't present in the current version of\n * the Conversations SDK.\n */\ntype ContentDataOther = {\n /**\n * The type discriminant.\n */\n readonly type: \"other\";\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * A union of possible data types in rich content templates.\n */\ntype ContentData =\n | ContentDataText\n | ContentDataMedia\n | ContentDataLocation\n | ContentDataQuickReply\n | ContentDataCallToAction\n | ContentDataListPicker\n | ContentDataCard\n | ContentDataOther;\n\nconst collectActions = (\n actions: ContentDataCallToActionResponse[\"actions\"]\n): ContentDataAction[] => {\n return actions.map((action) => {\n const rawData = JSON.stringify(action);\n\n switch (action.type) {\n case \"QUICK_REPLY\":\n return {\n type: \"reply\",\n title: action.title,\n id: action.id ?? \"\",\n index: action.index ?? 0,\n rawData,\n };\n case \"PHONE_NUMBER\":\n return {\n type: \"phone\",\n title: action.title,\n phone: action.phone ?? \"\",\n rawData,\n };\n case \"URL\":\n return {\n type: \"url\",\n title: action.title,\n url: action.url ?? \"\",\n rawData,\n };\n default:\n return {\n type: \"other\",\n rawData,\n };\n }\n });\n};\n\nconst parseVariant = (type: string, data: unknown): ContentData => {\n const rawData = JSON.stringify(data);\n\n switch (type) {\n case \"twilio/text\": {\n const variant = data as ContentDataTextResponse;\n return {\n type: \"text\",\n body: variant.body,\n rawData,\n };\n }\n case \"twilio/media\": {\n const variant = data as ContentDataMediaResponse;\n return {\n type: \"media\",\n body: variant.body,\n media: variant.media,\n rawData,\n };\n }\n case \"twilio/location\": {\n const variant = data as ContentDataLocationResponse;\n return {\n type: \"location\",\n longitude: variant.longitude,\n latitude: variant.latitude,\n label: variant.label,\n rawData,\n };\n }\n case \"twilio/quick-reply\": {\n const variant = data as ContentDataQuickReplyResponse;\n return {\n type: \"quickReply\",\n body: variant.body,\n replies: variant.actions,\n rawData,\n };\n }\n case \"twilio/call-to-action\": {\n const variant = data as ContentDataCallToActionResponse;\n return {\n type: \"callToAction\",\n body: variant.body,\n actions: collectActions(variant.actions),\n rawData,\n };\n }\n case \"twilio/list-picker\": {\n const variant = data as ContentDataListPickerResponse;\n return {\n type: \"listPicker\",\n body: variant.body,\n button: variant.button,\n items: variant.items,\n rawData,\n };\n }\n case \"twilio/card\": {\n const variant = data as ContentDataCardResponse;\n return {\n type: \"card\",\n title: variant.title,\n subtitle: variant.subtitle,\n media: variant.media ?? [],\n actions: collectActions(variant.actions ?? []),\n rawData,\n };\n }\n default:\n return {\n type: \"other\",\n rawData,\n };\n }\n};\n\nconst collectVariants = (\n variants: ContentTemplateResponse[\"variants\"]\n): Map<string, ContentData> => {\n const variantsMap = new Map<string, ContentData>();\n\n for (const [key, value] of Object.entries(variants)) {\n variantsMap.set(key, parseVariant(key, value));\n }\n\n return variantsMap;\n};\n\n/**\n * Represents a variable for a content template. See\n * {@link ContentTemplate.variables}.\n */\nclass ContentTemplateVariable {\n public constructor(\n /**\n * Name of the variable.\n */\n public readonly name: string,\n\n /**\n * Key of the variable\n */\n public readonly value: string\n ) {}\n\n /**\n * Copies the variable with a new value.\n *\n * @param value The new value for the variable.\n */\n public copyWithValue(value: string) {\n return new ContentTemplateVariable(this.name, value);\n }\n}\n\n/**\n * A rich content template.\n *\n * Use {@link Client.getContentTemplates} to request all the templates available\n * for the current account.\n */\nclass ContentTemplate {\n /**\n * The server-assigned unique identifier for the template.\n */\n public readonly sid: string;\n\n /**\n * Friendly name used to describe the content. Not visible to the recipient.\n */\n public readonly friendlyName: string;\n\n /**\n * Variables used by this template.\n */\n public readonly variables: ContentTemplateVariable[];\n\n /**\n * Variants of the content. See {@link ContentData}.\n */\n public readonly variants: Map<string, ContentData>;\n\n /**\n * Date of creation.\n */\n public readonly dateCreated: Date;\n\n /**\n * Date of the last update.\n */\n public readonly dateUpdated: Date;\n\n /**\n * @internal\n */\n public constructor(contentTemplateResponse: ContentTemplateResponse) {\n this.sid = contentTemplateResponse.sid;\n this.friendlyName = contentTemplateResponse.friendly_name;\n this.variables = Object.entries(\n JSON.parse(contentTemplateResponse.variables) as Record<string, string>\n ).map(([key, value]) => new ContentTemplateVariable(key, value));\n this.variants = collectVariants(contentTemplateResponse.variants);\n this.dateCreated = new Date(contentTemplateResponse.date_created);\n this.dateUpdated = new Date(contentTemplateResponse.date_updated);\n }\n}\n\nexport {\n ContentDataActionUrl,\n ContentDataActionPhone,\n ContentDataActionReply,\n ContentDataActionOther,\n ContentDataAction,\n ContentDataText,\n ContentDataMedia,\n ContentDataLocation,\n ContentDataReply,\n ContentDataQuickReply,\n ContentDataCallToAction,\n ContentDataListPicker,\n ContentDataListItem,\n ContentDataCard,\n ContentDataOther,\n ContentData,\n ContentTemplate,\n ContentTemplateVariable,\n parseVariant,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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