@@ -327,6 +327,19 @@ func (Section) Type() ComponentType {
327
327
return SectionComponent
328
328
}
329
329
330
+ // MarshalJSON is a method for marshaling Section to a JSON object.
331
+ func (s Section ) MarshalJSON () ([]byte , error ) {
332
+ type section Section
333
+
334
+ return Marshal (struct {
335
+ section
336
+ Type ComponentType `json:"type"`
337
+ }{
338
+ section : section (s ),
339
+ Type : s .Type (),
340
+ })
341
+ }
342
+
330
343
// TextDisplay is a top-level component that allows you to add markdown-formatted text to the message.
331
344
type TextDisplay struct {
332
345
Content string `json:"content"`
@@ -337,6 +350,19 @@ func (TextDisplay) Type() ComponentType {
337
350
return TextDisplayComponent
338
351
}
339
352
353
+ // MarshalJSON is a method for marshaling TextDisplay to a JSON object.
354
+ func (t TextDisplay ) MarshalJSON () ([]byte , error ) {
355
+ type textDisplay TextDisplay
356
+
357
+ return Marshal (struct {
358
+ textDisplay
359
+ Type ComponentType `json:"type"`
360
+ }{
361
+ textDisplay : textDisplay (t ),
362
+ Type : t .Type (),
363
+ })
364
+ }
365
+
340
366
// Thumbnail component can be used as an accessory for a section component.
341
367
type Thumbnail struct {
342
368
// Unique identifier for the component; auto populated through increment if not provided.
@@ -351,6 +377,19 @@ func (Thumbnail) Type() ComponentType {
351
377
return ThumbnailComponent
352
378
}
353
379
380
+ // MarshalJSON is a method for marshaling Thumbnail to a JSON object.
381
+ func (t Thumbnail ) MarshalJSON () ([]byte , error ) {
382
+ type thumbnail Thumbnail
383
+
384
+ return Marshal (struct {
385
+ thumbnail
386
+ Type ComponentType `json:"type"`
387
+ }{
388
+ thumbnail : thumbnail (t ),
389
+ Type : t .Type (),
390
+ })
391
+ }
392
+
354
393
// MediaGallery is a top-level component allows you to group images, videos or gifs into a gallery grid.
355
394
type MediaGallery struct {
356
395
// Unique identifier for the component; auto populated through increment if not provided.
@@ -364,6 +403,19 @@ func (MediaGallery) Type() ComponentType {
364
403
return MediaGalleryComponent
365
404
}
366
405
406
+ // MarshalJSON is a method for marshaling MediaGallery to a JSON object.
407
+ func (m MediaGallery ) MarshalJSON () ([]byte , error ) {
408
+ type mediaGallery MediaGallery
409
+
410
+ return Marshal (struct {
411
+ mediaGallery
412
+ Type ComponentType `json:"type"`
413
+ }{
414
+ mediaGallery : mediaGallery (m ),
415
+ Type : m .Type (),
416
+ })
417
+ }
418
+
367
419
// MediaGalleryItem represents an item used in MediaGallery.
368
420
type MediaGalleryItem struct {
369
421
Media UnfurledMediaItem `json:"media"`
@@ -384,6 +436,19 @@ func (FileComponent) Type() ComponentType {
384
436
return FileComponentType
385
437
}
386
438
439
+ // MarshalJSON is a method for marshaling FileComponent to a JSON object.
440
+ func (f FileComponent ) MarshalJSON () ([]byte , error ) {
441
+ type fileComponent FileComponent
442
+
443
+ return Marshal (struct {
444
+ fileComponent
445
+ Type ComponentType `json:"type"`
446
+ }{
447
+ fileComponent : fileComponent (f ),
448
+ Type : f .Type (),
449
+ })
450
+ }
451
+
387
452
// SeparatorSpacingSize represents spacing size around the separator.
388
453
type SeparatorSpacingSize uint
389
454
@@ -402,6 +467,24 @@ type Separator struct {
402
467
Spacing * SeparatorSpacingSize `json:"spacing,omitempty"`
403
468
}
404
469
470
+ // Type is a method to get the type of a component.
471
+ func (Separator ) Type () ComponentType {
472
+ return SeparatorComponent
473
+ }
474
+
475
+ // MarshalJSON is a method for marshaling Separator to a JSON object.
476
+ func (s Separator ) MarshalJSON () ([]byte , error ) {
477
+ type separator Separator
478
+
479
+ return Marshal (struct {
480
+ separator
481
+ Type ComponentType `json:"type"`
482
+ }{
483
+ separator : separator (s ),
484
+ Type : s .Type (),
485
+ })
486
+ }
487
+
405
488
// Container is a top-level layout component.
406
489
// Containers are visually distinct from surrounding components and have an optional customizable color bar (similar to embeds).
407
490
type Container struct {
@@ -412,6 +495,24 @@ type Container struct {
412
495
Components []MessageComponent `json:"components"`
413
496
}
414
497
498
+ // Type is a method to get the type of a component.
499
+ func (Container ) Type () ComponentType {
500
+ return ContainerComponent
501
+ }
502
+
503
+ // MarshalJSON is a method for marshaling Container to a JSON object.
504
+ func (c Container ) MarshalJSON () ([]byte , error ) {
505
+ type container Container
506
+
507
+ return Marshal (struct {
508
+ container
509
+ Type ComponentType `json:"type"`
510
+ }{
511
+ container : container (c ),
512
+ Type : c .Type (),
513
+ })
514
+ }
515
+
415
516
// UnfurledMediaItem represents an unfurled media item.
416
517
type UnfurledMediaItem struct {
417
518
URL string `json:"url"`
0 commit comments