diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index c236cc5c3..d39c2a141 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -19856,6 +19856,348 @@ GET https://DomainName/api/v1/search?query=000000111 + + + + +
Templates are used for end-user features such as custom user defined document generation (AKA UGD). They are based on {{ moustache }} templates. Think of them as a sort of built-in "mail merge" functionality.
+ +User Generated Documents (and other types of templates) can aggregate data from several Mifos X back-end API calls via mappers. Mappers can even access non-Mifos X REST services from other servers. UGDs can render such data in tables, show images, etc. TBD: Please have a look at some of the Example UGDs included in Mifos X (or the Wiki page, for now.).
+ +Templates can be assigned to an entity like client or loan and be of a typ like document. The entity and type of a template is only there for the convenience of user agents (UIs), in order to know where to show templates for the user (i.e. which tab). The Template Engine back-end runner does not actually need this metadata.
+Field Descriptions |
+
| name | +
| Describes the document which will be created. + It must be unique and appears listed in a tab at the assigned entity. | +
| type | +
| + For now only the type document is supported. + In a next version templates may be created for e-mails oder SMS. + | +
| entity | +
| + Indicates the primary resource reference. + Templates may be filtered by entity and type so the relevant templates may be listed at the belonging position. + | +
| text | +
| + The actual template which may be any html-text containing mustache tags. + | +
| mappers | +
| + By default one mapper is assigned to the template depending on the entity. + Mappers are used to create requests and get tags wich may be used in the template. + Also mappery are in order and may depend on the previous mappers. + For now mappers expect a response in JSON or plain/text. + JSON contains the keys and the values. + If the response is plain/text it can be accessed by {{$mapperskey.src}} + | +
This is a convenience resource. It can be useful when + building maintenance user interface screens for templates. + The template data returned consists of any or all of: +
+Example Request:
+
+GET https://DomainName/api/v1/templates/template
+
+
+{
+ "id": 1,
+ "name": "Test",
+ "entity": "loan",
+ "type": "Document",
+ "text": "This is a loan for {{loan.clientName}}",
+ "mappers": [
+ {
+ "mapperorder": 0,
+ "mapperkey": "loan",
+ "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}",
+ "id": 1
+ }
+ ]
+}
+
+ Adds a new template.
+Mandatory Fields |
+
| name | +
Example Requests:
+
+POST https://DomainName/api/v1/templates
+
+
+POST templates
+Content-Type: application/json
+Request Body:
+{
+ "id": 1,
+ "name": "Test",
+ "entity": "loan",
+ "type": "Document",
+ "text": "This is a loan for {{loan.clientName}}",
+ "mappers": [
+ {
+ "mapperorder": 0,
+ "mapperkey": "loan",
+ "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}",
+ "id": 1
+ }
+ ]
+}
+
+
+{
+ "resourceId": 1
+}
+
+ Example Requests:
++ It is also possible to get specific templates by entity and type: +
+Entity |
+ Id | +Type |
+ Id | +
| client | +0 | +Document | +0 | +
| loan | +1 | +E-Mail (not yet) | +1 | +
| + | + | SMS (not yet) | +2 | +
+GET https://DomainName/api/v1/templates
+
+
+[
+ {
+ "id": 1,
+ "name": "Test",
+ "entity": "loan",
+ "type": "Document",
+ "text": "This is a loan for {{loan.clientName}}",
+ "mappers": [
+ {
+ "mapperorder": 0,
+ "mapperkey": "loan",
+ "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}",
+ "id": 1
+ }
+ ]
+ }
+]
+
+ Example Requests:
+
+GET https://DomainName/api/v1/templates/{Id}
+
+
+{
+ "id": 1,
+ "name": "Test",
+ "entity": "loan",
+ "type": "Document",
+ "text": "This is a loan for {{loan.clientName}}",
+ "mappers": [
+ {
+ "mapperorder": 0,
+ "mapperkey": "loan",
+ "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}",
+ "id": 1
+ }
+ ]
+}
+
+
+PUT https://DomainName/api/v1/templates/{templateId}
+
+
+PUT templates/1
+Content-Type: application/json
+Request Body:
+{
+ "id": 1,
+ "name": "Test",
+ "entity": "loan",
+ "type": "Document",
+ "text": "This is a loan for {{loan.clientName}}",
+ "mappers": [
+ {
+ "mapperorder": 0,
+ "mapperkey": "loan",
+ "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}",
+ "id": 1
+ }
+ ]
+}
+
+
+{
+ "resourceId": 1
+}
+
+
+DELETE https://DomainName/api/v1/templates/{templateId}
+
+
+DELETE templates/1
+Content-Type: application/json
+No Request Body:
+
+
+{
+ "resourceId": 1
+}
+
+