Skip to content

Commit

Permalink
feat(api): updates (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Nov 13, 2023
1 parent afe25dd commit 674fc9e
Show file tree
Hide file tree
Showing 10 changed files with 1,099 additions and 33 deletions.
3 changes: 3 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (r *DisconnectResponse) UnmarshalJSON(data []byte) (err error) {
}

type Introspection struct {
// The Finch uuid of the account used to connect this company.
AccountID string `json:"account_id,required"`
// The client id of the application associated with the `access_token`.
ClientID string `json:"client_id,required"`
// The Finch uuid of the company associated with the `access_token`.
Expand All @@ -84,6 +86,7 @@ type Introspection struct {

// introspectionJSON contains the JSON metadata for the struct [Introspection]
type introspectionJSON struct {
AccountID apijson.Field
ClientID apijson.Field
CompanyID apijson.Field
Manual apijson.Field
Expand Down
27 changes: 27 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ package finchgo

import (
"github.com/Finch-API/finch-api-go/internal/apierror"
"github.com/Finch-API/finch-api-go/internal/shared"
)

type Error = apierror.Error

// - `supported`: This operation is supported by both the provider and Finch <br>
// - `not_supported_by_finch`: This operation is not supported by Finch but
// supported by the provider <br>
// - `not_supported_by_provider`: This operation is not supported by the provider,
// so Finch cannot support <br>
// - `client_access_only`: This behavior is supported by the provider, but only
// available to the client and not to Finch
//
// This is an alias to an internal type.
type OperationSupport = shared.OperationSupport

// This is an alias to an internal value.
const OperationSupportSupported = shared.OperationSupportSupported

// This is an alias to an internal value.
const OperationSupportNotSupportedByFinch = shared.OperationSupportNotSupportedByFinch

// This is an alias to an internal value.
const OperationSupportNotSupportedByProvider = shared.OperationSupportNotSupportedByProvider

// This is an alias to an internal value.
const OperationSupportClientAccessOnly = shared.OperationSupportClientAccessOnly

// This is an alias to an internal type.
type OperationSupportMatrix = shared.OperationSupportMatrix
26 changes: 17 additions & 9 deletions api.md

Large diffs are not rendered by default.

156 changes: 148 additions & 8 deletions hrisbenefit.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,38 +149,159 @@ const (
BenefitContributionTypePercent BenefitContributionType = "percent"
)

type BenefitFeaturesAndOperations struct {
SupportedFeatures BenefitFeaturesAndOperationsSupportedFeatures `json:"supported_features"`
SupportedOperations SupportPerBenefitType `json:"supported_operations"`
JSON benefitFeaturesAndOperationsJSON
}

// benefitFeaturesAndOperationsJSON contains the JSON metadata for the struct
// [BenefitFeaturesAndOperations]
type benefitFeaturesAndOperationsJSON struct {
SupportedFeatures apijson.Field
SupportedOperations apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *BenefitFeaturesAndOperations) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type BenefitFeaturesAndOperationsSupportedFeatures struct {
// Whether the provider supports an annual maximum for this benefit.
AnnualMaximum bool `json:"annual_maximum,nullable"`
// Whether the provider supports catch up for this benefit. This field will only be
// true for retirement benefits.
CatchUp bool `json:"catch_up,nullable"`
// Supported contribution types. An empty array indicates contributions are not
// supported.
CompanyContribution []BenefitFeaturesAndOperationsSupportedFeaturesCompanyContribution `json:"company_contribution,nullable"`
Description string `json:"description,nullable"`
// Supported deduction types. An empty array indicates deductions are not
// supported.
EmployeeDeduction []BenefitFeaturesAndOperationsSupportedFeaturesEmployeeDeduction `json:"employee_deduction,nullable"`
// The list of frequencies supported by the provider for this benefit
Frequencies []BenefitFrequency `json:"frequencies"`
// Whether the provider supports HSA contribution limits. Empty if this feature is
// not supported for the benefit. This array only has values for HSA benefits.
HsaContributionLimit []BenefitFeaturesAndOperationsSupportedFeaturesHsaContributionLimit `json:"hsa_contribution_limit,nullable"`
JSON benefitFeaturesAndOperationsSupportedFeaturesJSON
}

// benefitFeaturesAndOperationsSupportedFeaturesJSON contains the JSON metadata for
// the struct [BenefitFeaturesAndOperationsSupportedFeatures]
type benefitFeaturesAndOperationsSupportedFeaturesJSON struct {
AnnualMaximum apijson.Field
CatchUp apijson.Field
CompanyContribution apijson.Field
Description apijson.Field
EmployeeDeduction apijson.Field
Frequencies apijson.Field
HsaContributionLimit apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *BenefitFeaturesAndOperationsSupportedFeatures) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type BenefitFeaturesAndOperationsSupportedFeaturesCompanyContribution string

const (
BenefitFeaturesAndOperationsSupportedFeaturesCompanyContributionFixed BenefitFeaturesAndOperationsSupportedFeaturesCompanyContribution = "fixed"
BenefitFeaturesAndOperationsSupportedFeaturesCompanyContributionPercent BenefitFeaturesAndOperationsSupportedFeaturesCompanyContribution = "percent"
)

type BenefitFeaturesAndOperationsSupportedFeaturesEmployeeDeduction string

const (
BenefitFeaturesAndOperationsSupportedFeaturesEmployeeDeductionFixed BenefitFeaturesAndOperationsSupportedFeaturesEmployeeDeduction = "fixed"
BenefitFeaturesAndOperationsSupportedFeaturesEmployeeDeductionPercent BenefitFeaturesAndOperationsSupportedFeaturesEmployeeDeduction = "percent"
)

type BenefitFeaturesAndOperationsSupportedFeaturesHsaContributionLimit string

const (
BenefitFeaturesAndOperationsSupportedFeaturesHsaContributionLimitIndividual BenefitFeaturesAndOperationsSupportedFeaturesHsaContributionLimit = "individual"
BenefitFeaturesAndOperationsSupportedFeaturesHsaContributionLimitFamily BenefitFeaturesAndOperationsSupportedFeaturesHsaContributionLimit = "family"
)

type BenefitFrequency string

const (
BenefitFrequencyOneTime BenefitFrequency = "one_time"
BenefitFrequencyEveryPaycheck BenefitFrequency = "every_paycheck"
BenefitFrequencyMonthly BenefitFrequency = "monthly"
)

// Type of benefit.
type BenefitType string

const (
BenefitType401k BenefitType = "401k"
BenefitType401kRoth BenefitType = "401k_roth"
BenefitType401kLoan BenefitType = "401k_loan"
BenefitType403b BenefitType = "403b"
BenefitType403bRoth BenefitType = "403b_roth"
BenefitType457 BenefitType = "457"
BenefitType457Roth BenefitType = "457_roth"
BenefitType_401k BenefitType = "401k"
BenefitType_401kRoth BenefitType = "401k_roth"
BenefitType_401kLoan BenefitType = "401k_loan"
BenefitType_403b BenefitType = "403b"
BenefitType_403bRoth BenefitType = "403b_roth"
BenefitType_457 BenefitType = "457"
BenefitType_457Roth BenefitType = "457_roth"
BenefitTypeS125Medical BenefitType = "s125_medical"
BenefitTypeS125Dental BenefitType = "s125_dental"
BenefitTypeS125Vision BenefitType = "s125_vision"
BenefitTypeHsaPre BenefitType = "hsa_pre"
BenefitTypeHsaPost BenefitType = "hsa_post"
BenefitTypeFsaMedical BenefitType = "fsa_medical"
BenefitTypeFsaDependentCare BenefitType = "fsa_dependent_care"
BenefitTypeSimpleIra BenefitType = "simple_ira"
BenefitTypeSimpleIRA BenefitType = "simple_ira"
BenefitTypeSimple BenefitType = "simple"
BenefitTypeCommuter BenefitType = "commuter"
BenefitTypeCustomPostTax BenefitType = "custom_post_tax"
BenefitTypeCustomPreTax BenefitType = "custom_pre_tax"
)

// Each benefit type and their supported features. If the benefit type is not
// supported, the property will be null
type BenefitsSupport struct {
Commuter BenefitFeaturesAndOperations `json:"commuter,nullable"`
CustomPostTax BenefitFeaturesAndOperations `json:"custom_post_tax,nullable"`
CustomPreTax BenefitFeaturesAndOperations `json:"custom_pre_tax,nullable"`
FsaDependentCare BenefitFeaturesAndOperations `json:"fsa_dependent_care,nullable"`
FsaMedical BenefitFeaturesAndOperations `json:"fsa_medical,nullable"`
HsaPost BenefitFeaturesAndOperations `json:"hsa_post,nullable"`
HsaPre BenefitFeaturesAndOperations `json:"hsa_pre,nullable"`
S125Dental BenefitFeaturesAndOperations `json:"s125_dental,nullable"`
S125Medical BenefitFeaturesAndOperations `json:"s125_medical,nullable"`
S125Vision BenefitFeaturesAndOperations `json:"s125_vision,nullable"`
Simple BenefitFeaturesAndOperations `json:"simple,nullable"`
SimpleIRA BenefitFeaturesAndOperations `json:"simple_ira,nullable"`
ExtraFields map[string]BenefitFeaturesAndOperations `json:"-,extras"`
JSON benefitsSupportJSON
}

// benefitsSupportJSON contains the JSON metadata for the struct [BenefitsSupport]
type benefitsSupportJSON struct {
Commuter apijson.Field
CustomPostTax apijson.Field
CustomPreTax apijson.Field
FsaDependentCare apijson.Field
FsaMedical apijson.Field
HsaPost apijson.Field
HsaPre apijson.Field
S125Dental apijson.Field
S125Medical apijson.Field
S125Vision apijson.Field
Simple apijson.Field
SimpleIRA apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *BenefitsSupport) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type CompanyBenefit struct {
BenefitID string `json:"benefit_id,required"`
CompanyContribution BenefitContribution `json:"company_contribution,required,nullable"`
Expand Down Expand Up @@ -225,6 +346,25 @@ func (r *CreateCompanyBenefitsResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type SupportPerBenefitType struct {
CompanyBenefits shared.OperationSupportMatrix `json:"company_benefits"`
IndividualBenefits shared.OperationSupportMatrix `json:"individual_benefits"`
JSON supportPerBenefitTypeJSON
}

// supportPerBenefitTypeJSON contains the JSON metadata for the struct
// [SupportPerBenefitType]
type supportPerBenefitTypeJSON struct {
CompanyBenefits apijson.Field
IndividualBenefits apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *SupportPerBenefitType) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type SupportedBenefit struct {
// Whether the provider supports an annual maximum for this benefit.
AnnualMaximum bool `json:"annual_maximum,nullable"`
Expand Down
2 changes: 1 addition & 1 deletion hrisbenefit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestHRISBenefitNewWithOptionalParams(t *testing.T) {
_, err := client.HRIS.Benefits.New(context.TODO(), finchgo.HRISBenefitNewParams{
Description: finchgo.F("string"),
Frequency: finchgo.F(finchgo.BenefitFrequencyOneTime),
Type: finchgo.F(finchgo.BenefitType401k),
Type: finchgo.F(finchgo.BenefitType_401k),
})
if err != nil {
var apierr *finchgo.Error
Expand Down
23 changes: 23 additions & 0 deletions hrisemployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type EmploymentData struct {
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.
Expand Down Expand Up @@ -109,6 +112,7 @@ type EmploymentData struct {
type employmentDataJSON struct {
ID apijson.Field
ClassCode apijson.Field
CustomFields apijson.Field
Department apijson.Field
Employment apijson.Field
EndDate apijson.Field
Expand All @@ -134,6 +138,25 @@ func (r *EmploymentData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type EmploymentDataCustomField struct {
Name string `json:"name"`
Value interface{} `json:"value"`
JSON employmentDataCustomFieldJSON
}

// 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)
}

// The department object.
type EmploymentDataDepartment struct {
// The name of the department associated with the individual.
Expand Down
17 changes: 17 additions & 0 deletions hrisindividual.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type Individual struct {
ID string `json:"id"`
Dob string `json:"dob,nullable"`
Emails []IndividualEmail `json:"emails,nullable"`
// The EEOC-defined ethnicity of the individual.
Ethnicity IndividualEthnicity `json:"ethnicity,nullable"`
// The legal first name of the individual.
FirstName string `json:"first_name,nullable"`
// The gender of the individual.
Expand All @@ -81,6 +83,7 @@ type individualJSON struct {
ID apijson.Field
Dob apijson.Field
Emails apijson.Field
Ethnicity apijson.Field
FirstName apijson.Field
Gender apijson.Field
LastName apijson.Field
Expand Down Expand Up @@ -122,6 +125,20 @@ const (
IndividualEmailsTypePersonal IndividualEmailsType = "personal"
)

// 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"
)

// The gender of the individual.
type IndividualGender string

Expand Down
Loading

0 comments on commit 674fc9e

Please sign in to comment.