Skip to content

Commit

Permalink
feat(api): updates (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jun 6, 2024
1 parent 88bd8b3 commit c3c38df
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 34
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch-69265939ed1aa33d9890c86a334730210985961db56757efc28ff43696fbd1a7.yml
configured_endpoints: 36
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch-f1001da4ad3c1503330eebc1e61319a1a5db5e2da9fec98bc8682cb0967894d2.yml
14 changes: 14 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,17 @@ Methods:

- <code title="get /sandbox/jobs/configuration">client.Sandbox.Jobs.Configuration.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfigurationService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) ([]<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfiguration">SandboxJobConfiguration</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /sandbox/jobs/configuration">client.Sandbox.Jobs.Configuration.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfigurationService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfigurationUpdateParams">SandboxJobConfigurationUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#SandboxJobConfiguration">SandboxJobConfiguration</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Payroll

## PayGroups

Response Types:

- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupGetResponse">PayrollPayGroupGetResponse</a>
- <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupListResponse">PayrollPayGroupListResponse</a>

Methods:

- <code title="get /employer/pay-group/{pay_group_id}">client.Payroll.PayGroups.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, payGroupID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupGetResponse">PayrollPayGroupGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /employer/pay-groups">client.Payroll.PayGroups.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupListParams">PayrollPayGroupListParams</a>) (<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go/internal/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go">finchgo</a>.<a href="https://pkg.go.dev/github.com/Finch-API/finch-api-go#PayrollPayGroupListResponse">PayrollPayGroupListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Client struct {
RequestForwarding *RequestForwardingService
Jobs *JobService
Sandbox *SandboxService
Payroll *PayrollService
}

// NewClient generates a new client with the default option read from the
Expand Down Expand Up @@ -65,6 +66,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r.RequestForwarding = NewRequestForwardingService(opts...)
r.Jobs = NewJobService(opts...)
r.Sandbox = NewSandboxService(opts...)
r.Payroll = NewPayrollService(opts...)

return
}
Expand Down
28 changes: 28 additions & 0 deletions payroll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package finchgo

import (
"github.com/Finch-API/finch-api-go/option"
)

// PayrollService contains methods and other services that help with interacting
// with the Finch API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewPayrollService] method instead.
type PayrollService struct {
Options []option.RequestOption
PayGroups *PayrollPayGroupService
}

// NewPayrollService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewPayrollService(opts ...option.RequestOption) (r *PayrollService) {
r = &PayrollService{}
r.Options = opts
r.PayGroups = NewPayrollPayGroupService(opts...)
return
}
188 changes: 188 additions & 0 deletions payrollpaygroup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package finchgo

import (
"context"
"errors"
"fmt"
"net/http"
"net/url"

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

// PayrollPayGroupService contains methods and other services that help with
// interacting with the Finch API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewPayrollPayGroupService] method instead.
type PayrollPayGroupService struct {
Options []option.RequestOption
}

// NewPayrollPayGroupService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewPayrollPayGroupService(opts ...option.RequestOption) (r *PayrollPayGroupService) {
r = &PayrollPayGroupService{}
r.Options = opts
return
}

