DocumentService

This class is responsible of fetching the documents from the server. It is configured by an object containing the server URL and routes.

Constructor

new DocumentService(requestService, configServer)

Constructs a new document service.

Parameters:
NameTypeDescription
requestServiceRequestService

The request service.

configServerobject

The server configuration.

Properties
NameTypeAttributesDescription
urlstring

The server url.

documentstring

The base route for documents.

filestring

The route for document files.

authenticateboolean<optional>

If authentication should be used for the request.

Classes

DocumentService

Members

authenticate :boolean

If authentication should be used for the request.

Type:
  • boolean

documents :Array.<Document>

The list of documents.

Type:

requestService :RequestService

The request service.

Type:
  • RequestService

source :DocumentSource

The object that defines the server URLs to fetch documents.

Methods

(async) fetchDocumentImage(doc) → {string}

Fetches the image corresponding to the given document.

Parameters:
NameTypeDescription
docDocument

The document to fetch the image.

Returns:

The data string of the image.

Type: 
string

(async) fetchDocuments() → {Promise.<Array.<Document>>}

Fetches the documents from the server and return them in an array.

Returns:

A promise with an array of fetched documents

Type: 
Promise.<Array.<Document>>

setSource(docSource, authenticateopt) → {DocumentSource}

Sets the source of documents.

Parameters:
NameTypeAttributesDefaultDescription
docSourceDocumentSource

The document source.

authenticateboolean<optional>
false

Specifies if authentication should be used to fetch documents.

Returns:

The previous source.

Type: 
DocumentSource