-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinboundfednowtransfer.go
More file actions
316 lines (280 loc) · 13.1 KB
/
inboundfednowtransfer.go
File metadata and controls
316 lines (280 loc) · 13.1 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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package increase
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"time"
"github.com/Increase/increase-go/internal/apijson"
"github.com/Increase/increase-go/internal/apiquery"
"github.com/Increase/increase-go/internal/param"
"github.com/Increase/increase-go/internal/requestconfig"
"github.com/Increase/increase-go/option"
"github.com/Increase/increase-go/packages/pagination"
)
// InboundFednowTransferService contains methods and other services that help with
// interacting with the increase 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 [NewInboundFednowTransferService] method instead.
type InboundFednowTransferService struct {
Options []option.RequestOption
}
// NewInboundFednowTransferService 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 NewInboundFednowTransferService(opts ...option.RequestOption) (r *InboundFednowTransferService) {
r = &InboundFednowTransferService{}
r.Options = opts
return
}
// Retrieve an Inbound FedNow Transfer
func (r *InboundFednowTransferService) Get(ctx context.Context, inboundFednowTransferID string, opts ...option.RequestOption) (res *InboundFednowTransfer, err error) {
opts = slices.Concat(r.Options, opts)
if inboundFednowTransferID == "" {
err = errors.New("missing required inbound_fednow_transfer_id parameter")
return nil, err
}
path := fmt.Sprintf("inbound_fednow_transfers/%s", inboundFednowTransferID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// List Inbound FedNow Transfers
func (r *InboundFednowTransferService) List(ctx context.Context, query InboundFednowTransferListParams, opts ...option.RequestOption) (res *pagination.Page[InboundFednowTransfer], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "inbound_fednow_transfers"
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
}
// List Inbound FedNow Transfers
func (r *InboundFednowTransferService) ListAutoPaging(ctx context.Context, query InboundFednowTransferListParams, opts ...option.RequestOption) *pagination.PageAutoPager[InboundFednowTransfer] {
return pagination.NewPageAutoPager(r.List(ctx, query, opts...))
}
// An Inbound FedNow Transfer is a FedNow transfer initiated outside of Increase to
// your account.
type InboundFednowTransfer struct {
// The inbound FedNow transfer's identifier.
ID string `json:"id" api:"required"`
// The Account to which the transfer was sent.
AccountID string `json:"account_id" api:"required"`
// The identifier of the Account Number to which this transfer was sent.
AccountNumberID string `json:"account_number_id" api:"required"`
// The amount in USD cents.
Amount int64 `json:"amount" api:"required"`
// If your transfer is confirmed, this will contain details of the confirmation.
Confirmation InboundFednowTransferConfirmation `json:"confirmation" api:"required,nullable"`
// The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which
// the transfer was created.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// The name the sender of the transfer specified as the recipient of the transfer.
CreditorName string `json:"creditor_name" api:"required"`
// The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code of the transfer's
// currency. This will always be "USD" for a FedNow transfer.
Currency InboundFednowTransferCurrency `json:"currency" api:"required"`
// The account number of the account that sent the transfer.
DebtorAccountNumber string `json:"debtor_account_number" api:"required"`
// The name provided by the sender of the transfer.
DebtorName string `json:"debtor_name" api:"required"`
// The routing number of the account that sent the transfer.
DebtorRoutingNumber string `json:"debtor_routing_number" api:"required"`
// If your transfer is declined, this will contain details of the decline.
Decline InboundFednowTransferDecline `json:"decline" api:"required,nullable"`
// The lifecycle status of the transfer.
Status InboundFednowTransferStatus `json:"status" api:"required"`
// The identifier of the Transaction object created when the transfer was
// confirmed.
TransactionID string `json:"transaction_id" api:"required,nullable"`
// A constant representing the object's type. For this resource it will always be
// `inbound_fednow_transfer`.
Type InboundFednowTransferType `json:"type" api:"required"`
// Additional information included with the transfer.
UnstructuredRemittanceInformation string `json:"unstructured_remittance_information" api:"required,nullable"`
JSON inboundFednowTransferJSON `json:"-"`
}
// inboundFednowTransferJSON contains the JSON metadata for the struct
// [InboundFednowTransfer]
type inboundFednowTransferJSON struct {
ID apijson.Field
AccountID apijson.Field
AccountNumberID apijson.Field
Amount apijson.Field
Confirmation apijson.Field
CreatedAt apijson.Field
CreditorName apijson.Field
Currency apijson.Field
DebtorAccountNumber apijson.Field
DebtorName apijson.Field
DebtorRoutingNumber apijson.Field
Decline apijson.Field
Status apijson.Field
TransactionID apijson.Field
Type apijson.Field
UnstructuredRemittanceInformation apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InboundFednowTransfer) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inboundFednowTransferJSON) RawJSON() string {
return r.raw
}
// If your transfer is confirmed, this will contain details of the confirmation.
type InboundFednowTransferConfirmation struct {
// The identifier of the FedNow Transfer that led to this Transaction.
TransferID string `json:"transfer_id" api:"required"`
ExtraFields map[string]interface{} `json:"-" api:"extrafields"`
JSON inboundFednowTransferConfirmationJSON `json:"-"`
}
// inboundFednowTransferConfirmationJSON contains the JSON metadata for the struct
// [InboundFednowTransferConfirmation]
type inboundFednowTransferConfirmationJSON struct {
TransferID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InboundFednowTransferConfirmation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inboundFednowTransferConfirmationJSON) RawJSON() string {
return r.raw
}
// The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code of the transfer's
// currency. This will always be "USD" for a FedNow transfer.
type InboundFednowTransferCurrency string
const (
InboundFednowTransferCurrencyUsd InboundFednowTransferCurrency = "USD"
)
func (r InboundFednowTransferCurrency) IsKnown() bool {
switch r {
case InboundFednowTransferCurrencyUsd:
return true
}
return false
}
// If your transfer is declined, this will contain details of the decline.
type InboundFednowTransferDecline struct {
// Why the transfer was declined.
Reason InboundFednowTransferDeclineReason `json:"reason" api:"required"`
// The identifier of the FedNow Transfer that led to this declined transaction.
TransferID string `json:"transfer_id" api:"required"`
ExtraFields map[string]interface{} `json:"-" api:"extrafields"`
JSON inboundFednowTransferDeclineJSON `json:"-"`
}
// inboundFednowTransferDeclineJSON contains the JSON metadata for the struct
// [InboundFednowTransferDecline]
type inboundFednowTransferDeclineJSON struct {
Reason apijson.Field
TransferID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InboundFednowTransferDecline) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inboundFednowTransferDeclineJSON) RawJSON() string {
return r.raw
}
// Why the transfer was declined.
type InboundFednowTransferDeclineReason string
const (
InboundFednowTransferDeclineReasonAccountNumberCanceled InboundFednowTransferDeclineReason = "account_number_canceled"
InboundFednowTransferDeclineReasonAccountNumberDisabled InboundFednowTransferDeclineReason = "account_number_disabled"
InboundFednowTransferDeclineReasonAccountRestricted InboundFednowTransferDeclineReason = "account_restricted"
InboundFednowTransferDeclineReasonGroupLocked InboundFednowTransferDeclineReason = "group_locked"
InboundFednowTransferDeclineReasonEntityNotActive InboundFednowTransferDeclineReason = "entity_not_active"
InboundFednowTransferDeclineReasonFednowNotEnabled InboundFednowTransferDeclineReason = "fednow_not_enabled"
)
func (r InboundFednowTransferDeclineReason) IsKnown() bool {
switch r {
case InboundFednowTransferDeclineReasonAccountNumberCanceled, InboundFednowTransferDeclineReasonAccountNumberDisabled, InboundFednowTransferDeclineReasonAccountRestricted, InboundFednowTransferDeclineReasonGroupLocked, InboundFednowTransferDeclineReasonEntityNotActive, InboundFednowTransferDeclineReasonFednowNotEnabled:
return true
}
return false
}
// The lifecycle status of the transfer.
type InboundFednowTransferStatus string
const (
InboundFednowTransferStatusPendingConfirming InboundFednowTransferStatus = "pending_confirming"
InboundFednowTransferStatusTimedOut InboundFednowTransferStatus = "timed_out"
InboundFednowTransferStatusConfirmed InboundFednowTransferStatus = "confirmed"
InboundFednowTransferStatusDeclined InboundFednowTransferStatus = "declined"
InboundFednowTransferStatusRequiresAttention InboundFednowTransferStatus = "requires_attention"
)
func (r InboundFednowTransferStatus) IsKnown() bool {
switch r {
case InboundFednowTransferStatusPendingConfirming, InboundFednowTransferStatusTimedOut, InboundFednowTransferStatusConfirmed, InboundFednowTransferStatusDeclined, InboundFednowTransferStatusRequiresAttention:
return true
}
return false
}
// A constant representing the object's type. For this resource it will always be
// `inbound_fednow_transfer`.
type InboundFednowTransferType string
const (
InboundFednowTransferTypeInboundFednowTransfer InboundFednowTransferType = "inbound_fednow_transfer"
)
func (r InboundFednowTransferType) IsKnown() bool {
switch r {
case InboundFednowTransferTypeInboundFednowTransfer:
return true
}
return false
}
type InboundFednowTransferListParams struct {
// Filter Inbound FedNow Transfers to those belonging to the specified Account.
AccountID param.Field[string] `query:"account_id"`
// Filter Inbound FedNow Transfers to ones belonging to the specified Account
// Number.
AccountNumberID param.Field[string] `query:"account_number_id"`
CreatedAt param.Field[InboundFednowTransferListParamsCreatedAt] `query:"created_at"`
// Return the page of entries after this one.
Cursor param.Field[string] `query:"cursor"`
// Limit the size of the list that is returned. The default (and maximum) is 100
// objects.
Limit param.Field[int64] `query:"limit"`
}
// URLQuery serializes [InboundFednowTransferListParams]'s query parameters as
// `url.Values`.
func (r InboundFednowTransferListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}
type InboundFednowTransferListParamsCreatedAt struct {
// Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
// timestamp.
After param.Field[time.Time] `query:"after" format:"date-time"`
// Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
// timestamp.
Before param.Field[time.Time] `query:"before" format:"date-time"`
// Return results on or after this
// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp.
OnOrAfter param.Field[time.Time] `query:"on_or_after" format:"date-time"`
// Return results on or before this
// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp.
OnOrBefore param.Field[time.Time] `query:"on_or_before" format:"date-time"`
}
// URLQuery serializes [InboundFednowTransferListParamsCreatedAt]'s query
// parameters as `url.Values`.
func (r InboundFednowTransferListParamsCreatedAt) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}