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