Class Document

Represents a single document as part of an application. The following example demonstrates how to access individual documents from applications.

var api = new TVS.Api();
api.login('admin', 'password').then(function() {
    // get container results...
    return api.retrieveDocumentContainer(containerId);
}).then(function(application) {
    // list of documents
    console.log('Application:', application.getApplicationDisplayName());
    console.log('Documents:');
    for (var i = 0; i < application.Documents.length; i++) {
        var doc = application.Documents[i];
        console.log('document:', doc.getDocumentTypeDisplay(), doc.getFullname());
        console.log('supporting document?:', doc.isSupportingDocument());
        console.log('has MRZ:', doc.hasMRZ());
        console.log('MRZ character count:', doc.MrzCharacterCount);
        console.log('MRZ count of lines:', doc.MrzLineCount);

        // result properties
        console.log('Results:');
        for (var i = 0; i < doc.DocumentResultsSummary.length; i++) {
            var prop = doc.DocumentResultsSummary[i];
            console.log('name:', prop.Name, 'OK:', prop.Value);
        }
    }
});

See also

Class Container - a document is part of an application, which is represented by this class.

Creating a New Document for details of how to create new documents.

Retrieving Documents for more information on how to retrieve the metadata for particular documents.

class Document(json)

Represents a single identity document or supporting document as part of an application. Each document contains meta information alongside metadata about scanned or uploaded images and document-level custom fields.

Arguments
  • json (object()) – The original JSON data object on which this document is based.

Constant Properties

Document.FIELD_DOCUMENT_NUMBER

Refers to the document number field.

Document.FIELD_FIRSTNAME

Refers to the first name field.

Document.FIELD_MIDDLENAME

Refers to the middle name field.

Document.FIELD_LASTNAME

Refers to the last name field.

Document.FIELD_DATE_OF_BIRTH

Refers to the date of birth field.

Document.FIELD_GENDER_CODE

Refers to the gender field.

Document.FIELD_EXPIRY_DATE

Refers to the expiry date field.

Document.DOCUMENT_TYPE_PASSPORT

Identifies an international passport document.

Document.DOCUMENT_TYPE_VISA

Identifies an international VISA document.

Document.DOCUMENT_TYPE_IDENTITYCARD

Identifies a national identity card.

Document.DOCUMENT_TYPE_DRIVINGLICENCE

Identifies a national driving licence card or document.

Document.DOCUMENT_TYPE_SUPPORTINGDOCUMENT

Identifies a general supporting document that is usually part of an application to support it but not necessarily an identity document. This is typically a utility bill, birth certificate etc.

Document.DOCUMENT_TYPE_BIOMETRIC_RESIDENCE_PERMIT

Identifers a biometric residence permit document.

Document.GENDER_MALE

Identifies the document holder to be male gender.

Document.GENDER_FEMALE

Identifies the document holder to be female gender.

Document.GENDER_TRANSGENDER

Identifies the document holder to be transgender.

Document.GENDER_UNSPECIFIED

The document holder’s gender is not specified by this document.

Document.GENDER_UNKNOWN

The document holder’s gender is unknown or could not be identified.

Document.STATUS_UNDEFINED

The status of this document has not been defined yet.

Document.STATUS_ACCEPTED

This document has been accepted as a valid form of authentication.

Document.STATUS_REFERRED

The document has been referred and the status is not yet fully determined.

Document.STATUS_FAILED

The document has been considered to be invalid. For example, the document has expired.

Document.STATUS_REJECTED

The document has been rejected as a valid form of authentication. Perhaps the document (even though valid as such) is not acceptable in the context of the application.

Document.STATUS_NO_VALIDATION

The document has not been validated yet or a validation is not possible.

Document.FEEDBACK_PERSON_MATCHES_NO

According to the person who checked the document, the photo on the document does not match the document holder who presented the document in person.

Document.FEEDBACK_PERSON_MATCHES_YES

According to the person who checked the document, the photo on the document does indeed match the document holder who presented the document in person.

Document.FEEDBACK_PERSON_MATCHES_NOTSEEN

According to the person who checked the document, the document holder was not present in person and a comparison of the document photo with the document holder in person was not carried out for that reason. For example, checks were carried out over the phone or the document was sent by mail.

Document.DocumentType

Declares the type of the document.

Document.DocumentName

Declares the specific name of the type of a document.

Document.Images

Provides a list of metadata for each image that is attached to this document.

Document.CustomFields

Provides a list of document-level custom fields for this document.

Document.Mrz

Provides the MRZ for an identity document, if one is present.

Document.MrzCharacterCount

Provides the number of characters per line for the document’s MRZ.

Document.MrzLineCount

Provides the number of lines in the document’s MRZ.

Document.MrzSameLength

true if all lines of the MRZ have the same number of characters per line.

Document.MrzValidationProperties

Provides a list of feedback properties related to the validation of the document’s MRZ.

