In the Previous Post Part 1, we saw how to get the API key from clash of clans and use it in postman to get the response.
In this Post , we will use the details from postman and create a integration in Pega.
Integration was always a difficult topic for me , there is so many topics around it (authorization, authentication, data model , integration layer ,connection time out, certificate failure) which makes it look like a nightmare. All the terms which developers use for while working integration like Parsing , converting Json/XML , Request DT , Response DT , Mapping makes it more complicated to understand the topic.
I am going to learn one at a time and write a post about it for my future reference here. This Post will help me to understand the basic of integration and how Pega helps in creating the most of the rules required for integration.
Why do we need integration ?
For example : Consider two web applications which is already built in Java and Python. Now if you need data from One application to another which does not understand each other, then Integration is the way to connect to these two systems.
There are two types of rules in Pega which helps in integrating two applications. (another confusing terminology)
Connector - When you need some data , you create a connector to get the data. (Get Data - connector)
Service - when you need to give data , you create a service to give the data.(Give Data - Service)
Which API are gonna be used?
From the list of operations , I have selected two simple operations.
- To get information about all the locations
- To get the information about the player rankings for a specific location (For you to try)
Requirement in Pega :
Create two dropdown , one to fetch the list of location . After selecting location , pass the location to get the list of Player ranking
First lets create the integration rules then create a section to display to location and player list.
Open designer studio and Navigate to Create Rest Integration
There are 4 screens which needs to be completed.
First screen:
Provide the name : COC ("Clash of clans") and End point URL : https://api.clashofclans.com/v1/locations
Since we are using token as authentication type , we don’t need a separate authentication profile instead we can pass the token as header (reference postman).
Second screen: Provide Resource name and select the method you want to use for this integration. (For eg Get Method , Reference from postman)
Third screen: One of the important screen, where our Data model for our integration is determined. Also we can check if our integration works too.
Two options to add the data model :1) Either you can add the REST response from postman 2) Trigger the integration and get the response .
I am going with option 2 , Add a REST response . In the header , Authorization field provide the token copied from postman and click run.
Forth Screen : Another important screen , whether the class structure is defined.
Make sure for Integration layer , Int class is selected as Parent class and the context as Integration ruleset.
Make sure for Data layer , Data class is selected as Parent class and the context as Application ruleset.
If required Preview records and Click create . Please find the list of rules Pega has created below
- Datapage
- Connect Rest
- Class required for Integration
- Property required for integration
- Response Data transform
- Request Data transform
Now Provide the dropdown source as Datapage and check if results are populated.
Food for thought : Similarly , Now you can try to create the next integration ( To get the information about the player rankings for a specific location) to pass the location and get the list of players ranking.
Post a Comment