-
Notifications
You must be signed in to change notification settings - Fork 23
/
phlos.go
72 lines (61 loc) · 1.81 KB
/
phlos.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
package plivo
const nodeType = "multi_party_call"
type Phlo struct {
BaseResource
ApiId string `json:"api_id" url:"api_id"`
PhloId string `json:"phlo_id" url:"phlo_id"`
Name string `json:"name" url:"name"`
CreatedOn string `json:"created_on" url:"created_on"`
}
type Phlos struct {
BaseResourceInterface
}
func NewPhlos(client *PhloClient) (phlos *Phlos) {
phlos = &Phlos{}
phlos.client = client
return
}
type PhloRun struct {
ApiID string `json:"api_id" url:"api_id"`
PhloRunID string `json:"phlo_run_id" url:"phlo_run_id"`
PhloID string `json:"phlo_id" url:"phlo_id"`
Message string `json:"message" url:"message"`
}
func (self *Phlos) Get(phloId string) (response *Phlo, err error) {
req, err := self.client.NewRequest("GET", nil, "phlo/%s", phloId)
if err != nil {
return
}
response = &Phlo{}
response.client = self.client
err = self.client.ExecuteRequest(req, response)
return
}
func (self *Phlo) Node(nodeId string) (response *Node, err error) {
req, err := self.client.NewRequest("GET", nil, "phlo/%s/%s/%s", self.PhloId, nodeType, nodeId)
if err != nil {
return
}
response = &Node{}
err = self.client.ExecuteRequest(req, response)
return
}
func (self *Phlo) MultiPartyCall(nodeId string) (response *PhloMultiPartyCall, err error) {
req, err := self.client.NewRequest("GET", nil, "phlo/%s/%s/%s", self.PhloId, nodeType, nodeId)
if err != nil {
return
}
response = &PhloMultiPartyCall{}
response.client = self.client
err = self.client.ExecuteRequest(req, response)
return
}
func (self *Phlo) Run(data map[string]interface{}) (response *PhloRun, err error) {
req, err := self.client.NewRequest("POST", data, "account/%s/phlo/%s/", self.client.AuthId, self.PhloId)
if err != nil {
return
}
response = &PhloRun{}
err = self.client.ExecuteRequest(req, response)
return
}