Extensions and Configuration
R24 AMR | Min(s) read

Creating a Published API

Published APIs provide the following REST resources: Login, Logout, Add API, Update API, Remove API, Copy an API and Validation roles.

An API defined in Swagger 2.0 may be imported into an API project. The import process will create the Camel routes, mock responses and wire the routes to the mock responses. This is done using a Maven plugin, either from your IDE or from the command line.

When you access any API other than the login and logout APIs through an external REST client, first invoke the login API to ensure that user is authenticated. When the login API is invoked, the system stores the generated session cookie in a file, which is used in the next API invocations.

Importing the Publisher API Specification

You need to import a Swagger API specification into the workbench and generate the Publisher API using the following procedure.

  1. Select APIs > Import API Definition.

    Creating a Published API

  2. Select the publisher Swagger definition (Swagger JSON file) that you want to import and then click Upload.

    Import PublisherAPI

  3. In Service id enter a name for the service.

    Importing the Publisher API

  4. Click Upload & Generate.

  5. Download and extract the zip and place the generated files in the service project.

  6. Refresh the project view and verify the project structure.

    Importing the Publisher API

Mapping the Provider API to the Published API

You can map the path parameters from Provider API to Published API using the following procedure.

  1. Use the direct.published.PublishedPaymentStatusReport route to map the existing PSD2.getPaymentTransferList Provider services. Add the highlighted line to map path parameters. Example:
    <rest path="/v1.0.0/published" produces="application/json" id="published.service.restlet">
       <get uri="/payments/{accountid}/statusreport" id="PublishedPaymentStatusReport">
          <param name="accountid" type="path" required="true"/>
          <to uri="direct:published.PublishedPaymentStatusReport"/>
       </get>
    </rest>
    ...
    <route id="direct.published.PublishedPaymentStatusReport">
       <from uri="direct:published.PublishedPaymentStatusReport"/>
       <to uri="direct-vm:order-PSD2.getPaymentTransferList" />
       <process ref="FTStatusReportResponseMapper"/>
    </route>

    Use the direct-vm method in Camel to route all the Publisher path parameters, Camel context and the properties to the underlying Provider API.

  2. Save all the files, and build the publisher API project as Maven > Install.

    Sample Publisher routes for the reference are given below.

Sample Publisher routes

Additional Beans before the CamelContext tag

...
<bean id="FTInitiationRequestMapper" class="com.temenos.irf.published_FT_api.FTInitiationRequestProcessor"/>
<bean id="FTInitiationResponseMapper" class="com.temenos.irf.published_FT_api.FTInitiationResponseProcessor"/>
<bean id="FTStatusReportResponseMapper" class="com.temenos.irf.published_FT_api.FTStatusReportResponseProcessor"/>
<bean id="FTSubmissionResponseMapper" class="com.temenos.irf.published_FT_api.FTSubmissionResponseProcessor"/>

Published FT status report route

...
<get uri="/payments/{accountid}/statusreport" id="PublishedPaymentStatusReport">
   <param name="accountid" type="path" required="true"/>
   <to uri="direct:published.PublishedPaymentStatusReport"/>
</get>
...
<route id="direct.published.PublishedPaymentStatusReport">
   <from uri="direct:published.PublishedPaymentStatusReport"/>
   <to uri="direct-vm:order-PSD2.getPaymentTransferList" />
   <process ref="FTStatusReportResponseMapper"/>
</route>

Published FT Initiation Route

...
<post uri="/payments/transfer/initiation" id="PublishedPaymentTransferInitiation">
   <to uri="direct:published.PublishedPaymentTransferInitiation"/>
</post>
...
<route id="direct.published.PublishedPaymentTransferInitiation">
   <from uri="direct:published.PublishedPaymentTransferInitiation"/>
   <process ref="FTInitiationRequestMapper"/>
   <to uri="direct-vm:order-PSD2.getPaymentTransferList" />
   <process ref="FTInitiationResponseMapper"/>
</route>

Published FT Submission Route

...
<post uri="/payments/transfer/{id}/submission" id="PublishedPaymentTransferSubmission">
   <param name="id" type="path" required="true"/>
   <to uri="direct:published.PublishedPaymentTransferSubmission"/>
</post>
...
<route id="direct.published.PublishedPaymentTransferSubmission">
   <from uri="direct:published.PublishedPaymentTransferSubmission"/>
   <to uri="direct-vm:order-PSD2.getPaymentTransferList" />
   <process ref="FTSubmissionResponseMapper"/>
</route>

The request and response mappers configured will have Java code to transform from publisher JSON format to provider JSON and vice versa.

Automatic Generation of Publisher API

This feature automates the generation of swagger models which is required for creating Published API. It provides the solution to generate the models for the Published API and to be able to pack it with Swagger and service.xml, which in turn can be downloaded as a zip file from Workbench.

Below screen capture shows the overview of the solution and the component level interactions.

Importing the Publisher API

Copyright © 2020- Temenos Headquarters SA

Published on :
Friday, May 31, 2024 10:44:31 AM IST