-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhrispayment.go
More file actions
170 lines (150 loc) · 6.17 KB
/
hrispayment.go
File metadata and controls
170 lines (150 loc) · 6.17 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
// 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"
)
// HRISPaymentService 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 [NewHRISPaymentService] method instead.
type HRISPaymentService struct {
Options []option.RequestOption
}
// NewHRISPaymentService 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 NewHRISPaymentService(opts ...option.RequestOption) (r *HRISPaymentService) {
r = &HRISPaymentService{}
r.Options = opts
return
}
// Read payroll and contractor related payments by the company.
func (r *HRISPaymentService) List(ctx context.Context, query HRISPaymentListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Payment], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "employer/payment"
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 payroll and contractor related payments by the company.
func (r *HRISPaymentService) ListAutoPaging(ctx context.Context, query HRISPaymentListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Payment] {
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
}
type Payment struct {
// The unique id for the payment.
ID string `json:"id,required" format:"uuid"`
CompanyDebit Money `json:"company_debit,required,nullable"`
DebitDate string `json:"debit_date,required,nullable"`
EmployeeTaxes Money `json:"employee_taxes,required,nullable"`
EmployerTaxes Money `json:"employer_taxes,required,nullable"`
GrossPay Money `json:"gross_pay,required,nullable"`
// Array of every individual on this payment.
IndividualIDs []string `json:"individual_ids,required,nullable" format:"uuid"`
NetPay Money `json:"net_pay,required,nullable"`
PayDate string `json:"pay_date,required,nullable"`
// List of pay frequencies associated with this payment.
PayFrequencies []PaymentPayFrequency `json:"pay_frequencies,required,nullable"`
// Array of the Finch id (uuidv4) of every pay group associated with this payment.
PayGroupIDs []string `json:"pay_group_ids,required,nullable" format:"uuid"`
// The pay period object.
PayPeriod PaymentPayPeriod `json:"pay_period,required,nullable"`
JSON paymentJSON `json:"-"`
}
// paymentJSON contains the JSON metadata for the struct [Payment]
type paymentJSON struct {
ID apijson.Field
CompanyDebit apijson.Field
DebitDate apijson.Field
EmployeeTaxes apijson.Field
EmployerTaxes apijson.Field
GrossPay apijson.Field
IndividualIDs apijson.Field
NetPay apijson.Field
PayDate apijson.Field
PayFrequencies apijson.Field
PayGroupIDs apijson.Field
PayPeriod apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Payment) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r paymentJSON) RawJSON() string {
return r.raw
}
type PaymentPayFrequency string
const (
PaymentPayFrequencyAnnually PaymentPayFrequency = "annually"
PaymentPayFrequencyBiWeekly PaymentPayFrequency = "bi_weekly"
PaymentPayFrequencyDaily PaymentPayFrequency = "daily"
PaymentPayFrequencyMonthly PaymentPayFrequency = "monthly"
PaymentPayFrequencyOther PaymentPayFrequency = "other"
PaymentPayFrequencyQuarterly PaymentPayFrequency = "quarterly"
PaymentPayFrequencySemiAnnually PaymentPayFrequency = "semi_annually"
PaymentPayFrequencySemiMonthly PaymentPayFrequency = "semi_monthly"
PaymentPayFrequencyWeekly PaymentPayFrequency = "weekly"
)
func (r PaymentPayFrequency) IsKnown() bool {
switch r {
case PaymentPayFrequencyAnnually, PaymentPayFrequencyBiWeekly, PaymentPayFrequencyDaily, PaymentPayFrequencyMonthly, PaymentPayFrequencyOther, PaymentPayFrequencyQuarterly, PaymentPayFrequencySemiAnnually, PaymentPayFrequencySemiMonthly, PaymentPayFrequencyWeekly:
return true
}
return false
}
// The pay period object.
type PaymentPayPeriod struct {
EndDate string `json:"end_date,required,nullable"`
StartDate string `json:"start_date,required,nullable"`
JSON paymentPayPeriodJSON `json:"-"`
}
// paymentPayPeriodJSON contains the JSON metadata for the struct
// [PaymentPayPeriod]
type paymentPayPeriodJSON struct {
EndDate apijson.Field
StartDate apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PaymentPayPeriod) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r paymentPayPeriodJSON) RawJSON() string {
return r.raw
}
type HRISPaymentListParams struct {
// The end date to retrieve payments by a company (inclusive) in `YYYY-MM-DD`
// format.
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.
StartDate param.Field[time.Time] `query:"start_date,required" format:"date"`
}
// URLQuery serializes [HRISPaymentListParams]'s query parameters as `url.Values`.
func (r HRISPaymentListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}