Creating the REST integration interface
5 Tasks
30 mins
Scenario
As opposed to external hotel contacts logging into the Booking application to indicate the number of rooms to reserve for an event, FSG wants those contacts to log in to the Pega Cloud™-hosted Hotel Proxy application. The Hotel Proxy application’s Rooms Request case are created by the Hotel application. The Hotel Proxy application’s Rooms Request case relays the number of reserved rooms to the Hotel application.
The following table provides the credentials you need to verify the solution:
Role | User name | Password |
---|---|---|
Admin | admin@HotelDevOnly | rules |
Admin | admin@Hotel | rules |
Admin | admin@HotelProxy | rules |
Hotel Contact | [email protected] | rules |
Hotel Contact | [email protected] | rules |
Detailed Tasks
1 Identify design options
FSG does not want the Hotel contact to access the internal Hotel application. As a result, only the required room request goes to the Hotel Proxy application, which is accessible to Hotel contacts to confirm the availability of the rooms.
The interface allows the Hotel application to create a Rooms Request Proxy case in the Hotel Proxy application for every Rooms Request case in the Hotel application. The Hotel Proxy application allows a hotel contact to confirm the number of rooms reserved in the Rooms Request Proxy case. The interface then allows the Hotel Proxy application to send the number of rooms reserved to the originating Rooms Request case in the Hotel application.
The solution can be implemented by using one of the following options:
Option 1:
Use the out-of-the-box Pega Platform™ REST API {cases POST and PUT methods} to establish a communication channel between Hotel and Hotel Proxy applications.
The following is an example of the POST JSON for creating a Rooms Request Proxy case in the Hotel Proxy application:
{"caseTypeID":"FSG-HotelProxy-Work-RoomsRequest-Proxy" ,"processID":"pyStartCase" ,"content":{ "RoomsRequest":{ "FromDate":"20190331T130944.828 GMT" ,"HotelGUID":"d8825749-e2fb-46b3-97aa-3ead12b89584" ,"pxObjClass":"FSG-Data-Hotel-RoomsRequest" ,"pyLabel":" " ,"RequestSendDate":"20190325T130944.829 GMT" ,"ResponseDeadline":"20190329T130944.829 GMT" ,"RoomsRequested":"320" ,"ToDate":"20190402T130944.829 GMT" ,"Contact":{ "pxObjClass":"Data-Party" ,"pyEmail1":"[email protected]" ,"pyEmail1Type":"HTML" ,"pyFirstName":"Tony" ,"pyLabel":" " ,"pyLastName":"Parker" } } } }
The following is an example of the PUT JSON for updating a Rooms Request Proxy case in the Hotel Proxy application:
{ "content":{ "RoomsRequest":{ "FromDate":"20190331T130944.828 GMT" ,"HotelGUID":"d8825749-e2fb-46b3-97aa-3ead12b89584" ,"pxObjClass":"FSG-Data-Hotel-RoomsRequest" ,"pyLabel":" " ,"RequestSendDate":"20190325T130944.829 GMT" ,"ResponseDeadline":"20190329T130944.829 GMT" ,"RoomsRequested":"320" ,"ToDate":"20190402T130944.829 GMT" ,"Contact":{ "pxObjClass":"Data-Party" ,"pyEmail1":"[email protected]" ,"pyEmail1Type":"HTML" ,"pyFirstName":"Tony" ,"pyLabel":" " ,"pyLastName":"Parker" } } } }
Note: Do not just copy and paste the example text into separate text files. First, use JSONLint to verify and format the JSON correctly. Then, copy and paste the corrected text into two separate text files.
Option 2:
Create a REST service in the Hotel Proxy application to create a proxy case for all the incoming room requests from the Hotel application. Create a REST service in the Hotel application to update confirmed rooms on the Rooms Request case for all the incoming requests from Hotel Proxy application.
2 Evaluate design options
Design | Pros | Cons |
---|---|---|
Use out-of-the-box Pega Platform REST API {cases POST and PUT methods} |
|
|
Create custom REST APIs in Hotel and Hotel Proxy applications |
|
|
3 Recommend the best design option
After careful study of the current business scenario, it is recommended to use the Pega Platform OOTB REST API call as it does not require lot of development effort and need to customize the response.
4 Identify required configuration tasks
To implement a solution, according to the recommended design, you would accomplish the following tasks:
- Create a REST connector for the interface between the Hotel and Hotel Proxy applications.
- Configure the REST connector with request and response.
- Create the CreateProxyCase activity in the Hotel application to invoke the REST service, which creates the case in the Hotel Proxy application.
- Create the ConfirmRooms activity in the Hotel Proxy application to invoke the REST service which updates the Rooms Request case of the Hotel application with the confirmed rooms.
5 Review solution details
The solution is implemented in the following rulesets:
- RoomsRequestCase
- RoomRequestInt
- HotelShared_20191202T192854184
- RoomsRequestProxy
Create a proxy flow in the Hotel application to invoke the REST Connector.
Confirm the Rooms flow in the Hotel Proxy application to invoke the REST Connector.
Available in the following mission:
If you are having problems with your training, please review the Pega Academy Support FAQs.
Want to help us improve this content?