forked from intercom/intercom-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin.go
46 lines (38 loc) · 1.07 KB
/
admin.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
package intercom
import (
"encoding/json"
"fmt"
)
// Admin represents an Admin in Intercom.
type Admin struct {
ID json.Number `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Email string `json:"email"`
}
// AdminList represents an object holding list of Admins
type AdminList struct {
Admins []Admin
}
// AdminService handles interactions with the API through an AdminRepository.
type AdminService struct {
Repository AdminRepository
}
// List lists the Admins associated with your App.
func (c *AdminService) List() (AdminList, error) {
return c.Repository.list()
}
// IsNobodyAdmin is a helper function to determine if the Admin is 'Nobody'.
func (a Admin) IsNobodyAdmin() bool {
return a.Type == "nobody_admin"
}
// MessageAddress gets the address for a Contact in order to message them
func (a Admin) MessageAddress() MessageAddress {
return MessageAddress{
Type: "admin",
ID: a.ID.String(),
}
}
func (a Admin) String() string {
return fmt.Sprintf("[intercom] %s { id: %s name: %s, email: %s }", a.Type, a.ID, a.Name, a.Email)
}