forked from kevinburke/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
voice_insights_events.go
56 lines (47 loc) · 1.37 KB
/
voice_insights_events.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
package twilio
import (
"context"
"fmt"
"net/url"
)
const EventsPathPart = "Events"
type CallEventsService struct {
callSid string
client *Client
}
type CallEventsPage struct {
Meta Meta `json:"meta"`
Events []CallEvent `json:"events"`
}
type CallEvent struct {
AccountSid string `json:"account_sid"`
CallSid string `json:"call_sid"`
Edge string `json:"edge"`
Group string `json:"group"`
Level string `json:"level"`
Name string `json:"name"`
Timestamp TwilioTime `json:"timestamp"`
}
// Returns a list of events for a call. For more information on valid values,
// See https://www.twilio.com/docs/voice/insights/api/call-events-resource#get-call-events
func (s *CallEventsService) GetPage(ctx context.Context, data url.Values) (*CallEventsPage, error) {
return s.GetPageIterator(data).Next(ctx)
}
type CallEventsPageIterator struct {
p *PageIterator
}
func (s *CallEventsService) GetPageIterator(data url.Values) *CallEventsPageIterator {
iter := NewPageIterator(s.client, data, fmt.Sprintf("Voice/%s/%s", s.callSid, EventsPathPart))
return &CallEventsPageIterator{
p: iter,
}
}
func (c *CallEventsPageIterator) Next(ctx context.Context) (*CallEventsPage, error) {
cp := new(CallEventsPage)
err := c.p.Next(ctx, cp)
if err != nil {
return nil, err
}
c.p.SetNextPageURI(cp.Meta.NextPageURL)
return cp, nil
}