The official EmploymentHero Go client library.
- Go 1.16 or later
Make sure your project is using Go Modules (it will have a go.mod
file in its
root if it already is):
go mod init
Then, reference stripe-go in a Go program with import
:
import (
"github.com/Thinkei/employmenthero-go"
)
Run any of the normal go
commands (build
/install
/test
). The Go
toolchain will resolve and fetch the stripe-go module automatically.
Alternatively, you can also explicitly go get
the package into a project:
go get -u github.com/Thinkei/employmenthero-go
For a conprehensive list of examples, check out the API documentation
For details on all funtionality in this library, check out the Go documentation
Below are a few of simple examples:
import "github.com/Thinkei/employmenthero-go"
// Create a client instance
c, err := employmenthero.NewClient("clientID", "secretID", "redirectUri", "OAuthHost", "apiHost")
c.SetLog(os.Stdout) // Set log to terminal stdout
// Get Authorization code and then use it to get the EH OAuth2 Access tokens
authroizationCode = "<authorizationCode>"
responseToken, err := client.GetOAuth2Access(ctx, authorizationCode)
// Save the refresh_token to anywhere you want,
// but use it when you call other APIs to get our resources
refreshToken := responseToken.RefreshToken
c.SetRefreshToken(responseToken.RefreshToken)
// call other APIs
organisationsResp, err := client.ListOrganisations(ctx, employmenthero.ListParams{})
if err != nil {
fmt.Printf("Get Organisation failed - %s", err)
}
fmt.Println(organisationsResp.Data.Items)
response, err := c.ListOrganisations(context.TODO(), ListParams{})
organisations := response.Data.Items
response, err := c.GetOrganisation(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx")
organisation := response.Data
response, err := c.ListEmployees(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", ListParams{})
employees := response.Data.Items
response, err := c.GetEmployee(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "90a34ef1-50e4-4930-a9d6-yyyy")
employee := response.Data
response, err := c.ListLeaveRequests(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", ListParams{})
leaveRequests := response.Data.Items
response, err := c.GetLeaveRequest(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "90a34ef1-50e4-4930-a9d6-yyyy")
leaveRequest := response.Data
response, err := c.ListTimesheetEntries(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "-", ListParams{})
timesheetEntries := response.Data.Items
response, err := c.ListEmploymentHistories(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "xxxxxx-yyyy", ListParams{})
employmentHistories := response.Data.Items
response, err := c.ListEmergencyContacts(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "xxxx-yyy", ListParams{})
contacts := response.Data.Items
response, err := c.ListTeams(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", ListParams{})
teams := response.Data.Items
response, err := c.ListEmployeesByTeam(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXXX-YYYY-ZZZZ", ListParams{})
employees := response.Data.Items
response, err := c.ListBankAccounts(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXX-YY-ZZZ", ListParams{})
bankAccounts := response.Data.Items
response, err := c.GetTaxDeclaration(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXX-YY-ZZZ", ListParams{})
taxDeclaration := response.Data
response, err := c.GetSuperannuationDetail(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXX-YY-ZZZ", ListParams{})
superannuationDetail := response.Data
response, err := c.ListPayDetails(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXX-YY-ZZZ", ListParams{})
payDetails := response.Data.Items
response, err := c.ListCertifications(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", ListParams{})
certifications := response.Data.Items
response, err := c.ListPolicies(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", ListParams{})
policies := response.Data.Items
response, err := c.ListEmployeeCertifications(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXX-YY-ZZZ", ListParams{})
employeeCertifications := response.Data.Items
response, err := c.ListPayslips(context.TODO(), "90a34ef1-50e4-4930-a9d6-xxxx", "XXX-YY-ZZZ", ListParams{})
payslips := response.Data.Items
Pull requests from the community are welcome. If you submit one, please keep the following guidelines in mind:
- Code must be
go fmt
compliant. - Ensure that
go test
succeeds.
The test suite needs testify's require
package to run:
github.com/stretchr/testify/require
Before running the tests, make sure to grab all of the package's dependencies:
go get -t -v
Run all tests:
make test
For any requests, bug or comments, please [open an issue][issues] or [submit a pull request][pulls].