zenefits

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DateLayout = "2006-01-02"

Variables

This section is empty.

Functions

func GetVacations

func GetVacations(ctx context.Context, client *http.Client, param VacationRequest) (map[string]struct{}, error)

GetVacations returns IDs of users that are currently on vacation

func NewServer

func NewServer(req PeopleRequest, client *http.Client, options ...Option) *mux.Router

NewServer implements new Zenefits limited data exporter

Types

type Auth

type Auth struct {
	// Base is API URL, nil for default
	BaseURL *url.URL `validate:"-"`
}

Auth is API server auth parameters

func (Auth) RequestURL

func (a Auth) RequestURL(rel string) *url.URL

RequestURL returns request URL for a given core object by default, there's just one company corresponding to the api token however, according to API there may be multiple, in that case base API need be initialized to "/core/companies/{company_id}/"

type Department

type Department struct {
	ID   string `json:"id" mapstructure:"dept_id"`
	Name string `json:"name" mapstructure:"dept_name"`
}

Department see https://developers.zenefits.com/docs/department

type Kind

type Kind interface {
	Person | Department | Location | Vacation
}

Kind represents an object kind

type List

type List[T Kind] struct {
	Items   []T       `json:"data"`
	NextURL *util.URL `json:"next_url"`
}

List represents pageable response

type Location

type Location struct {
	ID      string `json:"id" mapstructure:"loc_id"`
	Name    string `json:"name" mapstructure:"loc_name"`
	Country string `json:"country" mapstructure:"loc_country"`
	City    string `json:"city" mapstructure:"loc_city"`
	State   string `json:"state" mapstructure:"loc_state"`
	Street1 string `json:"street1" mapstructure:"loc_street1"`
	Street2 string `json:"street2" mapstructure:"loc_street2"`
	Phone   string `json:"phone" mapstructure:"loc_phone"`
}

Location see https://developers.zenefits.com/docs/location

type Option

type Option func(*apiServer)

Option to customize

func WithLogger

func WithLogger(log zerolog.Logger) Option

func WithRemoveOnVacation

func WithRemoveOnVacation(location *time.Location) Option

type PeopleRequest

type PeopleRequest struct {
	Auth
	DepartmentID *string
	Status       *string
	LocationID   *string
}

func (*PeopleRequest) GetRequest

func (req *PeopleRequest) GetRequest(ctx context.Context) (*http.Request, error)

type Person

type Person struct {
	ID string `json:"id" mapstructure:"zenefits_id"`

	FirstName     string `json:"first_name" mapstructure:"first_name"`
	MiddleName    string `json:"middle_name" mapstructure:"middle_name,omitempty"`
	Lastname      string `json:"last_name" mapstructure:"last_name"`
	PreferredName string `json:"preferred_name" mapstructure:"preferred_name,omitempty"`

	WorkEmail     string `json:"work_email" mapstructure:"id,omitempty"`
	WorkPhone     string `json:"work_phone" mapstructure:"work_phone,omitempty"`
	PersonalEmail string `json:"personal_email" mapstructure:"personal_email,omitempty"`
	PersonalPhone string `json:"personal_phone" mapstructure:"personal_phone,omitempty"`

	Department *Department `json:"department" mapstructure:",squash,omitempty"`
	Title      string      `json:"title" mapstructure:"title"`
	Status     string      `json:"status" mapstructure:"status"`
	Type       string      `json:"type" mapstructure:"type"`

	Location *Location `json:"location" mapstructure:",squash,omitempty"`

	Country string `json:"country" mapstructure:"home_country,omitempty"`
	State   string `json:"state" mapstructure:"home_state,omitempty"`
	City    string `json:"city" mapstructure:"home_city,omitempty"`
	Street1 string `json:"street1" mapstructure:"home_street1,omitempty"`
	Street2 string `json:"street2" mapstructure:"home_street2,omitempty"`
}

Person see https://developers.zenefits.com/docs/people

func GetEmployees

func GetEmployees(ctx context.Context, client *http.Client, param PeopleRequest) ([]Person, error)

GetEmployees returns all employees for a company this method may be optimized by avoiding referenced objects inlining and fetching departments and locations (and other referenced fields, if necessary) individually or via list

type Response

type Response[T Kind] struct {
	Error  string  `json:"error"`
	Status int     `json:"status"`
	Data   List[T] `json:"data"`
}

Response is generic response from zenefits API

type Vacation

type Vacation struct {
	Person Person `json:"person"`
}

Vacation see https://developers.zenefits.com/docs/vacation-requests

type VacationRequest

type VacationRequest struct {
	Auth
	Start, End time.Time
}

func (*VacationRequest) GetRequest

func (req *VacationRequest) GetRequest(ctx context.Context) (*http.Request, error)

Jump to

Keyboard shortcuts

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