-
Notifications
You must be signed in to change notification settings - Fork 2
/
conferences.go
51 lines (39 loc) · 1.04 KB
/
conferences.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
package telapi
import (
"encoding/json"
"errors"
"fmt"
)
type ConferenceData struct {
Conferences []Conference
}
type Conference struct {
Sid string
DataCreated string
DateUpdated string
FriendlyName string
ActiveParticipantsCount int `json:"active_participants_count"`
Uri string
Status string
}
func (helper TelapiHelper) FindConferenceByFriendlyName(friendlyName string) (*Conference, error) {
if friendlyName == "" {
return nil, errors.New("Missing friendlyName!")
}
fmt.Println(friendlyName)
data := map[string]string{
"FriendlyName": friendlyName,
}
resp, err := helper.GetRequestWithParamsAdded(fmt.Sprintf("/Conferences"), data)
if err != nil {
return nil, err
}
conference := new(ConferenceData)
if err = json.Unmarshal(*resp, &conference); err != nil {
return nil, err
}
if len(conference.Conferences) < 1 {
return nil, errors.New("Could no locate conference by friendlyname")
}
return &conference.Conferences[0], nil
}