dukcapil/internal/contract/dukcapil_contract.go
Aditya Siregar c3317dd9ee update api
2026-05-08 10:06:43 +07:00

67 lines
2.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package contract
// FaceMatchRequest is the inbound payload from clients of this service to
// trigger a Dukcapil 1:N face recognition lookup.
//
// Only the image file is required from the client. All other parameters
// (transaction_id, transaction_source, threshold, ip) are generated or
// retrieved from configuration in the backend.
type FaceMatchRequest struct {
TransactionID string `json:"transaction_id"`
TransactionSource string `json:"transaction_source"`
Threshold string `json:"threshold"`
Image string `json:"image"`
IP string `json:"ip"`
}
// DukcapilFaceRequest is the exact JSON body sent to the Dukcapil
// face-recognition endpoint (CALL_FN). user_id and password are RSA encrypted
// with the provided public key and base64 encoded.
type DukcapilFaceRequest struct {
TransactionID string `json:"transactionId"`
TransactionSource string `json:"transactionSource"`
Threshold string `json:"threshold"`
Image string `json:"image"`
UserID string `json:"user_id"`
Password string `json:"password"`
IP string `json:"ip"`
}
// DukcapilFaceResponse is the standard Dukcapil response envelope (success +
// most error variants share this shape). Some error variants use a different
// shape clients should also inspect ErrorCode.
type DukcapilFaceResponse struct {
TID string `json:"tid"`
EncounterID interface{} `json:"encounter_id"`
Error string `json:"error"`
ErrorCode string `json:"errorCode"`
FingerData interface{} `json:"finger_data"`
IrisData interface{} `json:"iris_data"`
FaceData interface{} `json:"face_data"`
RequestType string `json:"request_type"`
MaxResults int `json:"maxResults"`
FaceThreshold string `json:"faceThreshold"`
FingerThreshold int `json:"fingerThreshold"`
IrisThreshold int `json:"irisThreshold"`
Response string `json:"response"`
}
// FaceMatchResponse is what we return to our API consumers.
type FaceMatchResponse struct {
TID string `json:"tid"`
ErrorCode string `json:"error_code"`
Error string `json:"error"`
RequestType string `json:"request_type"`
Threshold string `json:"threshold"`
MaxResults int `json:"max_results"`
Matches []FaceMatchResult `json:"matches"`
Raw *DukcapilFaceResponse `json:"raw,omitempty"`
}
// FaceMatchResult represents a single (NIK -> score) entry from the Dukcapil
// `response.face.FACE_T5` map.
type FaceMatchResult struct {
NIK string `json:"nik"`
Score float64 `json:"score"`
}