Skip to content

Grayscale-Labs/greenhouse-io-go

Repository files navigation

Greenhouse IO

A Go interface to Greenhouse.io's API

Useage

Creating the Client

NewClient accepts:

  • A context; used for any HTTP requests made using the client.
  • Any struct implementing the httpClient interface; this allows for useage of other HTTP clients, like go-retryablehttp.
  • The API token.
client, err := greenhouseio.NewClient(
  context.Background(),
  &http.Client{
    Timeout: httpTimeout,
  },
  os.Getenv("GREENHOUSE_API_KEY"),
)

Single Request

All candidates

candidates, err := client.Candidates().Fetch()

All candidates created before

candidates, err := client.Candidates().CreatedBefore(time.Now()).Fetch()

Streaming

Streaming puts each resource loaded into a given consumer channel while following the next URL found in each response header. When an error occurs or no next URL is found, an error or nil is sent to a given close signal channel.

All candidates

candidates, closeSignal := make(chan *models.Candidate), make(chan error)
go client.Candidates().Stream(candidates, closeSignal)

for {
	select {
	case err := <-closeSignal:
		if err != nil {
			log.Fatalf("error streaming candidates: %v", err)
		}

		os.Exit(0)
	case candidate := <-candidates:
		log.Default().Println("streamed", candidate.ID)
	}
}

API Documentation

Documentation for the Harvest and Job Board web APIs can be found at developers.greenhouse.io.

Development

Prerequisites

Install Docker.

Linting and tests are run within a golangci-lint container.

Commands

Linting

make lint

Run tests

make test

About

Go API wrapper for Greenhouse.io API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published