Debian Codegraph @

block_header.go

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