How to configure the update certificate API

Overview

This section will help an implementer configure the DIVOC “Update Certificate” API.

Intended output

  • Implementers can use the “Update Certificate” API to process the requested updates - both in the QR code and human-readable sections of a specific certificate.

API

  • The DIVOC platform provides API services for updating vaccination certificates. You can refer to the API service call ‘​/v3​/certificate’ for the method PUT here.

  • The payload of the update service is the same as that of the certificate generation request. Click here to know more.

  • The platform provides flexibility to update values in the ‘recipient,’ ‘vaccination,’ ‘vaccinator,’ and ‘facility’ sections. Click here if you want to understand the mandatory and non-mandatory information that should be there in a vaccination certificate, according to global standards.

Methods - Get details on the API request and field validations:

a. The update certificate request is processed in this function. The pre-enrollment code and dose-wise certificates will be searched in the system to make an update request. The function will trigger the subsequent process to update the certificates.

for _, request := range params.Body {
if certificateId := getCertificateIdToBeUpdated(request); certificateId != nil{
log.Infof("Certificate update request approved %+v", request)
	if request.Meta == nil {
		request.Meta = map[string]interface{}{
			"previousCertificateId": certificateId,
			"certificateType":       CERTIFICATE_TYPE_V3,
		}
	} else {
		meta := request.Meta.(map[string]interface{})
		meta["previousCertificateId"] = certificateId
		meta["certificateType"] = CERTIFICATE_TYPE_V3
	}
	if jsonRequestString, err := json.Marshal(request); err == nil {
		kafkaService.PublishCertifyMessage(jsonRequestString, nil, nil)
	}
} else {
	log.Infof("Certificate update request rejected %+v", request)
	return certification.NewUpdateCertificateV3PreconditionFailed()
}
}
return certification.NewUpdateCertificateV3OK()

b. An implementer has the provision to restrict the number of update requests against a specific certificate in order to avoid the misuse of this functionality (that is, fraudulent generation of multiple certificate copies). For instance, the implementer can configure the “Update Limit” to only “5,” in which case the certificate can only be updated five times. The following steps are needed to enable this configuration:

Step 1: Open this file and check the function that will limit the number of certificates being updated.

if count < (config.Config.Certificate.UpdateLimit + 1) {
  certificateId := doseWiseCertificateIds[int(*request.Vaccination.Dose)][count-1]
	return &certificateId
} else {
	log.Error("Certificate update limit reached")
}

Step 2: Open this file and update the limit by configuring CERTIFICATE_UPDATE_LIMIT.

UpdateLimit int `env:"CERTIFICATE_UPDATE_LIMIT" default:"5"`
  • Click here to understand how DIVOC's “Update Certificate” service works.

Last updated