github

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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