activity.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. package github
  6. import "context"
  7. // ActivityService handles communication with the activity related
  8. // methods of the GitHub API.
  9. //
  10. // GitHub API docs: https://developer.github.com/v3/activity/
  11. type ActivityService service
  12. // FeedLink represents a link to a related resource.
  13. type FeedLink struct {
  14. HRef *string `json:"href,omitempty"`
  15. Type *string `json:"type,omitempty"`
  16. }
  17. // Feeds represents timeline resources in Atom format.
  18. type Feeds struct {
  19. TimelineURL *string `json:"timeline_url,omitempty"`
  20. UserURL *string `json:"user_url,omitempty"`
  21. CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"`
  22. CurrentUserURL *string `json:"current_user_url,omitempty"`
  23. CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"`
  24. CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"`
  25. CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"`
  26. Links *struct {
  27. Timeline *FeedLink `json:"timeline,omitempty"`
  28. User *FeedLink `json:"user,omitempty"`
  29. CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
  30. CurrentUser *FeedLink `json:"current_user,omitempty"`
  31. CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
  32. CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
  33. CurrentUserOrganizations []FeedLink `json:"current_user_organizations,omitempty"`
  34. } `json:"_links,omitempty"`
  35. }
  36. // ListFeeds lists all the feeds available to the authenticated user.
  37. //
  38. // GitHub provides several timeline resources in Atom format:
  39. // Timeline: The GitHub global public timeline
  40. // User: The public timeline for any user, using URI template
  41. // Current user public: The public timeline for the authenticated user
  42. // Current user: The private timeline for the authenticated user
  43. // Current user actor: The private timeline for activity created by the
  44. // authenticated user
  45. // Current user organizations: The private timeline for the organizations
  46. // the authenticated user is a member of.
  47. //
  48. // Note: Private feeds are only returned when authenticating via Basic Auth
  49. // since current feed URIs use the older, non revocable auth tokens.
  50. func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) {
  51. req, err := s.client.NewRequest("GET", "feeds", nil)
  52. if err != nil {
  53. return nil, nil, err
  54. }
  55. f := &Feeds{}
  56. resp, err := s.client.Do(ctx, req, f)
  57. if err != nil {
  58. return nil, resp, err
  59. }
  60. return f, resp, nil
  61. }