-
Notifications
You must be signed in to change notification settings - Fork 20
/
digits.go
36 lines (29 loc) · 908 Bytes
/
digits.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
package hints
import (
"github.com/nyaruka/goflow/flows"
)
func init() {
RegisterType(TypeDigits, func() flows.Hint { return &DigitsHint{} })
}
// TypeDigits is the type of our digits hint
const TypeDigits string = "digits"
// DigitsHint requests a message containing one or more digits
type DigitsHint struct {
baseHint
Count *int `json:"count,omitempty"`
TerminatedBy string `json:"terminated_by,omitempty"`
}
// NewFixedDigitsHint creates a new digits hint for a fixed count of digits
func NewFixedDigitsHint(count int) *DigitsHint {
return &DigitsHint{
baseHint: newBaseHint(TypeDigits),
Count: &count,
}
}
// NewTerminatedDigitsHint creates a new digits hint for a sequence of digits terminated by the given key
func NewTerminatedDigitsHint(terminatedBy string) *DigitsHint {
return &DigitsHint{
baseHint: newBaseHint(TypeDigits),
TerminatedBy: terminatedBy,
}
}