// Read information from a single pay group
func (r *PayrollPayGroupService) Get(ctx context.Context, payGroupID string, opts ...option.RequestOption) (res *PayrollPayGroupGetResponse, err error) {
opts = append(r.Options[:], opts...)
if payGroupID == "" {
err = errors.New("missing required pay_group_id parameter")
return
}
path := fmt.Sprintf("employer/pay-group/%s", payGroupID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}

// Read company pay groups and frequencies
func (r *PayrollPayGroupService) List(ctx context.Context, query PayrollPayGroupListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PayrollPayGroupListResponse], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "employer/pay-groups"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 pay groups and frequencies
func (r *PayrollPayGroupService) ListAutoPaging(ctx context.Context, query PayrollPayGroupListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PayrollPayGroupListResponse] {
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
}

type PayrollPayGroupGetResponse struct {
// Finch id (uuidv4) for the pay group
ID string `json:"id,required" format:"uuid"`
IndividualIDs []string `json:"individual_ids,required" format:"uuid"`
// Name of the pay group
Name string `json:"name,required"`
// List of pay frequencies associated with this pay group
PayFrequencies []PayrollPayGroupGetResponsePayFrequency `json:"pay_frequencies,required"`
JSON payrollPayGroupGetResponseJSON `json:"-"`
}

// payrollPayGroupGetResponseJSON contains the JSON metadata for the struct
// [PayrollPayGroupGetResponse]
type payrollPayGroupGetResponseJSON struct {
ID apijson.Field
IndividualIDs apijson.Field
Name apijson.Field
PayFrequencies apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

func (r payrollPayGroupGetResponseJSON) RawJSON() string {
return r.raw
}

type PayrollPayGroupGetResponsePayFrequency string

const (
PayrollPayGroupGetResponsePayFrequencyAnnually PayrollPayGroupGetResponsePayFrequency = "annually"
PayrollPayGroupGetResponsePayFrequencySemiAnnually PayrollPayGroupGetResponsePayFrequency = "semi_annually"
PayrollPayGroupGetResponsePayFrequencyQuarterly PayrollPayGroupGetResponsePayFrequency = "quarterly"
PayrollPayGroupGetResponsePayFrequencyMonthly PayrollPayGroupGetResponsePayFrequency = "monthly"
PayrollPayGroupGetResponsePayFrequencySemiMonthly PayrollPayGroupGetResponsePayFrequency = "semi_monthly"
PayrollPayGroupGetResponsePayFrequencyBiWeekly PayrollPayGroupGetResponsePayFrequency = "bi_weekly"
PayrollPayGroupGetResponsePayFrequencyWeekly PayrollPayGroupGetResponsePayFrequency = "weekly"
PayrollPayGroupGetResponsePayFrequencyDaily PayrollPayGroupGetResponsePayFrequency = "daily"
PayrollPayGroupGetResponsePayFrequencyOther PayrollPayGroupGetResponsePayFrequency = "other"
)

func (r PayrollPayGroupGetResponsePayFrequency) IsKnown() bool {
switch r {
case PayrollPayGroupGetResponsePayFrequencyAnnually, PayrollPayGroupGetResponsePayFrequencySemiAnnually, PayrollPayGroupGetResponsePayFrequencyQuarterly, PayrollPayGroupGetResponsePayFrequencyMonthly, PayrollPayGroupGetResponsePayFrequencySemiMonthly, PayrollPayGroupGetResponsePayFrequencyBiWeekly, PayrollPayGroupGetResponsePayFrequencyWeekly, PayrollPayGroupGetResponsePayFrequencyDaily, PayrollPayGroupGetResponsePayFrequencyOther:
return true
}
return false
}

type PayrollPayGroupListResponse struct {
// Finch id (uuidv4) for the pay group
ID string `json:"id" format:"uuid"`
// Name of the pay group
Name string `json:"name"`
// List of pay frequencies associated with this pay group
PayFrequencies []PayrollPayGroupListResponsePayFrequency `json:"pay_frequencies"`
JSON payrollPayGroupListResponseJSON `json:"-"`
}

// payrollPayGroupListResponseJSON contains the JSON metadata for the struct
// [PayrollPayGroupListResponse]
type payrollPayGroupListResponseJSON struct {
ID apijson.Field
Name apijson.Field
PayFrequencies apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

func (r payrollPayGroupListResponseJSON) RawJSON() string {
return r.raw
}

type PayrollPayGroupListResponsePayFrequency string

const (
PayrollPayGroupListResponsePayFrequencyAnnually PayrollPayGroupListResponsePayFrequency = "annually"
PayrollPayGroupListResponsePayFrequencySemiAnnually PayrollPayGroupListResponsePayFrequency = "semi_annually"
PayrollPayGroupListResponsePayFrequencyQuarterly PayrollPayGroupListResponsePayFrequency = "quarterly"
PayrollPayGroupListResponsePayFrequencyMonthly PayrollPayGroupListResponsePayFrequency = "monthly"
PayrollPayGroupListResponsePayFrequencySemiMonthly PayrollPayGroupListResponsePayFrequency = "semi_monthly"
PayrollPayGroupListResponsePayFrequencyBiWeekly PayrollPayGroupListResponsePayFrequency = "bi_weekly"
PayrollPayGroupListResponsePayFrequencyWeekly PayrollPayGroupListResponsePayFrequency = "weekly"
PayrollPayGroupListResponsePayFrequencyDaily PayrollPayGroupListResponsePayFrequency = "daily"
PayrollPayGroupListResponsePayFrequencyOther PayrollPayGroupListResponsePayFrequency = "other"
)

func (r PayrollPayGroupListResponsePayFrequency) IsKnown() bool {
switch r {
case PayrollPayGroupListResponsePayFrequencyAnnually, PayrollPayGroupListResponsePayFrequencySemiAnnually, PayrollPayGroupListResponsePayFrequencyQuarterly, PayrollPayGroupListResponsePayFrequencyMonthly, PayrollPayGroupListResponsePayFrequencySemiMonthly, PayrollPayGroupListResponsePayFrequencyBiWeekly, PayrollPayGroupListResponsePayFrequencyWeekly, PayrollPayGroupListResponsePayFrequencyDaily, PayrollPayGroupListResponsePayFrequencyOther:
return true
}
return false
}

type PayrollPayGroupListParams struct {
IndividualID param.Field[string] `query:"individual_id" format:"uuid"`
PayFrequencies param.Field[[]string] `query:"pay_frequencies"`
}

// URLQuery serializes [PayrollPayGroupListParams]'s query parameters as
// `url.Values`.
func (r PayrollPayGroupListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
65 changes: 65 additions & 0 deletions payrollpaygroup_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package finchgo_test

import (
"context"
"errors"
"os"
"testing"

"github.com/Finch-API/finch-api-go"
"github.com/Finch-API/finch-api-go/internal/testutil"
"github.com/Finch-API/finch-api-go/option"
)

func TestPayrollPayGroupGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
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(), "string")
if err != nil {
var apierr *finchgo.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestPayrollPayGroupListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
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{
IndividualID: finchgo.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
PayFrequencies: finchgo.F([]string{"string", "string", "string"}),
})
if err != nil {
var apierr *finchgo.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

0 comments on commit c3c38df

Please sign in to comment.