-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapplications.go
49 lines (39 loc) · 1.23 KB
/
applications.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
package ari
import (
"fmt"
"net/url"
)
type ApplicationService struct {
client *Client
}
func (s *ApplicationService) List() ([]*Application, error) {
var out []*Application
return out, s.client.Get("/applications", nil, &out)
}
func (s *ApplicationService) Get(applicationName string) (*Application, error) {
var out Application
return &out, s.client.Get(fmt.Sprintf("/applications/%s", applicationName), nil, &out)
}
type Application struct {
BridgeIds []string `json:"bridge_ids"`
ChannelIds []string `json:"channel_ids"`
DeviceNames []string `json:"device_names"`
EndpointIds []string `json:"endpoint_ids"`
Name string
// For further mutations
client *Client
}
func (a *Application) setClient(client *Client) {
a.client = client
}
func (a *Application) Subscribe(eventSource string) (*Application, error) {
var out Application
params := map[string]string{
"eventSource": eventSource,
}
return &out, a.client.Post(fmt.Sprintf("/applications/%s/subscription", a.Name), params, &out)
}
func (a *Application) Unsubscribe(eventSource string) (*Application, error) {
var out Application
return &out, a.client.Delete(fmt.Sprintf("/applications/%s/subscription?eventSource=%s", a.Name, url.QueryEscape(eventSource)), &out)
}