| 1 |
// Copyright 2013 The go-github AUTHORS. All rights reserved. |
| 2 |
// |
| 3 |
// Use of this source code is governed by a BSD-style |
| 4 |
// license that can be found in the LICENSE file. |
| 5 |
|
| 6 |
package github |
| 7 |
|
| 8 |
import "context" |
| 9 |
|
| 10 |
// ActivityService handles communication with the activity related |
| 11 |
// methods of the GitHub API. |
| 12 |
// |
| 13 |
// GitHub API docs: https://docs.github.com/rest/activity/ |
| 14 |
type ActivityService service |
| 15 |
|
| 16 |
// FeedLink represents a link to a related resource. |
| 17 |
type FeedLink struct { |
| 18 |
HRef *string `json:"href,omitempty"` |
| 19 |
Type *string `json:"type,omitempty"` |
| 20 |
} |
| 21 |
|
| 22 |
// Feeds represents timeline resources in Atom format. |
| 23 |
type Feeds struct { |
| 24 |
TimelineURL *string `json:"timeline_url,omitempty"` |
| 25 |
UserURL *string `json:"user_url,omitempty"` |
| 26 |
CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"` |
| 27 |
CurrentUserURL *string `json:"current_user_url,omitempty"` |
| 28 |
CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"` |
| 29 |
CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"` |
| 30 |
CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"` |
| 31 |
Links *FeedLinks `json:"_links,omitempty"` |
| 32 |
} |
| 33 |
|
| 34 |
// FeedLinks represents the links in a Feed. |
| 35 |
type FeedLinks struct { |
| 36 |
Timeline *FeedLink `json:"timeline,omitempty"` |
| 37 |
User *FeedLink `json:"user,omitempty"` |
| 38 |
CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"` |
| 39 |
CurrentUser *FeedLink `json:"current_user,omitempty"` |
| 40 |
CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"` |
| 41 |
CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"` |
| 42 |
CurrentUserOrganizations []*FeedLink `json:"current_user_organizations,omitempty"` |
| 43 |
} |
| 44 |
|
| 45 |
// ListFeeds lists all the feeds available to the authenticated user. |
| 46 |
// |
| 47 |
// GitHub provides several timeline resources in Atom format: |
| 48 |
// |
| 49 |
// Timeline: The GitHub global public timeline |
| 50 |
// User: The public timeline for any user, using URI template |
| 51 |
// Current user public: The public timeline for the authenticated user |
| 52 |
// Current user: The private timeline for the authenticated user |
| 53 |
// Current user actor: The private timeline for activity created by the |
| 54 |
// authenticated user |
| 55 |
// Current user organizations: The private timeline for the organizations |
| 56 |
// the authenticated user is a member of. |
| 57 |
// |
| 58 |
// Note: Private feeds are only returned when authenticating via Basic Auth |
| 59 |
// since current feed URIs use the older, non revocable auth tokens. |
| 60 |
// |
| 61 |
// GitHub API docs: https://docs.github.com/rest/activity/feeds#get-feeds |
| 62 |
// |
| 63 |
//meta:operation GET /feeds |
| 64 |
func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) { |
| 65 |
req, err := s.client.NewRequest("GET", "feeds", nil) |
| 66 |
if err != nil { |
| 67 |
return nil, nil, err |
| 68 |
} |
| 69 |
|
| 70 |
f := &Feeds{} |
| 71 |
resp, err := s.client.Do(ctx, req, f) |
| 72 |
if err != nil { |
| 73 |
return nil, resp, err |
| 74 |
} |
| 75 |
|
| 76 |
return f, resp, nil |
| 77 |
} |