Document.MissingFieldsProperties

Provides a list of feedback properties relating to missing document data.

Document.GeneralDocumentProperties

Provides a list of feedback properties relating to general document properties.

Document.DocumentResultsSummary

Provides a list of feedback properties relating to general document properties concerned with the overall result of the document.

Document.FeedbackPersonMatches

Indicates if an operator decided that the person who presented the document matches the photo on the document, did not match the photo, or was not seen.

Feedback Person Matches Value

Description

Document.FEEDBACK_PERSON_MATCHES_NO

The person does not match the photo.

Document.FEEDBACK_PERSON_MATCHES_YES

The person does match the photo.

Document.FEEDBACK_PERSON_MATCHES_NOTSEEN

The person has not been seen.

Methods

Document.createCustomFields(customFields, customFieldValues)

Create document-level custom fields that can be passed into Api.createDocument or Api.updateDocument as document-level custom fields through the document property CustomFieldDictionary.

Document-level custom fields must be composed out of meta information about all available fields the system provides and the actual field values for any particular document.

Arguments
  • customFields (object()) – Object representing meta information about all document-level custom fields that the system supports.

  • customFieldValues (object()) – Object representing name/value pairs that are representing a set of document-level custom field values.

See also

Creating a New Document With Custom Fields for an example of how to set document-level custom fields using this method.

Document.documentTypeRequiresBackSide(documentType)

Return true if the given document type requires a back side image to be provided.

Arguments
  • documentType (int()) – The document type for which the requirement of the back side is evaluated.

Document.getField(fieldname)

Return the meta information of the document field with the given fieldname or undefined if no such document field exists. If multiple fields are defined then the document field with the highest SourceId is returned.

Arguments
  • fieldname (string()) – Name of the internal document field.

Document.getFieldValue(fieldname)

Return the value of the document field with given fieldname.

Arguments
  • fieldname (string()) – Name of the internal document field.

Document.getDocumentNumber()

Return the document number of this document.

Document.getFirstname()

Return the first name of the document holder.

Document.getMiddlename()

Return the middle name of the document holder.

Document.getLastname()

Return the last name of the document holder.

Document.getDateOfBirth()

Return the date of birth of the document holder.

Document.getGenderCode()

Return the date of birth of the document holder.

Document.getExpiryDate()

Return the expiry date of the document.

Document.isPassport()

Return true if this document is a passport document.

Document.isVisa()

Return true if this document is a VISA document.

Document.isIdentityCard()

Return true if this document is a national identity card document.

Document.isDrivingLicence()

Return true if this document is a driving licence document.

Document.isSupportingDocument()

Return true if this document is a supporting document.

Document.getCreatedAtDisplay()

Return the date this document was created or scanned (human-readable).

Document.hasMRZ()

Return true if this document has a machine-readable zone (MRZ).

Document.getDocumentStatus()

Return the document status of this document. Since the system maintains an operator status and an auditor status, the corresponding status with higher priority is returned. An auditor status has higher priority than an operator status but is only taken into consideration if the document has actually been audited.

Document.hasValidStatus()

Return true if the document has a valid document status (e.g. has been accepted). If the document status is currently undefined, the HasError flag is used to determine the outcome: true is returned if the document has no errors associated with it.

Document.hasWarningStatus()

Return true if the document status does not necessarily reflect an invalid status, but the document has either been rejected or no validation could be performed.

Document.getStatusDisplay()

Return the document status display text in a human-readable format.

Document.getNameComponents()

Return all non-empty components of the applicant name.

Document.getFullname()

Return the full name of the applicant based on first name, middle name and last name. Empty or undefined components of the name are omitted.

Document.getDocumentTypeDisplay()

Return the document type in human-readable format. If the document is a supporting document, return the name of the supporting document if available, otherwise default back to Supporting Document.

Document.getImageByType(imageType)

Return the first image of given type that is associated with this document.

Arguments
  • imageType (int()) – The type of image that is returned.

Document.getImageUrl()

Return the url for the primary document image for this document.

Document.getImageId()

Return the main image id for this document.

Document.getIssuingCountryDisplay()

Return the name of the issuing country of empty string.

Document.getDateOfBirthDisplay()

Return the document holder’s date of birth in a human-readable format.

Document.getGenderDisplay()

Return the document holder’s gender in a human-readable format.

Document.getNationalityDisplay()

Return the name of the nationality or empty string.

Document.getExpiryDateDisplay()

Return the document’s expiry date in a human-readable format.

Document.hasCustomFields()

Return true if this document has at least one custom field.

Document.getCustomFieldValues()

Return a list of values for all custom fields that have a value.

Document.getCustomFieldValuesDisplay()

Return all custom fields separated by commas for display purposes.

Document.hasAuditorNotes()

Return true if there are auditor notes available for this document.

Document.hasNotes()

Return true if there are general notes available for this document.