-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbank_accounts.go
487 lines (430 loc) · 14 KB
/
bank_accounts.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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
// This file was auto-generated by Fern from our API Definition.
package square
import (
json "encoding/json"
fmt "fmt"
internal "github.com/square/square-go-sdk/internal"
)
type BankAccountsGetByV1IDRequest struct {
// Connect V1 ID of the desired `BankAccount`. For more information, see
// [Retrieve a bank account by using an ID issued by V1 Bank Accounts API](https://developer.squareup.com/docs/bank-accounts-api#retrieve-a-bank-account-by-using-an-id-issued-by-v1-bank-accounts-api).
V1BankAccountID string `json:"-" url:"-"`
}
type BankAccountsGetRequest struct {
// Square-issued ID of the desired `BankAccount`.
BankAccountID string `json:"-" url:"-"`
}
type BankAccountsListRequest struct {
// The pagination cursor returned by a previous call to this endpoint.
// Use it in the next `ListBankAccounts` request to retrieve the next set
// of results.
//
// See the [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) guide for more information.
Cursor *string `json:"-" url:"cursor,omitempty"`
// Upper limit on the number of bank accounts to return in the response.
// Currently, 1000 is the largest supported limit. You can specify a limit
// of up to 1000 bank accounts. This is also the default limit.
Limit *int `json:"-" url:"limit,omitempty"`
// Location ID. You can specify this optional filter
// to retrieve only the linked bank accounts belonging to a specific location.
LocationID *string `json:"-" url:"location_id,omitempty"`
}
// Represents a bank account. For more information about
// linking a bank account to a Square account, see
// [Bank Accounts API](https://developer.squareup.com/docs/bank-accounts-api).
type BankAccount struct {
// The unique, Square-issued identifier for the bank account.
ID string `json:"id" url:"id"`
// The last few digits of the account number.
AccountNumberSuffix string `json:"account_number_suffix" url:"account_number_suffix"`
// The ISO 3166 Alpha-2 country code where the bank account is based.
// See [Country](#type-country) for possible values
Country Country `json:"country" url:"country"`
// The 3-character ISO 4217 currency code indicating the operating
// currency of the bank account. For example, the currency code for US dollars
// is `USD`.
// See [Currency](#type-currency) for possible values
Currency Currency `json:"currency" url:"currency"`
// The financial purpose of the associated bank account.
// See [BankAccountType](#type-bankaccounttype) for possible values
AccountType BankAccountType `json:"account_type" url:"account_type"`
// Name of the account holder. This name must match the name
// on the targeted bank account record.
HolderName string `json:"holder_name" url:"holder_name"`
// Primary identifier for the bank. For more information, see
// [Bank Accounts API](https://developer.squareup.com/docs/bank-accounts-api).
PrimaryBankIdentificationNumber string `json:"primary_bank_identification_number" url:"primary_bank_identification_number"`
// Secondary identifier for the bank. For more information, see
// [Bank Accounts API](https://developer.squareup.com/docs/bank-accounts-api).
SecondaryBankIdentificationNumber *string `json:"secondary_bank_identification_number,omitempty" url:"secondary_bank_identification_number,omitempty"`
// Reference identifier that will be displayed to UK bank account owners
// when collecting direct debit authorization. Only required for UK bank accounts.
DebitMandateReferenceID *string `json:"debit_mandate_reference_id,omitempty" url:"debit_mandate_reference_id,omitempty"`
// Client-provided identifier for linking the banking account to an entity
// in a third-party system (for example, a bank account number or a user identifier).
ReferenceID *string `json:"reference_id,omitempty" url:"reference_id,omitempty"`
// The location to which the bank account belongs.
LocationID *string `json:"location_id,omitempty" url:"location_id,omitempty"`
// Read-only. The current verification status of this BankAccount object.
// See [BankAccountStatus](#type-bankaccountstatus) for possible values
Status BankAccountStatus `json:"status" url:"status"`
// Indicates whether it is possible for Square to send money to this bank account.
Creditable bool `json:"creditable" url:"creditable"`
// Indicates whether it is possible for Square to take money from this
// bank account.
Debitable bool `json:"debitable" url:"debitable"`
// A Square-assigned, unique identifier for the bank account based on the
// account information. The account fingerprint can be used to compare account
// entries and determine if the they represent the same real-world bank account.
Fingerprint *string `json:"fingerprint,omitempty" url:"fingerprint,omitempty"`
// The current version of the `BankAccount`.
Version *int `json:"version,omitempty" url:"version,omitempty"`
// Read only. Name of actual financial institution.
// For example "Bank of America".
BankName *string `json:"bank_name,omitempty" url:"bank_name,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BankAccount) GetID() string {
if b == nil {
return ""
}
return b.ID
}
func (b *BankAccount) GetAccountNumberSuffix() string {
if b == nil {
return ""
}
return b.AccountNumberSuffix
}
func (b *BankAccount) GetCountry() Country {
if b == nil {
return ""
}
return b.Country
}
func (b *BankAccount) GetCurrency() Currency {
if b == nil {
return ""
}
return b.Currency
}
func (b *BankAccount) GetAccountType() BankAccountType {
if b == nil {
return ""
}
return b.AccountType
}
func (b *BankAccount) GetHolderName() string {
if b == nil {
return ""
}
return b.HolderName
}
func (b *BankAccount) GetPrimaryBankIdentificationNumber() string {
if b == nil {
return ""
}
return b.PrimaryBankIdentificationNumber
}
func (b *BankAccount) GetSecondaryBankIdentificationNumber() *string {
if b == nil {
return nil
}
return b.SecondaryBankIdentificationNumber
}
func (b *BankAccount) GetDebitMandateReferenceID() *string {
if b == nil {
return nil
}
return b.DebitMandateReferenceID
}
func (b *BankAccount) GetReferenceID() *string {
if b == nil {
return nil
}
return b.ReferenceID
}
func (b *BankAccount) GetLocationID() *string {
if b == nil {
return nil
}
return b.LocationID
}
func (b *BankAccount) GetStatus() BankAccountStatus {
if b == nil {
return ""
}
return b.Status
}
func (b *BankAccount) GetCreditable() bool {
if b == nil {
return false
}
return b.Creditable
}
func (b *BankAccount) GetDebitable() bool {
if b == nil {
return false
}
return b.Debitable
}
func (b *BankAccount) GetFingerprint() *string {
if b == nil {
return nil
}
return b.Fingerprint
}
func (b *BankAccount) GetVersion() *int {
if b == nil {
return nil
}
return b.Version
}
func (b *BankAccount) GetBankName() *string {
if b == nil {
return nil
}
return b.BankName
}
func (b *BankAccount) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BankAccount) UnmarshalJSON(data []byte) error {
type unmarshaler BankAccount
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BankAccount(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BankAccount) String() string {
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
// Indicates the current verification status of a `BankAccount` object.
type BankAccountStatus string
const (
BankAccountStatusVerificationInProgress BankAccountStatus = "VERIFICATION_IN_PROGRESS"
BankAccountStatusVerified BankAccountStatus = "VERIFIED"
BankAccountStatusDisabled BankAccountStatus = "DISABLED"
)
func NewBankAccountStatusFromString(s string) (BankAccountStatus, error) {
switch s {
case "VERIFICATION_IN_PROGRESS":
return BankAccountStatusVerificationInProgress, nil
case "VERIFIED":
return BankAccountStatusVerified, nil
case "DISABLED":
return BankAccountStatusDisabled, nil
}
var t BankAccountStatus
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (b BankAccountStatus) Ptr() *BankAccountStatus {
return &b
}
// Indicates the financial purpose of the bank account.
type BankAccountType string
const (
BankAccountTypeChecking BankAccountType = "CHECKING"
BankAccountTypeSavings BankAccountType = "SAVINGS"
BankAccountTypeInvestment BankAccountType = "INVESTMENT"
BankAccountTypeOther BankAccountType = "OTHER"
BankAccountTypeBusinessChecking BankAccountType = "BUSINESS_CHECKING"
)
func NewBankAccountTypeFromString(s string) (BankAccountType, error) {
switch s {
case "CHECKING":
return BankAccountTypeChecking, nil
case "SAVINGS":
return BankAccountTypeSavings, nil
case "INVESTMENT":
return BankAccountTypeInvestment, nil
case "OTHER":
return BankAccountTypeOther, nil
case "BUSINESS_CHECKING":
return BankAccountTypeBusinessChecking, nil
}
var t BankAccountType
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (b BankAccountType) Ptr() *BankAccountType {
return &b
}
// Response object returned by GetBankAccountByV1Id.
type GetBankAccountByV1IDResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The requested `BankAccount` object.
BankAccount *BankAccount `json:"bank_account,omitempty" url:"bank_account,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (g *GetBankAccountByV1IDResponse) GetErrors() []*Error {
if g == nil {
return nil
}
return g.Errors
}
func (g *GetBankAccountByV1IDResponse) GetBankAccount() *BankAccount {
if g == nil {
return nil
}
return g.BankAccount
}
func (g *GetBankAccountByV1IDResponse) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GetBankAccountByV1IDResponse) UnmarshalJSON(data []byte) error {
type unmarshaler GetBankAccountByV1IDResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetBankAccountByV1IDResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g.rawJSON = json.RawMessage(data)
return nil
}
func (g *GetBankAccountByV1IDResponse) String() string {
if len(g.rawJSON) > 0 {
if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
// Response object returned by `GetBankAccount`.
type GetBankAccountResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The requested `BankAccount` object.
BankAccount *BankAccount `json:"bank_account,omitempty" url:"bank_account,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (g *GetBankAccountResponse) GetErrors() []*Error {
if g == nil {
return nil
}
return g.Errors
}
func (g *GetBankAccountResponse) GetBankAccount() *BankAccount {
if g == nil {
return nil
}
return g.BankAccount
}
func (g *GetBankAccountResponse) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GetBankAccountResponse) UnmarshalJSON(data []byte) error {
type unmarshaler GetBankAccountResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetBankAccountResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g.rawJSON = json.RawMessage(data)
return nil
}
func (g *GetBankAccountResponse) String() string {
if len(g.rawJSON) > 0 {
if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
// Response object returned by ListBankAccounts.
type ListBankAccountsResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// List of BankAccounts associated with this account.
BankAccounts []*BankAccount `json:"bank_accounts,omitempty" url:"bank_accounts,omitempty"`
// When a response is truncated, it includes a cursor that you can
// use in a subsequent request to fetch next set of bank accounts.
// If empty, this is the final response.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination).
Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (l *ListBankAccountsResponse) GetErrors() []*Error {
if l == nil {
return nil
}
return l.Errors
}
func (l *ListBankAccountsResponse) GetBankAccounts() []*BankAccount {
if l == nil {
return nil
}
return l.BankAccounts
}
func (l *ListBankAccountsResponse) GetCursor() *string {
if l == nil {
return nil
}
return l.Cursor
}
func (l *ListBankAccountsResponse) GetExtraProperties() map[string]interface{} {
return l.extraProperties
}
func (l *ListBankAccountsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ListBankAccountsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListBankAccountsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *l)
if err != nil {
return err
}
l.extraProperties = extraProperties
l.rawJSON = json.RawMessage(data)
return nil
}
func (l *ListBankAccountsResponse) String() string {
if len(l.rawJSON) > 0 {
if value, err := internal.StringifyJSON(l.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}