-
Notifications
You must be signed in to change notification settings - Fork 20
/
dial_wait.go
51 lines (42 loc) · 1.35 KB
/
dial_wait.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
package events
import (
"time"
"github.com/nyaruka/gocommon/urns"
"github.com/nyaruka/goflow/flows"
)
func init() {
registerType(TypeDialWait, func() flows.Event { return &DialWaitEvent{} })
}
// TypeDialWait is the type of our dial wait event
const TypeDialWait string = "dial_wait"
// DialWaitEvent events are created when a flow pauses waiting for an IVR dial to complete.
//
// {
// "type": "dial_wait",
// "created_on": "2019-01-02T15:04:05Z",
// "urn": "tel:+593979123456",
// "dial_limit_seconds": 60,
// "call_limit_seconds": 120,
// "expires_on": "2022-02-02T13:27:30Z"
// }
//
// @event dial_wait
type DialWaitEvent struct {
BaseEvent
URN urns.URN `json:"urn" validate:"required,urn"`
DialLimitSeconds int `json:"dial_limit_seconds"`
CallLimitSeconds int `json:"call_limit_seconds"`
// when this wait expires and the whole run can be expired
ExpiresOn *time.Time `json:"expires_on,omitempty"`
}
// NewDialWait returns a new dial wait with the passed in URN
func NewDialWait(urn urns.URN, dialLimitSeconds, callLimitSeconds int, expiresOn *time.Time) *DialWaitEvent {
return &DialWaitEvent{
BaseEvent: NewBaseEvent(TypeDialWait),
URN: urn,
DialLimitSeconds: dialLimitSeconds,
CallLimitSeconds: callLimitSeconds,
ExpiresOn: expiresOn,
}
}
var _ flows.Event = (*DialWaitEvent)(nil)