aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/users_emails.go
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-10-04 19:44:06 -0700
committerChristine Dodrill <me@christine.website>2018-10-04 19:44:06 -0700
commit1c1d089725dd9f98b7ac73276d07dbadb388b748 (patch)
treeb0e783f5e2d485050e0072faf3b303bdc66e3539 /vendor/github.com/google/go-github/github/users_emails.go
parente36f755db2198a96e2b87781f5f5432fcee092dd (diff)
downloadx-1c1d089725dd9f98b7ac73276d07dbadb388b748.tar.xz
x-1c1d089725dd9f98b7ac73276d07dbadb388b748.zip
add Dockerfile
Diffstat (limited to 'vendor/github.com/google/go-github/github/users_emails.go')
-rw-r--r--vendor/github.com/google/go-github/github/users_emails.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/vendor/github.com/google/go-github/github/users_emails.go b/vendor/github.com/google/go-github/github/users_emails.go
new file mode 100644
index 0000000..0bbd462
--- /dev/null
+++ b/vendor/github.com/google/go-github/github/users_emails.go
@@ -0,0 +1,71 @@
+// Copyright 2013 The go-github AUTHORS. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package github
+
+import "context"
+
+// UserEmail represents user's email address
+type UserEmail struct {
+ Email *string `json:"email,omitempty"`
+ Primary *bool `json:"primary,omitempty"`
+ Verified *bool `json:"verified,omitempty"`
+}
+
+// ListEmails lists all email addresses for the authenticated user.
+//
+// GitHub API docs: https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user
+func (s *UsersService) ListEmails(ctx context.Context, opt *ListOptions) ([]*UserEmail, *Response, error) {
+ u := "user/emails"
+ u, err := addOptions(u, opt)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var emails []*UserEmail
+ resp, err := s.client.Do(ctx, req, &emails)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return emails, resp, nil
+}
+
+// AddEmails adds email addresses of the authenticated user.
+//
+// GitHub API docs: https://developer.github.com/v3/users/emails/#add-email-addresses
+func (s *UsersService) AddEmails(ctx context.Context, emails []string) ([]*UserEmail, *Response, error) {
+ u := "user/emails"
+ req, err := s.client.NewRequest("POST", u, emails)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var e []*UserEmail
+ resp, err := s.client.Do(ctx, req, &e)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return e, resp, nil
+}
+
+// DeleteEmails deletes email addresses from authenticated user.
+//
+// GitHub API docs: https://developer.github.com/v3/users/emails/#delete-email-addresses
+func (s *UsersService) DeleteEmails(ctx context.Context, emails []string) (*Response, error) {
+ u := "user/emails"
+ req, err := s.client.NewRequest("DELETE", u, emails)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(ctx, req, nil)
+}