From 5510a408b788a874300714c4f9cc18672e7f9397 Mon Sep 17 00:00:00 2001 From: Andreas Weigel Date: Thu, 26 Sep 2013 16:05:33 +0200 Subject: [PATCH 1/2] added api documentation --- api-docs/apiLive.htm | 339 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index c236cc5c3..bfae1e325 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -19856,6 +19856,345 @@ GET https://DomainName/api/v1/search?query=000000111 + + + +   +
+
+

Templates

+

Templates are for custom document generation.

+

Templates can be assigned to an entity like client or loan and be of a typ like document .

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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}} +
+
+
+ +   +
+
+

Retrieve Template Details Template

+

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: +

+
Arguments
+
+
name
+
+ String +
+
entity
+
+ String +
+
type
+
+ String +
+
text
+
+ String optional +
+
mappers
+
+ Mapper optional +
+
+

Example Request:

+
templates/template
+
+
+ +GET https://DomainName/api/v1/templates/template + + +{ + "id": 1, + "name": "Test", + "entity": "loan", + "type": "Document", + "text": "This is a text with a {{mustache.tag}} ", + "mappers": [ + { + "mapperorder": 0, + "mapperkey": "loan", + "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}", + "id": 1 + } + ] +} + +
+
+ +   +
+
+

Add a Template

+

Adds a new template.

+ + + + + + + +
Mandatory Fields
name
+

Example Requests:

+
templates/1
+
+
+ +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 text with a {{mustache.tag}} ", + "mappers": [ + { + "mapperorder": 0, + "mapperkey": "loan", + "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}", + "id": 1 + } + ] +} + + +{ + "resourceId": 1 +} + +
+
+ +   +
+
+

Retrieve all Templates

+ +

Example Requests:

+
templates
+
+

+ It is also possible to get specific templates by entity and type: +

+
templates?type=0&entity=0
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Entity
Id
Type
Id
client0Document0
loan1E-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 text with a {{mustache.tag}} ", + "mappers": [ + { + "mapperorder": 0, + "mapperkey": "loan", + "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}", + "id": 1 + } + ] + } +] + +
+
+ +   +
+
+

Retrieve a Template

+

Example Requests:

+
templates/1
+
+
+ +GET https://DomainName/api/v1/templates/{Id} + + +{ + "id": 1, + "name": "Test", + "entity": "loan", + "type": "Document", + "text": "This is a text with a {{mustache.tag}} ", + "mappers": [ + { + "mapperorder": 0, + "mapperkey": "loan", + "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}", + "id": 1 + } + ] +} + +
+
+ +   +
+
+

Update a Template

+
+
+ +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 text with a {{mustache.tag}} ", + "mappers": [ + { + "mapperorder": 0, + "mapperkey": "loan", + "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier={{tenantIdentifier}}", + "id": 1 + } + ] +} + + +{ + "resourceId": 1 +} + +
+
+ +   +
+
+

Delete a Template

+
+
+ +DELETE https://DomainName/api/v1/templates/{templateId} + + +DELETE templates/1 +Content-Type: application/json +No Request Body: + + +{ + "resourceId": 1 +} + +
+
+ + + + + + + + + + From bebcea8c4220fdc17efc4627cb67080254043ac9 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sat, 12 Oct 2013 15:14:10 +0200 Subject: [PATCH 2/2] GSoC UGD API Doc: Some more intro. blurb, plus minor changes to better illustrate the idea of placeholders in Moustache templates by using concrete loan.* instead abstract {{moustache.tag}} --- api-docs/apiLive.htm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index bfae1e325..d39c2a141 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -19863,8 +19863,11 @@ GET https://DomainName/api/v1/search?query=000000111

Templates

-

Templates are for custom document generation.

-

Templates can be assigned to an entity like client or loan and be of a typ like document .

+

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.

@@ -19963,7 +19966,7 @@ GET https://DomainName/api/v1/templates/template "name": "Test", "entity": "loan", "type": "Document", - "text": "This is a text with a {{mustache.tag}} ", + "text": "This is a loan for {{loan.clientName}}", "mappers": [ { "mapperorder": 0, @@ -20007,7 +20010,7 @@ Request Body: "name": "Test", "entity": "loan", "type": "Document", - "text": "This is a text with a {{mustache.tag}} ", + "text": "This is a loan for {{loan.clientName}}", "mappers": [ { "mapperorder": 0, @@ -20078,7 +20081,7 @@ GET https://DomainName/api/v1/templates "name": "Test", "entity": "loan", "type": "Document", - "text": "This is a text with a {{mustache.tag}} ", + "text": "This is a loan for {{loan.clientName}}", "mappers": [ { "mapperorder": 0, @@ -20111,7 +20114,7 @@ GET https://DomainName/api/v1/templates/{Id} "name": "Test", "entity": "loan", "type": "Document", - "text": "This is a text with a {{mustache.tag}} ", + "text": "This is a loan for {{loan.clientName}}", "mappers": [ { "mapperorder": 0, @@ -20144,7 +20147,7 @@ Request Body: "name": "Test", "entity": "loan", "type": "Document", - "text": "This is a text with a {{mustache.tag}} ", + "text": "This is a loan for {{loan.clientName}}", "mappers": [ { "mapperorder": 0,
Field Descriptions