github

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package github provides a client for interacting with the GitHub API, including fetching authenticated user information and contribution data.

Package github provides a function to initialize the GitHub client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	Do(query string, variables map[string]interface{}, response interface{}) error
}

APIClient interface defines the methods we need from the client

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds the API client

func NewClient

func NewClient(apiClient APIClient) *Client

NewClient creates a new GitHub client

func (*Client) FetchContributions

func (c *Client) FetchContributions(username string, year int) (*types.ContributionsResponse, error)

FetchContributions retrieves the contribution data for a given username and year from GitHub.

func (*Client) GetAuthenticatedUser

func (c *Client) GetAuthenticatedUser() (string, error)

GetAuthenticatedUser fetches the authenticated user's login name from GitHub.

func (*Client) GetUserJoinYear

func (c *Client) GetUserJoinYear(username string) (int, error)

GetUserJoinYear fetches the year a user joined GitHub using the GitHub API.

type ClientInitializer

type ClientInitializer func() (*Client, error)

ClientInitializer is a function type for initializing GitHub clients

var InitializeGitHubClient ClientInitializer = func() (*Client, error) {
	apiClient, err := api.DefaultGraphQLClient()
	if err != nil {
		return nil, fmt.Errorf("failed to create GraphQL client: %w", err)
	}
	return NewClient(apiClient), nil
}

InitializeGitHubClient is the default client initializer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL