forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 83
/
user.go
73 lines (60 loc) · 1.73 KB
/
user.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2017 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package scm
import (
"context"
"time"
)
type (
// User represents a user account.
User struct {
ID int
Login string
Name string
Email string
Avatar string
Link string
IsAdmin bool `json:"isAdmin,omitempty"`
Created time.Time
Updated time.Time
}
// Email represents a user email.
Email struct {
Value string
Primary bool
Verified bool
}
// UserToken represents a user token.
UserToken struct {
ID int64
Token string
}
// Invitation represents a repo invitation
Invitation struct {
ID int64
Repo *Repository
Invitee *User
Inviter *User
Permissions string
Link string
Created time.Time
}
// UserService provides access to user account resources.
UserService interface {
// Find returns the authenticated user.
Find(context.Context) (*User, *Response, error)
// CreateToken creates a user token.
CreateToken(context.Context, string, string) (*UserToken, *Response, error)
// DeleteToken deletes a user token.
DeleteToken(context.Context, int64) (*Response, error)
// FindEmail returns the authenticated user email.
FindEmail(context.Context) (string, *Response, error)
// FindLogin returns the user account by username.
FindLogin(context.Context, string) (*User, *Response, error)
// ListInvitations lists repository or organization invitations for the current user
ListInvitations(context.Context) ([]*Invitation, *Response, error)
// AcceptInvitation accepts an invitation for the current user
AcceptInvitation(context.Context, int64) (*Response, error)
}
)