-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutingnumber.go
154 lines (134 loc) · 6.03 KB
/
routingnumber.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
// File generated from our OpenAPI spec by Stainless.
package acme
import (
"context"
"net/http"
"net/url"
"github.com/acme/acme-go/internal/apijson"
"github.com/acme/acme-go/internal/apiquery"
"github.com/acme/acme-go/internal/param"
"github.com/acme/acme-go/internal/requestconfig"
"github.com/acme/acme-go/internal/shared"
"github.com/acme/acme-go/option"
)
// RoutingNumberService contains methods and other services that help with
// interacting with the acme 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 [NewRoutingNumberService] method
// instead.
type RoutingNumberService struct {
Options []option.RequestOption
}
// NewRoutingNumberService 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 NewRoutingNumberService(opts ...option.RequestOption) (r *RoutingNumberService) {
r = &RoutingNumberService{}
r.Options = opts
return
}
// You can use this API to confirm if a routing number is valid, such as when a
// user is providing you with bank account details. Since routing numbers uniquely
// identify a bank, this will always return 0 or 1 entry. In Sandbox, the only
// valid routing number for this method is 110000000.
func (r *RoutingNumberService) List(ctx context.Context, query RoutingNumberListParams, opts ...option.RequestOption) (res *shared.Page[RoutingNumber], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "routing_numbers"
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
}
// You can use this API to confirm if a routing number is valid, such as when a
// user is providing you with bank account details. Since routing numbers uniquely
// identify a bank, this will always return 0 or 1 entry. In Sandbox, the only
// valid routing number for this method is 110000000.
func (r *RoutingNumberService) ListAutoPaging(ctx context.Context, query RoutingNumberListParams, opts ...option.RequestOption) *shared.PageAutoPager[RoutingNumber] {
return shared.NewPageAutoPager(r.List(ctx, query, opts...))
}
// Routing numbers are used to identify your bank in a financial transaction.
type RoutingNumber struct {
// This routing number's support for ACH Transfers.
ACHTransfers RoutingNumberACHTransfers `json:"ach_transfers,required"`
// The name of the financial institution belonging to a routing number.
Name string `json:"name,required"`
// This routing number's support for Real-Time Payments Transfers.
RealTimePaymentsTransfers RoutingNumberRealTimePaymentsTransfers `json:"real_time_payments_transfers,required"`
// The nine digit routing number identifier.
RoutingNumber string `json:"routing_number,required"`
// A constant representing the object's type. For this resource it will always be
// `routing_number`.
Type RoutingNumberType `json:"type,required"`
// This routing number's support for Wire Transfers.
WireTransfers RoutingNumberWireTransfers `json:"wire_transfers,required"`
JSON routingNumberJSON `json:"-"`
}
// routingNumberJSON contains the JSON metadata for the struct [RoutingNumber]
type routingNumberJSON struct {
ACHTransfers apijson.Field
Name apijson.Field
RealTimePaymentsTransfers apijson.Field
RoutingNumber apijson.Field
Type apijson.Field
WireTransfers apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RoutingNumber) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
// This routing number's support for ACH Transfers.
type RoutingNumberACHTransfers string
const (
// The routing number can receive this transfer type.
RoutingNumberACHTransfersSupported RoutingNumberACHTransfers = "supported"
// The routing number cannot receive this transfer type.
RoutingNumberACHTransfersNotSupported RoutingNumberACHTransfers = "not_supported"
)
// This routing number's support for Real-Time Payments Transfers.
type RoutingNumberRealTimePaymentsTransfers string
const (
// The routing number can receive this transfer type.
RoutingNumberRealTimePaymentsTransfersSupported RoutingNumberRealTimePaymentsTransfers = "supported"
// The routing number cannot receive this transfer type.
RoutingNumberRealTimePaymentsTransfersNotSupported RoutingNumberRealTimePaymentsTransfers = "not_supported"
)
// A constant representing the object's type. For this resource it will always be
// `routing_number`.
type RoutingNumberType string
const (
RoutingNumberTypeRoutingNumber RoutingNumberType = "routing_number"
)
// This routing number's support for Wire Transfers.
type RoutingNumberWireTransfers string
const (
// The routing number can receive this transfer type.
RoutingNumberWireTransfersSupported RoutingNumberWireTransfers = "supported"
// The routing number cannot receive this transfer type.
RoutingNumberWireTransfersNotSupported RoutingNumberWireTransfers = "not_supported"
)
type RoutingNumberListParams struct {
// Filter financial institutions by routing number.
RoutingNumber param.Field[string] `query:"routing_number,required"`
// 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 [RoutingNumberListParams]'s query parameters as
// `url.Values`.
func (r RoutingNumberListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}