-
Notifications
You must be signed in to change notification settings - Fork 0
/
hrisemployment.go
330 lines (286 loc) · 12.4 KB
/
hrisemployment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"net/http"
"github.com/Finch-API/finch-api-go/internal/apijson"
"github.com/Finch-API/finch-api-go/internal/param"
"github.com/Finch-API/finch-api-go/internal/requestconfig"
"github.com/Finch-API/finch-api-go/option"
"github.com/Finch-API/finch-api-go/packages/pagination"
)
// HRISEmploymentService contains methods and other services that help with
// interacting with the Finch API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewHRISEmploymentService] method instead.
type HRISEmploymentService struct {
Options []option.RequestOption
}
// NewHRISEmploymentService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewHRISEmploymentService(opts ...option.RequestOption) (r *HRISEmploymentService) {
r = &HRISEmploymentService{}
r.Options = opts
return
}
// Read individual employment and income data
func (r *HRISEmploymentService) GetMany(ctx context.Context, body HRISEmploymentGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[EmploymentDataResponse], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "employer/employment"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Read individual employment and income data
func (r *HRISEmploymentService) GetManyAutoPaging(ctx context.Context, body HRISEmploymentGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[EmploymentDataResponse] {
return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, body, opts...))
}
type EmploymentData struct {
// string A stable Finch `id` (UUID v4) for an individual in the company.
ID string `json:"id"`
// Worker's compensation classification code for this employee
ClassCode string `json:"class_code,nullable"`
// Custom fields for the individual. These are fields which are defined by the
// employer in the system.
CustomFields []EmploymentDataCustomField `json:"custom_fields,nullable"`
// The department object.
Department EmploymentDataDepartment `json:"department,nullable"`
// The employment object.
Employment EmploymentDataEmployment `json:"employment,nullable"`
// The detailed employment status of the individual. Available options: `active`, `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`.
EmploymentStatus EmploymentDataEmploymentStatus `json:"employment_status,nullable"`
EndDate string `json:"end_date,nullable"`
// The legal first name of the individual.
FirstName string `json:"first_name,nullable"`
// The employee's income as reported by the provider. This may not always be
// annualized income, but may be in units of bi-weekly, semi-monthly, daily, etc,
// depending on what information the provider returns.
Income Income `json:"income,nullable"`
// The array of income history.
IncomeHistory []Income `json:"income_history,nullable"`
// `true` if the individual an an active employee or contractor at the company.
IsActive bool `json:"is_active,nullable"`
// The legal last name of the individual.
LastName string `json:"last_name,nullable"`
LatestRehireDate string `json:"latest_rehire_date,nullable"`
Location Location `json:"location,nullable"`
// The manager object representing the manager of the individual within the org.
Manager EmploymentDataManager `json:"manager,nullable"`
// The legal middle name of the individual.
MiddleName string `json:"middle_name,nullable"`
// The source system's unique employment identifier for this individual
SourceID string `json:"source_id,nullable"`
StartDate string `json:"start_date,nullable"`
// The current title of the individual.
Title string `json:"title,nullable"`
// This field is deprecated in favour of `source_id`
WorkID string `json:"work_id,nullable"`
JSON employmentDataJSON `json:"-"`
}
// employmentDataJSON contains the JSON metadata for the struct [EmploymentData]
type employmentDataJSON struct {
ID apijson.Field
ClassCode apijson.Field
CustomFields apijson.Field
Department apijson.Field
Employment apijson.Field
EmploymentStatus apijson.Field
EndDate apijson.Field
FirstName apijson.Field
Income apijson.Field
IncomeHistory apijson.Field
IsActive apijson.Field
LastName apijson.Field
LatestRehireDate apijson.Field
Location apijson.Field
Manager apijson.Field
MiddleName apijson.Field
SourceID apijson.Field
StartDate apijson.Field
Title apijson.Field
WorkID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EmploymentData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r employmentDataJSON) RawJSON() string {
return r.raw
}
type EmploymentDataCustomField struct {
Name string `json:"name"`
Value interface{} `json:"value"`
JSON employmentDataCustomFieldJSON `json:"-"`
}
// employmentDataCustomFieldJSON contains the JSON metadata for the struct
// [EmploymentDataCustomField]
type employmentDataCustomFieldJSON struct {
Name apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EmploymentDataCustomField) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r employmentDataCustomFieldJSON) RawJSON() string {
return r.raw
}
// The department object.
type EmploymentDataDepartment struct {
// The name of the department associated with the individual.
Name string `json:"name,nullable"`
JSON employmentDataDepartmentJSON `json:"-"`
}
// employmentDataDepartmentJSON contains the JSON metadata for the struct
// [EmploymentDataDepartment]
type employmentDataDepartmentJSON struct {
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EmploymentDataDepartment) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r employmentDataDepartmentJSON) RawJSON() string {
return r.raw
}
// The employment object.
type EmploymentDataEmployment struct {
// The secondary employment type of the individual. Options: `full_time`, `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`.
Subtype EmploymentDataEmploymentSubtype `json:"subtype,nullable"`
// The main employment type of the individual.
Type EmploymentDataEmploymentType `json:"type,nullable"`
JSON employmentDataEmploymentJSON `json:"-"`
}
// employmentDataEmploymentJSON contains the JSON metadata for the struct
// [EmploymentDataEmployment]
type employmentDataEmploymentJSON struct {
Subtype apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EmploymentDataEmployment) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r employmentDataEmploymentJSON) RawJSON() string {
return r.raw
}
// The secondary employment type of the individual. Options: `full_time`, `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`.
type EmploymentDataEmploymentSubtype string
const (
EmploymentDataEmploymentSubtypeFullTime EmploymentDataEmploymentSubtype = "full_time"
EmploymentDataEmploymentSubtypeIntern EmploymentDataEmploymentSubtype = "intern"
EmploymentDataEmploymentSubtypePartTime EmploymentDataEmploymentSubtype = "part_time"
EmploymentDataEmploymentSubtypeTemp EmploymentDataEmploymentSubtype = "temp"
EmploymentDataEmploymentSubtypeSeasonal EmploymentDataEmploymentSubtype = "seasonal"
EmploymentDataEmploymentSubtypeIndividualContractor EmploymentDataEmploymentSubtype = "individual_contractor"
)
func (r EmploymentDataEmploymentSubtype) IsKnown() bool {
switch r {
case EmploymentDataEmploymentSubtypeFullTime, EmploymentDataEmploymentSubtypeIntern, EmploymentDataEmploymentSubtypePartTime, EmploymentDataEmploymentSubtypeTemp, EmploymentDataEmploymentSubtypeSeasonal, EmploymentDataEmploymentSubtypeIndividualContractor:
return true
}
return false
}
// The main employment type of the individual.
type EmploymentDataEmploymentType string
const (
EmploymentDataEmploymentTypeEmployee EmploymentDataEmploymentType = "employee"
EmploymentDataEmploymentTypeContractor EmploymentDataEmploymentType = "contractor"
)
func (r EmploymentDataEmploymentType) IsKnown() bool {
switch r {
case EmploymentDataEmploymentTypeEmployee, EmploymentDataEmploymentTypeContractor:
return true
}
return false
}
// The detailed employment status of the individual. Available options: `active`, `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`.
type EmploymentDataEmploymentStatus string
const (
EmploymentDataEmploymentStatusActive EmploymentDataEmploymentStatus = "active"
EmploymentDataEmploymentStatusDeceased EmploymentDataEmploymentStatus = "deceased"
EmploymentDataEmploymentStatusLeave EmploymentDataEmploymentStatus = "leave"
EmploymentDataEmploymentStatusOnboarding EmploymentDataEmploymentStatus = "onboarding"
EmploymentDataEmploymentStatusPrehire EmploymentDataEmploymentStatus = "prehire"
EmploymentDataEmploymentStatusRetired EmploymentDataEmploymentStatus = "retired"
EmploymentDataEmploymentStatusTerminated EmploymentDataEmploymentStatus = "terminated"
)
func (r EmploymentDataEmploymentStatus) IsKnown() bool {
switch r {
case EmploymentDataEmploymentStatusActive, EmploymentDataEmploymentStatusDeceased, EmploymentDataEmploymentStatusLeave, EmploymentDataEmploymentStatusOnboarding, EmploymentDataEmploymentStatusPrehire, EmploymentDataEmploymentStatusRetired, EmploymentDataEmploymentStatusTerminated:
return true
}
return false
}
// The manager object representing the manager of the individual within the org.
type EmploymentDataManager struct {
// A stable Finch `id` (UUID v4) for an individual in the company.
ID string `json:"id"`
JSON employmentDataManagerJSON `json:"-"`
}
// employmentDataManagerJSON contains the JSON metadata for the struct
// [EmploymentDataManager]
type employmentDataManagerJSON struct {
ID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EmploymentDataManager) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r employmentDataManagerJSON) RawJSON() string {
return r.raw
}
type EmploymentDataResponse struct {
Body EmploymentData `json:"body"`
Code int64 `json:"code"`
IndividualID string `json:"individual_id"`
JSON employmentDataResponseJSON `json:"-"`
}
// employmentDataResponseJSON contains the JSON metadata for the struct
// [EmploymentDataResponse]
type employmentDataResponseJSON struct {
Body apijson.Field
Code apijson.Field
IndividualID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EmploymentDataResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r employmentDataResponseJSON) RawJSON() string {
return r.raw
}
type HRISEmploymentGetManyParams struct {
// The array of batch requests.
Requests param.Field[[]HRISEmploymentGetManyParamsRequest] `json:"requests,required"`
}
func (r HRISEmploymentGetManyParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type HRISEmploymentGetManyParamsRequest struct {
// A stable Finch `id` (UUID v4) for an individual in the company. There is no
// limit to the number of `individual_id` to send per request. It is preferantial
// to send all ids in a single request for Finch to optimize provider rate-limits.
IndividualID param.Field[string] `json:"individual_id,required"`
}
func (r HRISEmploymentGetManyParamsRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}