-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhriscompanypaystatementitem.go
More file actions
189 lines (166 loc) · 8.34 KB
/
hriscompanypaystatementitem.go
File metadata and controls
189 lines (166 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"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"
"github.com/Finch-API/finch-api-go/packages/pagination"
)
// HRISCompanyPayStatementItemService 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 [NewHRISCompanyPayStatementItemService] method instead.
type HRISCompanyPayStatementItemService struct {
Options []option.RequestOption
Rules *HRISCompanyPayStatementItemRuleService
}
// NewHRISCompanyPayStatementItemService 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 NewHRISCompanyPayStatementItemService(opts ...option.RequestOption) (r *HRISCompanyPayStatementItemService) {
r = &HRISCompanyPayStatementItemService{}
r.Options = opts
r.Rules = NewHRISCompanyPayStatementItemRuleService(opts...)
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.
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)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "employer/pay-statement-item"
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
}
// **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.
func (r *HRISCompanyPayStatementItemService) ListAutoPaging(ctx context.Context, query HRISCompanyPayStatementItemListParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[HRISCompanyPayStatementItemListResponse] {
return pagination.NewResponsesPageAutoPager(r.List(ctx, query, opts...))
}
type HRISCompanyPayStatementItemListResponse struct {
// The attributes of the pay statement item.
Attributes HRISCompanyPayStatementItemListResponseAttributes `json:"attributes,required"`
// The category of the pay statement item.
Category HRISCompanyPayStatementItemListResponseCategory `json:"category,required"`
// The name of the pay statement item.
Name string `json:"name,required"`
JSON hrisCompanyPayStatementItemListResponseJSON `json:"-"`
}
// hrisCompanyPayStatementItemListResponseJSON contains the JSON metadata for the
// struct [HRISCompanyPayStatementItemListResponse]
type hrisCompanyPayStatementItemListResponseJSON struct {
Attributes apijson.Field
Category apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *HRISCompanyPayStatementItemListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r hrisCompanyPayStatementItemListResponseJSON) RawJSON() string {
return r.raw
}
// The attributes of the pay statement item.
type HRISCompanyPayStatementItemListResponseAttributes struct {
// The metadata of the pay statement item derived by the rules engine if available.
// Each attribute will be a key-value pair defined by a rule.
Metadata map[string]interface{} `json:"metadata,required,nullable"`
// `true` if the amount is paid by the employers. This field is only available for
// taxes.
Employer bool `json:"employer,nullable"`
// `true` if the pay statement item is pre-tax. This field is only available for
// employee deductions.
PreTax bool `json:"pre_tax,nullable"`
// The type of the pay statement item.
Type string `json:"type,nullable"`
JSON hrisCompanyPayStatementItemListResponseAttributesJSON `json:"-"`
}
// hrisCompanyPayStatementItemListResponseAttributesJSON contains the JSON metadata
// for the struct [HRISCompanyPayStatementItemListResponseAttributes]
type hrisCompanyPayStatementItemListResponseAttributesJSON struct {
Metadata apijson.Field
Employer apijson.Field
PreTax apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *HRISCompanyPayStatementItemListResponseAttributes) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r hrisCompanyPayStatementItemListResponseAttributesJSON) RawJSON() string {
return r.raw
}
// The category of the pay statement item.
type HRISCompanyPayStatementItemListResponseCategory string
const (
HRISCompanyPayStatementItemListResponseCategoryEarnings HRISCompanyPayStatementItemListResponseCategory = "earnings"
HRISCompanyPayStatementItemListResponseCategoryTaxes HRISCompanyPayStatementItemListResponseCategory = "taxes"
HRISCompanyPayStatementItemListResponseCategoryEmployeeDeductions HRISCompanyPayStatementItemListResponseCategory = "employee_deductions"
HRISCompanyPayStatementItemListResponseCategoryEmployerContributions HRISCompanyPayStatementItemListResponseCategory = "employer_contributions"
)
func (r HRISCompanyPayStatementItemListResponseCategory) IsKnown() bool {
switch r {
case HRISCompanyPayStatementItemListResponseCategoryEarnings, HRISCompanyPayStatementItemListResponseCategoryTaxes, HRISCompanyPayStatementItemListResponseCategoryEmployeeDeductions, HRISCompanyPayStatementItemListResponseCategoryEmployerContributions:
return true
}
return false
}
type HRISCompanyPayStatementItemListParams struct {
// Comma-delimited list of pay statement item categories to filter on. If empty,
// defaults to all categories.
Categories param.Field[[]HRISCompanyPayStatementItemListParamsCategory] `query:"categories"`
// 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"`
// 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
// (inclusive) in `YYYY-MM-DD` format.
StartDate param.Field[time.Time] `query:"start_date" format:"date"`
// String search by pay statement item type.
Type param.Field[string] `query:"type"`
}
// URLQuery serializes [HRISCompanyPayStatementItemListParams]'s query parameters
// as `url.Values`.
func (r HRISCompanyPayStatementItemListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type HRISCompanyPayStatementItemListParamsCategory string
const (
HRISCompanyPayStatementItemListParamsCategoryEarnings HRISCompanyPayStatementItemListParamsCategory = "earnings"
HRISCompanyPayStatementItemListParamsCategoryTaxes HRISCompanyPayStatementItemListParamsCategory = "taxes"
HRISCompanyPayStatementItemListParamsCategoryEmployeeDeductions HRISCompanyPayStatementItemListParamsCategory = "employee_deductions"
HRISCompanyPayStatementItemListParamsCategoryEmployerContributions HRISCompanyPayStatementItemListParamsCategory = "employer_contributions"
)
func (r HRISCompanyPayStatementItemListParamsCategory) IsKnown() bool {
switch r {
case HRISCompanyPayStatementItemListParamsCategoryEarnings, HRISCompanyPayStatementItemListParamsCategoryTaxes, HRISCompanyPayStatementItemListParamsCategoryEmployeeDeductions, HRISCompanyPayStatementItemListParamsCategoryEmployerContributions:
return true
}
return false
}