...

Source file src/github.com/google/go-github/v47/github/activity.go

Documentation: github.com/google/go-github/v47/github

     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/en/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  func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) {
    61  	req, err := s.client.NewRequest("GET", "feeds", nil)
    62  	if err != nil {
    63  		return nil, nil, err
    64  	}
    65  
    66  	f := &Feeds{}
    67  	resp, err := s.client.Do(ctx, req, f)
    68  	if err != nil {
    69  		return nil, resp, err
    70  	}
    71  
    72  	return f, resp, nil
    73  }
    74  

View as plain text