-
Notifications
You must be signed in to change notification settings - Fork 15
/
account_attributes.go
688 lines (480 loc) · 17 KB
/
account_attributes.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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"log"
"strconv"
"github.com/form3tech-oss/go-form3/pkg/client"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// AccountAttributes account attributes
// swagger:model AccountAttributes
type AccountAttributes struct {
// Is the account business or personal?
// Enum: [Personal Business]
AccountClassification *string `json:"account_classification,omitempty"`
// Is the account opted out of account matching, e.g. CoP?
AccountMatchingOptOut *bool `json:"account_matching_opt_out,omitempty"`
// Account number of the account. A unique number will automatically be generated if not provided.
// Pattern: ^[A-Z0-9]{0,64}$
AccountNumber string `json:"account_number,omitempty"`
// Alternative account names. Used for Confirmation of Payee matching.
// Max Items: 3
AlternativeBankAccountNames []string `json:"alternative_bank_account_names"`
// Primary account name. Used for Confirmation of Payee matching. Required if confirmation_of_payee_enabled is true for the organisation.
// Max Length: 140
// Min Length: 1
BankAccountName string `json:"bank_account_name,omitempty"`
// Local country bank identifier. In the UK this is the sort code.
// Pattern: ^[A-Z0-9]{0,16}$
BankID string `json:"bank_id,omitempty"`
// ISO 20022 code used to identify the type of bank ID being used
// Pattern: ^[A-Z]{0,16}$
BankIDCode string `json:"bank_id_code,omitempty"`
// ISO 4217 code used to identify the base currency of the account
// Pattern: ^[A-Z]{3}$
BaseCurrency string `json:"base_currency,omitempty"`
// SWIFT BIC in either 8 or 11 character format
// Pattern: ^([A-Z]{6}[A-Z0-9]{2}|[A-Z]{6}[A-Z0-9]{5})$
Bic string `json:"bic,omitempty"`
// ISO 3166-1 code used to identify the domicile of the account
// Required: true
// Pattern: ^[A-Z]{2}$
Country *string `json:"country"`
// A free-format reference that can be used to link this account to an external system
// Pattern: ^[a-zA-Z0-9-$@., ]{0,256}$
CustomerID string `json:"customer_id,omitempty"`
// - deprecated - Customer first name.
// Max Length: 40
// Min Length: 1
FirstName string `json:"first_name,omitempty"`
// IBAN of the account. Will be calculated from other fields if not supplied.
// Pattern: ^[A-Z]{2}[0-9]{2}[A-Z0-9]{0,64}$
Iban string `json:"iban,omitempty"`
// Is the account joint?
JointAccount *bool `json:"joint_account,omitempty"`
// organisation identification
OrganisationIdentification *AccountAttributesOrganisationIdentification `json:"organisation_identification,omitempty"`
// private identification
PrivateIdentification *AccountAttributesPrivateIdentification `json:"private_identification,omitempty"`
// Secondary identification, e.g. building society roll number. Used for Confirmation of Payee.
// Max Length: 140
// Min Length: 1
SecondaryIdentification string `json:"secondary_identification,omitempty"`
// Indicates whether the account has been switched using the Current Account Switch Service.
Switched *bool `json:"switched,omitempty"`
// - deprecated - Customer title.
// Max Length: 40
// Min Length: 1
Title string `json:"title,omitempty"`
}
func AccountAttributesWithDefaults(defaults client.Defaults) *AccountAttributes {
return &AccountAttributes{
AccountClassification: defaults.GetStringPtr("AccountAttributes", "account_classification"),
AccountMatchingOptOut: defaults.GetBoolPtr("AccountAttributes", "account_matching_opt_out"),
AccountNumber: defaults.GetString("AccountAttributes", "account_number"),
AlternativeBankAccountNames: make([]string, 0),
BankAccountName: defaults.GetString("AccountAttributes", "bank_account_name"),
BankID: defaults.GetString("AccountAttributes", "bank_id"),
BankIDCode: defaults.GetString("AccountAttributes", "bank_id_code"),
BaseCurrency: defaults.GetString("AccountAttributes", "base_currency"),
Bic: defaults.GetString("AccountAttributes", "bic"),
Country: defaults.GetStringPtr("AccountAttributes", "country"),
CustomerID: defaults.GetString("AccountAttributes", "customer_id"),
FirstName: defaults.GetString("AccountAttributes", "first_name"),
Iban: defaults.GetString("AccountAttributes", "iban"),
JointAccount: defaults.GetBoolPtr("AccountAttributes", "joint_account"),
OrganisationIdentification: AccountAttributesOrganisationIdentificationWithDefaults(defaults),
PrivateIdentification: AccountAttributesPrivateIdentificationWithDefaults(defaults),
SecondaryIdentification: defaults.GetString("AccountAttributes", "secondary_identification"),
Switched: defaults.GetBoolPtr("AccountAttributes", "switched"),
Title: defaults.GetString("AccountAttributes", "title"),
}
}
func (m *AccountAttributes) WithAccountClassification(accountClassification string) *AccountAttributes {
m.AccountClassification = &accountClassification
return m
}
func (m *AccountAttributes) WithoutAccountClassification() *AccountAttributes {
m.AccountClassification = nil
return m
}
func (m *AccountAttributes) WithAccountMatchingOptOut(accountMatchingOptOut bool) *AccountAttributes {
m.AccountMatchingOptOut = &accountMatchingOptOut
return m
}
func (m *AccountAttributes) WithoutAccountMatchingOptOut() *AccountAttributes {
m.AccountMatchingOptOut = nil
return m
}
func (m *AccountAttributes) WithAccountNumber(accountNumber string) *AccountAttributes {
m.AccountNumber = accountNumber
return m
}
func (m *AccountAttributes) WithAlternativeBankAccountNames(alternativeBankAccountNames []string) *AccountAttributes {
m.AlternativeBankAccountNames = alternativeBankAccountNames
return m
}
func (m *AccountAttributes) WithBankAccountName(bankAccountName string) *AccountAttributes {
m.BankAccountName = bankAccountName
return m
}
func (m *AccountAttributes) WithBankID(bankID string) *AccountAttributes {
m.BankID = bankID
return m
}
func (m *AccountAttributes) WithBankIDCode(bankIDCode string) *AccountAttributes {
m.BankIDCode = bankIDCode
return m
}
func (m *AccountAttributes) WithBaseCurrency(baseCurrency string) *AccountAttributes {
m.BaseCurrency = baseCurrency
return m
}
func (m *AccountAttributes) WithBic(bic string) *AccountAttributes {
m.Bic = bic
return m
}
func (m *AccountAttributes) WithCountry(country string) *AccountAttributes {
m.Country = &country
return m
}
func (m *AccountAttributes) WithoutCountry() *AccountAttributes {
m.Country = nil
return m
}
func (m *AccountAttributes) WithCustomerID(customerID string) *AccountAttributes {
m.CustomerID = customerID
return m
}
func (m *AccountAttributes) WithFirstName(firstName string) *AccountAttributes {
m.FirstName = firstName
return m
}
func (m *AccountAttributes) WithIban(iban string) *AccountAttributes {
m.Iban = iban
return m
}
func (m *AccountAttributes) WithJointAccount(jointAccount bool) *AccountAttributes {
m.JointAccount = &jointAccount
return m
}
func (m *AccountAttributes) WithoutJointAccount() *AccountAttributes {
m.JointAccount = nil
return m
}
func (m *AccountAttributes) WithOrganisationIdentification(organisationIdentification AccountAttributesOrganisationIdentification) *AccountAttributes {
m.OrganisationIdentification = &organisationIdentification
return m
}
func (m *AccountAttributes) WithoutOrganisationIdentification() *AccountAttributes {
m.OrganisationIdentification = nil
return m
}
func (m *AccountAttributes) WithPrivateIdentification(privateIdentification AccountAttributesPrivateIdentification) *AccountAttributes {
m.PrivateIdentification = &privateIdentification
return m
}
func (m *AccountAttributes) WithoutPrivateIdentification() *AccountAttributes {
m.PrivateIdentification = nil
return m
}
func (m *AccountAttributes) WithSecondaryIdentification(secondaryIdentification string) *AccountAttributes {
m.SecondaryIdentification = secondaryIdentification
return m
}
func (m *AccountAttributes) WithSwitched(switched bool) *AccountAttributes {
m.Switched = &switched
return m
}
func (m *AccountAttributes) WithoutSwitched() *AccountAttributes {
m.Switched = nil
return m
}
func (m *AccountAttributes) WithTitle(title string) *AccountAttributes {
m.Title = title
return m
}
// Validate validates this account attributes
func (m *AccountAttributes) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAccountClassification(formats); err != nil {
res = append(res, err)
}
if err := m.validateAccountNumber(formats); err != nil {
res = append(res, err)
}
if err := m.validateAlternativeBankAccountNames(formats); err != nil {
res = append(res, err)
}
if err := m.validateBankAccountName(formats); err != nil {
res = append(res, err)
}
if err := m.validateBankID(formats); err != nil {
res = append(res, err)
}
if err := m.validateBankIDCode(formats); err != nil {
res = append(res, err)
}
if err := m.validateBaseCurrency(formats); err != nil {
res = append(res, err)
}
if err := m.validateBic(formats); err != nil {
res = append(res, err)
}
if err := m.validateCountry(formats); err != nil {
res = append(res, err)
}
if err := m.validateCustomerID(formats); err != nil {
res = append(res, err)
}
if err := m.validateFirstName(formats); err != nil {
res = append(res, err)
}
if err := m.validateIban(formats); err != nil {
res = append(res, err)
}
if err := m.validateOrganisationIdentification(formats); err != nil {
res = append(res, err)
}
if err := m.validatePrivateIdentification(formats); err != nil {
res = append(res, err)
}
if err := m.validateSecondaryIdentification(formats); err != nil {
res = append(res, err)
}
if err := m.validateTitle(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var accountAttributesTypeAccountClassificationPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["Personal","Business"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
accountAttributesTypeAccountClassificationPropEnum = append(accountAttributesTypeAccountClassificationPropEnum, v)
}
}
const (
// AccountAttributesAccountClassificationPersonal captures enum value "Personal"
AccountAttributesAccountClassificationPersonal string = "Personal"
// AccountAttributesAccountClassificationBusiness captures enum value "Business"
AccountAttributesAccountClassificationBusiness string = "Business"
)
// prop value enum
func (m *AccountAttributes) validateAccountClassificationEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, accountAttributesTypeAccountClassificationPropEnum); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateAccountClassification(formats strfmt.Registry) error {
if swag.IsZero(m.AccountClassification) { // not required
return nil
}
// value enum
if err := m.validateAccountClassificationEnum("account_classification", "body", *m.AccountClassification); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateAccountNumber(formats strfmt.Registry) error {
if swag.IsZero(m.AccountNumber) { // not required
return nil
}
if err := validate.Pattern("account_number", "body", string(m.AccountNumber), `^[A-Z0-9]{0,64}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateAlternativeBankAccountNames(formats strfmt.Registry) error {
if swag.IsZero(m.AlternativeBankAccountNames) { // not required
return nil
}
iAlternativeBankAccountNamesSize := int64(len(m.AlternativeBankAccountNames))
if err := validate.MaxItems("alternative_bank_account_names", "body", iAlternativeBankAccountNamesSize, 3); err != nil {
return err
}
for i := 0; i < len(m.AlternativeBankAccountNames); i++ {
if err := validate.MinLength("alternative_bank_account_names"+"."+strconv.Itoa(i), "body", string(m.AlternativeBankAccountNames[i]), 1); err != nil {
return err
}
if err := validate.MaxLength("alternative_bank_account_names"+"."+strconv.Itoa(i), "body", string(m.AlternativeBankAccountNames[i]), 140); err != nil {
return err
}
}
return nil
}
func (m *AccountAttributes) validateBankAccountName(formats strfmt.Registry) error {
if swag.IsZero(m.BankAccountName) { // not required
return nil
}
if err := validate.MinLength("bank_account_name", "body", string(m.BankAccountName), 1); err != nil {
return err
}
if err := validate.MaxLength("bank_account_name", "body", string(m.BankAccountName), 140); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateBankID(formats strfmt.Registry) error {
if swag.IsZero(m.BankID) { // not required
return nil
}
if err := validate.Pattern("bank_id", "body", string(m.BankID), `^[A-Z0-9]{0,16}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateBankIDCode(formats strfmt.Registry) error {
if swag.IsZero(m.BankIDCode) { // not required
return nil
}
if err := validate.Pattern("bank_id_code", "body", string(m.BankIDCode), `^[A-Z]{0,16}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateBaseCurrency(formats strfmt.Registry) error {
if swag.IsZero(m.BaseCurrency) { // not required
return nil
}
if err := validate.Pattern("base_currency", "body", string(m.BaseCurrency), `^[A-Z]{3}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateBic(formats strfmt.Registry) error {
if swag.IsZero(m.Bic) { // not required
return nil
}
if err := validate.Pattern("bic", "body", string(m.Bic), `^([A-Z]{6}[A-Z0-9]{2}|[A-Z]{6}[A-Z0-9]{5})$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateCountry(formats strfmt.Registry) error {
if err := validate.Required("country", "body", m.Country); err != nil {
return err
}
if err := validate.Pattern("country", "body", string(*m.Country), `^[A-Z]{2}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateCustomerID(formats strfmt.Registry) error {
if swag.IsZero(m.CustomerID) { // not required
return nil
}
if err := validate.Pattern("customer_id", "body", string(m.CustomerID), `^[a-zA-Z0-9-$@., ]{0,256}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateFirstName(formats strfmt.Registry) error {
if swag.IsZero(m.FirstName) { // not required
return nil
}
if err := validate.MinLength("first_name", "body", string(m.FirstName), 1); err != nil {
return err
}
if err := validate.MaxLength("first_name", "body", string(m.FirstName), 40); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateIban(formats strfmt.Registry) error {
if swag.IsZero(m.Iban) { // not required
return nil
}
if err := validate.Pattern("iban", "body", string(m.Iban), `^[A-Z]{2}[0-9]{2}[A-Z0-9]{0,64}$`); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateOrganisationIdentification(formats strfmt.Registry) error {
if swag.IsZero(m.OrganisationIdentification) { // not required
return nil
}
if m.OrganisationIdentification != nil {
if err := m.OrganisationIdentification.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("organisation_identification")
}
return err
}
}
return nil
}
func (m *AccountAttributes) validatePrivateIdentification(formats strfmt.Registry) error {
if swag.IsZero(m.PrivateIdentification) { // not required
return nil
}
if m.PrivateIdentification != nil {
if err := m.PrivateIdentification.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("private_identification")
}
return err
}
}
return nil
}
func (m *AccountAttributes) validateSecondaryIdentification(formats strfmt.Registry) error {
if swag.IsZero(m.SecondaryIdentification) { // not required
return nil
}
if err := validate.MinLength("secondary_identification", "body", string(m.SecondaryIdentification), 1); err != nil {
return err
}
if err := validate.MaxLength("secondary_identification", "body", string(m.SecondaryIdentification), 140); err != nil {
return err
}
return nil
}
func (m *AccountAttributes) validateTitle(formats strfmt.Registry) error {
if swag.IsZero(m.Title) { // not required
return nil
}
if err := validate.MinLength("title", "body", string(m.Title), 1); err != nil {
return err
}
if err := validate.MaxLength("title", "body", string(m.Title), 40); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *AccountAttributes) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *AccountAttributes) UnmarshalBinary(b []byte) error {
var res AccountAttributes
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
func (m *AccountAttributes) Json() string {
json, err := json.MarshalIndent(m, " ", " ")
if err != nil {
log.Fatal(err)
}
return string(json)
}