forked from abourget/ari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybacks.go
53 lines (43 loc) · 991 Bytes
/
playbacks.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
package ari
import (
"fmt"
)
//
// Service
//
type PlaybackService struct {
client *Client
}
func (s *PlaybackService) Get(playbackID string) (*Playback, error) {
var out Playback
return &out, s.client.Get(fmt.Sprintf("/playbacks/%s", playbackID), nil, &out)
}
//
// Model
//
type Playback struct {
ID string
Language string
MediaURI string `json:"media_uri"`
State string
TargetURI string `json:"target_uri"`
// For further manipulations
client *Client
}
func (p *Playback) setClient(client *Client) {
p.client = client
}
func (p *Playback) Stop() error {
return p.client.Delete(fmt.Sprintf("/playbacks/%s", p.ID), nil)
}
func (p *Playback) Control(operation string) (status int, err error) {
query := map[string]string{"operation": operation}
res, err := p.client.PostWithResponse(fmt.Sprintf("/playbacks/%s/control", p.ID), query, nil)
if err != nil {
if res == nil {
return 0, err
}
return res.Status(), err
}
return res.Status(), err
}