-
Notifications
You must be signed in to change notification settings - Fork 2
/
openbanking_brasil_payment_v3_details.go
232 lines (186 loc) · 7.3 KB
/
openbanking_brasil_payment_v3_details.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
// 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 (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// OpenbankingBrasilPaymentV3Details OpenbankingBrasilPaymentV3Details Details
//
// Objeto contendo os detalhes do pagamento.
//
// swagger:model OpenbankingBrasilPaymentV3Details
type OpenbankingBrasilPaymentV3Details struct {
// creditor account
// Required: true
CreditorAccount *OpenbankingBrasilPaymentV3CreditorAccount `json:"creditorAccount" yaml:"creditorAccount"`
// local instrument
// Required: true
LocalInstrument *OpenbankingBrasilPaymentV3EnumLocalInstrument `json:"localInstrument" yaml:"localInstrument"`
// Chave cadastrada no DICT pertencente ao recebedor. Os tipos de chaves podem ser: telefone, e-mail, cpf/cnpj ou chave aleatria.
// No caso de telefone celular deve ser informado no padro E.1641.
// Para e-mail deve ter o formato xxxxxxxx@xxxxxxx.xxx(.xx) e no mximo 77 caracteres.
// No caso de CPF dever ser informado com 11 nmeros, sem pontos ou traos.
// Para o caso de CNPJ dever ser informado com 14 nmeros, sem pontos ou traos.
// No caso de chave aleatria deve ser informado o UUID gerado pelo DICT, conforme formato especificado na RFC41223.
// Se informado, a detentora da conta deve validar o proxy no DICT quando localInstrument for igual a DICT, QRDN ou QRES e validar o campo creditorAccount.
// Esta validao opcional caso o localInstrument for igual a INIC.
// [Restrio]
// Se localInstrument for igual a MANU, o campo proxy no deve ser preenchido.
// Se localInstrument for igual INIC, DICT, QRDN ou QRES, o campo proxy deve ser sempre preenchido com a chave Pix.
// Example: 12345678901
// Max Length: 77
// Pattern: [\w\W\s]*
Proxy string `json:"proxy,omitempty" yaml:"proxy,omitempty"`
// Sequncia de caracteres que corresponde ao QR Code disponibilizado para o pagador.
//
// a sequncia de caracteres que seria lida pelo leitor de QR Code, e deve propiciar o retorno dos dados do pagador aps consulta na DICT.
//
// Essa funcionalidade possvel tanto para QR Code esttico quanto para QR Code dinmico.
// No arranjo do Pix esta a mesma sequncia gerada e/ou lida pela funcionalidade Pix Copia e Cola.
// Este campo dever ser no formato UTF-8.
// [Restrio] Preenchimento obrigatrio para pagamentos por QR Code, observado o tamanho mximo de 512 bytes.
// Example: 00020104141234567890123426660014BR.GOV.BCB.PIX014466756C616E6F32303139406578616D706C652E636F6D27300012\\nBR.COM.OUTRO011001234567895204000053039865406123.455802BR5915NOMEDORECEBEDOR6008BRASILIA61087007490062\\n530515RP12345678-201950300017BR.GOV.BCB.BRCODE01051.0.080450014BR.GOV.BCB.PIX0123PADRAO.URL.PIX/0123AB\\nCD81390012BR.COM.OUTRO01190123.ABCD.3456.WXYZ6304EB76\\n
// Max Length: 512
// Pattern: [\w\W\s]*
QrCode string `json:"qrCode,omitempty" yaml:"qrCode,omitempty"`
}
// Validate validates this openbanking brasil payment v3 details
func (m *OpenbankingBrasilPaymentV3Details) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreditorAccount(formats); err != nil {
res = append(res, err)
}
if err := m.validateLocalInstrument(formats); err != nil {
res = append(res, err)
}
if err := m.validateProxy(formats); err != nil {
res = append(res, err)
}
if err := m.validateQrCode(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *OpenbankingBrasilPaymentV3Details) validateCreditorAccount(formats strfmt.Registry) error {
if err := validate.Required("creditorAccount", "body", m.CreditorAccount); err != nil {
return err
}
if m.CreditorAccount != nil {
if err := m.CreditorAccount.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("creditorAccount")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("creditorAccount")
}
return err
}
}
return nil
}
func (m *OpenbankingBrasilPaymentV3Details) validateLocalInstrument(formats strfmt.Registry) error {
if err := validate.Required("localInstrument", "body", m.LocalInstrument); err != nil {
return err
}
if err := validate.Required("localInstrument", "body", m.LocalInstrument); err != nil {
return err
}
if m.LocalInstrument != nil {
if err := m.LocalInstrument.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("localInstrument")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("localInstrument")
}
return err
}
}
return nil
}
func (m *OpenbankingBrasilPaymentV3Details) validateProxy(formats strfmt.Registry) error {
if swag.IsZero(m.Proxy) { // not required
return nil
}
if err := validate.MaxLength("proxy", "body", m.Proxy, 77); err != nil {
return err
}
if err := validate.Pattern("proxy", "body", m.Proxy, `[\w\W\s]*`); err != nil {
return err
}
return nil
}
func (m *OpenbankingBrasilPaymentV3Details) validateQrCode(formats strfmt.Registry) error {
if swag.IsZero(m.QrCode) { // not required
return nil
}
if err := validate.MaxLength("qrCode", "body", m.QrCode, 512); err != nil {
return err
}
if err := validate.Pattern("qrCode", "body", m.QrCode, `[\w\W\s]*`); err != nil {
return err
}
return nil
}
// ContextValidate validate this openbanking brasil payment v3 details based on the context it is used
func (m *OpenbankingBrasilPaymentV3Details) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCreditorAccount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateLocalInstrument(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *OpenbankingBrasilPaymentV3Details) contextValidateCreditorAccount(ctx context.Context, formats strfmt.Registry) error {
if m.CreditorAccount != nil {
if err := m.CreditorAccount.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("creditorAccount")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("creditorAccount")
}
return err
}
}
return nil
}
func (m *OpenbankingBrasilPaymentV3Details) contextValidateLocalInstrument(ctx context.Context, formats strfmt.Registry) error {
if m.LocalInstrument != nil {
if err := m.LocalInstrument.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("localInstrument")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("localInstrument")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *OpenbankingBrasilPaymentV3Details) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OpenbankingBrasilPaymentV3Details) UnmarshalBinary(b []byte) error {
var res OpenbankingBrasilPaymentV3Details
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}