-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandboxpayment.go
244 lines (210 loc) · 11.1 KB
/
sandboxpayment.go
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"net/http"
"github.com/Finch-API/finch-api-go/internal/apijson"
"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"
)
// SandboxPaymentService 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 [NewSandboxPaymentService] method instead.
type SandboxPaymentService struct {
Options []option.RequestOption
}
// NewSandboxPaymentService 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 NewSandboxPaymentService(opts ...option.RequestOption) (r *SandboxPaymentService) {
r = &SandboxPaymentService{}
r.Options = opts
return
}
// Add a new sandbox payment
func (r *SandboxPaymentService) New(ctx context.Context, body SandboxPaymentNewParams, opts ...option.RequestOption) (res *SandboxPaymentNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "sandbox/payment"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type SandboxPaymentNewResponse struct {
// The date of the payment.
PayDate string `json:"pay_date,required"`
// The ID of the payment.
PaymentID string `json:"payment_id,required"`
JSON sandboxPaymentNewResponseJSON `json:"-"`
}
// sandboxPaymentNewResponseJSON contains the JSON metadata for the struct
// [SandboxPaymentNewResponse]
type sandboxPaymentNewResponseJSON struct {
PayDate apijson.Field
PaymentID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *SandboxPaymentNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r sandboxPaymentNewResponseJSON) RawJSON() string {
return r.raw
}
type SandboxPaymentNewParams struct {
EndDate param.Field[string] `json:"end_date"`
PayStatements param.Field[[]SandboxPaymentNewParamsPayStatement] `json:"pay_statements"`
StartDate param.Field[string] `json:"start_date"`
}
func (r SandboxPaymentNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type SandboxPaymentNewParamsPayStatement struct {
// The array of earnings objects associated with this pay statement
Earnings param.Field[[]SandboxPaymentNewParamsPayStatementsEarning] `json:"earnings"`
// The array of deductions objects associated with this pay statement.
EmployeeDeductions param.Field[[]SandboxPaymentNewParamsPayStatementsEmployeeDeduction] `json:"employee_deductions"`
EmployerContributions param.Field[[]SandboxPaymentNewParamsPayStatementsEmployerContribution] `json:"employer_contributions"`
GrossPay param.Field[MoneyParam] `json:"gross_pay"`
// A stable Finch `id` (UUID v4) for an individual in the company
IndividualID param.Field[string] `json:"individual_id"`
NetPay param.Field[MoneyParam] `json:"net_pay"`
// The payment method.
PaymentMethod param.Field[SandboxPaymentNewParamsPayStatementsPaymentMethod] `json:"payment_method"`
// The array of taxes objects associated with this pay statement.
Taxes param.Field[[]SandboxPaymentNewParamsPayStatementsTax] `json:"taxes"`
// The number of hours worked for this pay period
TotalHours param.Field[float64] `json:"total_hours"`
// The type of the payment associated with the pay statement.
Type param.Field[SandboxPaymentNewParamsPayStatementsType] `json:"type"`
}
func (r SandboxPaymentNewParamsPayStatement) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type SandboxPaymentNewParamsPayStatementsEarning struct {
// The earnings amount in cents.
Amount param.Field[int64] `json:"amount"`
// The earnings currency code.
Currency param.Field[string] `json:"currency"`
// The number of hours associated with this earning. (For salaried employees, this
// could be hours per pay period, `0` or `null`, depending on the provider).
Hours param.Field[float64] `json:"hours"`
// The exact name of the deduction from the pay statement.
Name param.Field[string] `json:"name"`
// The type of earning.
Type param.Field[SandboxPaymentNewParamsPayStatementsEarningsType] `json:"type"`
}
func (r SandboxPaymentNewParamsPayStatementsEarning) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The type of earning.
type SandboxPaymentNewParamsPayStatementsEarningsType string
const (
SandboxPaymentNewParamsPayStatementsEarningsTypeSalary SandboxPaymentNewParamsPayStatementsEarningsType = "salary"
SandboxPaymentNewParamsPayStatementsEarningsTypeWage SandboxPaymentNewParamsPayStatementsEarningsType = "wage"
SandboxPaymentNewParamsPayStatementsEarningsTypeReimbursement SandboxPaymentNewParamsPayStatementsEarningsType = "reimbursement"
SandboxPaymentNewParamsPayStatementsEarningsTypeOvertime SandboxPaymentNewParamsPayStatementsEarningsType = "overtime"
SandboxPaymentNewParamsPayStatementsEarningsTypeSeverance SandboxPaymentNewParamsPayStatementsEarningsType = "severance"
SandboxPaymentNewParamsPayStatementsEarningsTypeDoubleOvertime SandboxPaymentNewParamsPayStatementsEarningsType = "double_overtime"
SandboxPaymentNewParamsPayStatementsEarningsTypePto SandboxPaymentNewParamsPayStatementsEarningsType = "pto"
SandboxPaymentNewParamsPayStatementsEarningsTypeSick SandboxPaymentNewParamsPayStatementsEarningsType = "sick"
SandboxPaymentNewParamsPayStatementsEarningsTypeBonus SandboxPaymentNewParamsPayStatementsEarningsType = "bonus"
SandboxPaymentNewParamsPayStatementsEarningsTypeCommission SandboxPaymentNewParamsPayStatementsEarningsType = "commission"
SandboxPaymentNewParamsPayStatementsEarningsTypeTips SandboxPaymentNewParamsPayStatementsEarningsType = "tips"
SandboxPaymentNewParamsPayStatementsEarningsType1099 SandboxPaymentNewParamsPayStatementsEarningsType = "1099"
SandboxPaymentNewParamsPayStatementsEarningsTypeOther SandboxPaymentNewParamsPayStatementsEarningsType = "other"
)
func (r SandboxPaymentNewParamsPayStatementsEarningsType) IsKnown() bool {
switch r {
case SandboxPaymentNewParamsPayStatementsEarningsTypeSalary, SandboxPaymentNewParamsPayStatementsEarningsTypeWage, SandboxPaymentNewParamsPayStatementsEarningsTypeReimbursement, SandboxPaymentNewParamsPayStatementsEarningsTypeOvertime, SandboxPaymentNewParamsPayStatementsEarningsTypeSeverance, SandboxPaymentNewParamsPayStatementsEarningsTypeDoubleOvertime, SandboxPaymentNewParamsPayStatementsEarningsTypePto, SandboxPaymentNewParamsPayStatementsEarningsTypeSick, SandboxPaymentNewParamsPayStatementsEarningsTypeBonus, SandboxPaymentNewParamsPayStatementsEarningsTypeCommission, SandboxPaymentNewParamsPayStatementsEarningsTypeTips, SandboxPaymentNewParamsPayStatementsEarningsType1099, SandboxPaymentNewParamsPayStatementsEarningsTypeOther:
return true
}
return false
}
type SandboxPaymentNewParamsPayStatementsEmployeeDeduction struct {
// The deduction amount in cents.
Amount param.Field[int64] `json:"amount"`
// The deduction currency.
Currency param.Field[string] `json:"currency"`
// The deduction name from the pay statement.
Name param.Field[string] `json:"name"`
// Boolean indicating if the deduction is pre-tax.
PreTax param.Field[bool] `json:"pre_tax"`
// Type of benefit.
Type param.Field[BenefitType] `json:"type"`
}
func (r SandboxPaymentNewParamsPayStatementsEmployeeDeduction) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type SandboxPaymentNewParamsPayStatementsEmployerContribution struct {
// The contribution amount in cents.
Amount param.Field[int64] `json:"amount"`
// The contribution currency.
Currency param.Field[string] `json:"currency"`
// The contribution name from the pay statement.
Name param.Field[string] `json:"name"`
// Type of benefit.
Type param.Field[BenefitType] `json:"type"`
}
func (r SandboxPaymentNewParamsPayStatementsEmployerContribution) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The payment method.
type SandboxPaymentNewParamsPayStatementsPaymentMethod string
const (
SandboxPaymentNewParamsPayStatementsPaymentMethodCheck SandboxPaymentNewParamsPayStatementsPaymentMethod = "check"
SandboxPaymentNewParamsPayStatementsPaymentMethodDirectDeposit SandboxPaymentNewParamsPayStatementsPaymentMethod = "direct_deposit"
)
func (r SandboxPaymentNewParamsPayStatementsPaymentMethod) IsKnown() bool {
switch r {
case SandboxPaymentNewParamsPayStatementsPaymentMethodCheck, SandboxPaymentNewParamsPayStatementsPaymentMethodDirectDeposit:
return true
}
return false
}
type SandboxPaymentNewParamsPayStatementsTax struct {
// The tax amount in cents.
Amount param.Field[int64] `json:"amount"`
// The currency code.
Currency param.Field[string] `json:"currency"`
// `true` if the amount is paid by the employers.
Employer param.Field[bool] `json:"employer"`
// The exact name of tax from the pay statement.
Name param.Field[string] `json:"name"`
// The type of taxes.
Type param.Field[SandboxPaymentNewParamsPayStatementsTaxesType] `json:"type"`
}
func (r SandboxPaymentNewParamsPayStatementsTax) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The type of taxes.
type SandboxPaymentNewParamsPayStatementsTaxesType string
const (
SandboxPaymentNewParamsPayStatementsTaxesTypeState SandboxPaymentNewParamsPayStatementsTaxesType = "state"
SandboxPaymentNewParamsPayStatementsTaxesTypeFederal SandboxPaymentNewParamsPayStatementsTaxesType = "federal"
SandboxPaymentNewParamsPayStatementsTaxesTypeLocal SandboxPaymentNewParamsPayStatementsTaxesType = "local"
SandboxPaymentNewParamsPayStatementsTaxesTypeFica SandboxPaymentNewParamsPayStatementsTaxesType = "fica"
)
func (r SandboxPaymentNewParamsPayStatementsTaxesType) IsKnown() bool {
switch r {
case SandboxPaymentNewParamsPayStatementsTaxesTypeState, SandboxPaymentNewParamsPayStatementsTaxesTypeFederal, SandboxPaymentNewParamsPayStatementsTaxesTypeLocal, SandboxPaymentNewParamsPayStatementsTaxesTypeFica:
return true
}
return false
}
// The type of the payment associated with the pay statement.
type SandboxPaymentNewParamsPayStatementsType string
const (
SandboxPaymentNewParamsPayStatementsTypeRegularPayroll SandboxPaymentNewParamsPayStatementsType = "regular_payroll"
SandboxPaymentNewParamsPayStatementsTypeOffCyclePayroll SandboxPaymentNewParamsPayStatementsType = "off_cycle_payroll"
SandboxPaymentNewParamsPayStatementsTypeOneTimePayment SandboxPaymentNewParamsPayStatementsType = "one_time_payment"
)
func (r SandboxPaymentNewParamsPayStatementsType) IsKnown() bool {
switch r {
case SandboxPaymentNewParamsPayStatementsTypeRegularPayroll, SandboxPaymentNewParamsPayStatementsTypeOffCyclePayroll, SandboxPaymentNewParamsPayStatementsTypeOneTimePayment:
return true
}
return false
}