-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest.go
58 lines (48 loc) · 1.51 KB
/
rest.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
package common
// TooManyRequests defines the error code returned when KYC status check requests send too frequently.
const TooManyRequests = "429"
// CheckCustomerRequest represents the request for the CheckCustomer handler.
type CheckCustomerRequest struct {
Provider KYCProvider
UserData *UserData
}
// CheckStatusRequest represents the status check request payload of the CheckStatus handler.
type CheckStatusRequest struct {
Provider KYCProvider
ReferenceID string
}
// ErrorResponse represents the error response payload from the service.
type ErrorResponse struct {
Error string
}
// KYCResponse represents the response for the CheckCustomer and the CheckStatus handlers.
type KYCResponse struct {
Result *Result
Error string
}
// Result represents the verification result for the KYCResponse.
type Result struct {
Status string
Details *Details
ErrorCode string
StatusCheck *KYCStatusCheck
}
// Details defines additional details about the verification result.
type Details struct {
Finality string
Reasons []string
}
// ResultFromKYCResult converts KYC verification result into the API representation.
func ResultFromKYCResult(kycResult KYCResult) (result *Result) {
result = &Result{}
result.Status = KYCStatus2Status[kycResult.Status]
if kycResult.Details != nil {
result.Details = &Details{
Finality: KYCFinality2Finality[kycResult.Details.Finality],
Reasons: kycResult.Details.Reasons,
}
}
result.ErrorCode = kycResult.ErrorCode
result.StatusCheck = kycResult.StatusCheck
return
}