forked from intercom/intercom-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
segments.go
36 lines (29 loc) · 980 Bytes
/
segments.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
package intercom
import "fmt"
// SegmentService handles interactions with the API through a SegmentRepository.
type SegmentService struct {
Repository SegmentRepository
}
// Segment represents an Segment in Intercom.
type Segment struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
PersonType string `json:"person_type,omitempty"`
}
// SegmentList, an object holding a list of Segments
type SegmentList struct {
Segments []Segment `json:"segments,omitempty"`
}
// List all Segments for the App
func (t *SegmentService) List() (SegmentList, error) {
return t.Repository.list()
}
// Find a particular Segment in the App
func (t *SegmentService) Find(id string) (Segment, error) {
return t.Repository.find(id)
}
func (s Segment) String() string {
return fmt.Sprintf("[intercom] segment { id: %s, type: %s }", s.ID, s.PersonType)
}