-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputs.go
102 lines (82 loc) · 2.86 KB
/
inputs.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package msteams
// InputType ...
type InputType string
// ChoiceStyle ...
type ChoiceStyle string
const (
// Text ...
Text InputType = "TextInput"
// Date ...
Date InputType = "DateInput"
// MultiChoice ...
MultiChoice InputType = "MultichoiceInput"
// DefaultChoiceStyle ...
DefaultChoiceStyle ChoiceStyle = "normal"
// expandedChoiceStyle ...
expandedChoiceStyle ChoiceStyle = "expanded"
)
// Input for ActionCard Actions
type Input struct {
Type InputType `json:"@type"`
// ID Uniquely identifies the input so it is possible to reference it in the URL or
// body of an HttpPOST action. See Input value substitution.
ID string `json:"id"`
// Indicates whether users are required to type a value before they are able to
// take an action that would take the value of the input as a parameter.
IsRequired bool `json:"isRequired"`
// Defines a title for the input.
Title string `json:"title"`
// Defines the initial value of the input. For multi-choice inputs,
// value must be equal to the value property of one of the input's choices.
Value string `json:"value"`
}
// TextInput ...
type TextInput struct {
Type InputType `json:"@type"`
ID string `json:"id"`
IsRequired bool `json:"isRequired"`
Title string `json:"title"`
Value string `json:"value"`
// Indicates whether the text input should accept multiple lines of text.
IsMultiline bool `json:"isMultiline"`
// Indicates the maximum number of characters that can be entered.
MaxLength int `json:"maxLength"`
}
// DateInput ...
type DateInput struct {
Type InputType `json:"@type"`
ID string `json:"id"`
IsRequired bool `json:"isRequired"`
Title string `json:"title"`
Value string `json:"value"`
// Indicates whether the date input should allow for the selection of a time in addition to the date.
IncludeTime bool `json:"includeTime"`
}
// MultichoiceInput ...
type MultichoiceInput struct {
// Choices Defines the values that can be selected for the multichoice input.
Choices []Choice `json:"choices"`
// If set to true, indicates that the user can select more than one choice.
// The specified choices will be displayed as a list of checkboxes. Default value is false.
IsMultiSelect bool `json:"isMultiSelect"`
// When isMultiSelect is false, setting the style property to expanded will instruct
// the host application to try and display all choices on the screen,
// typically using a set of radio buttons.
Style ChoiceStyle `json:"style"`
}
// Choice ...
type Choice struct {
Display string `json:"display"`
Value string `json:"value"`
}
// AddTextInput ...
func (api *Client) AddTextInput(title, value string, isMultiline bool, maxLength int) *TextInput {
return &TextInput{
Type: Text,
IsRequired: true,
Title: title,
Value: value,
IsMultiline: isMultiline,
MaxLength: maxLength,
}
}