| 1 | package slack |
| 2 | |
| 3 | import "encoding/json" |
| 4 | |
| 5 | // AttachmentField contains information for an attachment field |
| 6 | // An Attachment can contain multiple of these |
| 7 | type AttachmentField struct { |
| 8 | Title string `json:"title"` |
| 9 | Value string `json:"value"` |
| 10 | Short bool `json:"short"` |
| 11 | } |
| 12 | |
| 13 | // AttachmentAction is a button or menu to be included in the attachment. Required when |
| 14 | // using message buttons or menus and otherwise not useful. A maximum of 5 actions may be |
| 15 | // provided per attachment. |
| 16 | type AttachmentAction struct { |
| 17 | Name string `json:"name"` // Required. |
| 18 | Text string `json:"text"` // Required. |
| 19 | Style string `json:"style,omitempty"` // Optional. Allowed values: "default", "primary", "danger". |
| 20 | Type ActionType `json:"type"` // Required. Must be set to "button" or "select". |
| 21 | Value string `json:"value,omitempty"` // Optional. |
| 22 | DataSource string `json:"data_source,omitempty"` // Optional. |
| 23 | MinQueryLength int `json:"min_query_length,omitempty"` // Optional. Default value is 1. |
| 24 | Options []AttachmentActionOption `json:"options,omitempty"` // Optional. Maximum of 100 options can be provided in each menu. |
| 25 | SelectedOptions []AttachmentActionOption `json:"selected_options,omitempty"` // Optional. The first element of this array will be set as the pre-selected option for this menu. |
| 26 | OptionGroups []AttachmentActionOptionGroup `json:"option_groups,omitempty"` // Optional. |
| 27 | Confirm *ConfirmationField `json:"confirm,omitempty"` // Optional. |
| 28 | URL string `json:"url,omitempty"` // Optional. |
| 29 | } |
| 30 | |
| 31 | // actionType returns the type of the action |
| 32 | func (a AttachmentAction) actionType() ActionType { |
| 33 | return a.Type |
| 34 | } |
| 35 | |
| 36 | // AttachmentActionOption the individual option to appear in action menu. |
| 37 | type AttachmentActionOption struct { |
| 38 | Text string `json:"text"` // Required. |
| 39 | Value string `json:"value"` // Required. |
| 40 | Description string `json:"description,omitempty"` // Optional. Up to 30 characters. |
| 41 | } |
| 42 | |
| 43 | // AttachmentActionOptionGroup is a semi-hierarchal way to list available options to appear in action menu. |
| 44 | type AttachmentActionOptionGroup struct { |
| 45 | Text string `json:"text"` // Required. |
| 46 | Options []AttachmentActionOption `json:"options"` // Required. |
| 47 | } |
| 48 | |
| 49 | // AttachmentActionCallback is sent from Slack when a user clicks a button in an interactive message (aka AttachmentAction) |
| 50 | // DEPRECATED: use InteractionCallback |
| 51 | type AttachmentActionCallback InteractionCallback |
| 52 | |
| 53 | // ConfirmationField are used to ask users to confirm actions |
| 54 | type ConfirmationField struct { |
| 55 | Title string `json:"title,omitempty"` // Optional. |
| 56 | Text string `json:"text"` // Required. |
| 57 | OkText string `json:"ok_text,omitempty"` // Optional. Defaults to "Okay" |
| 58 | DismissText string `json:"dismiss_text,omitempty"` // Optional. Defaults to "Cancel" |
| 59 | } |
| 60 | |
| 61 | // Attachment contains all the information for an attachment |
| 62 | type Attachment struct { |
| 63 | Color string `json:"color,omitempty"` |
| 64 | Fallback string `json:"fallback,omitempty"` |
| 65 | |
| 66 | CallbackID string `json:"callback_id,omitempty"` |
| 67 | ID int `json:"id,omitempty"` |
| 68 | |
| 69 | AuthorID string `json:"author_id,omitempty"` |
| 70 | AuthorName string `json:"author_name,omitempty"` |
| 71 | AuthorSubname string `json:"author_subname,omitempty"` |
| 72 | AuthorLink string `json:"author_link,omitempty"` |
| 73 | AuthorIcon string `json:"author_icon,omitempty"` |
| 74 | |
| 75 | Title string `json:"title,omitempty"` |
| 76 | TitleLink string `json:"title_link,omitempty"` |
| 77 | Pretext string `json:"pretext,omitempty"` |
| 78 | Text string `json:"text,omitempty"` |
| 79 | |
| 80 | ImageURL string `json:"image_url,omitempty"` |
| 81 | ThumbURL string `json:"thumb_url,omitempty"` |
| 82 | |
| 83 | ServiceName string `json:"service_name,omitempty"` |
| 84 | ServiceIcon string `json:"service_icon,omitempty"` |
| 85 | FromURL string `json:"from_url,omitempty"` |
| 86 | OriginalURL string `json:"original_url,omitempty"` |
| 87 | |
| 88 | Fields []AttachmentField `json:"fields,omitempty"` |
| 89 | Actions []AttachmentAction `json:"actions,omitempty"` |
| 90 | MarkdownIn []string `json:"mrkdwn_in,omitempty"` |
| 91 | |
| 92 | Blocks Blocks `json:"blocks,omitempty"` |
| 93 | |
| 94 | Footer string `json:"footer,omitempty"` |
| 95 | FooterIcon string `json:"footer_icon,omitempty"` |
| 96 | |
| 97 | Ts json.Number `json:"ts,omitempty"` |
| 98 | } |