recurse

package
v0.0.0-...-6c1d02c Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken string

An AccessToken is used to authenticate requests to the Recurse API.

type AccessTokenFunc

type AccessTokenFunc func(context.Context) (AccessToken, error)

AccessTokenFunc returns the current Recurse API access token.

func StaticAccessToken

func StaticAccessToken(token string) AccessTokenFunc

StaticAccessToken makes an AccessTokenFunc that always returns the provided access token.

type Batch

type Batch struct {
	Name      string    `json:"name"`
	StartDate Datestamp `json:"start_date"`
}

A Batch is a cycle of the Recurse Center retreat.

https://github.com/recursecenter/wiki/wiki/Recurse-Center-API#Batches

func (Batch) IsMini

func (b Batch) IsMini() bool

IsMini returns whether the batch was a mini batch.

func (Batch) IsSecondWeek

func (b Batch) IsSecondWeek(now time.Time) bool

IsSecondWeek returns whether the time is within the batch's second week.

type Client

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

A Client sends HTTP requests to the Recurse API.

func NewClient

func NewClient(accessToken AccessTokenFunc, opts ...ClientOpt) (*Client, error)

NewClient creates a new Recurse API client.

func (*Client) ActiveRecursers

func (c *Client) ActiveRecursers(ctx context.Context) ([]Profile, error)

ActiveRecursers fetches the profiles for all recursers currently at RC.

https://github.com/recursecenter/wiki/wiki/Recurse-Center-API#search

func (*Client) AllBatches

func (c *Client) AllBatches(ctx context.Context) ([]Batch, error)

AllBatches returns all RC batches up to the current batch with the most recent batch first.

https://github.com/recursecenter/wiki/wiki/Recurse-Center-API#list-all-batches

func (*Client) IsCurrentlyAtRC

func (c *Client) IsCurrentlyAtRC(ctx context.Context, zulipID int64) (bool, error)

IsCurrentlyAtRC returns whether the user's Zulip ID appears in the list of profiles for recursers currently at RC.

type ClientOpt

type ClientOpt func(*Client) error

A ClientOpt is used to configure a Client.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOpt

WithBaseURL sets a custom Recurse API URL.

The default value is "https://www.recurse.com/api/v1".

func WithHTTP

func WithHTTP(http *http.Client) ClientOpt

WithHTTP sets a custom HTTP client for sending requests.

The default value is `http.DefaultClient`.

type Datestamp

type Datestamp time.Time

Datestamp is a time.Time wrapper for parsing dates. It implements json.Unmarshaler by parsing the value with time.DateOnly in UTC.

func (Datestamp) Equal

func (d Datestamp) Equal(other Datestamp) bool

func (*Datestamp) MarshalJSON

func (d *Datestamp) MarshalJSON() ([]byte, error)

func (*Datestamp) UnmarshalJSON

func (d *Datestamp) UnmarshalJSON(b []byte) error

type Profile

type Profile struct {
	Name    string `json:"name"`
	ZulipID int64  `json:"zulip_id"`
}

A Profile contains information about a Recurser.

Profile data is updated at midnight on the last day (Friday) of a batch.

https://github.com/recursecenter/wiki/wiki/Recurse-Center-API#Profiles

type ResponseError

type ResponseError struct {
	Response *http.Response
}

ResponseError is the type of error returned when the response status indicates an error (400 or greater).

func (*ResponseError) Error

func (r *ResponseError) Error() string

Jump to

Keyboard shortcuts

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