PlatformApplicable to all products in Temenos Journey Manager. | Platform Developer | 21.05 This feature was introduced in 21.05.
Journey Manager comes with Fluent API enabling you to implement various complex business requirements. All you need to do is to just write a Groovy scrip that calls required API methods and run it within your service. And it all works. However, what happens when you want to invoke the same Fluent API outside Manager. Now, we have a solution for you!
The 21.05 release of Journey Manager introduced a new service (com.avoka.fc.admin.service.FluentApiService.java
) which exposes some of Manager's Fluent API via RESTREST or RESTful API design (Representational State Transfer) is designed to take advantage of existing protocols. While REST can be used over nearly any protocol, it usually takes advantage of HTTP when used for Web APIs. end points. This service is simple to understand and use and yet it provides you with ability to invoke rich in functionality Fluent API.
Now, you are probably curious to find out how it all works. Well, it's rather simple. The Fluent API REST service is included in the new Transact Manager WAR module, along with other REST services, so if you've installed or upgraded Journey Manager to the 21.05 release, you can start using the Fluent API REST service. The new service architecture is illustrated in the diagram below:
You interaction with the Fluent API REST service starts by sending a REST request. Each Fluent API class and every of its methods (operations) form a single endpoint, which you call by sending a request to a URL in the following format:
https://{SERVER}/manager/secure/rest/fluentapi/{CLASSNAME}/{OPERATION}
Where:
SERVER
is your Manager server instanceCLASSNAME
is a case-insensitive name of Fluent API class, for example, txnupdater
for the TxnUpdater
classOPERATION
is a case-insensitive name of a final method (oreration) to be called on this API, for example, update
We have chosen the combination of class names and methods to simplify the learning curve for developers, who are already familiar with our Fluent API.
You have to provide a body payload for an operation in a JSONJSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays. format, where each set
method has its own entry in the JSON payload. The Fluent API REST server processes the request and sends back a response including a response code and a payload, depending on an operation.
Let's illustrate it with a simple example. Suppose, you want to update a transaction delivery status from a Groovy script. For that, you use the TxnUpdater
class, as shown below.
import com.avoka.tm.svc.*
import com.avoka.tm.vo.*
new TxnUpdater(txn)
.setId​(733)
.setDeliveryStatus(Txn.DELIVERY_READY)
.update()
You can achieve the same result by executing this POST request with a payload:
POST https://{SERVER}/manager/secure/rest/fluentapi/txnupdater/update
Content-Type:application/json
Accept:application/json
{
"setId" : "733",
"setDeliveryStatus" : "Ready"
}
Let's examine the REST POST method:
txnupdater
is the TxnUpdater
classupdate
is the last method to be called on the instance of TxnUpdater class, which is the update ()
methodsetId
sets a transaction ID to be updated, which is the setId()
methodsetDeliveryStatus
sets the Ready status of a transaction, which is the setDeliveryStatus()
method You can see the REST method basically mimics the Fluent API call, which makes developer's life much easier.
Each Fluent API REST request has a corresponding response including an HTTP code and data in a JSON format or an error message. We've simplified and minimized the number of responses, so it's easy to use the service.
The Fluent API REST service returns the following HTTP response codes:
HTTP Code | Description |
---|---|
200 OK |
This code is returned when a Fluent API REST call is successful. |
400 Bad Request |
This code is returned when a Fluent API REST call fails due to bad input. The error message in the response includes an error log ID so you can find more details about the error in the error log. |
404 Not Found |
This code is returned when a Fluent API REST call fails trying to update or access objects that don't match provided ID. The error message in the response includes an error log ID so you can find more details about the error in the error log. |
Manager has a new REST Fluent API core permission which you must assign to roles of users who will invoke the Fluent API REST service. The Administrator role has this permission set by default. We recommend creating a dedicated user with this permission.
This release of Manager has the following CLASSNAMEs implemented:
CLASSNAME | Usage Example |
---|---|
ActionResultBuilder | |
DeliveryTxnBuilder | |
Emailer | |
GroupQuery | |
JobActionQuery | |
JobBuilder | |
JobQuery | |
JobStepQuery | |
JobUpdater | |
PaymentLogQuery | |
PropertyQuery |
|
PropertyBuilder | |
RefDataSvc | |
RefDataQuery | |
RoleQuery | |
SpaceQuery | |
SvcConnQuery | |
SvcDefQuery | |
SvcConnUpdater | |
TrackingCodeBuilder | |
TxnBuilder | |
TxnUpdater | |
TxnHistoryQuery | |
TxnQuery |
Query by ID
|
UserQuery | |
UserBuilder |
|
UserEmailer |
|
Next, learn about Fluent Groovy services.