diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9594c35..0c540bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup go uses: actions/setup-go@v5 @@ -35,7 +35,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/finch-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup go uses: actions/setup-go@v5 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 9446d50..44959ac 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.34.1" + ".": "1.35.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 18fe76f..5157ee7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-9c32d7e477bd1c441abd65db0dfe6220948aa00face05fc8b57395e368ee2099.yml -openapi_spec_hash: 3da940ffc5da8000a4f359c958ed341f -config_hash: 6d3585c0032e08d723d077d660fc8448 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-46f433f34d440aa1dfcc48cc8d822c598571b68be2f723ec99e1b4fba6c13b1e.yml +openapi_spec_hash: 5b5cd728776723ac773900f7e8a32c05 +config_hash: ccdf6a5b4aaa2a0897c89ac8685d8eb0 diff --git a/CHANGELOG.md b/CHANGELOG.md index b4815cd..f8ba85d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,48 @@ # Changelog +## 1.35.0 (2026-01-28) + +Full Changelog: [v1.34.1...v1.35.0](https://github.com/Finch-API/finch-api-go/compare/v1.34.1...v1.35.0) + +### Features + +* **api:** add per endpoint security ([4f6a61c](https://github.com/Finch-API/finch-api-go/commit/4f6a61cb9e3290136a7c3d8564ebb4ce0b493c55)) +* **api:** api update ([d869d30](https://github.com/Finch-API/finch-api-go/commit/d869d30065f591dea7781b6dc3124306e26e88fe)) +* **api:** api update ([0e69b17](https://github.com/Finch-API/finch-api-go/commit/0e69b1715d0da0aaba88240f51dc8950bb893015)) +* **api:** api update ([6708aac](https://github.com/Finch-API/finch-api-go/commit/6708aacc01982e5141ac1ca52412987994f3aecd)) +* **api:** api update ([e4f5130](https://github.com/Finch-API/finch-api-go/commit/e4f5130e25eb506c09204f69d6085e9b243cfd76)) +* **api:** api update ([f5c5bbc](https://github.com/Finch-API/finch-api-go/commit/f5c5bbcf3cf0d07df31e2330159de37d36e946f2)) +* **api:** api update ([6385a1f](https://github.com/Finch-API/finch-api-go/commit/6385a1ff8de901c11dd7452adc89f44542144247)) +* **api:** api update ([60a3e0c](https://github.com/Finch-API/finch-api-go/commit/60a3e0c4abdcac96bb7ca1a5ce64f99367fb5a12)) +* **api:** api update ([66108ba](https://github.com/Finch-API/finch-api-go/commit/66108ba1d8a47acf7663432e1d9b5744800575e6)) +* **api:** manual updates ([1ed52cf](https://github.com/Finch-API/finch-api-go/commit/1ed52cffc078b436f3899b736e5deb7e8cb5f703)) +* **api:** update automated code reviewer selection ([03c7271](https://github.com/Finch-API/finch-api-go/commit/03c7271b89082892da533f8e9fb102ce18de39da)) + + +### Bug Fixes + +* **docs:** add missing pointer prefix to api.md return types ([5aba5fa](https://github.com/Finch-API/finch-api-go/commit/5aba5fa426a29a3084302bc382a7d15af2eb8bea)) +* **docs:** fix mcp installation instructions for remote servers ([ad830d2](https://github.com/Finch-API/finch-api-go/commit/ad830d20499fffdd11c6b197f921177b4abd65f3)) +* **java:** Resolve name collisions ([0844ac5](https://github.com/Finch-API/finch-api-go/commit/0844ac58ae69b2d0c1274bac8cf7c1ee0eb8e349)) +* **mcp:** correct code tool API endpoint ([78d27b1](https://github.com/Finch-API/finch-api-go/commit/78d27b1c7b5a74781897a42d948994a923957e28)) +* rename param to avoid collision ([a23c9b2](https://github.com/Finch-API/finch-api-go/commit/a23c9b2b69248225624750994cc66775535fe3f9)) +* **tests:** skip broken date validation test ([2a9c325](https://github.com/Finch-API/finch-api-go/commit/2a9c325c2352c3b2cd113b412c621cf611cecd3a)) + + +### Chores + +* elide duplicate aliases ([fe9cc50](https://github.com/Finch-API/finch-api-go/commit/fe9cc50323a51a6caafe44cebf2628f3dd788c4a)) +* **internal:** codegen related update ([513bd70](https://github.com/Finch-API/finch-api-go/commit/513bd70b2b8fa7d55c23e6ee3d80f025a47e96e9)) +* **internal:** codegen related update ([97407f5](https://github.com/Finch-API/finch-api-go/commit/97407f552709b01565f5f627a182ac3bebbb2ed4)) +* **internal:** codegen related update ([2e87c84](https://github.com/Finch-API/finch-api-go/commit/2e87c84e8db41801091a7d05df535abe45831140)) +* **internal:** codegen related update ([da796cf](https://github.com/Finch-API/finch-api-go/commit/da796cf9a6f4f8bb56d92c6a13707a1eb3c8e762)) +* **internal:** update `actions/checkout` version ([842d28f](https://github.com/Finch-API/finch-api-go/commit/842d28fa959584aef8f23bb9e7984295faf61980)) + + +### Documentation + +* prominently feature MCP server setup in root SDK readmes ([8d0c7b6](https://github.com/Finch-API/finch-api-go/commit/8d0c7b66a2c2dc08f0d93b299416c76e7fc4dd90)) + ## 1.34.1 (2025-10-31) Full Changelog: [v1.34.0...v1.34.1](https://github.com/Finch-API/finch-api-go/compare/v1.34.0...v1.34.1) diff --git a/LICENSE b/LICENSE index eee6001..489cf4d 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 Finch + Copyright 2026 Finch Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index bdb5a8c..58c4055 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,15 @@ from applications written in Go. It is generated with [Stainless](https://www.stainless.com/). +## MCP Server + +Use the Finch MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40tryfinch%2Ffinch-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB0cnlmaW5jaC9maW5jaC1hcGktbWNwIl0sImVudiI6eyJGSU5DSF9BQ0NFU1NfVE9LRU4iOiJNeSBBY2Nlc3MgVG9rZW4iLCJGSU5DSF9DTElFTlRfSUQiOiI0YWIxNWU1MS0xMWFkLTQ5ZjQtYWNhZS1mMzQzYjc3OTQzNzUiLCJGSU5DSF9DTElFTlRfU0VDUkVUIjoiTXkgQ2xpZW50IFNlY3JldCIsIkZJTkNIX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40tryfinch%2Ffinch-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40tryfinch%2Ffinch-api-mcp%22%5D%2C%22env%22%3A%7B%22FINCH_ACCESS_TOKEN%22%3A%22My%20Access%20Token%22%2C%22FINCH_CLIENT_ID%22%3A%224ab15e51-11ad-49f4-acae-f343b7794375%22%2C%22FINCH_CLIENT_SECRET%22%3A%22My%20Client%20Secret%22%2C%22FINCH_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) + +> Note: You may need to set environment variables in your MCP client. + ## Installation @@ -24,7 +33,7 @@ Or to pin the version: ```sh -go get -u 'github.com/Finch-API/finch-api-go@v1.34.1' +go get -u 'github.com/Finch-API/finch-api-go@v1.35.0' ``` @@ -199,7 +208,7 @@ When the API returns a non-success status code, we return an error with type To handle errors, we recommend that you use the `errors.As` pattern: ```go -_, err := client.HRIS.Company.Get(context.TODO()) +_, err := client.HRIS.Company.Get(context.TODO(), finchgo.HRISCompanyGetParams{}) if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { @@ -267,6 +276,77 @@ client.HRIS.Directory.List( ) ``` +### Accessing raw response data (e.g. response headers) + +You can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when +you need to examine response headers, status codes, or other details. + +```go +// Create a variable to store the HTTP response +var response *http.Response +page, err := client.HRIS.Directory.List( + context.TODO(), + finchgo.HRISDirectoryListParams{}, + option.WithResponseInto(&response), +) +if err != nil { + // handle error +} +fmt.Printf("%+v\n", page) + +fmt.Printf("Status Code: %d\n", response.StatusCode) +fmt.Printf("Headers: %+#v\n", response.Header) +``` + +### Making custom/undocumented requests + +This library is typed for convenient access to the documented API. If you need to access undocumented +endpoints, params, or response properties, the library can still be used. + +#### Undocumented endpoints + +To make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs. +`RequestOptions` on the client, such as retries, will be respected when making these requests. + +```go +var ( + // params can be an io.Reader, a []byte, an encoding/json serializable object, + // or a "…Params" struct defined in this library. + params map[string]interface{} + + // result can be an []byte, *http.Response, a encoding/json deserializable object, + // or a model defined in this library. + result *http.Response +) +err := client.Post(context.Background(), "/unspecified", params, &result) +if err != nil { + … +} +``` + +#### Undocumented request params + +To make requests using undocumented parameters, you may use either the `option.WithQuerySet()` +or the `option.WithJSONSet()` methods. + +```go +params := FooNewParams{ + ID: finchgo.F("id_xxxx"), + Data: finchgo.F(FooNewParamsData{ + FirstName: finchgo.F("John"), + }), +} +client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe")) +``` + +#### Undocumented response properties + +To access undocumented response properties, you may either access the raw JSON of the response as a string +with `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with +`result.JSON.Foo.Raw()`. + +Any fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`. + ### Middleware We provide `option.WithMiddleware` which applies the given diff --git a/accesstoken.go b/accesstoken.go index 61ebd7f..3a2dca5 100644 --- a/accesstoken.go +++ b/accesstoken.go @@ -89,6 +89,8 @@ type CreateAccessTokenResponse struct { // - `provider` - connection to an external provider // - `finch` - finch-generated data. ConnectionType CreateAccessTokenResponseConnectionType `json:"connection_type,required"` + // An array of entity IDs that can be accessed with this access token + EntityIDs []string `json:"entity_ids,required" format:"uuid"` // An array of the authorized products associated with the `access_token` Products []string `json:"products,required"` // The ID of the provider associated with the `access_token` @@ -118,6 +120,7 @@ type createAccessTokenResponseJSON struct { ClientType apijson.Field ConnectionID apijson.Field ConnectionType apijson.Field + EntityIDs apijson.Field Products apijson.Field ProviderID apijson.Field TokenType apijson.Field diff --git a/accesstoken_test.go b/accesstoken_test.go index 723297e..93c2f42 100644 --- a/accesstoken_test.go +++ b/accesstoken_test.go @@ -14,6 +14,7 @@ import ( ) func TestAccessTokenNewWithOptionalParams(t *testing.T) { + t.Skip("prism doesnt like the format for the API-Version header") baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,6 +25,8 @@ func TestAccessTokenNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.AccessTokens.New(context.TODO(), finchgo.AccessTokenNewParams{ Code: finchgo.F("code"), diff --git a/account.go b/account.go index 63b27fc..baf7d22 100644 --- a/account.go +++ b/account.go @@ -111,6 +111,9 @@ type Introspection struct { // The name of your customer you provided to Finch when a connect session was // created for this connection CustomerName string `json:"customer_name,nullable"` + // Array of detailed entity information for each connected account in multi-account + // mode + Entities []IntrospectionEntity `json:"entities"` // Whether the connection associated with the `access_token` uses the Assisted // Connect Flow. (`true` if using Assisted Connect, `false` if connection is // automated) @@ -141,6 +144,7 @@ type introspectionJSON struct { CustomerEmail apijson.Field CustomerID apijson.Field CustomerName apijson.Field + Entities apijson.Field Manual apijson.Field PayrollProviderID apijson.Field Username apijson.Field @@ -333,3 +337,31 @@ func init() { }, ) } + +type IntrospectionEntity struct { + // The connection account ID for this entity + ID string `json:"id,required" format:"uuid"` + // The name of the entity (payroll provider company name) + Name string `json:"name,required,nullable"` + // The source ID of the entity + SourceID string `json:"source_id,required,nullable"` + JSON introspectionEntityJSON `json:"-"` +} + +// introspectionEntityJSON contains the JSON metadata for the struct +// [IntrospectionEntity] +type introspectionEntityJSON struct { + ID apijson.Field + Name apijson.Field + SourceID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntrospectionEntity) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r introspectionEntityJSON) RawJSON() string { + return r.raw +} diff --git a/account_test.go b/account_test.go index 47c2224..882fd1f 100644 --- a/account_test.go +++ b/account_test.go @@ -24,6 +24,8 @@ func TestAccountDisconnect(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Account.Disconnect(context.TODO()) if err != nil { @@ -46,6 +48,8 @@ func TestAccountIntrospect(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Account.Introspect(context.TODO()) if err != nil { diff --git a/api.md b/api.md index 8a5a397..75e9bcc 100644 --- a/api.md +++ b/api.md @@ -24,7 +24,7 @@ Response Types: Methods: -- client.AccessTokens.New(ctx context.Context, body finchgo.AccessTokenNewParams) (finchgo.CreateAccessTokenResponse, error) +- client.AccessTokens.New(ctx context.Context, body finchgo.AccessTokenNewParams) (\*finchgo.CreateAccessTokenResponse, error) # HRIS @@ -47,7 +47,7 @@ Response Types: Methods: -- client.HRIS.Company.Get(ctx context.Context) (finchgo.Company, error) +- client.HRIS.Company.Get(ctx context.Context, query finchgo.HRISCompanyGetParams) (\*finchgo.Company, error) ### PayStatementItem @@ -57,7 +57,7 @@ Response Types: Methods: -- client.HRIS.Company.PayStatementItem.List(ctx context.Context, query finchgo.HRISCompanyPayStatementItemListParams) (pagination.ResponsesPage[finchgo.HRISCompanyPayStatementItemListResponse], error) +- client.HRIS.Company.PayStatementItem.List(ctx context.Context, query finchgo.HRISCompanyPayStatementItemListParams) (\*pagination.ResponsesPage[finchgo.HRISCompanyPayStatementItemListResponse], error) #### Rules @@ -70,10 +70,10 @@ Response Types: Methods: -- client.HRIS.Company.PayStatementItem.Rules.New(ctx context.Context, body finchgo.HRISCompanyPayStatementItemRuleNewParams) (finchgo.HRISCompanyPayStatementItemRuleNewResponse, error) -- client.HRIS.Company.PayStatementItem.Rules.Update(ctx context.Context, ruleID string, body finchgo.HRISCompanyPayStatementItemRuleUpdateParams) (finchgo.HRISCompanyPayStatementItemRuleUpdateResponse, error) -- client.HRIS.Company.PayStatementItem.Rules.List(ctx context.Context) (pagination.ResponsesPage[finchgo.HRISCompanyPayStatementItemRuleListResponse], error) -- client.HRIS.Company.PayStatementItem.Rules.Delete(ctx context.Context, ruleID string) (finchgo.HRISCompanyPayStatementItemRuleDeleteResponse, error) +- client.HRIS.Company.PayStatementItem.Rules.New(ctx context.Context, params finchgo.HRISCompanyPayStatementItemRuleNewParams) (\*finchgo.HRISCompanyPayStatementItemRuleNewResponse, error) +- client.HRIS.Company.PayStatementItem.Rules.Update(ctx context.Context, ruleID string, params finchgo.HRISCompanyPayStatementItemRuleUpdateParams) (\*finchgo.HRISCompanyPayStatementItemRuleUpdateResponse, error) +- client.HRIS.Company.PayStatementItem.Rules.List(ctx context.Context, query finchgo.HRISCompanyPayStatementItemRuleListParams) (\*pagination.ResponsesPage[finchgo.HRISCompanyPayStatementItemRuleListResponse], error) +- client.HRIS.Company.PayStatementItem.Rules.Delete(ctx context.Context, ruleID string, body finchgo.HRISCompanyPayStatementItemRuleDeleteParams) (\*finchgo.HRISCompanyPayStatementItemRuleDeleteResponse, error) ## Directory @@ -83,7 +83,7 @@ Response Types: Methods: -- client.HRIS.Directory.List(ctx context.Context, query finchgo.HRISDirectoryListParams) (finchgo.IndividualsPage, error) +- client.HRIS.Directory.List(ctx context.Context, query finchgo.HRISDirectoryListParams) (\*finchgo.IndividualsPage, error) ## Individuals @@ -94,7 +94,7 @@ Response Types: Methods: -- client.HRIS.Individuals.GetMany(ctx context.Context, body finchgo.HRISIndividualGetManyParams) (pagination.ResponsesPage[finchgo.IndividualResponse], error) +- client.HRIS.Individuals.GetMany(ctx context.Context, params finchgo.HRISIndividualGetManyParams) (\*pagination.ResponsesPage[finchgo.IndividualResponse], error) ## Employments @@ -105,7 +105,7 @@ Response Types: Methods: -- client.HRIS.Employments.GetMany(ctx context.Context, body finchgo.HRISEmploymentGetManyParams) (pagination.ResponsesPage[finchgo.EmploymentDataResponse], error) +- client.HRIS.Employments.GetMany(ctx context.Context, params finchgo.HRISEmploymentGetManyParams) (\*pagination.ResponsesPage[finchgo.EmploymentDataResponse], error) ## Payments @@ -115,7 +115,7 @@ Response Types: Methods: -- client.HRIS.Payments.List(ctx context.Context, query finchgo.HRISPaymentListParams) (pagination.SinglePage[finchgo.Payment], error) +- client.HRIS.Payments.List(ctx context.Context, query finchgo.HRISPaymentListParams) (\*pagination.SinglePage[finchgo.Payment], error) ## PayStatements @@ -128,7 +128,7 @@ Response Types: Methods: -- client.HRIS.PayStatements.GetMany(ctx context.Context, body finchgo.HRISPayStatementGetManyParams) (pagination.ResponsesPage[finchgo.PayStatementResponse], error) +- client.HRIS.PayStatements.GetMany(ctx context.Context, params finchgo.HRISPayStatementGetManyParams) (\*pagination.ResponsesPage[finchgo.PayStatementResponse], error) ## Documents @@ -142,8 +142,8 @@ Response Types: Methods: -- client.HRIS.Documents.List(ctx context.Context, query finchgo.HRISDocumentListParams) (finchgo.HRISDocumentListResponse, error) -- client.HRIS.Documents.Retreive(ctx context.Context, documentID string) (finchgo.HRISDocumentRetreiveResponse, error) +- client.HRIS.Documents.List(ctx context.Context, query finchgo.HRISDocumentListParams) (\*finchgo.HRISDocumentListResponse, error) +- client.HRIS.Documents.Retreive(ctx context.Context, documentID string, query finchgo.HRISDocumentRetreiveParams) (\*finchgo.HRISDocumentRetreiveResponse, error) ## Benefits @@ -166,11 +166,11 @@ Response Types: Methods: -- client.HRIS.Benefits.New(ctx context.Context, body finchgo.HRISBenefitNewParams) (finchgo.CreateCompanyBenefitsResponse, error) -- client.HRIS.Benefits.Get(ctx context.Context, benefitID string) (finchgo.CompanyBenefit, error) -- client.HRIS.Benefits.Update(ctx context.Context, benefitID string, body finchgo.HRISBenefitUpdateParams) (finchgo.UpdateCompanyBenefitResponse, error) -- client.HRIS.Benefits.List(ctx context.Context) (pagination.SinglePage[finchgo.CompanyBenefit], error) -- client.HRIS.Benefits.ListSupportedBenefits(ctx context.Context) (pagination.SinglePage[finchgo.SupportedBenefit], error) +- client.HRIS.Benefits.New(ctx context.Context, params finchgo.HRISBenefitNewParams) (\*finchgo.CreateCompanyBenefitsResponse, error) +- client.HRIS.Benefits.Get(ctx context.Context, benefitID string, query finchgo.HRISBenefitGetParams) (\*finchgo.CompanyBenefit, error) +- client.HRIS.Benefits.Update(ctx context.Context, benefitID string, params finchgo.HRISBenefitUpdateParams) (\*finchgo.UpdateCompanyBenefitResponse, error) +- client.HRIS.Benefits.List(ctx context.Context, query finchgo.HRISBenefitListParams) (\*pagination.SinglePage[finchgo.CompanyBenefit], error) +- client.HRIS.Benefits.ListSupportedBenefits(ctx context.Context, query finchgo.HRISBenefitListSupportedBenefitsParams) (\*pagination.SinglePage[finchgo.SupportedBenefit], error) ### Individuals @@ -182,9 +182,9 @@ Response Types: Methods: -- client.HRIS.Benefits.Individuals.EnrolledIDs(ctx context.Context, benefitID string) (finchgo.HRISBenefitIndividualEnrolledIDsResponse, error) -- client.HRIS.Benefits.Individuals.GetManyBenefits(ctx context.Context, benefitID string, query finchgo.HRISBenefitIndividualGetManyBenefitsParams) (pagination.SinglePage[finchgo.IndividualBenefit], error) -- client.HRIS.Benefits.Individuals.UnenrollMany(ctx context.Context, benefitID string, body finchgo.HRISBenefitIndividualUnenrollManyParams) (finchgo.UnenrolledIndividualBenefitResponse, error) +- client.HRIS.Benefits.Individuals.EnrolledIDs(ctx context.Context, benefitID string, query finchgo.HRISBenefitIndividualEnrolledIDsParams) (\*finchgo.HRISBenefitIndividualEnrolledIDsResponse, error) +- client.HRIS.Benefits.Individuals.GetManyBenefits(ctx context.Context, benefitID string, query finchgo.HRISBenefitIndividualGetManyBenefitsParams) (\*pagination.SinglePage[finchgo.IndividualBenefit], error) +- client.HRIS.Benefits.Individuals.UnenrollMany(ctx context.Context, benefitID string, params finchgo.HRISBenefitIndividualUnenrollManyParams) (\*finchgo.UnenrolledIndividualBenefitResponse, error) # Providers @@ -194,7 +194,7 @@ Response Types: Methods: -- client.Providers.List(ctx context.Context) (pagination.SinglePage[finchgo.ProviderListResponse], error) +- client.Providers.List(ctx context.Context) (\*pagination.SinglePage[finchgo.ProviderListResponse], error) # Account @@ -205,8 +205,8 @@ Response Types: Methods: -- client.Account.Disconnect(ctx context.Context) (finchgo.DisconnectResponse, error) -- client.Account.Introspect(ctx context.Context) (finchgo.Introspection, error) +- client.Account.Disconnect(ctx context.Context) (\*finchgo.DisconnectResponse, error) +- client.Account.Introspect(ctx context.Context) (\*finchgo.Introspection, error) # Webhooks @@ -236,7 +236,7 @@ Response Types: Methods: -- client.RequestForwarding.Forward(ctx context.Context, body finchgo.RequestForwardingForwardParams) (finchgo.RequestForwardingForwardResponse, error) +- client.RequestForwarding.Forward(ctx context.Context, body finchgo.RequestForwardingForwardParams) (\*finchgo.RequestForwardingForwardResponse, error) # Jobs @@ -250,9 +250,9 @@ Response Types: Methods: -- client.Jobs.Automated.New(ctx context.Context, body finchgo.JobAutomatedNewParams) (finchgo.JobAutomatedNewResponse, error) -- client.Jobs.Automated.Get(ctx context.Context, jobID string) (finchgo.AutomatedAsyncJob, error) -- client.Jobs.Automated.List(ctx context.Context, query finchgo.JobAutomatedListParams) (finchgo.JobAutomatedListResponse, error) +- client.Jobs.Automated.New(ctx context.Context, body finchgo.JobAutomatedNewParams) (\*finchgo.JobAutomatedNewResponse, error) +- client.Jobs.Automated.Get(ctx context.Context, jobID string) (\*finchgo.AutomatedAsyncJob, error) +- client.Jobs.Automated.List(ctx context.Context, query finchgo.JobAutomatedListParams) (\*finchgo.JobAutomatedListResponse, error) ## Manual @@ -262,7 +262,7 @@ Response Types: Methods: -- client.Jobs.Manual.Get(ctx context.Context, jobID string) (finchgo.ManualAsyncJob, error) +- client.Jobs.Manual.Get(ctx context.Context, jobID string) (\*finchgo.ManualAsyncJob, error) # Sandbox @@ -274,7 +274,7 @@ Response Types: Methods: -- client.Sandbox.Connections.New(ctx context.Context, body finchgo.SandboxConnectionNewParams) (finchgo.SandboxConnectionNewResponse, error) +- client.Sandbox.Connections.New(ctx context.Context, body finchgo.SandboxConnectionNewParams) (\*finchgo.SandboxConnectionNewResponse, error) ### Accounts @@ -285,8 +285,8 @@ Response Types: Methods: -- client.Sandbox.Connections.Accounts.New(ctx context.Context, body finchgo.SandboxConnectionAccountNewParams) (finchgo.SandboxConnectionAccountNewResponse, error) -- client.Sandbox.Connections.Accounts.Update(ctx context.Context, body finchgo.SandboxConnectionAccountUpdateParams) (finchgo.SandboxConnectionAccountUpdateResponse, error) +- client.Sandbox.Connections.Accounts.New(ctx context.Context, body finchgo.SandboxConnectionAccountNewParams) (\*finchgo.SandboxConnectionAccountNewResponse, error) +- client.Sandbox.Connections.Accounts.Update(ctx context.Context, body finchgo.SandboxConnectionAccountUpdateParams) (\*finchgo.SandboxConnectionAccountUpdateResponse, error) ## Company @@ -296,7 +296,7 @@ Response Types: Methods: -- client.Sandbox.Company.Update(ctx context.Context, body finchgo.SandboxCompanyUpdateParams) (finchgo.SandboxCompanyUpdateResponse, error) +- client.Sandbox.Company.Update(ctx context.Context, body finchgo.SandboxCompanyUpdateParams) (\*finchgo.SandboxCompanyUpdateResponse, error) ## Directory @@ -306,7 +306,7 @@ Response Types: Methods: -- client.Sandbox.Directory.New(ctx context.Context, body finchgo.SandboxDirectoryNewParams) ([]finchgo.SandboxDirectoryNewResponse, error) +- client.Sandbox.Directory.New(ctx context.Context, body finchgo.SandboxDirectoryNewParams) (\*[]finchgo.SandboxDirectoryNewResponse, error) ## Individual @@ -316,7 +316,7 @@ Response Types: Methods: -- client.Sandbox.Individual.Update(ctx context.Context, individualID string, body finchgo.SandboxIndividualUpdateParams) (finchgo.SandboxIndividualUpdateResponse, error) +- client.Sandbox.Individual.Update(ctx context.Context, individualID string, body finchgo.SandboxIndividualUpdateParams) (\*finchgo.SandboxIndividualUpdateResponse, error) ## Employment @@ -326,7 +326,7 @@ Response Types: Methods: -- client.Sandbox.Employment.Update(ctx context.Context, individualID string, body finchgo.SandboxEmploymentUpdateParams) (finchgo.SandboxEmploymentUpdateResponse, error) +- client.Sandbox.Employment.Update(ctx context.Context, individualID string, body finchgo.SandboxEmploymentUpdateParams) (\*finchgo.SandboxEmploymentUpdateResponse, error) ## Payment @@ -336,7 +336,7 @@ Response Types: Methods: -- client.Sandbox.Payment.New(ctx context.Context, body finchgo.SandboxPaymentNewParams) (finchgo.SandboxPaymentNewResponse, error) +- client.Sandbox.Payment.New(ctx context.Context, body finchgo.SandboxPaymentNewParams) (\*finchgo.SandboxPaymentNewResponse, error) ## Jobs @@ -346,7 +346,7 @@ Response Types: Methods: -- client.Sandbox.Jobs.New(ctx context.Context, body finchgo.SandboxJobNewParams) (finchgo.SandboxJobNewResponse, error) +- client.Sandbox.Jobs.New(ctx context.Context, body finchgo.SandboxJobNewParams) (\*finchgo.SandboxJobNewResponse, error) ### Configuration @@ -356,8 +356,8 @@ Response Types: Methods: -- client.Sandbox.Jobs.Configuration.Get(ctx context.Context) ([]finchgo.SandboxJobConfiguration, error) -- client.Sandbox.Jobs.Configuration.Update(ctx context.Context, body finchgo.SandboxJobConfigurationUpdateParams) (finchgo.SandboxJobConfiguration, error) +- client.Sandbox.Jobs.Configuration.Get(ctx context.Context) (\*[]finchgo.SandboxJobConfiguration, error) +- client.Sandbox.Jobs.Configuration.Update(ctx context.Context, body finchgo.SandboxJobConfigurationUpdateParams) (\*finchgo.SandboxJobConfiguration, error) # Payroll @@ -370,8 +370,8 @@ Response Types: Methods: -- client.Payroll.PayGroups.Get(ctx context.Context, payGroupID string) (finchgo.PayrollPayGroupGetResponse, error) -- client.Payroll.PayGroups.List(ctx context.Context, query finchgo.PayrollPayGroupListParams) (pagination.SinglePage[finchgo.PayrollPayGroupListResponse], error) +- client.Payroll.PayGroups.Get(ctx context.Context, payGroupID string, query finchgo.PayrollPayGroupGetParams) (\*finchgo.PayrollPayGroupGetResponse, error) +- client.Payroll.PayGroups.List(ctx context.Context, query finchgo.PayrollPayGroupListParams) (\*pagination.SinglePage[finchgo.PayrollPayGroupListResponse], error) # Connect @@ -384,5 +384,5 @@ Response Types: Methods: -- client.Connect.Sessions.New(ctx context.Context, body finchgo.ConnectSessionNewParams) (finchgo.ConnectSessionNewResponse, error) -- client.Connect.Sessions.Reauthenticate(ctx context.Context, body finchgo.ConnectSessionReauthenticateParams) (finchgo.ConnectSessionReauthenticateResponse, error) +- client.Connect.Sessions.New(ctx context.Context, body finchgo.ConnectSessionNewParams) (\*finchgo.ConnectSessionNewResponse, error) +- client.Connect.Sessions.Reauthenticate(ctx context.Context, body finchgo.ConnectSessionReauthenticateParams) (\*finchgo.ConnectSessionReauthenticateResponse, error) diff --git a/client_test.go b/client_test.go index 36abf9c..71d3f7f 100644 --- a/client_test.go +++ b/client_test.go @@ -27,6 +27,8 @@ func TestUserAgentHeader(t *testing.T) { var userAgent string client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -48,6 +50,8 @@ func TestRetryAfter(t *testing.T) { retryCountHeaders := make([]string, 0) client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -82,6 +86,8 @@ func TestDeleteRetryCountHeader(t *testing.T) { retryCountHeaders := make([]string, 0) client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -112,6 +118,8 @@ func TestOverwriteRetryCountHeader(t *testing.T) { retryCountHeaders := make([]string, 0) client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -142,6 +150,8 @@ func TestRetryAfterMs(t *testing.T) { attempts := 0 client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -168,6 +178,8 @@ func TestRetryAfterMs(t *testing.T) { func TestContextCancel(t *testing.T) { client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -188,6 +200,8 @@ func TestContextCancel(t *testing.T) { func TestContextCancelDelay(t *testing.T) { client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { @@ -216,6 +230,8 @@ func TestContextDeadline(t *testing.T) { go func() { client := finchgo.NewClient( option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), option.WithHTTPClient(&http.Client{ Transport: &closureTransport{ fn: func(req *http.Request) (*http.Response, error) { diff --git a/connectsession.go b/connectsession.go index db8b4dc..4be62ab 100644 --- a/connectsession.go +++ b/connectsession.go @@ -99,37 +99,61 @@ func (r connectSessionReauthenticateResponseJSON) RawJSON() string { } type ConnectSessionNewParams struct { - // Email address of the customer - CustomerEmail param.Field[string] `json:"customer_email,required" format:"email"` // Unique identifier for the customer CustomerID param.Field[string] `json:"customer_id,required"` // Name of the customer CustomerName param.Field[string] `json:"customer_name,required"` + // The Finch products to request access to + Products param.Field[[]ConnectSessionNewParamsProduct] `json:"products,required"` + // Email address of the customer + CustomerEmail param.Field[string] `json:"customer_email" format:"email"` // Integration configuration for the connect session - Integration param.Field[ConnectSessionNewParamsIntegration] `json:"integration,required"` + Integration param.Field[ConnectSessionNewParamsIntegration] `json:"integration"` // Enable manual authentication mode - Manual param.Field[bool] `json:"manual,required"` + Manual param.Field[bool] `json:"manual"` // The number of minutes until the session expires (defaults to 129,600, which is // 90 days) - MinutesToExpire param.Field[float64] `json:"minutes_to_expire,required"` - // The Finch products to request access to - Products param.Field[[]ConnectSessionNewParamsProduct] `json:"products,required"` + MinutesToExpire param.Field[float64] `json:"minutes_to_expire"` // The URI to redirect to after the Connect flow is completed - RedirectUri param.Field[string] `json:"redirect_uri,required"` + RedirectUri param.Field[string] `json:"redirect_uri"` // Sandbox mode for testing - Sandbox param.Field[ConnectSessionNewParamsSandbox] `json:"sandbox,required"` + Sandbox param.Field[ConnectSessionNewParamsSandbox] `json:"sandbox"` } func (r ConnectSessionNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// The Finch products that can be requested during the Connect flow. +type ConnectSessionNewParamsProduct string + +const ( + ConnectSessionNewParamsProductBenefits ConnectSessionNewParamsProduct = "benefits" + ConnectSessionNewParamsProductCompany ConnectSessionNewParamsProduct = "company" + ConnectSessionNewParamsProductDeduction ConnectSessionNewParamsProduct = "deduction" + ConnectSessionNewParamsProductDirectory ConnectSessionNewParamsProduct = "directory" + ConnectSessionNewParamsProductDocuments ConnectSessionNewParamsProduct = "documents" + ConnectSessionNewParamsProductEmployment ConnectSessionNewParamsProduct = "employment" + ConnectSessionNewParamsProductIndividual ConnectSessionNewParamsProduct = "individual" + ConnectSessionNewParamsProductPayment ConnectSessionNewParamsProduct = "payment" + ConnectSessionNewParamsProductPayStatement ConnectSessionNewParamsProduct = "pay_statement" + ConnectSessionNewParamsProductSsn ConnectSessionNewParamsProduct = "ssn" +) + +func (r ConnectSessionNewParamsProduct) IsKnown() bool { + switch r { + case ConnectSessionNewParamsProductBenefits, ConnectSessionNewParamsProductCompany, ConnectSessionNewParamsProductDeduction, ConnectSessionNewParamsProductDirectory, ConnectSessionNewParamsProductDocuments, ConnectSessionNewParamsProductEmployment, ConnectSessionNewParamsProductIndividual, ConnectSessionNewParamsProductPayment, ConnectSessionNewParamsProductPayStatement, ConnectSessionNewParamsProductSsn: + return true + } + return false +} + // Integration configuration for the connect session type ConnectSessionNewParamsIntegration struct { - // The authentication method to use - AuthMethod param.Field[ConnectSessionNewParamsIntegrationAuthMethod] `json:"auth_method,required"` // The provider to integrate with Provider param.Field[string] `json:"provider,required"` + // The authentication method to use + AuthMethod param.Field[ConnectSessionNewParamsIntegrationAuthMethod] `json:"auth_method"` } func (r ConnectSessionNewParamsIntegration) MarshalJSON() (data []byte, err error) { @@ -154,30 +178,6 @@ func (r ConnectSessionNewParamsIntegrationAuthMethod) IsKnown() bool { return false } -// The Finch products that can be requested during the Connect flow. -type ConnectSessionNewParamsProduct string - -const ( - ConnectSessionNewParamsProductBenefits ConnectSessionNewParamsProduct = "benefits" - ConnectSessionNewParamsProductCompany ConnectSessionNewParamsProduct = "company" - ConnectSessionNewParamsProductDeduction ConnectSessionNewParamsProduct = "deduction" - ConnectSessionNewParamsProductDirectory ConnectSessionNewParamsProduct = "directory" - ConnectSessionNewParamsProductDocuments ConnectSessionNewParamsProduct = "documents" - ConnectSessionNewParamsProductEmployment ConnectSessionNewParamsProduct = "employment" - ConnectSessionNewParamsProductIndividual ConnectSessionNewParamsProduct = "individual" - ConnectSessionNewParamsProductPayment ConnectSessionNewParamsProduct = "payment" - ConnectSessionNewParamsProductPayStatement ConnectSessionNewParamsProduct = "pay_statement" - ConnectSessionNewParamsProductSsn ConnectSessionNewParamsProduct = "ssn" -) - -func (r ConnectSessionNewParamsProduct) IsKnown() bool { - switch r { - case ConnectSessionNewParamsProductBenefits, ConnectSessionNewParamsProductCompany, ConnectSessionNewParamsProductDeduction, ConnectSessionNewParamsProductDirectory, ConnectSessionNewParamsProductDocuments, ConnectSessionNewParamsProductEmployment, ConnectSessionNewParamsProductIndividual, ConnectSessionNewParamsProductPayment, ConnectSessionNewParamsProductPayStatement, ConnectSessionNewParamsProductSsn: - return true - } - return false -} - // Sandbox mode for testing type ConnectSessionNewParamsSandbox string @@ -199,11 +199,11 @@ type ConnectSessionReauthenticateParams struct { ConnectionID param.Field[string] `json:"connection_id,required"` // The number of minutes until the session expires (defaults to 43,200, which is 30 // days) - MinutesToExpire param.Field[int64] `json:"minutes_to_expire,required"` + MinutesToExpire param.Field[int64] `json:"minutes_to_expire"` // The products to request access to (optional for reauthentication) - Products param.Field[[]ConnectSessionReauthenticateParamsProduct] `json:"products,required"` + Products param.Field[[]ConnectSessionReauthenticateParamsProduct] `json:"products"` // The URI to redirect to after the Connect flow is completed - RedirectUri param.Field[string] `json:"redirect_uri,required" format:"uri"` + RedirectUri param.Field[string] `json:"redirect_uri" format:"uri"` } func (r ConnectSessionReauthenticateParams) MarshalJSON() (data []byte, err error) { diff --git a/connectsession_test.go b/connectsession_test.go index 18c76f6..699e429 100644 --- a/connectsession_test.go +++ b/connectsession_test.go @@ -13,7 +13,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestConnectSessionNew(t *testing.T) { +func TestConnectSessionNewWithOptionalParams(t *testing.T) { t.Skip("prism tests are broken") baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { @@ -25,18 +25,20 @@ func TestConnectSessionNew(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Connect.Sessions.New(context.TODO(), finchgo.ConnectSessionNewParams{ - CustomerEmail: finchgo.F("dev@stainless.com"), CustomerID: finchgo.F("x"), CustomerName: finchgo.F("x"), + Products: finchgo.F([]finchgo.ConnectSessionNewParamsProduct{finchgo.ConnectSessionNewParamsProductBenefits}), + CustomerEmail: finchgo.F("dev@stainless.com"), Integration: finchgo.F(finchgo.ConnectSessionNewParamsIntegration{ - AuthMethod: finchgo.F(finchgo.ConnectSessionNewParamsIntegrationAuthMethodAssisted), Provider: finchgo.F("provider"), + AuthMethod: finchgo.F(finchgo.ConnectSessionNewParamsIntegrationAuthMethodAssisted), }), Manual: finchgo.F(true), MinutesToExpire: finchgo.F(1.000000), - Products: finchgo.F([]finchgo.ConnectSessionNewParamsProduct{finchgo.ConnectSessionNewParamsProductBenefits}), RedirectUri: finchgo.F("redirect_uri"), Sandbox: finchgo.F(finchgo.ConnectSessionNewParamsSandboxFinch), }) @@ -49,7 +51,7 @@ func TestConnectSessionNew(t *testing.T) { } } -func TestConnectSessionReauthenticate(t *testing.T) { +func TestConnectSessionReauthenticateWithOptionalParams(t *testing.T) { t.Skip("prism tests are broken") baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { @@ -61,6 +63,8 @@ func TestConnectSessionReauthenticate(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Connect.Sessions.Reauthenticate(context.TODO(), finchgo.ConnectSessionReauthenticateParams{ ConnectionID: finchgo.F("connection_id"), diff --git a/hrisbenefit.go b/hrisbenefit.go index 6606f6e..992877e 100644 --- a/hrisbenefit.go +++ b/hrisbenefit.go @@ -7,9 +7,11 @@ import ( "errors" "fmt" "net/http" + "net/url" "slices" "github.com/Finch-API/finch-api-go/internal/apijson" + "github.com/Finch-API/finch-api-go/internal/apiquery" "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" @@ -40,44 +42,44 @@ func NewHRISBenefitService(opts ...option.RequestOption) (r *HRISBenefitService) // Creates a new company-wide deduction or contribution. Please use the // `/providers` endpoint to view available types for each provider. -func (r *HRISBenefitService) New(ctx context.Context, body HRISBenefitNewParams, opts ...option.RequestOption) (res *CreateCompanyBenefitsResponse, err error) { +func (r *HRISBenefitService) New(ctx context.Context, params HRISBenefitNewParams, opts ...option.RequestOption) (res *CreateCompanyBenefitsResponse, err error) { opts = slices.Concat(r.Options, opts) path := "employer/benefits" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) return } // Lists deductions and contributions information for a given item -func (r *HRISBenefitService) Get(ctx context.Context, benefitID string, opts ...option.RequestOption) (res *CompanyBenefit, err error) { +func (r *HRISBenefitService) Get(ctx context.Context, benefitID string, query HRISBenefitGetParams, opts ...option.RequestOption) (res *CompanyBenefit, err error) { opts = slices.Concat(r.Options, opts) if benefitID == "" { err = errors.New("missing required benefit_id parameter") return } path := fmt.Sprintf("employer/benefits/%s", benefitID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } // Updates an existing company-wide deduction or contribution -func (r *HRISBenefitService) Update(ctx context.Context, benefitID string, body HRISBenefitUpdateParams, opts ...option.RequestOption) (res *UpdateCompanyBenefitResponse, err error) { +func (r *HRISBenefitService) Update(ctx context.Context, benefitID string, params HRISBenefitUpdateParams, opts ...option.RequestOption) (res *UpdateCompanyBenefitResponse, err error) { opts = slices.Concat(r.Options, opts) if benefitID == "" { err = errors.New("missing required benefit_id parameter") return } path := fmt.Sprintf("employer/benefits/%s", benefitID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) return } // List all company-wide deductions and contributions. -func (r *HRISBenefitService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[CompanyBenefit], err error) { +func (r *HRISBenefitService) List(ctx context.Context, query HRISBenefitListParams, opts ...option.RequestOption) (res *pagination.SinglePage[CompanyBenefit], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "employer/benefits" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err } @@ -90,17 +92,17 @@ func (r *HRISBenefitService) List(ctx context.Context, opts ...option.RequestOpt } // List all company-wide deductions and contributions. -func (r *HRISBenefitService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CompanyBenefit] { - return pagination.NewSinglePageAutoPager(r.List(ctx, opts...)) +func (r *HRISBenefitService) ListAutoPaging(ctx context.Context, query HRISBenefitListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CompanyBenefit] { + return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Get deductions metadata -func (r *HRISBenefitService) ListSupportedBenefits(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[SupportedBenefit], err error) { +func (r *HRISBenefitService) ListSupportedBenefits(ctx context.Context, query HRISBenefitListSupportedBenefitsParams, opts ...option.RequestOption) (res *pagination.SinglePage[SupportedBenefit], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "employer/benefits/meta" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err } @@ -113,8 +115,8 @@ func (r *HRISBenefitService) ListSupportedBenefits(ctx context.Context, opts ... } // Get deductions metadata -func (r *HRISBenefitService) ListSupportedBenefitsAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SupportedBenefit] { - return pagination.NewSinglePageAutoPager(r.ListSupportedBenefits(ctx, opts...)) +func (r *HRISBenefitService) ListSupportedBenefitsAutoPaging(ctx context.Context, query HRISBenefitListSupportedBenefitsParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SupportedBenefit] { + return pagination.NewSinglePageAutoPager(r.ListSupportedBenefits(ctx, query, opts...)) } type BenefitFeaturesAndOperations struct { @@ -489,6 +491,8 @@ func (r updateCompanyBenefitResponseJSON) RawJSON() string { } type HRISBenefitNewParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // The company match for this benefit. CompanyContribution param.Field[HRISBenefitNewParamsCompanyContribution] `json:"company_contribution"` // Name of the benefit as it appears in the provider and pay statements. Recommend @@ -505,6 +509,14 @@ func (r HRISBenefitNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// URLQuery serializes [HRISBenefitNewParams]'s query parameters as `url.Values`. +func (r HRISBenefitNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + // The company match for this benefit. type HRISBenefitNewParamsCompanyContribution struct { Tiers param.Field[[]HRISBenefitNewParamsCompanyContributionTier] `json:"tiers,required"` @@ -538,7 +550,22 @@ func (r HRISBenefitNewParamsCompanyContributionType) IsKnown() bool { return false } +type HRISBenefitGetParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISBenefitGetParams]'s query parameters as `url.Values`. +func (r HRISBenefitGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type HRISBenefitUpdateParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Updated name or description. Description param.Field[string] `json:"description"` } @@ -546,3 +573,39 @@ type HRISBenefitUpdateParams struct { func (r HRISBenefitUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } + +// URLQuery serializes [HRISBenefitUpdateParams]'s query parameters as +// `url.Values`. +func (r HRISBenefitUpdateParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HRISBenefitListParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISBenefitListParams]'s query parameters as `url.Values`. +func (r HRISBenefitListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HRISBenefitListSupportedBenefitsParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISBenefitListSupportedBenefitsParams]'s query parameters +// as `url.Values`. +func (r HRISBenefitListSupportedBenefitsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/hrisbenefit_test.go b/hrisbenefit_test.go index 92e0b82..ef6bb9a 100644 --- a/hrisbenefit_test.go +++ b/hrisbenefit_test.go @@ -24,8 +24,11 @@ func TestHRISBenefitNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Benefits.New(context.TODO(), finchgo.HRISBenefitNewParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), CompanyContribution: finchgo.F(finchgo.HRISBenefitNewParamsCompanyContribution{ Tiers: finchgo.F([]finchgo.HRISBenefitNewParamsCompanyContributionTier{{ Match: finchgo.F(int64(1)), @@ -46,7 +49,7 @@ func TestHRISBenefitNewWithOptionalParams(t *testing.T) { } } -func TestHRISBenefitGet(t *testing.T) { +func TestHRISBenefitGetWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -57,8 +60,16 @@ func TestHRISBenefitGet(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), + ) + _, err := client.HRIS.Benefits.Get( + context.TODO(), + "benefit_id", + finchgo.HRISBenefitGetParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }, ) - _, err := client.HRIS.Benefits.Get(context.TODO(), "benefit_id") if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { @@ -79,11 +90,14 @@ func TestHRISBenefitUpdateWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Benefits.Update( context.TODO(), "benefit_id", finchgo.HRISBenefitUpdateParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), Description: finchgo.F("description"), }, ) @@ -96,7 +110,7 @@ func TestHRISBenefitUpdateWithOptionalParams(t *testing.T) { } } -func TestHRISBenefitList(t *testing.T) { +func TestHRISBenefitListWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -107,8 +121,12 @@ func TestHRISBenefitList(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) - _, err := client.HRIS.Benefits.List(context.TODO()) + _, err := client.HRIS.Benefits.List(context.TODO(), finchgo.HRISBenefitListParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }) if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { @@ -118,7 +136,7 @@ func TestHRISBenefitList(t *testing.T) { } } -func TestHRISBenefitListSupportedBenefits(t *testing.T) { +func TestHRISBenefitListSupportedBenefitsWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -129,8 +147,12 @@ func TestHRISBenefitListSupportedBenefits(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) - _, err := client.HRIS.Benefits.ListSupportedBenefits(context.TODO()) + _, err := client.HRIS.Benefits.ListSupportedBenefits(context.TODO(), finchgo.HRISBenefitListSupportedBenefitsParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }) if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { diff --git a/hrisbenefitindividual.go b/hrisbenefitindividual.go index e1cb190..f816715 100644 --- a/hrisbenefitindividual.go +++ b/hrisbenefitindividual.go @@ -40,14 +40,14 @@ func NewHRISBenefitIndividualService(opts ...option.RequestOption) (r *HRISBenef } // Lists individuals currently enrolled in a given deduction. -func (r *HRISBenefitIndividualService) EnrolledIDs(ctx context.Context, benefitID string, opts ...option.RequestOption) (res *HRISBenefitIndividualEnrolledIDsResponse, err error) { +func (r *HRISBenefitIndividualService) EnrolledIDs(ctx context.Context, benefitID string, query HRISBenefitIndividualEnrolledIDsParams, opts ...option.RequestOption) (res *HRISBenefitIndividualEnrolledIDsResponse, err error) { opts = slices.Concat(r.Options, opts) if benefitID == "" { err = errors.New("missing required benefit_id parameter") return } path := fmt.Sprintf("employer/benefits/%s/enrolled", benefitID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -79,14 +79,14 @@ func (r *HRISBenefitIndividualService) GetManyBenefitsAutoPaging(ctx context.Con } // Unenroll individuals from a deduction or contribution -func (r *HRISBenefitIndividualService) UnenrollMany(ctx context.Context, benefitID string, body HRISBenefitIndividualUnenrollManyParams, opts ...option.RequestOption) (res *UnenrolledIndividualBenefitResponse, err error) { +func (r *HRISBenefitIndividualService) UnenrollMany(ctx context.Context, benefitID string, params HRISBenefitIndividualUnenrollManyParams, opts ...option.RequestOption) (res *UnenrolledIndividualBenefitResponse, err error) { opts = slices.Concat(r.Options, opts) if benefitID == "" { err = errors.New("missing required benefit_id parameter") return } path := fmt.Sprintf("employer/benefits/%s/individuals", benefitID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &res, opts...) return } @@ -201,9 +201,14 @@ type IndividualBenefitBodyObject struct { AnnualMaximum int64 `json:"annual_maximum,required,nullable"` // If the benefit supports catch up (401k, 403b, etc.), whether catch up is enabled // for this individual. - CatchUp bool `json:"catch_up,required,nullable"` + CatchUp bool `json:"catch_up,required,nullable"` + // Company contribution configuration. Supports fixed amounts (in cents), + // percentage-based contributions (in basis points where 100 = 1%), or tiered + // matching structures. CompanyContribution IndividualBenefitBodyObjectCompanyContribution `json:"company_contribution,required,nullable"` - EmployeeDeduction IndividualBenefitBodyObjectEmployeeDeduction `json:"employee_deduction,required,nullable"` + // Employee deduction configuration. Supports both fixed amounts (in cents) and + // percentage-based contributions (in basis points where 100 = 1%). + EmployeeDeduction IndividualBenefitBodyObjectEmployeeDeduction `json:"employee_deduction,required,nullable"` // Type for HSA contribution limit if the benefit is a HSA. HsaContributionLimit IndividualBenefitBodyObjectHsaContributionLimit `json:"hsa_contribution_limit,nullable"` JSON individualBenefitBodyObjectJSON `json:"-"` @@ -231,10 +236,15 @@ func (r individualBenefitBodyObjectJSON) RawJSON() string { func (r IndividualBenefitBodyObject) implementsIndividualBenefitBody() {} +// Company contribution configuration. Supports fixed amounts (in cents), +// percentage-based contributions (in basis points where 100 = 1%), or tiered +// matching structures. type IndividualBenefitBodyObjectCompanyContribution struct { - // Fixed contribution type. + // Contribution type. Supported values: "fixed" (amount in cents), "percent" + // (amount in basis points), or "tiered" (multi-tier matching). Type IndividualBenefitBodyObjectCompanyContributionType `json:"type,required"` - // Contribution amount in cents. + // Contribution amount in cents (for type=fixed) or basis points (for type=percent, + // where 100 = 1%). Not used for type=tiered. Amount int64 `json:"amount"` // This field can have the runtime type of // [[]IndividualBenefitBodyObjectCompanyContributionObjectTier]. @@ -277,6 +287,10 @@ func (r IndividualBenefitBodyObjectCompanyContribution) AsUnion() IndividualBene return r.union } +// Company contribution configuration. Supports fixed amounts (in cents), +// percentage-based contributions (in basis points where 100 = 1%), or tiered +// matching structures. +// // Union satisfied by [IndividualBenefitBodyObjectCompanyContributionObject], // [IndividualBenefitBodyObjectCompanyContributionObject] or // [IndividualBenefitBodyObjectCompanyContributionObject]. @@ -304,9 +318,11 @@ func init() { } type IndividualBenefitBodyObjectCompanyContributionObject struct { - // Contribution amount in cents. + // Contribution amount in cents (for type=fixed) or basis points (for type=percent, + // where 100 = 1%). Not used for type=tiered. Amount int64 `json:"amount,required"` - // Fixed contribution type. + // Contribution type. Supported values: "fixed" (amount in cents), "percent" + // (amount in basis points), or "tiered" (multi-tier matching). Type IndividualBenefitBodyObjectCompanyContributionObjectType `json:"type,required"` JSON individualBenefitBodyObjectCompanyContributionObjectJSON `json:"-"` } @@ -331,7 +347,8 @@ func (r individualBenefitBodyObjectCompanyContributionObjectJSON) RawJSON() stri func (r IndividualBenefitBodyObjectCompanyContributionObject) implementsIndividualBenefitBodyObjectCompanyContribution() { } -// Fixed contribution type. +// Contribution type. Supported values: "fixed" (amount in cents), "percent" +// (amount in basis points), or "tiered" (multi-tier matching). type IndividualBenefitBodyObjectCompanyContributionObjectType string const ( @@ -346,7 +363,8 @@ func (r IndividualBenefitBodyObjectCompanyContributionObjectType) IsKnown() bool return false } -// Fixed contribution type. +// Contribution type. Supported values: "fixed" (amount in cents), "percent" +// (amount in basis points), or "tiered" (multi-tier matching). type IndividualBenefitBodyObjectCompanyContributionType string const ( @@ -363,10 +381,14 @@ func (r IndividualBenefitBodyObjectCompanyContributionType) IsKnown() bool { return false } +// Employee deduction configuration. Supports both fixed amounts (in cents) and +// percentage-based contributions (in basis points where 100 = 1%). type IndividualBenefitBodyObjectEmployeeDeduction struct { - // Contribution amount in cents. + // Contribution amount in cents (for type=fixed) or basis points (for type=percent, + // where 100 = 1%). Amount int64 `json:"amount,required"` - // Fixed contribution type. + // Contribution type. Supported values: "fixed" (amount in cents) or "percent" + // (amount in basis points). Type IndividualBenefitBodyObjectEmployeeDeductionType `json:"type,required"` JSON individualBenefitBodyObjectEmployeeDeductionJSON `json:"-"` union IndividualBenefitBodyObjectEmployeeDeductionUnion @@ -404,6 +426,9 @@ func (r IndividualBenefitBodyObjectEmployeeDeduction) AsUnion() IndividualBenefi return r.union } +// Employee deduction configuration. Supports both fixed amounts (in cents) and +// percentage-based contributions (in basis points where 100 = 1%). +// // Union satisfied by [IndividualBenefitBodyObjectEmployeeDeductionObject] or // [IndividualBenefitBodyObjectEmployeeDeductionObject]. type IndividualBenefitBodyObjectEmployeeDeductionUnion interface { @@ -426,9 +451,11 @@ func init() { } type IndividualBenefitBodyObjectEmployeeDeductionObject struct { - // Contribution amount in cents. + // Contribution amount in cents (for type=fixed) or basis points (for type=percent, + // where 100 = 1%). Amount int64 `json:"amount,required"` - // Fixed contribution type. + // Contribution type. Supported values: "fixed" (amount in cents) or "percent" + // (amount in basis points). Type IndividualBenefitBodyObjectEmployeeDeductionObjectType `json:"type,required"` JSON individualBenefitBodyObjectEmployeeDeductionObjectJSON `json:"-"` } @@ -453,7 +480,8 @@ func (r individualBenefitBodyObjectEmployeeDeductionObjectJSON) RawJSON() string func (r IndividualBenefitBodyObjectEmployeeDeductionObject) implementsIndividualBenefitBodyObjectEmployeeDeduction() { } -// Fixed contribution type. +// Contribution type. Supported values: "fixed" (amount in cents) or "percent" +// (amount in basis points). type IndividualBenefitBodyObjectEmployeeDeductionObjectType string const ( @@ -468,7 +496,8 @@ func (r IndividualBenefitBodyObjectEmployeeDeductionObjectType) IsKnown() bool { return false } -// Fixed contribution type. +// Contribution type. Supported values: "fixed" (amount in cents) or "percent" +// (amount in basis points). type IndividualBenefitBodyObjectEmployeeDeductionType string const ( @@ -590,7 +619,23 @@ func (r hrisBenefitIndividualEnrolledIDsResponseJSON) RawJSON() string { return r.raw } +type HRISBenefitIndividualEnrolledIDsParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISBenefitIndividualEnrolledIDsParams]'s query parameters +// as `url.Values`. +func (r HRISBenefitIndividualEnrolledIDsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type HRISBenefitIndividualGetManyBenefitsParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // comma-delimited list of stable Finch uuids for each individual. If empty, // defaults to all individuals IndividualIDs param.Field[string] `query:"individual_ids"` @@ -606,6 +651,8 @@ func (r HRISBenefitIndividualGetManyBenefitsParams) URLQuery() (v url.Values) { } type HRISBenefitIndividualUnenrollManyParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Array of individual_ids to unenroll. IndividualIDs param.Field[[]string] `json:"individual_ids"` } @@ -613,3 +660,12 @@ type HRISBenefitIndividualUnenrollManyParams struct { func (r HRISBenefitIndividualUnenrollManyParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } + +// URLQuery serializes [HRISBenefitIndividualUnenrollManyParams]'s query parameters +// as `url.Values`. +func (r HRISBenefitIndividualUnenrollManyParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/hrisbenefitindividual_test.go b/hrisbenefitindividual_test.go index 90207da..a0aaff0 100644 --- a/hrisbenefitindividual_test.go +++ b/hrisbenefitindividual_test.go @@ -13,7 +13,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestHRISBenefitIndividualEnrolledIDs(t *testing.T) { +func TestHRISBenefitIndividualEnrolledIDsWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,8 +24,16 @@ func TestHRISBenefitIndividualEnrolledIDs(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), + ) + _, err := client.HRIS.Benefits.Individuals.EnrolledIDs( + context.TODO(), + "benefit_id", + finchgo.HRISBenefitIndividualEnrolledIDsParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }, ) - _, err := client.HRIS.Benefits.Individuals.EnrolledIDs(context.TODO(), "benefit_id") if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { @@ -46,11 +54,14 @@ func TestHRISBenefitIndividualGetManyBenefitsWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Benefits.Individuals.GetManyBenefits( context.TODO(), "benefit_id", finchgo.HRISBenefitIndividualGetManyBenefitsParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), IndividualIDs: finchgo.F("d675d2b7-6d7b-41a8-b2d3-001eb3fb88f6,d02a6346-1f08-4312-a064-49ff3cafaa7a"), }, ) @@ -74,11 +85,14 @@ func TestHRISBenefitIndividualUnenrollManyWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Benefits.Individuals.UnenrollMany( context.TODO(), "benefit_id", finchgo.HRISBenefitIndividualUnenrollManyParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), IndividualIDs: finchgo.F([]string{"string"}), }, ) diff --git a/hriscompany.go b/hriscompany.go index 875b651..d85b69b 100644 --- a/hriscompany.go +++ b/hriscompany.go @@ -5,9 +5,12 @@ package finchgo import ( "context" "net/http" + "net/url" "slices" "github.com/Finch-API/finch-api-go/internal/apijson" + "github.com/Finch-API/finch-api-go/internal/apiquery" + "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" ) @@ -34,10 +37,10 @@ func NewHRISCompanyService(opts ...option.RequestOption) (r *HRISCompanyService) } // Read basic company data -func (r *HRISCompanyService) Get(ctx context.Context, opts ...option.RequestOption) (res *Company, err error) { +func (r *HRISCompanyService) Get(ctx context.Context, query HRISCompanyGetParams, opts ...option.RequestOption) (res *Company, err error) { opts = slices.Concat(r.Options, opts) path := "employer/company" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -246,3 +249,16 @@ func (r CompanyEntityType) IsKnown() bool { } return false } + +type HRISCompanyGetParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISCompanyGetParams]'s query parameters as `url.Values`. +func (r HRISCompanyGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/hriscompany_test.go b/hriscompany_test.go index fb80f54..c9af8ec 100644 --- a/hriscompany_test.go +++ b/hriscompany_test.go @@ -13,7 +13,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestHRISCompanyGet(t *testing.T) { +func TestHRISCompanyGetWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,8 +24,12 @@ func TestHRISCompanyGet(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) - _, err := client.HRIS.Company.Get(context.TODO()) + _, err := client.HRIS.Company.Get(context.TODO(), finchgo.HRISCompanyGetParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }) if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { diff --git a/hriscompanypaystatementitem.go b/hriscompanypaystatementitem.go index ce57c60..ef2c255 100644 --- a/hriscompanypaystatementitem.go +++ b/hriscompanypaystatementitem.go @@ -38,9 +38,8 @@ func NewHRISCompanyPayStatementItemService(opts ...option.RequestOption) (r *HRI return } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon Retrieve a list of detailed pay statement -// items for the access token's connection account. +// Retrieve a list of detailed pay statement items for the access token's +// connection account. func (r *HRISCompanyPayStatementItemService) List(ctx context.Context, query HRISCompanyPayStatementItemListParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[HRISCompanyPayStatementItemListResponse], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) @@ -58,9 +57,8 @@ func (r *HRISCompanyPayStatementItemService) List(ctx context.Context, query HRI return res, nil } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon Retrieve a list of detailed pay statement -// items for the access token's connection account. +// Retrieve a list of detailed pay statement items for the access token's +// connection account. func (r *HRISCompanyPayStatementItemService) ListAutoPaging(ctx context.Context, query HRISCompanyPayStatementItemListParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[HRISCompanyPayStatementItemListResponse] { return pagination.NewResponsesPageAutoPager(r.List(ctx, query, opts...)) } @@ -153,6 +151,8 @@ type HRISCompanyPayStatementItemListParams struct { // The end date to retrieve pay statement items by via their last seen pay date in // `YYYY-MM-DD` format. EndDate param.Field[time.Time] `query:"end_date" format:"date"` + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Case-insensitive partial match search by pay statement item name. Name param.Field[string] `query:"name"` // The start date to retrieve pay statement items by via their last seen pay date diff --git a/hriscompanypaystatementitem_test.go b/hriscompanypaystatementitem_test.go index b827b4d..0685b08 100644 --- a/hriscompanypaystatementitem_test.go +++ b/hriscompanypaystatementitem_test.go @@ -25,10 +25,13 @@ func TestHRISCompanyPayStatementItemListWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Company.PayStatementItem.List(context.TODO(), finchgo.HRISCompanyPayStatementItemListParams{ Categories: finchgo.F([]finchgo.HRISCompanyPayStatementItemListParamsCategory{finchgo.HRISCompanyPayStatementItemListParamsCategoryEarnings}), EndDate: finchgo.F(time.Now()), + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), Name: finchgo.F("name"), StartDate: finchgo.F(time.Now()), Type: finchgo.F("base_compensation"), diff --git a/hriscompanypaystatementitemrule.go b/hriscompanypaystatementitemrule.go index 88e3c7d..4f9b4a8 100644 --- a/hriscompanypaystatementitemrule.go +++ b/hriscompanypaystatementitemrule.go @@ -7,10 +7,12 @@ import ( "errors" "fmt" "net/http" + "net/url" "slices" "time" "github.com/Finch-API/finch-api-go/internal/apijson" + "github.com/Finch-API/finch-api-go/internal/apiquery" "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" @@ -36,40 +38,36 @@ func NewHRISCompanyPayStatementItemRuleService(opts ...option.RequestOption) (r return } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon Custom rules can be created to associate -// specific attributes to pay statement items depending on the use case. For -// example, pay statement items that meet certain conditions can be labeled as a -// pre-tax 401k. This metadata can be retrieved where pay statement item -// information is available. -func (r *HRISCompanyPayStatementItemRuleService) New(ctx context.Context, body HRISCompanyPayStatementItemRuleNewParams, opts ...option.RequestOption) (res *HRISCompanyPayStatementItemRuleNewResponse, err error) { +// Custom rules can be created to associate specific attributes to pay statement +// items depending on the use case. For example, pay statement items that meet +// certain conditions can be labeled as a pre-tax 401k. This metadata can be +// retrieved where pay statement item information is available. +func (r *HRISCompanyPayStatementItemRuleService) New(ctx context.Context, params HRISCompanyPayStatementItemRuleNewParams, opts ...option.RequestOption) (res *HRISCompanyPayStatementItemRuleNewResponse, err error) { opts = slices.Concat(r.Options, opts) path := "employer/pay-statement-item/rule" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) return } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon Update a rule for a pay statement item. -func (r *HRISCompanyPayStatementItemRuleService) Update(ctx context.Context, ruleID string, body HRISCompanyPayStatementItemRuleUpdateParams, opts ...option.RequestOption) (res *HRISCompanyPayStatementItemRuleUpdateResponse, err error) { +// Update a rule for a pay statement item. +func (r *HRISCompanyPayStatementItemRuleService) Update(ctx context.Context, ruleID string, params HRISCompanyPayStatementItemRuleUpdateParams, opts ...option.RequestOption) (res *HRISCompanyPayStatementItemRuleUpdateResponse, err error) { opts = slices.Concat(r.Options, opts) if ruleID == "" { err = errors.New("missing required rule_id parameter") return } path := fmt.Sprintf("employer/pay-statement-item/rule/%s", ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) return } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon List all rules of a connection account. -func (r *HRISCompanyPayStatementItemRuleService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.ResponsesPage[HRISCompanyPayStatementItemRuleListResponse], err error) { +// List all rules of a connection account. +func (r *HRISCompanyPayStatementItemRuleService) List(ctx context.Context, query HRISCompanyPayStatementItemRuleListParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[HRISCompanyPayStatementItemRuleListResponse], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "employer/pay-statement-item/rule" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err } @@ -81,22 +79,20 @@ func (r *HRISCompanyPayStatementItemRuleService) List(ctx context.Context, opts return res, nil } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon List all rules of a connection account. -func (r *HRISCompanyPayStatementItemRuleService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[HRISCompanyPayStatementItemRuleListResponse] { - return pagination.NewResponsesPageAutoPager(r.List(ctx, opts...)) +// List all rules of a connection account. +func (r *HRISCompanyPayStatementItemRuleService) ListAutoPaging(ctx context.Context, query HRISCompanyPayStatementItemRuleListParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[HRISCompanyPayStatementItemRuleListResponse] { + return pagination.NewResponsesPageAutoPager(r.List(ctx, query, opts...)) } -// **Beta:** this endpoint currently serves employers onboarded after March 4th and -// historical support will be added soon Delete a rule for a pay statement item. -func (r *HRISCompanyPayStatementItemRuleService) Delete(ctx context.Context, ruleID string, opts ...option.RequestOption) (res *HRISCompanyPayStatementItemRuleDeleteResponse, err error) { +// Delete a rule for a pay statement item. +func (r *HRISCompanyPayStatementItemRuleService) Delete(ctx context.Context, ruleID string, body HRISCompanyPayStatementItemRuleDeleteParams, opts ...option.RequestOption) (res *HRISCompanyPayStatementItemRuleDeleteResponse, err error) { opts = slices.Concat(r.Options, opts) if ruleID == "" { err = errors.New("missing required rule_id parameter") return } path := fmt.Sprintf("employer/pay-statement-item/rule/%s", ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) return } @@ -614,6 +610,8 @@ func (r HRISCompanyPayStatementItemRuleDeleteResponseEntityType) IsKnown() bool } type HRISCompanyPayStatementItemRuleNewParams struct { + // The entity IDs to create the rule for. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Specifies the fields to be applied when the condition is met. Attributes param.Field[HRISCompanyPayStatementItemRuleNewParamsAttributes] `json:"attributes"` Conditions param.Field[[]HRISCompanyPayStatementItemRuleNewParamsCondition] `json:"conditions"` @@ -629,6 +627,15 @@ func (r HRISCompanyPayStatementItemRuleNewParams) MarshalJSON() (data []byte, er return apijson.MarshalRoot(r) } +// URLQuery serializes [HRISCompanyPayStatementItemRuleNewParams]'s query +// parameters as `url.Values`. +func (r HRISCompanyPayStatementItemRuleNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + // Specifies the fields to be applied when the condition is met. type HRISCompanyPayStatementItemRuleNewParamsAttributes struct { // The metadata to be attached in the entity. It is a key-value pairs where the @@ -684,9 +691,48 @@ func (r HRISCompanyPayStatementItemRuleNewParamsEntityType) IsKnown() bool { } type HRISCompanyPayStatementItemRuleUpdateParams struct { + // The entity IDs to update the rule for. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` OptionalProperty param.Field[interface{}] `json:"optionalProperty"` } func (r HRISCompanyPayStatementItemRuleUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } + +// URLQuery serializes [HRISCompanyPayStatementItemRuleUpdateParams]'s query +// parameters as `url.Values`. +func (r HRISCompanyPayStatementItemRuleUpdateParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HRISCompanyPayStatementItemRuleListParams struct { + // The entity IDs to retrieve rules for. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISCompanyPayStatementItemRuleListParams]'s query +// parameters as `url.Values`. +func (r HRISCompanyPayStatementItemRuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HRISCompanyPayStatementItemRuleDeleteParams struct { + // The entity IDs to delete the rule for. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISCompanyPayStatementItemRuleDeleteParams]'s query +// parameters as `url.Values`. +func (r HRISCompanyPayStatementItemRuleDeleteParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/hriscompanypaystatementitemrule_test.go b/hriscompanypaystatementitemrule_test.go index b4c8e3e..7d61be5 100644 --- a/hriscompanypaystatementitemrule_test.go +++ b/hriscompanypaystatementitemrule_test.go @@ -24,8 +24,11 @@ func TestHRISCompanyPayStatementItemRuleNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Company.PayStatementItem.Rules.New(context.TODO(), finchgo.HRISCompanyPayStatementItemRuleNewParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), Attributes: finchgo.F(finchgo.HRISCompanyPayStatementItemRuleNewParamsAttributes{ Metadata: finchgo.F(map[string]interface{}{ "foo": "bar", @@ -60,11 +63,14 @@ func TestHRISCompanyPayStatementItemRuleUpdateWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Company.PayStatementItem.Rules.Update( context.TODO(), "rule_id", finchgo.HRISCompanyPayStatementItemRuleUpdateParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), OptionalProperty: finchgo.F[any](map[string]interface{}{}), }, ) @@ -77,7 +83,7 @@ func TestHRISCompanyPayStatementItemRuleUpdateWithOptionalParams(t *testing.T) { } } -func TestHRISCompanyPayStatementItemRuleList(t *testing.T) { +func TestHRISCompanyPayStatementItemRuleListWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -88,8 +94,12 @@ func TestHRISCompanyPayStatementItemRuleList(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) - _, err := client.HRIS.Company.PayStatementItem.Rules.List(context.TODO()) + _, err := client.HRIS.Company.PayStatementItem.Rules.List(context.TODO(), finchgo.HRISCompanyPayStatementItemRuleListParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }) if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { @@ -99,7 +109,7 @@ func TestHRISCompanyPayStatementItemRuleList(t *testing.T) { } } -func TestHRISCompanyPayStatementItemRuleDelete(t *testing.T) { +func TestHRISCompanyPayStatementItemRuleDeleteWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -110,8 +120,16 @@ func TestHRISCompanyPayStatementItemRuleDelete(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), + ) + _, err := client.HRIS.Company.PayStatementItem.Rules.Delete( + context.TODO(), + "rule_id", + finchgo.HRISCompanyPayStatementItemRuleDeleteParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }, ) - _, err := client.HRIS.Company.PayStatementItem.Rules.Delete(context.TODO(), "rule_id") if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { diff --git a/hrisdirectory.go b/hrisdirectory.go index ff2ca22..c9e2647 100644 --- a/hrisdirectory.go +++ b/hrisdirectory.go @@ -62,28 +62,11 @@ func (r *HRISDirectoryService) ListAutoPaging(ctx context.Context, query HRISDir // Read company directory and organization structure // // Deprecated: use `List` instead -func (r *HRISDirectoryService) ListIndividuals(ctx context.Context, body HRISDirectoryListIndividualsParams, opts ...option.RequestOption) (res *IndividualsPage, err error) { - var raw *http.Response +func (r *HRISDirectoryService) ListIndividuals(ctx context.Context, body HRISDirectoryListIndividualsParams, opts ...option.RequestOption) (res *HRISDirectoryListIndividualsResponse, err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "employer/directory" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, 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 company directory and organization structure -// -// Deprecated: use `List` instead -func (r *HRISDirectoryService) ListIndividualsAutoPaging(ctx context.Context, body HRISDirectoryListIndividualsParams, opts ...option.RequestOption) *IndividualsPageAutoPager { - return NewIndividualsPageAutoPager(r.ListIndividuals(ctx, body, opts...)) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, body, &res, opts...) + return } type IndividualsPage struct { @@ -120,7 +103,9 @@ func (r *IndividualsPage) GetNextPage() (res *IndividualsPage, err error) { } cfg := r.cfg.Clone(r.cfg.Context) - next := r.Paging.Offset + offset := r.Paging.Offset + length := int64(len(r.Individuals)) + next := offset + length if next < r.Paging.Count && next != 0 { err = cfg.Apply(option.WithQuery("offset", strconv.FormatInt(next, 10))) @@ -280,6 +265,8 @@ func (r individualInDirectoryManagerJSON) RawJSON() string { } type HRISDirectoryListParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Number of employees to return (defaults to all) Limit param.Field[int64] `query:"limit"` // Index to start from (defaults to 0) @@ -296,6 +283,8 @@ func (r HRISDirectoryListParams) URLQuery() (v url.Values) { } type HRISDirectoryListIndividualsParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Number of employees to return (defaults to all) Limit param.Field[int64] `query:"limit"` // Index to start from (defaults to 0) diff --git a/hrisdirectory_test.go b/hrisdirectory_test.go index 656a836..70d90d5 100644 --- a/hrisdirectory_test.go +++ b/hrisdirectory_test.go @@ -24,10 +24,13 @@ func TestHRISDirectoryListWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Directory.List(context.TODO(), finchgo.HRISDirectoryListParams{ - Limit: finchgo.F(int64(0)), - Offset: finchgo.F(int64(0)), + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + Limit: finchgo.F(int64(0)), + Offset: finchgo.F(int64(0)), }) if err != nil { var apierr *finchgo.Error @@ -49,10 +52,13 @@ func TestHRISDirectoryListIndividualsWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Directory.ListIndividuals(context.TODO(), finchgo.HRISDirectoryListIndividualsParams{ - Limit: finchgo.F(int64(0)), - Offset: finchgo.F(int64(0)), + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + Limit: finchgo.F(int64(0)), + Offset: finchgo.F(int64(0)), }) if err != nil { var apierr *finchgo.Error diff --git a/hrisdocument.go b/hrisdocument.go index 46683b2..af7abc5 100644 --- a/hrisdocument.go +++ b/hrisdocument.go @@ -50,14 +50,14 @@ func (r *HRISDocumentService) List(ctx context.Context, query HRISDocumentListPa // **Beta:** This endpoint is in beta and may change. Retrieve details of a // specific document by its ID. -func (r *HRISDocumentService) Retreive(ctx context.Context, documentID string, opts ...option.RequestOption) (res *HRISDocumentRetreiveResponse, err error) { +func (r *HRISDocumentService) Retreive(ctx context.Context, documentID string, query HRISDocumentRetreiveParams, opts ...option.RequestOption) (res *HRISDocumentRetreiveResponse, err error) { opts = slices.Concat(r.Options, opts) if documentID == "" { err = errors.New("missing required document_id parameter") return } path := fmt.Sprintf("employer/documents/%s", documentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -442,6 +442,8 @@ func (r HRISDocumentRetreiveResponseType) IsKnown() bool { } type HRISDocumentListParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` // Comma-delimited list of stable Finch uuids for each individual. If empty, // defaults to all individuals IndividualIDs param.Field[[]string] `query:"individual_ids"` @@ -476,3 +478,17 @@ func (r HRISDocumentListParamsType) IsKnown() bool { } return false } + +type HRISDocumentRetreiveParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [HRISDocumentRetreiveParams]'s query parameters as +// `url.Values`. +func (r HRISDocumentRetreiveParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/hrisdocument_test.go b/hrisdocument_test.go index 294ebfd..9b1257c 100644 --- a/hrisdocument_test.go +++ b/hrisdocument_test.go @@ -24,8 +24,11 @@ func TestHRISDocumentListWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Documents.List(context.TODO(), finchgo.HRISDocumentListParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), IndividualIDs: finchgo.F([]string{"string"}), Limit: finchgo.F(int64(0)), Offset: finchgo.F(int64(0)), @@ -40,7 +43,7 @@ func TestHRISDocumentListWithOptionalParams(t *testing.T) { } } -func TestHRISDocumentRetreive(t *testing.T) { +func TestHRISDocumentRetreiveWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -51,8 +54,16 @@ func TestHRISDocumentRetreive(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), + ) + _, err := client.HRIS.Documents.Retreive( + context.TODO(), + "document_id", + finchgo.HRISDocumentRetreiveParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }, ) - _, err := client.HRIS.Documents.Retreive(context.TODO(), "document_id") if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { diff --git a/hrisemployment.go b/hrisemployment.go index 25b213e..39c3951 100644 --- a/hrisemployment.go +++ b/hrisemployment.go @@ -5,10 +5,12 @@ package finchgo import ( "context" "net/http" + "net/url" "reflect" "slices" "github.com/Finch-API/finch-api-go/internal/apijson" + "github.com/Finch-API/finch-api-go/internal/apiquery" "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" @@ -37,12 +39,12 @@ func NewHRISEmploymentService(opts ...option.RequestOption) (r *HRISEmploymentSe } // Read individual employment and income data -func (r *HRISEmploymentService) GetMany(ctx context.Context, body HRISEmploymentGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[EmploymentDataResponse], err error) { +func (r *HRISEmploymentService) GetMany(ctx context.Context, params HRISEmploymentGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[EmploymentDataResponse], err error) { var raw *http.Response opts = slices.Concat(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...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...) if err != nil { return nil, err } @@ -55,8 +57,8 @@ func (r *HRISEmploymentService) GetMany(ctx context.Context, body HRISEmployment } // 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...)) +func (r *HRISEmploymentService) GetManyAutoPaging(ctx context.Context, params HRISEmploymentGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[EmploymentDataResponse] { + return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, params, opts...)) } type EmploymentData struct { @@ -71,8 +73,7 @@ type EmploymentData struct { Department interface{} `json:"department"` // This field can have the runtime type of [EmploymentDataObjectEmployment]. Employment interface{} `json:"employment"` - // The detailed employment status of the individual. Available options: `active`, - // `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + // The detailed employment status of the individual. EmploymentStatus EmploymentDataEmploymentStatus `json:"employment_status,nullable"` EndDate string `json:"end_date,nullable"` FinchCode string `json:"finch_code"` @@ -190,8 +191,7 @@ type EmploymentDataObject struct { Department EmploymentDataObjectDepartment `json:"department,required,nullable"` // The employment object. Employment EmploymentDataObjectEmployment `json:"employment,required,nullable"` - // The detailed employment status of the individual. Available options: `active`, - // `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + // The detailed employment status of the individual. EmploymentStatus EmploymentDataObjectEmploymentStatus `json:"employment_status,required,nullable"` EndDate string `json:"end_date,required,nullable"` // The legal first name of the individual. @@ -352,8 +352,7 @@ func (r EmploymentDataObjectEmploymentType) IsKnown() bool { return false } -// The detailed employment status of the individual. Available options: `active`, -// `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. +// The detailed employment status of the individual. type EmploymentDataObjectEmploymentStatus string const ( @@ -488,8 +487,7 @@ func (r employmentDataBatchErrorJSON) RawJSON() string { func (r EmploymentDataBatchError) implementsEmploymentData() {} -// The detailed employment status of the individual. Available options: `active`, -// `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. +// The detailed employment status of the individual. type EmploymentDataEmploymentStatus string const ( @@ -539,12 +537,23 @@ func (r employmentDataResponseJSON) RawJSON() string { type HRISEmploymentGetManyParams struct { // The array of batch requests. Requests param.Field[[]HRISEmploymentGetManyParamsRequest] `json:"requests,required"` + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` } func (r HRISEmploymentGetManyParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// URLQuery serializes [HRISEmploymentGetManyParams]'s query parameters as +// `url.Values`. +func (r HRISEmploymentGetManyParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + 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 diff --git a/hrisemployment_test.go b/hrisemployment_test.go index 8ae337c..e3d618e 100644 --- a/hrisemployment_test.go +++ b/hrisemployment_test.go @@ -13,7 +13,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestHRISEmploymentGetMany(t *testing.T) { +func TestHRISEmploymentGetManyWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,11 +24,14 @@ func TestHRISEmploymentGetMany(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Employments.GetMany(context.TODO(), finchgo.HRISEmploymentGetManyParams{ Requests: finchgo.F([]finchgo.HRISEmploymentGetManyParamsRequest{{ IndividualID: finchgo.F("individual_id"), }}), + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), }) if err != nil { var apierr *finchgo.Error diff --git a/hrisindividual.go b/hrisindividual.go index 11098ad..ae91410 100644 --- a/hrisindividual.go +++ b/hrisindividual.go @@ -5,10 +5,12 @@ package finchgo import ( "context" "net/http" + "net/url" "reflect" "slices" "github.com/Finch-API/finch-api-go/internal/apijson" + "github.com/Finch-API/finch-api-go/internal/apiquery" "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" @@ -36,12 +38,12 @@ func NewHRISIndividualService(opts ...option.RequestOption) (r *HRISIndividualSe } // 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) { +func (r *HRISIndividualService) GetMany(ctx context.Context, params 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...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...) if err != nil { return nil, err } @@ -54,8 +56,8 @@ func (r *HRISIndividualService) GetMany(ctx context.Context, body HRISIndividual } // 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...)) +func (r *HRISIndividualService) GetManyAutoPaging(ctx context.Context, params HRISIndividualGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[IndividualResponse] { + return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, params, opts...)) } type Individual struct { @@ -433,14 +435,25 @@ func (r individualResponseJSON) RawJSON() string { } type HRISIndividualGetManyParams struct { - Options param.Field[HRISIndividualGetManyParamsOptions] `json:"options"` - Requests param.Field[[]HRISIndividualGetManyParamsRequest] `json:"requests"` + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` + Options param.Field[HRISIndividualGetManyParamsOptions] `json:"options"` + Requests param.Field[[]HRISIndividualGetManyParamsRequest] `json:"requests"` } func (r HRISIndividualGetManyParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// URLQuery serializes [HRISIndividualGetManyParams]'s query parameters as +// `url.Values`. +func (r HRISIndividualGetManyParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type HRISIndividualGetManyParamsOptions struct { Include param.Field[[]string] `json:"include"` } diff --git a/hrisindividual_test.go b/hrisindividual_test.go index fed2a75..52b4b24 100644 --- a/hrisindividual_test.go +++ b/hrisindividual_test.go @@ -24,8 +24,11 @@ func TestHRISIndividualGetManyWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Individuals.GetMany(context.TODO(), finchgo.HRISIndividualGetManyParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), Options: finchgo.F(finchgo.HRISIndividualGetManyParamsOptions{ Include: finchgo.F([]string{"string"}), }), diff --git a/hrispayment.go b/hrispayment.go index d9a9bf9..7406948 100644 --- a/hrispayment.go +++ b/hrispayment.go @@ -154,11 +154,13 @@ func (r paymentPayPeriodJSON) RawJSON() string { type HRISPaymentListParams struct { // The end date to retrieve payments by a company (inclusive) in `YYYY-MM-DD` - // format. + // format. Filters payments by their **pay_date** field. EndDate param.Field[time.Time] `query:"end_date,required" format:"date"` // The start date to retrieve payments by a company (inclusive) in `YYYY-MM-DD` - // format. + // format. Filters payments by their **pay_date** field. StartDate param.Field[time.Time] `query:"start_date,required" format:"date"` + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` } // URLQuery serializes [HRISPaymentListParams]'s query parameters as `url.Values`. diff --git a/hrispayment_test.go b/hrispayment_test.go index df34cbd..89244d4 100644 --- a/hrispayment_test.go +++ b/hrispayment_test.go @@ -14,7 +14,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestHRISPaymentList(t *testing.T) { +func TestHRISPaymentListWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -25,10 +25,13 @@ func TestHRISPaymentList(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.Payments.List(context.TODO(), finchgo.HRISPaymentListParams{ EndDate: finchgo.F(time.Now()), StartDate: finchgo.F(time.Now()), + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), }) if err != nil { var apierr *finchgo.Error diff --git a/hrispaystatement.go b/hrispaystatement.go index 270b490..db0a268 100644 --- a/hrispaystatement.go +++ b/hrispaystatement.go @@ -5,10 +5,12 @@ package finchgo import ( "context" "net/http" + "net/url" "reflect" "slices" "github.com/Finch-API/finch-api-go/internal/apijson" + "github.com/Finch-API/finch-api-go/internal/apiquery" "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" @@ -39,12 +41,12 @@ func NewHRISPayStatementService(opts ...option.RequestOption) (r *HRISPayStateme // // Deduction and contribution types are supported by the payroll systems that // supports Benefits. -func (r *HRISPayStatementService) GetMany(ctx context.Context, body HRISPayStatementGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[PayStatementResponse], err error) { +func (r *HRISPayStatementService) GetMany(ctx context.Context, params HRISPayStatementGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[PayStatementResponse], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "employer/pay-statement" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...) if err != nil { return nil, err } @@ -60,8 +62,8 @@ func (r *HRISPayStatementService) GetMany(ctx context.Context, body HRISPayState // // Deduction and contribution types are supported by the payroll systems that // supports Benefits. -func (r *HRISPayStatementService) GetManyAutoPaging(ctx context.Context, body HRISPayStatementGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[PayStatementResponse] { - return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, body, opts...)) +func (r *HRISPayStatementService) GetManyAutoPaging(ctx context.Context, params HRISPayStatementGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[PayStatementResponse] { + return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, params, opts...)) } type PayStatement struct { @@ -640,12 +642,23 @@ func (r PayStatementResponseBodyBatchError) implementsPayStatementResponseBody() type HRISPayStatementGetManyParams struct { // The array of batch requests. Requests param.Field[[]HRISPayStatementGetManyParamsRequest] `json:"requests,required"` + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` } func (r HRISPayStatementGetManyParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// URLQuery serializes [HRISPayStatementGetManyParams]'s query parameters as +// `url.Values`. +func (r HRISPayStatementGetManyParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type HRISPayStatementGetManyParamsRequest struct { // A stable Finch `id` (UUID v4) for a payment. PaymentID param.Field[string] `json:"payment_id,required" format:"uuid"` diff --git a/hrispaystatement_test.go b/hrispaystatement_test.go index 6408a78..455ffa4 100644 --- a/hrispaystatement_test.go +++ b/hrispaystatement_test.go @@ -13,7 +13,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestHRISPayStatementGetMany(t *testing.T) { +func TestHRISPayStatementGetManyWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,6 +24,8 @@ func TestHRISPayStatementGetMany(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.HRIS.PayStatements.GetMany(context.TODO(), finchgo.HRISPayStatementGetManyParams{ Requests: finchgo.F([]finchgo.HRISPayStatementGetManyParamsRequest{{ @@ -31,6 +33,7 @@ func TestHRISPayStatementGetMany(t *testing.T) { Limit: finchgo.F(int64(50)), Offset: finchgo.F(int64(0)), }}), + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), }) if err != nil { var apierr *finchgo.Error diff --git a/internal/version.go b/internal/version.go index 6b316ac..33b1bc6 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "1.34.1" // x-release-please-version +const PackageVersion = "1.35.0" // x-release-please-version diff --git a/jobautomated_test.go b/jobautomated_test.go index d7a8792..a436354 100644 --- a/jobautomated_test.go +++ b/jobautomated_test.go @@ -24,6 +24,8 @@ func TestJobAutomatedNew(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Jobs.Automated.New(context.TODO(), finchgo.JobAutomatedNewParamsDataSyncAll{ Type: finchgo.F(finchgo.JobAutomatedNewParamsDataSyncAllTypeDataSyncAll), @@ -48,6 +50,8 @@ func TestJobAutomatedGet(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Jobs.Automated.Get(context.TODO(), "job_id") if err != nil { @@ -70,6 +74,8 @@ func TestJobAutomatedListWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Jobs.Automated.List(context.TODO(), finchgo.JobAutomatedListParams{ Limit: finchgo.F(int64(0)), diff --git a/jobmanual.go b/jobmanual.go index 8a6d103..2722053 100644 --- a/jobmanual.go +++ b/jobmanual.go @@ -33,8 +33,8 @@ func NewJobManualService(opts ...option.RequestOption) (r *JobManualService) { return } -// Get a manual job by `job_id`. Manual jobs are completed by a human and include -// Assisted Benefits jobs. +// Check the status and outcome of a job by `job_id`. This includes all deductions +// jobs including those for both automated and assisted integrations. func (r *JobManualService) Get(ctx context.Context, jobID string, opts ...option.RequestOption) (res *ManualAsyncJob, err error) { opts = slices.Concat(r.Options, opts) if jobID == "" { diff --git a/jobmanual_test.go b/jobmanual_test.go index 8fe52ff..c707e08 100644 --- a/jobmanual_test.go +++ b/jobmanual_test.go @@ -24,6 +24,8 @@ func TestJobManualGet(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Jobs.Manual.Get(context.TODO(), "job_id") if err != nil { diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go index 40487f7..2a8f4af 100644 --- a/packages/pagination/pagination.go +++ b/packages/pagination/pagination.go @@ -241,7 +241,9 @@ func (r *Page[T]) GetNextPage() (res *Page[T], err error) { } cfg := r.cfg.Clone(r.cfg.Context) - next := r.Paging.Offset + offset := r.Paging.Offset + length := int64(len(r.Data)) + next := offset + length if next < r.Paging.Count && next != 0 { err = cfg.Apply(option.WithQuery("offset", strconv.FormatInt(next, 10))) diff --git a/paginationauto_test.go b/paginationauto_test.go index 603f7ef..b905c2f 100644 --- a/paginationauto_test.go +++ b/paginationauto_test.go @@ -23,6 +23,8 @@ func TestAutoPagination(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) iter := client.HRIS.Directory.ListAutoPaging(context.TODO(), finchgo.HRISDirectoryListParams{}) // Prism mock isn't going to give us real pagination diff --git a/paginationmanual_test.go b/paginationmanual_test.go index fb4ca33..6b17758 100644 --- a/paginationmanual_test.go +++ b/paginationmanual_test.go @@ -23,6 +23,8 @@ func TestManualPagination(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) page, err := client.HRIS.Directory.List(context.TODO(), finchgo.HRISDirectoryListParams{}) if err != nil { diff --git a/payrollpaygroup.go b/payrollpaygroup.go index 3bd4196..2727855 100644 --- a/payrollpaygroup.go +++ b/payrollpaygroup.go @@ -38,14 +38,14 @@ func NewPayrollPayGroupService(opts ...option.RequestOption) (r *PayrollPayGroup } // Read information from a single pay group -func (r *PayrollPayGroupService) Get(ctx context.Context, payGroupID string, opts ...option.RequestOption) (res *PayrollPayGroupGetResponse, err error) { +func (r *PayrollPayGroupService) Get(ctx context.Context, payGroupID string, query PayrollPayGroupGetParams, opts ...option.RequestOption) (res *PayrollPayGroupGetResponse, err error) { opts = slices.Concat(r.Options, opts) if payGroupID == "" { err = errors.New("missing required pay_group_id parameter") return } path := fmt.Sprintf("employer/pay-groups/%s", payGroupID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -174,7 +174,23 @@ func (r PayrollPayGroupListResponsePayFrequency) IsKnown() bool { return false } +type PayrollPayGroupGetParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` +} + +// URLQuery serializes [PayrollPayGroupGetParams]'s query parameters as +// `url.Values`. +func (r PayrollPayGroupGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type PayrollPayGroupListParams struct { + // The entity IDs to specify which entities' data to access. + EntityIDs param.Field[[]string] `query:"entity_ids" format:"uuid"` IndividualID param.Field[string] `query:"individual_id" format:"uuid"` PayFrequencies param.Field[[]string] `query:"pay_frequencies"` } diff --git a/payrollpaygroup_test.go b/payrollpaygroup_test.go index c1983a3..306c232 100644 --- a/payrollpaygroup_test.go +++ b/payrollpaygroup_test.go @@ -13,7 +13,7 @@ import ( "github.com/Finch-API/finch-api-go/option" ) -func TestPayrollPayGroupGet(t *testing.T) { +func TestPayrollPayGroupGetWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,8 +24,16 @@ func TestPayrollPayGroupGet(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), + ) + _, err := client.Payroll.PayGroups.Get( + context.TODO(), + "pay_group_id", + finchgo.PayrollPayGroupGetParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), + }, ) - _, err := client.Payroll.PayGroups.Get(context.TODO(), "pay_group_id") if err != nil { var apierr *finchgo.Error if errors.As(err, &apierr) { @@ -46,8 +54,11 @@ func TestPayrollPayGroupListWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Payroll.PayGroups.List(context.TODO(), finchgo.PayrollPayGroupListParams{ + EntityIDs: finchgo.F([]string{"550e8400-e29b-41d4-a716-446655440000"}), IndividualID: finchgo.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), PayFrequencies: finchgo.F([]string{"string"}), }) diff --git a/provider_test.go b/provider_test.go index 708dfc6..cd7374e 100644 --- a/provider_test.go +++ b/provider_test.go @@ -24,6 +24,8 @@ func TestProviderList(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Providers.List(context.TODO()) if err != nil { diff --git a/requestforwarding.go b/requestforwarding.go index cecc843..541bda8 100644 --- a/requestforwarding.go +++ b/requestforwarding.go @@ -93,7 +93,7 @@ type RequestForwardingForwardResponseRequest struct { // The body that was specified for the forwarded request. Data RequestForwardingForwardResponseRequestDataUnion `json:"data,nullable"` // The HTTP headers that were specified for the forwarded request. - Headers map[string]interface{} `json:"headers,nullable"` + Headers map[string]string `json:"headers,nullable"` // The query parameters that were specified for the forwarded request. Params map[string]interface{} `json:"params,nullable"` JSON requestForwardingForwardResponseRequestJSON `json:"-"` @@ -158,13 +158,13 @@ type RequestForwardingForwardParams struct { // The body for the forwarded request. This value must be specified as either a // string or a valid JSON object. Data param.Field[string] `json:"data"` - // The HTTP headers to include on the forwarded request. This value must be - // specified as an object of key-value pairs. Example: - // `{"Content-Type": "application/xml", "X-API-Version": "v1" }` - Headers param.Field[map[string]interface{}] `json:"headers"` // The query parameters for the forwarded request. This value must be specified as // a valid JSON object rather than a query string. Params param.Field[map[string]interface{}] `json:"params"` + // The HTTP headers to include on the forwarded request. This value must be + // specified as an object of key-value pairs. Example: + // `{"Content-Type": "application/xml", "X-API-Version": "v1" }` + RequestHeaders param.Field[map[string]interface{}] `json:"request_headers"` } func (r RequestForwardingForwardParams) MarshalJSON() (data []byte, err error) { diff --git a/requestforwarding_test.go b/requestforwarding_test.go index ec9aacf..6af3ffc 100644 --- a/requestforwarding_test.go +++ b/requestforwarding_test.go @@ -24,15 +24,17 @@ func TestRequestForwardingForwardWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.RequestForwarding.Forward(context.TODO(), finchgo.RequestForwardingForwardParams{ Method: finchgo.F("method"), Route: finchgo.F("route"), Data: finchgo.F("data"), - Headers: finchgo.F(map[string]interface{}{ + Params: finchgo.F(map[string]interface{}{ "foo": "bar", }), - Params: finchgo.F(map[string]interface{}{ + RequestHeaders: finchgo.F(map[string]interface{}{ "foo": "bar", }), }) diff --git a/sandboxcompany_test.go b/sandboxcompany_test.go index 1a4e45f..f3516f5 100644 --- a/sandboxcompany_test.go +++ b/sandboxcompany_test.go @@ -24,6 +24,8 @@ func TestSandboxCompanyUpdateWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Company.Update(context.TODO(), finchgo.SandboxCompanyUpdateParams{ Accounts: finchgo.F([]finchgo.SandboxCompanyUpdateParamsAccount{{ diff --git a/sandboxconnection.go b/sandboxconnection.go index 9bcfda9..823274e 100644 --- a/sandboxconnection.go +++ b/sandboxconnection.go @@ -54,8 +54,10 @@ type SandboxConnectionNewResponse struct { // Deprecated: deprecated CompanyID string `json:"company_id,required" format:"uuid"` // The ID of the new connection - ConnectionID string `json:"connection_id,required" format:"uuid"` - Products []string `json:"products,required"` + ConnectionID string `json:"connection_id,required" format:"uuid"` + // The ID of the entity for this connection + EntityID string `json:"entity_id,required" format:"uuid"` + Products []string `json:"products,required"` // The ID of the provider associated with the `access_token`. ProviderID string `json:"provider_id,required" format:"uuid"` TokenType string `json:"token_type"` @@ -70,6 +72,7 @@ type sandboxConnectionNewResponseJSON struct { AuthenticationType apijson.Field CompanyID apijson.Field ConnectionID apijson.Field + EntityID apijson.Field Products apijson.Field ProviderID apijson.Field TokenType apijson.Field diff --git a/sandboxconnection_test.go b/sandboxconnection_test.go index 0f57206..f262883 100644 --- a/sandboxconnection_test.go +++ b/sandboxconnection_test.go @@ -25,6 +25,8 @@ func TestSandboxConnectionNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Connections.New(context.TODO(), finchgo.SandboxConnectionNewParams{ ProviderID: finchgo.F("provider_id"), diff --git a/sandboxconnectionaccount.go b/sandboxconnectionaccount.go index 644e032..d4e81e0 100644 --- a/sandboxconnectionaccount.go +++ b/sandboxconnectionaccount.go @@ -62,8 +62,10 @@ type SandboxConnectionAccountNewResponse struct { // Deprecated: deprecated CompanyID string `json:"company_id,required" format:"uuid"` // The ID of the new connection - ConnectionID string `json:"connection_id,required" format:"uuid"` - Products []string `json:"products,required"` + ConnectionID string `json:"connection_id,required" format:"uuid"` + // The ID of the entity for this connection + EntityID string `json:"entity_id,required" format:"uuid"` + Products []string `json:"products,required"` // The ID of the provider associated with the `access_token` ProviderID string `json:"provider_id,required"` JSON sandboxConnectionAccountNewResponseJSON `json:"-"` @@ -77,6 +79,7 @@ type sandboxConnectionAccountNewResponseJSON struct { AuthenticationType apijson.Field CompanyID apijson.Field ConnectionID apijson.Field + EntityID apijson.Field Products apijson.Field ProviderID apijson.Field raw string @@ -117,13 +120,15 @@ type SandboxConnectionAccountUpdateResponse struct { // [DEPRECATED] Use `connection_id` to associate a connection with an access token // // Deprecated: deprecated - CompanyID string `json:"company_id,required" format:"uuid"` - Products []string `json:"products,required"` - // The ID of the provider associated with the `access_token` - ProviderID string `json:"provider_id,required"` + CompanyID string `json:"company_id,required" format:"uuid"` // The ID of the new connection - ConnectionID string `json:"connection_id" format:"uuid"` - JSON sandboxConnectionAccountUpdateResponseJSON `json:"-"` + ConnectionID string `json:"connection_id,required" format:"uuid"` + // The ID of the entity whose status was updated + EntityID string `json:"entity_id,required" format:"uuid"` + Products []string `json:"products,required"` + // The ID of the provider associated with the `access_token` + ProviderID string `json:"provider_id,required"` + JSON sandboxConnectionAccountUpdateResponseJSON `json:"-"` } // sandboxConnectionAccountUpdateResponseJSON contains the JSON metadata for the @@ -132,9 +137,10 @@ type sandboxConnectionAccountUpdateResponseJSON struct { AccountID apijson.Field AuthenticationType apijson.Field CompanyID apijson.Field + ConnectionID apijson.Field + EntityID apijson.Field Products apijson.Field ProviderID apijson.Field - ConnectionID apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/sandboxconnectionaccount_test.go b/sandboxconnectionaccount_test.go index a79e6ee..98ac832 100644 --- a/sandboxconnectionaccount_test.go +++ b/sandboxconnectionaccount_test.go @@ -26,6 +26,8 @@ func TestSandboxConnectionAccountNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Connections.Accounts.New(context.TODO(), finchgo.SandboxConnectionAccountNewParams{ CompanyID: finchgo.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), @@ -53,6 +55,8 @@ func TestSandboxConnectionAccountUpdateWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Connections.Accounts.Update(context.TODO(), finchgo.SandboxConnectionAccountUpdateParams{ ConnectionStatus: finchgo.F(shared.ConnectionStatusTypeReauth), diff --git a/sandboxdirectory.go b/sandboxdirectory.go index 49a278e..f14c669 100644 --- a/sandboxdirectory.go +++ b/sandboxdirectory.go @@ -65,8 +65,7 @@ type SandboxDirectoryNewParamsBody struct { Emails param.Field[[]SandboxDirectoryNewParamsBodyEmail] `json:"emails"` // The employment object. Employment param.Field[SandboxDirectoryNewParamsBodyEmployment] `json:"employment"` - // The detailed employment status of the individual. Available options: `active`, - // `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + // The detailed employment status of the individual. EmploymentStatus param.Field[SandboxDirectoryNewParamsBodyEmploymentStatus] `json:"employment_status"` // Social Security Number of the individual in **encrypted** format. This field is // only available with the `ssn` scope enabled and the @@ -208,8 +207,7 @@ func (r SandboxDirectoryNewParamsBodyEmploymentType) IsKnown() bool { return false } -// The detailed employment status of the individual. Available options: `active`, -// `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. +// The detailed employment status of the individual. type SandboxDirectoryNewParamsBodyEmploymentStatus string const ( diff --git a/sandboxdirectory_test.go b/sandboxdirectory_test.go index b18682a..3c013ca 100644 --- a/sandboxdirectory_test.go +++ b/sandboxdirectory_test.go @@ -25,6 +25,8 @@ func TestSandboxDirectoryNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Directory.New(context.TODO(), finchgo.SandboxDirectoryNewParams{ Body: []finchgo.SandboxDirectoryNewParamsBody{{ diff --git a/sandboxemployment.go b/sandboxemployment.go index bc946ed..a25cab3 100644 --- a/sandboxemployment.go +++ b/sandboxemployment.go @@ -59,8 +59,7 @@ type SandboxEmploymentUpdateResponse struct { Department SandboxEmploymentUpdateResponseDepartment `json:"department,nullable"` // The employment object. Employment SandboxEmploymentUpdateResponseEmployment `json:"employment,nullable"` - // The detailed employment status of the individual. Available options: `active`, - // `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + // The detailed employment status of the individual. EmploymentStatus SandboxEmploymentUpdateResponseEmploymentStatus `json:"employment_status,nullable"` EndDate string `json:"end_date,nullable"` // The legal first name of the individual. @@ -233,8 +232,7 @@ func (r SandboxEmploymentUpdateResponseEmploymentType) IsKnown() bool { return false } -// The detailed employment status of the individual. Available options: `active`, -// `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. +// The detailed employment status of the individual. type SandboxEmploymentUpdateResponseEmploymentStatus string const ( @@ -289,8 +287,7 @@ type SandboxEmploymentUpdateParams struct { Department param.Field[SandboxEmploymentUpdateParamsDepartment] `json:"department"` // The employment object. Employment param.Field[SandboxEmploymentUpdateParamsEmployment] `json:"employment"` - // The detailed employment status of the individual. Available options: `active`, - // `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + // The detailed employment status of the individual. EmploymentStatus param.Field[SandboxEmploymentUpdateParamsEmploymentStatus] `json:"employment_status"` EndDate param.Field[string] `json:"end_date"` // The legal first name of the individual. @@ -391,8 +388,7 @@ func (r SandboxEmploymentUpdateParamsEmploymentType) IsKnown() bool { return false } -// The detailed employment status of the individual. Available options: `active`, -// `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. +// The detailed employment status of the individual. type SandboxEmploymentUpdateParamsEmploymentStatus string const ( diff --git a/sandboxemployment_test.go b/sandboxemployment_test.go index 2634723..765797f 100644 --- a/sandboxemployment_test.go +++ b/sandboxemployment_test.go @@ -25,6 +25,8 @@ func TestSandboxEmploymentUpdateWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Employment.Update( context.TODO(), diff --git a/sandboxindividual_test.go b/sandboxindividual_test.go index a55e9aa..d777e9d 100644 --- a/sandboxindividual_test.go +++ b/sandboxindividual_test.go @@ -24,6 +24,8 @@ func TestSandboxIndividualUpdateWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Individual.Update( context.TODO(), diff --git a/sandboxjob_test.go b/sandboxjob_test.go index 48e1214..0944d7e 100644 --- a/sandboxjob_test.go +++ b/sandboxjob_test.go @@ -24,6 +24,8 @@ func TestSandboxJobNew(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Jobs.New(context.TODO(), finchgo.SandboxJobNewParams{ Type: finchgo.F(finchgo.SandboxJobNewParamsTypeDataSyncAll), diff --git a/sandboxjobconfiguration_test.go b/sandboxjobconfiguration_test.go index 0311d5a..09ccbab 100644 --- a/sandboxjobconfiguration_test.go +++ b/sandboxjobconfiguration_test.go @@ -24,6 +24,8 @@ func TestSandboxJobConfigurationGet(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Jobs.Configuration.Get(context.TODO()) if err != nil { @@ -46,6 +48,8 @@ func TestSandboxJobConfigurationUpdate(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Jobs.Configuration.Update(context.TODO(), finchgo.SandboxJobConfigurationUpdateParams{ CompletionStatus: finchgo.F(finchgo.SandboxJobConfigurationUpdateParamsCompletionStatusComplete), diff --git a/sandboxpayment.go b/sandboxpayment.go index f65992d..ea7ca46 100644 --- a/sandboxpayment.go +++ b/sandboxpayment.go @@ -132,7 +132,8 @@ func (r SandboxPaymentNewParamsPayStatementsEarningsType) IsKnown() bool { } type SandboxPaymentNewParamsPayStatementsEmployeeDeduction struct { - Amount param.Field[int64] `json:"amount"` + Amount param.Field[int64] `json:"amount"` + // The deduction name. Required when type is specified. Name param.Field[string] `json:"name"` PreTax param.Field[bool] `json:"pre_tax"` Type param.Field[SandboxPaymentNewParamsPayStatementsEmployeeDeductionsType] `json:"type"` @@ -175,9 +176,10 @@ func (r SandboxPaymentNewParamsPayStatementsEmployeeDeductionsType) IsKnown() bo } type SandboxPaymentNewParamsPayStatementsEmployerContribution struct { - Amount param.Field[int64] `json:"amount"` - Name param.Field[string] `json:"name"` - Type param.Field[SandboxPaymentNewParamsPayStatementsEmployerContributionsType] `json:"type"` + Amount param.Field[int64] `json:"amount"` + // The contribution name. Required when type is specified. + Name param.Field[string] `json:"name"` + Type param.Field[SandboxPaymentNewParamsPayStatementsEmployerContributionsType] `json:"type"` } func (r SandboxPaymentNewParamsPayStatementsEmployerContribution) MarshalJSON() (data []byte, err error) { diff --git a/sandboxpayment_test.go b/sandboxpayment_test.go index a733f40..ca67b00 100644 --- a/sandboxpayment_test.go +++ b/sandboxpayment_test.go @@ -25,6 +25,8 @@ func TestSandboxPaymentNewWithOptionalParams(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) _, err := client.Sandbox.Payment.New(context.TODO(), finchgo.SandboxPaymentNewParams{ EndDate: finchgo.F(time.Now()), diff --git a/usage_test.go b/usage_test.go index 40a3309..3cebfb2 100644 --- a/usage_test.go +++ b/usage_test.go @@ -23,6 +23,8 @@ func TestUsage(t *testing.T) { client := finchgo.NewClient( option.WithBaseURL(baseURL), option.WithAccessToken("My Access Token"), + option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"), + option.WithClientSecret("My Client Secret"), ) page, err := client.HRIS.Directory.List(context.TODO(), finchgo.HRISDirectoryListParams{}) if err != nil {