/
collaborations.go
42 lines (38 loc) · 1.07 KB
/
collaborations.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
package brightbox
import (
"time"
)
// Collaboration represents a User's links to it's Accounts
// https://api.gb1.brightbox.com/1.0/#user
type Collaboration struct {
Id string
Email string
Role string
RoleLabel string `json:"role_label"`
Status string
CreatedAt *time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
Account Account
User User
Inviter User
}
// Collaborations retrieves a list of all the current user's collaborations
func (c *Client) Collaborations() ([]Collaboration, error) {
var cl []Collaboration
_, err := c.MakeApiRequest("GET", "/1.0/user/collaborations", nil, &cl)
if err != nil {
return nil, err
}
return cl, err
}
// Collaboration retrieves a detailed view of one of the current user's
// collaborations
func (c *Client) Collaboration(identifier string) (*Collaboration, error) {
col := new(Collaboration)
_, err := c.MakeApiRequest("GET", "/1.0/user/collaborations/"+identifier, nil, col)
if err != nil {
return nil, err
}
return col, err
}