-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinboundwiretransfer.go
More file actions
404 lines (360 loc) · 17.1 KB
/
inboundwiretransfer.go
File metadata and controls
404 lines (360 loc) · 17.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
// 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"
)
// InboundWireTransferService 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 [NewInboundWireTransferService] method instead.
type InboundWireTransferService struct {
Options []option.RequestOption
}
// NewInboundWireTransferService 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 NewInboundWireTransferService(opts ...option.RequestOption) (r *InboundWireTransferService) {
r = &InboundWireTransferService{}
r.Options = opts
return
}
// Retrieve an Inbound Wire Transfer
func (r *InboundWireTransferService) Get(ctx context.Context, inboundWireTransferID string, opts ...option.RequestOption) (res *InboundWireTransfer, err error) {
opts = slices.Concat(r.Options, opts)
if inboundWireTransferID == "" {
err = errors.New("missing required inbound_wire_transfer_id parameter")
return nil, err
}
path := fmt.Sprintf("inbound_wire_transfers/%s", inboundWireTransferID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// List Inbound Wire Transfers
func (r *InboundWireTransferService) List(ctx context.Context, query InboundWireTransferListParams, opts ...option.RequestOption) (res *pagination.Page[InboundWireTransfer], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "inbound_wire_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 Wire Transfers
func (r *InboundWireTransferService) ListAutoPaging(ctx context.Context, query InboundWireTransferListParams, opts ...option.RequestOption) *pagination.PageAutoPager[InboundWireTransfer] {
return pagination.NewPageAutoPager(r.List(ctx, query, opts...))
}
// Reverse an Inbound Wire Transfer
func (r *InboundWireTransferService) Reverse(ctx context.Context, inboundWireTransferID string, body InboundWireTransferReverseParams, opts ...option.RequestOption) (res *InboundWireTransfer, err error) {
opts = slices.Concat(r.Options, opts)
if inboundWireTransferID == "" {
err = errors.New("missing required inbound_wire_transfer_id parameter")
return nil, err
}
path := fmt.Sprintf("inbound_wire_transfers/%s/reverse", inboundWireTransferID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// An Inbound Wire Transfer is a wire transfer initiated outside of Increase to
// your account.
type InboundWireTransfer struct {
// The inbound wire transfer's identifier.
ID string `json:"id" api:"required"`
// If the transfer is accepted, this will contain details of the acceptance.
Acceptance InboundWireTransferAcceptance `json:"acceptance" api:"required,nullable"`
// The Account to which the transfer belongs.
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"`
// The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which
// the inbound wire transfer was created.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// A free-form address field set by the sender.
CreditorAddressLine1 string `json:"creditor_address_line1" api:"required,nullable"`
// A free-form address field set by the sender.
CreditorAddressLine2 string `json:"creditor_address_line2" api:"required,nullable"`
// A free-form address field set by the sender.
CreditorAddressLine3 string `json:"creditor_address_line3" api:"required,nullable"`
// A name set by the sender.
CreditorName string `json:"creditor_name" api:"required,nullable"`
// A free-form address field set by the sender.
DebtorAddressLine1 string `json:"debtor_address_line1" api:"required,nullable"`
// A free-form address field set by the sender.
DebtorAddressLine2 string `json:"debtor_address_line2" api:"required,nullable"`
// A free-form address field set by the sender.
DebtorAddressLine3 string `json:"debtor_address_line3" api:"required,nullable"`
// A name set by the sender.
DebtorName string `json:"debtor_name" api:"required,nullable"`
// An Increase-constructed description of the transfer.
Description string `json:"description" api:"required"`
// A free-form reference string set by the sender, to help identify the transfer.
EndToEndIdentification string `json:"end_to_end_identification" api:"required,nullable"`
// A unique identifier available to the originating and receiving banks, commonly
// abbreviated as IMAD. It is created when the wire is submitted to the Fedwire
// service and is helpful when debugging wires with the originating bank.
InputMessageAccountabilityData string `json:"input_message_accountability_data" api:"required,nullable"`
// The American Banking Association (ABA) routing number of the bank that sent the
// wire.
InstructingAgentRoutingNumber string `json:"instructing_agent_routing_number" api:"required,nullable"`
// The sending bank's identifier for the wire transfer.
InstructionIdentification string `json:"instruction_identification" api:"required,nullable"`
// If the transfer is reversed, this will contain details of the reversal.
Reversal InboundWireTransferReversal `json:"reversal" api:"required,nullable"`
// The status of the transfer.
Status InboundWireTransferStatus `json:"status" api:"required"`
// A constant representing the object's type. For this resource it will always be
// `inbound_wire_transfer`.
Type InboundWireTransferType `json:"type" api:"required"`
// The Unique End-to-end Transaction Reference
// ([UETR](https://www.swift.com/payments/what-unique-end-end-transaction-reference-uetr))
// of the transfer.
UniqueEndToEndTransactionReference string `json:"unique_end_to_end_transaction_reference" api:"required,nullable"`
// A free-form message set by the sender.
UnstructuredRemittanceInformation string `json:"unstructured_remittance_information" api:"required,nullable"`
// The wire drawdown request the inbound wire transfer is fulfilling.
WireDrawdownRequestID string `json:"wire_drawdown_request_id" api:"required,nullable"`
ExtraFields map[string]interface{} `json:"-" api:"extrafields"`
JSON inboundWireTransferJSON `json:"-"`
}
// inboundWireTransferJSON contains the JSON metadata for the struct
// [InboundWireTransfer]
type inboundWireTransferJSON struct {
ID apijson.Field
Acceptance apijson.Field
AccountID apijson.Field
AccountNumberID apijson.Field
Amount apijson.Field
CreatedAt apijson.Field
CreditorAddressLine1 apijson.Field
CreditorAddressLine2 apijson.Field
CreditorAddressLine3 apijson.Field
CreditorName apijson.Field
DebtorAddressLine1 apijson.Field
DebtorAddressLine2 apijson.Field
DebtorAddressLine3 apijson.Field
DebtorName apijson.Field
Description apijson.Field
EndToEndIdentification apijson.Field
InputMessageAccountabilityData apijson.Field
InstructingAgentRoutingNumber apijson.Field
InstructionIdentification apijson.Field
Reversal apijson.Field
Status apijson.Field
Type apijson.Field
UniqueEndToEndTransactionReference apijson.Field
UnstructuredRemittanceInformation apijson.Field
WireDrawdownRequestID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InboundWireTransfer) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inboundWireTransferJSON) RawJSON() string {
return r.raw
}
// If the transfer is accepted, this will contain details of the acceptance.
type InboundWireTransferAcceptance struct {
// The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which
// the transfer was accepted.
AcceptedAt time.Time `json:"accepted_at" api:"required" format:"date-time"`
// The identifier of the transaction for the accepted transfer.
TransactionID string `json:"transaction_id" api:"required"`
JSON inboundWireTransferAcceptanceJSON `json:"-"`
}
// inboundWireTransferAcceptanceJSON contains the JSON metadata for the struct
// [InboundWireTransferAcceptance]
type inboundWireTransferAcceptanceJSON struct {
AcceptedAt apijson.Field
TransactionID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InboundWireTransferAcceptance) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inboundWireTransferAcceptanceJSON) RawJSON() string {
return r.raw
}
// If the transfer is reversed, this will contain details of the reversal.
type InboundWireTransferReversal struct {
// The reason for the reversal.
Reason InboundWireTransferReversalReason `json:"reason" api:"required"`
// The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which
// the transfer was reversed.
ReversedAt time.Time `json:"reversed_at" api:"required" format:"date-time"`
JSON inboundWireTransferReversalJSON `json:"-"`
}
// inboundWireTransferReversalJSON contains the JSON metadata for the struct
// [InboundWireTransferReversal]
type inboundWireTransferReversalJSON struct {
Reason apijson.Field
ReversedAt apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InboundWireTransferReversal) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inboundWireTransferReversalJSON) RawJSON() string {
return r.raw
}
// The reason for the reversal.
type InboundWireTransferReversalReason string
const (
InboundWireTransferReversalReasonDuplicate InboundWireTransferReversalReason = "duplicate"
InboundWireTransferReversalReasonCreditorRequest InboundWireTransferReversalReason = "creditor_request"
InboundWireTransferReversalReasonTransactionForbidden InboundWireTransferReversalReason = "transaction_forbidden"
)
func (r InboundWireTransferReversalReason) IsKnown() bool {
switch r {
case InboundWireTransferReversalReasonDuplicate, InboundWireTransferReversalReasonCreditorRequest, InboundWireTransferReversalReasonTransactionForbidden:
return true
}
return false
}
// The status of the transfer.
type InboundWireTransferStatus string
const (
InboundWireTransferStatusPending InboundWireTransferStatus = "pending"
InboundWireTransferStatusAccepted InboundWireTransferStatus = "accepted"
InboundWireTransferStatusDeclined InboundWireTransferStatus = "declined"
InboundWireTransferStatusReversed InboundWireTransferStatus = "reversed"
)
func (r InboundWireTransferStatus) IsKnown() bool {
switch r {
case InboundWireTransferStatusPending, InboundWireTransferStatusAccepted, InboundWireTransferStatusDeclined, InboundWireTransferStatusReversed:
return true
}
return false
}
// A constant representing the object's type. For this resource it will always be
// `inbound_wire_transfer`.
type InboundWireTransferType string
const (
InboundWireTransferTypeInboundWireTransfer InboundWireTransferType = "inbound_wire_transfer"
)
func (r InboundWireTransferType) IsKnown() bool {
switch r {
case InboundWireTransferTypeInboundWireTransfer:
return true
}
return false
}
type InboundWireTransferListParams struct {
// Filter Inbound Wire Transfers to ones belonging to the specified Account.
AccountID param.Field[string] `query:"account_id"`
// Filter Inbound Wire Transfers to ones belonging to the specified Account Number.
AccountNumberID param.Field[string] `query:"account_number_id"`
CreatedAt param.Field[InboundWireTransferListParamsCreatedAt] `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"`
Status param.Field[InboundWireTransferListParamsStatus] `query:"status"`
// Filter Inbound Wire Transfers to ones belonging to the specified Wire Drawdown
// Request.
WireDrawdownRequestID param.Field[string] `query:"wire_drawdown_request_id"`
}
// URLQuery serializes [InboundWireTransferListParams]'s query parameters as
// `url.Values`.
func (r InboundWireTransferListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}
type InboundWireTransferListParamsCreatedAt 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 [InboundWireTransferListParamsCreatedAt]'s query parameters
// as `url.Values`.
func (r InboundWireTransferListParamsCreatedAt) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}
type InboundWireTransferListParamsStatus struct {
// Filter Inbound Wire Transfers to those with the specified status. For GET
// requests, this should be encoded as a comma-delimited string, such as
// `?in=one,two,three`.
In param.Field[[]InboundWireTransferListParamsStatusIn] `query:"in"`
}
// URLQuery serializes [InboundWireTransferListParamsStatus]'s query parameters as
// `url.Values`.
func (r InboundWireTransferListParamsStatus) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}
type InboundWireTransferListParamsStatusIn string
const (
InboundWireTransferListParamsStatusInPending InboundWireTransferListParamsStatusIn = "pending"
InboundWireTransferListParamsStatusInAccepted InboundWireTransferListParamsStatusIn = "accepted"
InboundWireTransferListParamsStatusInDeclined InboundWireTransferListParamsStatusIn = "declined"
InboundWireTransferListParamsStatusInReversed InboundWireTransferListParamsStatusIn = "reversed"
)
func (r InboundWireTransferListParamsStatusIn) IsKnown() bool {
switch r {
case InboundWireTransferListParamsStatusInPending, InboundWireTransferListParamsStatusInAccepted, InboundWireTransferListParamsStatusInDeclined, InboundWireTransferListParamsStatusInReversed:
return true
}
return false
}
type InboundWireTransferReverseParams struct {
// Reason for the reversal.
Reason param.Field[InboundWireTransferReverseParamsReason] `json:"reason" api:"required"`
}
func (r InboundWireTransferReverseParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Reason for the reversal.
type InboundWireTransferReverseParamsReason string
const (
InboundWireTransferReverseParamsReasonDuplicate InboundWireTransferReverseParamsReason = "duplicate"
InboundWireTransferReverseParamsReasonCreditorRequest InboundWireTransferReverseParamsReason = "creditor_request"
InboundWireTransferReverseParamsReasonTransactionForbidden InboundWireTransferReverseParamsReason = "transaction_forbidden"
)
func (r InboundWireTransferReverseParamsReason) IsKnown() bool {
switch r {
case InboundWireTransferReverseParamsReasonDuplicate, InboundWireTransferReverseParamsReasonCreditorRequest, InboundWireTransferReverseParamsReasonTransactionForbidden:
return true
}
return false
}