File tree Expand file tree Collapse file tree 3 files changed +76
-1
lines changed Expand file tree Collapse file tree 3 files changed +76
-1
lines changed Original file line number Diff line number Diff line change @@ -43,4 +43,5 @@ the most basic methods or features.
43
43
- [ Complex template with reply buttons] ( template.md#complex-template-with-reply-buttons )
44
44
- [ Complex template with call to action url] ( template.md#complex-template-with-call-to-action-url )
45
45
- [ Complex template with Carousel] ( template.md#complex-template-with-carousel )
46
+ - [ Complex template with Limited-Time Offer] ( template.md#complex-template-with-limited-time-offer )
46
47
- [ OTP prefab template] ( template.md#otp-prefab-template )
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ import {
169
169
URLComponent
170
170
} from " whatsapp-api-js/messages" ;
171
171
172
- const template_multi_product_message = new Template (
172
+ const template_carousel_message = new Template (
173
173
" template_name" ,
174
174
" en" ,
175
175
new BodyComponent (new BodyParameter (" PROMO10" )),
@@ -186,6 +186,25 @@ const template_multi_product_message = new Template(
186
186
);
187
187
```
188
188
189
+ ## Complex template with Limited-Time Offer
190
+
191
+ ``` ts
192
+ import {
193
+ Template ,
194
+ LTOComponent ,
195
+ URLComponent ,
196
+ CopyComponent
197
+ } from " whatsapp-api-js/messages" ;
198
+
199
+ const template_limited_time_offer_message = new Template (
200
+ " template_name" ,
201
+ " en" ,
202
+ new LTOComponent (1696622508595 ),
203
+ new CopyComponent (" PROMO10" ),
204
+ new URLComponent (" ?code=PROMO10&product=1" )
205
+ );
206
+ ```
207
+
189
208
## OTP prefab template
190
209
191
210
``` ts
@@ -205,3 +224,4 @@ https://whatsappapijs.web.app/classes/messages.CopyComponent.html
205
224
https://whatsappapijs.web.app/classes/messages.CatalogComponent.html
206
225
https://whatsappapijs.web.app/classes/messages.MPMComponent.html
207
226
https://whatsappapijs.web.app/classes/messages.CarouselComponent.html
227
+ https://whatsappapijs.web.app/classes/messages.LTOComponent.html
Original file line number Diff line number Diff line change @@ -849,3 +849,57 @@ export class CarouselCard implements ClientBuildableMessageComponent {
849
849
return this ;
850
850
}
851
851
}
852
+
853
+ /**
854
+ * Components API object
855
+ *
856
+ * @group Template
857
+ */
858
+ export class LTOComponent implements ClientBuildableMessageComponent {
859
+ /**
860
+ * The type of the component
861
+ */
862
+ readonly type = "limited_time_offer" ;
863
+ /**
864
+ * The parameters of the component
865
+ */
866
+ readonly parameters : [
867
+ {
868
+ type : "limited_time_offer" ;
869
+ limited_time_offer : {
870
+ expiration_time_ms : number ;
871
+ } ;
872
+ }
873
+ ] ;
874
+
875
+ /**
876
+ * Builds a limited-time offer component for a Template message
877
+ *
878
+ * @param expiration - Offer code expiration time as a UNIX timestamp in milliseconds
879
+ * @throws If expiration is negative
880
+ */
881
+ constructor ( expiration : number ) {
882
+ if ( expiration < 0 ) {
883
+ throw new Error (
884
+ "Expiration time must be a positive Unix timestamp"
885
+ ) ;
886
+ }
887
+
888
+ this . parameters = [
889
+ {
890
+ type : "limited_time_offer" ,
891
+ limited_time_offer : {
892
+ expiration_time_ms : expiration
893
+ }
894
+ }
895
+ ] ;
896
+ }
897
+
898
+ /**
899
+ * @override
900
+ * @internal
901
+ */
902
+ _build ( ) {
903
+ return this ;
904
+ }
905
+ }
You can’t perform that action at this time.
0 commit comments