A Go interface to Greenhouse.io's API
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"),
)
All candidates
candidates, err := client.Candidates().Fetch()
All candidates created before
candidates, err := client.Candidates().CreatedBefore(time.Now()).Fetch()
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)
}
}
Documentation for the Harvest and Job Board web APIs can be found at developers.greenhouse.io.
Install Docker.
Linting and tests are run within a golangci-lint
container.
Linting
make lint
Run tests
make test