forked from abourget/ari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecordings.go
105 lines (81 loc) · 2.7 KB
/
recordings.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
103
104
105
package ari
import "fmt"
//
// Service
//
type RecordingService struct {
client *Client
}
func (s *RecordingService) ListStored() ([]*StoredRecording, error) {
var out []*StoredRecording
return out, s.client.Get("/recordings/stored", nil, &out)
}
func (s *RecordingService) GetStored(recordingName string) (*StoredRecording, error) {
var out StoredRecording
return &out, s.client.Get(fmt.Sprintf("/recordings/stored/%s", recordingName), nil, &out)
}
func (s *RecordingService) GetLive(recordingName string) (*LiveRecording, error) {
var out LiveRecording
return &out, s.client.Get(fmt.Sprintf("/recordings/live/%s", recordingName), nil, &out)
}
func (s *RecordingService) DeleteStored(recordingName string) error {
return s.client.Delete(fmt.Sprintf("/recordings/stored/%s", recordingName), nil)
}
func (s *RecordingService) CopyStored(recordingName, destinationRecordingName string) (*StoredRecording, error) {
var out StoredRecording
params := map[string]string{
"destinationRecordingName": destinationRecordingName,
}
return &out, s.client.Post(fmt.Sprintf("/recordings/stored/%s/copy", recordingName), params, &out)
}
//
// Models
//
type StoredRecording struct {
Format string
Name string
// For further manipulations
client *Client
}
func (s *StoredRecording) setClient(client *Client) {
s.client = client
}
func (s *StoredRecording) Delete() error {
return s.client.Recordings.DeleteStored(s.Name)
}
func (s *StoredRecording) Copy(destinationRecordingName string) (*StoredRecording, error) {
return s.client.Recordings.CopyStored(s.Name, destinationRecordingName)
}
type LiveRecording struct {
Cause string
Duration *int64
Format string
Name string
SilenceDuration *int64 `json:"silence_duration"`
State string
TalkingDuration *int64 `json:"talking_duration"`
TargetURI string `json:"target_uri"`
// For further manipulations
client *Client
}
func (l *LiveRecording) setClient(client *Client) {
l.client = client
}
func (l *LiveRecording) Cancel() error {
return l.client.Delete(fmt.Sprintf("/recordings/live/%s", l.Name), nil)
}
func (l *LiveRecording) Stop() error {
return l.client.Post(fmt.Sprintf("/recordings/live/%s/stop", l.Name), nil, nil)
}
func (l *LiveRecording) Pause() error {
return l.client.Post(fmt.Sprintf("/recordings/live/%s/pause", l.Name), nil, nil)
}
func (l *LiveRecording) Unpause() error {
return l.client.Delete(fmt.Sprintf("/recordings/live/%s/pause", l.Name), nil)
}
func (l *LiveRecording) Mute() error {
return l.client.Post(fmt.Sprintf("/recordings/live/%s/mute", l.Name), nil, nil)
}
func (l *LiveRecording) Unmute() error {
return l.client.Delete(fmt.Sprintf("/recordings/live/%s/mute", l.Name), nil)
}