/
send_and_wait_for_reply.go
67 lines (59 loc) · 2.04 KB
/
send_and_wait_for_reply.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
// Package widgets contains auto-generated files. DO NOT MODIFY
package widgets
import (
"fmt"
"github.com/RJPearson94/twilio-sdk-go/studio/flow"
"github.com/RJPearson94/twilio-sdk-go/studio/properties"
"github.com/RJPearson94/twilio-sdk-go/utils"
)
type SendAndWaitForReplyNextTransitions struct {
DeliveryFailure *string
IncomingMessage string `validate:"required"`
Timeout *string
}
type SendAndWaitForReplyProperties struct {
Attributes *string `json:"attributes,omitempty"`
Body string `validate:"required" json:"body"`
Channel *string `json:"channel,omitempty"`
From string `validate:"required" json:"from"`
MediaURL *string `json:"media_url,omitempty"`
Offset *properties.Offset `json:"offset,omitempty"`
Service *string `json:"service,omitempty"`
Timeout string `validate:"required" json:"timeout"`
}
// SendAndWaitForReply widget allows you to send a SMS and wait for a reply
type SendAndWaitForReply struct {
NextTransitions SendAndWaitForReplyNextTransitions
Properties SendAndWaitForReplyProperties `validate:"required"`
Name string `validate:"required"`
}
// Validate checks the widget is correctly configured
func (widget SendAndWaitForReply) Validate() error {
if err := utils.ValidateInput(widget); err != nil {
return fmt.Errorf("Invalid input supplied. Errors %s", err.Error())
}
return nil
}
// ToState returns a populated Studio Widget State struct
func (widget SendAndWaitForReply) ToState() (*flow.State, error) {
transitions := []flow.Transition{
{
Event: "deliveryFailure",
Next: widget.NextTransitions.DeliveryFailure,
},
{
Event: "incomingMessage",
Next: utils.String(widget.NextTransitions.IncomingMessage),
},
{
Event: "timeout",
Next: widget.NextTransitions.Timeout,
},
}
return &flow.State{
Name: widget.Name,
Type: "send-and-wait-for-reply",
Transitions: transitions,
Properties: widget.Properties,
}, nil
}