-
Notifications
You must be signed in to change notification settings - Fork 0
/
govChecksBrazil.go
301 lines (269 loc) · 11.5 KB
/
govChecksBrazil.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
package metamap
type (
// BrazilCNPJValidation
BrazilCNPJValidationRequest struct {
Cnpj string `json:"cnpj"`
CallbackUrl string `json:"callbackUrl"`
}
BrazilCNPJValidationResponse struct {
Status int `json:"status"`
Error interface{} `json:"error"`
Data struct {
CompanyName string `json:"companyName"`
CommercialName string `json:"commercialName"`
Cpnj string `json:"cpnj"`
DateOfOpening string `json:"dateOfOpening"`
CompanySize string `json:"companySize"`
Status string `json:"status"`
StatusReason interface{} `json:"statusReason"`
StatusDate string `json:"statusDate"`
SpecialStatus interface{} `json:"specialStatus"`
SpecialStatusReason interface{} `json:"specialStatusReason"`
MainActivity string `json:"mainActivity"`
SecondaryActivities []string `json:"secondaryActivities"`
CompanyType string `json:"companyType"`
Address struct {
Street string `json:"street"`
Number string `json:"number"`
ZipCode string `json:"zipCode"`
District string `json:"district"`
Municipality string `json:"municipality"`
State string `json:"state"`
Details string `json:"details"`
} `json:"address"`
Contact struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
} `json:"contact"`
EFR interface{} `json:"EFR"`
} `json:"data"`
Timestamp string `json:"timestamp"`
}
// BrazilCNPJExtendedValidation
BrazilCNPJExtendedValidationRequest struct {
Cnpj string `json:"cnpj"`
CallbackUrl string `json:"callbackUrl"`
}
BrazilCNPJExtendedValidationResponse struct {
Error interface{} `json:"error"`
Data struct {
RegistrationNumber string `json:"registrationNumber"`
TipoEstabelecimento string `json:"tipoEstabelecimento"`
CompanyName string `json:"companyName"`
LegalName string `json:"legalName"`
CadastralStatus struct {
RegistrationStatus string `json:"registrationStatus"`
StatusDate string `json:"statusDate"`
Reason string `json:"reason"`
} `json:"cadastralStatus"`
LegalNature struct {
LegalCode string `json:"legalCode"`
LegalDescription string `json:"legalDescription"`
} `json:"legalNature"`
RegistrationDate string `json:"registrationDate"`
CnaePrincipal struct {
CnaeCode string `json:"cnaeCode"`
CnaeDescription string `json:"cnaeDescription"`
} `json:"cnaePrincipal"`
Address struct {
Street string `json:"street"`
Locality string `json:"locality"`
AreaNumber string `json:"areaNumber"`
AdditionalAddress string `json:"additionalAddress"`
Postcode string `json:"postcode"`
LocalitySector string `json:"localitySector"`
FederationUnit string `json:"federationUnit"`
Country struct {
Code string `json:"code"`
Description string `json:"description"`
} `json:"country"`
County struct {
AdministrativeCode string `json:"administrativeCode"`
AdministrativeName string `json:"administrativeName"`
} `json:"county"`
} `json:"address"`
MunicipalitiesJurisdiction struct {
Code string `json:"code"`
Description string `json:"description"`
} `json:"municipalitiesJurisdiction"`
Phones []struct {
PhoneCode string `json:"phoneCode"`
PhoneNumber string `json:"phoneNumber"`
} `json:"phones"`
Email string `json:"email"`
CapitalSocial string `json:"capitalSocial"`
CompanySize string `json:"companySize"`
SituacaoEspecial string `json:"situacaoEspecial"`
DataSituacaoEspecial string `json:"dataSituacaoEspecial"`
InformacoesAdicionais struct {
OptanteSimples string `json:"optanteSimples"`
OptanteMei string `json:"optanteMei"`
ListaPeriodosSimples []interface{} `json:"listaPeriodosSimples"`
} `json:"informacoesAdicionais"`
ShareholdersInfo []struct {
ShareholderType string `json:"shareholderType"`
CpfNumber string `json:"cpfNumber"`
ShareholderName string `json:"shareholderName"`
Qualificacao string `json:"qualificacao"`
AssignationDate string `json:"assignationDate"`
Country struct {
Code string `json:"code"`
Description string `json:"description"`
} `json:"country"`
LegalRepresentation struct {
RepresentativeCpf string `json:"representativeCpf"`
RepresentativeName string `json:"representativeName"`
Qualificacao string `json:"qualificacao"`
} `json:"legalRepresentation"`
} `json:"shareholdersInfo"`
} `json:"data"`
}
// BrazilCPFValidationResponse
BrazilCPFValidationRequest struct {
CpfNumber string `json:"cpfNumber"`
FullName string `json:"fullName"`
DateOfBirth string `json:"dateOfBirth"`
MothersName string `json:"mothersName"`
FathersName string `json:"fathersName"`
// nationalId or driving-license
DocumentType string `json:"documentType"`
DocumentNumber string `json:"documentNumber"`
// M for male, F for female. Returns null if there is no gender data.
Gender string `json:"gender"`
CallbackUrl string `json:"callbackUrl"`
}
BrazilCPFValidationResponse struct {
Error interface{} `json:"error"`
Data struct {
CpfNumberMatched bool `json:"cpfNumberMatched"`
Gender string `json:"gender"`
Nationality string `json:"nationality"`
TaxStatus string `json:"taxStatus"`
FullNameSimilarity int `json:"fullNameSimilarity"`
DateOfBirthMatched bool `json:"dateOfBirthMatched"`
DocumentType string `json:"documentType"`
DocumentNumberMatched bool `json:"documentNumberMatched"`
MothersNameSimilarity int `json:"mothersNameSimilarity"`
FathersNameSimilarity int `json:"fathersNameSimilarity"`
} `json:"data"`
}
// BrazilCPFLEGACY
BrazilCPFLEGACYRequest struct {
CpfNumber string `json:"cpfNumber"`
FullName string `json:"fullName"`
DocumentNumber string `json:"documentNumber"`
DateOfBirth string `json:"dateOfBirth"`
DateOfExpiry string `json:"dateOfExpiry"`
DocumentType string `json:"documentType"`
}
BrazilCPFLEGACYResponse struct {
Error interface{} `json:"error"`
Data struct {
CPFNumber string `json:"CPFNumber"`
Gender string `json:"gender"`
Nationality string `json:"nationality"`
TaxStatus string `json:"taxStatus"`
FullName string `json:"fullName"`
DateOfBirth string `json:"dateOfBirth"`
DocumentType string `json:"documentType"`
DocumentNumber string `json:"documentNumber"`
} `json:"data"`
}
// BrazilCPFLight
BrazilCPFLightRequest struct {
// CPF number
Cpf string `json:"cpf"`
CallbackUrl string `json:"callbackUrl"`
}
BrazilCPFLightResponse struct {
Status int `json:"status"`
Id string `json:"id"`
Error interface{} `json:"error"`
Data struct {
FullName string `json:"fullName"`
DateOfBirth string `json:"dateOfBirth"`
Cpf string `json:"cpf"`
TaxStatus string `json:"taxStatus"`
} `json:"data"`
Timestamp string `json:"timestamp"`
}
)
/*
BrazilCNPJValidation validate a business's National Registry of Legal Entities number.
This method takes in the BrazilCNPJValidationRequest{} struct as a parameter.
MetaMap connects with the Brazilian Internal Revenue Service (Ministério da Fazenda / Treasury) to validate the National Registry of Legal Entities (Cadastro Nacional de Pessoas Jurídicas / CNPJ) number.
*/
func (c *Client) BrazilCNPJValidation(req BrazilCNPJValidationRequest) (*BrazilCNPJValidationResponse, error) {
url := "govchecks/v1/br/cnpj"
method := MethodPOST
var response BrazilCNPJValidationResponse
c.IsBasic = false
if err := c.newRequest(method, url, req, response); err != nil {
return &BrazilCNPJValidationResponse{}, err
}
return &response, nil
}
/*
BrazilCNPJExtendedValidation validate a business's National Registry of Legal Entities number.
This method takes in the BrazilCNPJExtendedValidationRequest{} struct as a parameter.
MetaMap connects with the Brazilian Internal Revenue Service (Ministério da Fazenda / Treasury) to validate the National Registry of Legal Entities (Cadastro Nacional de Pessoas Jurídicas / CNPJ) number.
If the CNPJ number is valid, the endpoint will also pull up additional information, including company registration data, type of business, phone, email, physical address, and information about shareholders, including their names and CPF numbers.
*/
func (c *Client) BrazilCNPJExtendedValidation(req BrazilCNPJExtendedValidationRequest) (*BrazilCNPJExtendedValidationResponse, error) {
url := "govchecks/v1/br/cnpj-extended"
method := MethodPOST
var response BrazilCNPJExtendedValidationResponse
c.IsBasic = false
if err := c.newRequest(method, url, req, response); err != nil {
return &BrazilCNPJExtendedValidationResponse{}, err
}
return &response, nil
}
/*
BrazilCPFValidation verify a user's CPF number and identity.
This method takes in the BrazilCPFValidationRequest{} struct as a parameter.
MetaMap connects with the Brazilian Internal Revenue Service (Ministério da Fazenda / Treasury) to validate that the Registration of Individuals (Cadastro de Pessoas Físicas / CPF) number present in the ID card exists and its owner matches the data obtained from it.
*/
func (c *Client) BrazilCPFValidation(req BrazilCPFValidationRequest) (*BrazilCPFValidationResponse, error) {
url := "govchecks/v1/br/cpf-validation"
method := MethodPOST
var response BrazilCPFValidationResponse
c.IsBasic = false
if err := c.newRequest(method, url, req, response); err != nil {
return &BrazilCPFValidationResponse{}, err
}
return &response, nil
}
/*
BrazilCPFLEGACY verify a user's CPF number and identity.
This method takes in the BrazilCPFLEGACYRequest{} struct as a parameter.
NOTE: This version of the CPF check only handles individual validation requests. Use the new version of the BrazilCPFValidation() which can handle batch validation requests.
MetaMap connects with the Brazilian IRS (Ministério da Fazenda / Treasury) to validate that the CPF (Cadastro de Pessoas Físicas / Registration of Individuals) number present in the ID card exists and its owner matches the data obtained from it.
*/
func (c *Client) BrazilCPFLEGACY(req BrazilCPFLEGACYRequest) (*BrazilCPFLEGACYResponse, error) {
url := "govchecks/v1/br/cpf"
method := MethodPOST
var response BrazilCPFLEGACYResponse
c.IsBasic = false
//this method required multipart form data
c.IsMultipartHeader = true
if err := c.newRequest(method, url, req, response); err != nil {
return &BrazilCPFLEGACYResponse{}, err
}
return &response, nil
}
/*
BrazilCPFLight verify a user's CPF number and identity.
This method takes in the BrazilCPFLightRequest{} struct as a parameter.
MetaMap connects with the Brazilian Internal Revenue Service (Ministério da Fazenda / Treasury) to validate that the Registration of Individuals (Cadastro de Pessoas Físicas / CPF) number present on the national ID card or driver license exists and its owner matches the data obtained from it.
*/
func (c *Client) BrazilCPFLight(req BrazilCPFLightRequest) (*BrazilCPFLightResponse, error) {
url := "govchecks/v1/br/cpf-light"
method := MethodPOST
var response BrazilCPFLightResponse
c.IsBasic = false
if err := c.newRequest(method, url, req, response); err != nil {
return &BrazilCPFLightResponse{}, err
}
return &response, nil
}