-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0af2458
commit e889ea7
Showing
6 changed files
with
299 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |