-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhrisindividual.go
More file actions
458 lines (398 loc) · 16.1 KB
/
hrisindividual.go
File metadata and controls
458 lines (398 loc) · 16.1 KB
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"net/http"
"reflect"
"slices"
"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"
"github.com/tidwall/gjson"
)
// HRISIndividualService 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 [NewHRISIndividualService] method instead.
type HRISIndividualService struct {
Options []option.RequestOption
}
// NewHRISIndividualService 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 NewHRISIndividualService(opts ...option.RequestOption) (r *HRISIndividualService) {
r = &HRISIndividualService{}
r.Options = opts
return
}
// Read individual data, excluding income and employment data
func (r *HRISIndividualService) GetMany(ctx context.Context, body HRISIndividualGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[IndividualResponse], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "employer/individual"
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 data, excluding income and employment data
func (r *HRISIndividualService) GetManyAutoPaging(ctx context.Context, body HRISIndividualGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[IndividualResponse] {
return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, body, opts...))
}
type Individual struct {
// A stable Finch `id` (UUID v4) for an individual in the company.
ID string `json:"id" format:"uuid"`
Code float64 `json:"code"`
Dob string `json:"dob,nullable"`
// This field can have the runtime type of [[]IndividualObjectEmail].
Emails interface{} `json:"emails"`
// Social Security Number of the individual in **encrypted** format. This field is
// only available with the `ssn` scope enabled and the
// `options: { include: ['ssn'] }` param set in the body.
EncryptedSsn string `json:"encrypted_ssn,nullable"`
// The EEOC-defined ethnicity of the individual.
Ethnicity IndividualEthnicity `json:"ethnicity,nullable"`
FinchCode string `json:"finch_code"`
// The legal first name of the individual.
FirstName string `json:"first_name,nullable"`
// The gender of the individual.
Gender IndividualGender `json:"gender,nullable"`
// The legal last name of the individual.
LastName string `json:"last_name,nullable"`
Message string `json:"message"`
// The legal middle name of the individual.
MiddleName string `json:"middle_name,nullable"`
Name string `json:"name"`
// This field can have the runtime type of [[]IndividualObjectPhoneNumber].
PhoneNumbers interface{} `json:"phone_numbers"`
// The preferred name of the individual.
PreferredName string `json:"preferred_name,nullable"`
Residence Location `json:"residence,nullable"`
// Social Security Number of the individual. This field is only available with the
// `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in the
// body.
// [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field).
Ssn string `json:"ssn,nullable"`
JSON individualJSON `json:"-"`
union IndividualUnion
}
// individualJSON contains the JSON metadata for the struct [Individual]
type individualJSON struct {
ID apijson.Field
Code apijson.Field
Dob apijson.Field
Emails apijson.Field
EncryptedSsn apijson.Field
Ethnicity apijson.Field
FinchCode apijson.Field
FirstName apijson.Field
Gender apijson.Field
LastName apijson.Field
Message apijson.Field
MiddleName apijson.Field
Name apijson.Field
PhoneNumbers apijson.Field
PreferredName apijson.Field
Residence apijson.Field
Ssn apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r individualJSON) RawJSON() string {
return r.raw
}
func (r *Individual) UnmarshalJSON(data []byte) (err error) {
*r = Individual{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [IndividualUnion] interface which you can cast to the specific
// types for more type safety.
//
// Possible runtime types of the union are [IndividualObject],
// [IndividualBatchError].
func (r Individual) AsUnion() IndividualUnion {
return r.union
}
// Union satisfied by [IndividualObject] or [IndividualBatchError].
type IndividualUnion interface {
implementsIndividual()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*IndividualUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(IndividualObject{}),
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(IndividualBatchError{}),
},
)
}
type IndividualObject struct {
// A stable Finch `id` (UUID v4) for an individual in the company.
ID string `json:"id,required" format:"uuid"`
Dob string `json:"dob,required,nullable"`
// The EEOC-defined ethnicity of the individual.
Ethnicity IndividualObjectEthnicity `json:"ethnicity,required,nullable"`
// The legal first name of the individual.
FirstName string `json:"first_name,required,nullable"`
// The gender of the individual.
Gender IndividualObjectGender `json:"gender,required,nullable"`
// The legal last name of the individual.
LastName string `json:"last_name,required,nullable"`
// The legal middle name of the individual.
MiddleName string `json:"middle_name,required,nullable"`
PhoneNumbers []IndividualObjectPhoneNumber `json:"phone_numbers,required,nullable"`
// The preferred name of the individual.
PreferredName string `json:"preferred_name,required,nullable"`
Residence Location `json:"residence,required,nullable"`
Emails []IndividualObjectEmail `json:"emails,nullable"`
// Social Security Number of the individual in **encrypted** format. This field is
// only available with the `ssn` scope enabled and the
// `options: { include: ['ssn'] }` param set in the body.
EncryptedSsn string `json:"encrypted_ssn,nullable"`
// Social Security Number of the individual. This field is only available with the
// `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in the
// body.
// [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field).
Ssn string `json:"ssn,nullable"`
JSON individualObjectJSON `json:"-"`
}
// individualObjectJSON contains the JSON metadata for the struct
// [IndividualObject]
type individualObjectJSON struct {
ID apijson.Field
Dob apijson.Field
Ethnicity apijson.Field
FirstName apijson.Field
Gender apijson.Field
LastName apijson.Field
MiddleName apijson.Field
PhoneNumbers apijson.Field
PreferredName apijson.Field
Residence apijson.Field
Emails apijson.Field
EncryptedSsn apijson.Field
Ssn apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IndividualObject) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r individualObjectJSON) RawJSON() string {
return r.raw
}
func (r IndividualObject) implementsIndividual() {}
// The EEOC-defined ethnicity of the individual.
type IndividualObjectEthnicity string
const (
IndividualObjectEthnicityAsian IndividualObjectEthnicity = "asian"
IndividualObjectEthnicityWhite IndividualObjectEthnicity = "white"
IndividualObjectEthnicityBlackOrAfricanAmerican IndividualObjectEthnicity = "black_or_african_american"
IndividualObjectEthnicityNativeHawaiianOrPacificIslander IndividualObjectEthnicity = "native_hawaiian_or_pacific_islander"
IndividualObjectEthnicityAmericanIndianOrAlaskaNative IndividualObjectEthnicity = "american_indian_or_alaska_native"
IndividualObjectEthnicityHispanicOrLatino IndividualObjectEthnicity = "hispanic_or_latino"
IndividualObjectEthnicityTwoOrMoreRaces IndividualObjectEthnicity = "two_or_more_races"
IndividualObjectEthnicityDeclineToSpecify IndividualObjectEthnicity = "decline_to_specify"
)
func (r IndividualObjectEthnicity) IsKnown() bool {
switch r {
case IndividualObjectEthnicityAsian, IndividualObjectEthnicityWhite, IndividualObjectEthnicityBlackOrAfricanAmerican, IndividualObjectEthnicityNativeHawaiianOrPacificIslander, IndividualObjectEthnicityAmericanIndianOrAlaskaNative, IndividualObjectEthnicityHispanicOrLatino, IndividualObjectEthnicityTwoOrMoreRaces, IndividualObjectEthnicityDeclineToSpecify:
return true
}
return false
}
// The gender of the individual.
type IndividualObjectGender string
const (
IndividualObjectGenderFemale IndividualObjectGender = "female"
IndividualObjectGenderMale IndividualObjectGender = "male"
IndividualObjectGenderOther IndividualObjectGender = "other"
IndividualObjectGenderDeclineToSpecify IndividualObjectGender = "decline_to_specify"
)
func (r IndividualObjectGender) IsKnown() bool {
switch r {
case IndividualObjectGenderFemale, IndividualObjectGenderMale, IndividualObjectGenderOther, IndividualObjectGenderDeclineToSpecify:
return true
}
return false
}
type IndividualObjectPhoneNumber struct {
Data string `json:"data,required,nullable"`
Type IndividualObjectPhoneNumbersType `json:"type,required,nullable"`
JSON individualObjectPhoneNumberJSON `json:"-"`
}
// individualObjectPhoneNumberJSON contains the JSON metadata for the struct
// [IndividualObjectPhoneNumber]
type individualObjectPhoneNumberJSON struct {
Data apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IndividualObjectPhoneNumber) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r individualObjectPhoneNumberJSON) RawJSON() string {
return r.raw
}
type IndividualObjectPhoneNumbersType string
const (
IndividualObjectPhoneNumbersTypeWork IndividualObjectPhoneNumbersType = "work"
IndividualObjectPhoneNumbersTypePersonal IndividualObjectPhoneNumbersType = "personal"
)
func (r IndividualObjectPhoneNumbersType) IsKnown() bool {
switch r {
case IndividualObjectPhoneNumbersTypeWork, IndividualObjectPhoneNumbersTypePersonal:
return true
}
return false
}
type IndividualObjectEmail struct {
Data string `json:"data,required"`
Type IndividualObjectEmailsType `json:"type,required,nullable"`
JSON individualObjectEmailJSON `json:"-"`
}
// individualObjectEmailJSON contains the JSON metadata for the struct
// [IndividualObjectEmail]
type individualObjectEmailJSON struct {
Data apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IndividualObjectEmail) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r individualObjectEmailJSON) RawJSON() string {
return r.raw
}
type IndividualObjectEmailsType string
const (
IndividualObjectEmailsTypeWork IndividualObjectEmailsType = "work"
IndividualObjectEmailsTypePersonal IndividualObjectEmailsType = "personal"
)
func (r IndividualObjectEmailsType) IsKnown() bool {
switch r {
case IndividualObjectEmailsTypeWork, IndividualObjectEmailsTypePersonal:
return true
}
return false
}
type IndividualBatchError struct {
Code float64 `json:"code,required"`
Message string `json:"message,required"`
Name string `json:"name,required"`
FinchCode string `json:"finch_code"`
JSON individualBatchErrorJSON `json:"-"`
}
// individualBatchErrorJSON contains the JSON metadata for the struct
// [IndividualBatchError]
type individualBatchErrorJSON struct {
Code apijson.Field
Message apijson.Field
Name apijson.Field
FinchCode apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IndividualBatchError) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r individualBatchErrorJSON) RawJSON() string {
return r.raw
}
func (r IndividualBatchError) implementsIndividual() {}
// The EEOC-defined ethnicity of the individual.
type IndividualEthnicity string
const (
IndividualEthnicityAsian IndividualEthnicity = "asian"
IndividualEthnicityWhite IndividualEthnicity = "white"
IndividualEthnicityBlackOrAfricanAmerican IndividualEthnicity = "black_or_african_american"
IndividualEthnicityNativeHawaiianOrPacificIslander IndividualEthnicity = "native_hawaiian_or_pacific_islander"
IndividualEthnicityAmericanIndianOrAlaskaNative IndividualEthnicity = "american_indian_or_alaska_native"
IndividualEthnicityHispanicOrLatino IndividualEthnicity = "hispanic_or_latino"
IndividualEthnicityTwoOrMoreRaces IndividualEthnicity = "two_or_more_races"
IndividualEthnicityDeclineToSpecify IndividualEthnicity = "decline_to_specify"
)
func (r IndividualEthnicity) IsKnown() bool {
switch r {
case IndividualEthnicityAsian, IndividualEthnicityWhite, IndividualEthnicityBlackOrAfricanAmerican, IndividualEthnicityNativeHawaiianOrPacificIslander, IndividualEthnicityAmericanIndianOrAlaskaNative, IndividualEthnicityHispanicOrLatino, IndividualEthnicityTwoOrMoreRaces, IndividualEthnicityDeclineToSpecify:
return true
}
return false
}
// The gender of the individual.
type IndividualGender string
const (
IndividualGenderFemale IndividualGender = "female"
IndividualGenderMale IndividualGender = "male"
IndividualGenderOther IndividualGender = "other"
IndividualGenderDeclineToSpecify IndividualGender = "decline_to_specify"
)
func (r IndividualGender) IsKnown() bool {
switch r {
case IndividualGenderFemale, IndividualGenderMale, IndividualGenderOther, IndividualGenderDeclineToSpecify:
return true
}
return false
}
type IndividualResponse struct {
Body Individual `json:"body,required"`
Code int64 `json:"code,required"`
IndividualID string `json:"individual_id,required"`
JSON individualResponseJSON `json:"-"`
}
// individualResponseJSON contains the JSON metadata for the struct
// [IndividualResponse]
type individualResponseJSON struct {
Body apijson.Field
Code apijson.Field
IndividualID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IndividualResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r individualResponseJSON) RawJSON() string {
return r.raw
}
type HRISIndividualGetManyParams struct {
Options param.Field[HRISIndividualGetManyParamsOptions] `json:"options"`
Requests param.Field[[]HRISIndividualGetManyParamsRequest] `json:"requests"`
}
func (r HRISIndividualGetManyParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type HRISIndividualGetManyParamsOptions struct {
Include param.Field[[]string] `json:"include"`
}
func (r HRISIndividualGetManyParamsOptions) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type HRISIndividualGetManyParamsRequest struct {
IndividualID param.Field[string] `json:"individual_id"`
}
func (r HRISIndividualGetManyParamsRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}