create

suspend fun create(systemOfRecordData: DataItem, configName: String): CredentialDisplay

Creates CredentialDisplay using credential data and the name of the configuration parameter that describes how title and card art should be generated.

Server configuration is queried for the parameter given in configName. It must be a JSON object. If the parameter is not given or JSON object does not contain value "title", a CredentialDisplay with the title "Untitled" is returned.

Otherwise the value of the title is used to create title string, dot-separated names in curly brackets are substituted with the content of the fields in systemOfRecordData.

If "cardArt" value is present and is an object, it is used to create card art. The following values are used:

  • blank: name of the resource image that contains blank image of this document

  • if blank is not given, width (default 810) and height (default 510) define the size of the drawing area that will start up as fully transparent.

  • content: array of drawing commands

Drawing commands are identified by their operation name encoded in the field named op. The following operations and their parameters are supported:

  • text - draws text, parameters defined in Canvas.drawText, and also:

    • field text holds the text to draw, dot-separated names in curly brackets are substituted with the content of the fields in systemOfRecordData.

  • rect - draws rectangle, parameters defined in Canvas.drawRect

  • image - draws image, parameters defined in Canvas.drawImage, and also

    • field - dot-separated names of the fields to find image data in systemOfRecordData

    • image - name of the image from the resources if image data is missing or field is not given

Return

new CredentialDisplay

Parameters

systemOfRecordData

data that was used to create the credential

configName

name of the server configuration parameter that hold the definition of the card art drawing