Debian Codegraph @

block_section.go

raw symbols SCIP
1 package slack
2
3 // SectionBlock defines a new block of type section
4 //
5 // More Information: https://api.slack.com/reference/messaging/blocks#section
6 type SectionBlock struct {
7 Type MessageBlockType `json:"type"`
8 Text *TextBlockObject `json:"text,omitempty"`
9 BlockID string `json:"block_id,omitempty"`
10 Fields []*TextBlockObject `json:"fields,omitempty"`
11 Accessory *Accessory `json:"accessory,omitempty"`
12 }
13
14 // BlockType returns the type of the block
15 func (s SectionBlock) BlockType() MessageBlockType {
16 return s.Type
17 }
18
19 // SectionBlockOption allows configuration of options for a new section block
20 type SectionBlockOption func(*SectionBlock)
21
22 func SectionBlockOptionBlockID(blockID string) SectionBlockOption {
23 return func(block *SectionBlock) {
24 block.BlockID = blockID
25 }
26 }
27
28 // NewSectionBlock returns a new instance of a section block to be rendered
29 func NewSectionBlock(textObj *TextBlockObject, fields []*TextBlockObject, accessory *Accessory, options ...SectionBlockOption) *SectionBlock {
30 block := SectionBlock{
31 Type: MBTSection,
32 Text: textObj,
33 Fields: fields,
34 Accessory: accessory,
35 }
36
37 for _, option := range options {
38 option(&block)
39 }
40
41 return &block
42 }