-
Notifications
You must be signed in to change notification settings - Fork 2
/
person.go
55 lines (48 loc) · 1.31 KB
/
person.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
package spark
import (
"encoding/json"
"errors"
"fmt"
"time"
)
const PeopleUrl = "https://api.ciscospark.com/v1/people"
type Person struct {
Id string `json:"id"`
Emails []string `json:"emails"`
DisplayName string `json:"displayName"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Avatar string `json:"avatar"`
OrgId string `json:"orgId"`
Roles []string `json:"roles"`
Licenses []string `json:"licenses"`
Created time.Time `json:"created"`
Timezone string `json:"timezone"`
LastActivity time.Time `json:"lastActivity"`
Status string `json:"status"`
}
// https://developer.ciscospark.com/resource-webhooks.html
type People struct {
Items []Person
}
func (s *Spark) GetPerson(personId string) (Person, error) {
var person Person
if personId == "" {
return person, errors.New("No person ID specified")
}
bytes, err := s.GetRequest(fmt.Sprintf("%s/%s", PeopleUrl, personId), nil)
if err != nil {
return person, err
}
err = json.Unmarshal(bytes, &person)
return person, err
}
func (s *Spark) GetMyself() (Person, error) {
var me Person
bytes, err := s.GetRequest(fmt.Sprintf("%s/me", PeopleUrl), nil)
if err != nil {
return me, err
}
err = json.Unmarshal(bytes, &me)
return me, err
}