Producing Clarity’s Object APIs
Liferay simplifies API creation with automatically generated APIs for objects. Clarity's distributor management app requires integration with a third-party partner’s APIs for Know-Your-Customer (KYC) reporting. Upon successful validation of a business entity, the third party service sends a PATCH request with the following sample payload:
With this payload documentation, Clarity's developers designed a Liferay Object aligning with the required KYC structure to leverage the produced APIs.
In these exercises, you’ll learn how to create APIs through Liferay Objects and leverage those APIs to interact with incoming webhook calls.
Exercise: Producing Clarity’s Distributor Validation APIs
Here, you’ll produce distributor validation APIs by creating an object aligning with Clarity’s KYC partner’s payloads.
-
Sign in as the Clarity Admin user.
-
Username:
admin@clarityvisionsolutions.com
-
Password:
learn
-
-
Open the Global Menu ([INSERT ICON]), go to the Control Panel tab, and click Objects.
-
Click on the Distributor Management folder and select View in Model Builder.
-
Click Create New Object.
-
Enter these details
Field Value Label Distributor Validation
Plural Name Distributor Validations
Object Name DistributorValidation
-
From the Model Builder UI, select the Distributor Validation object.
-
Click Actions (
) and select Edit ERC.
-
Enter
D4B8_DISTRIBUTOR_VALIDATION
and click Save. -
In the right side panel, configure these settings:
Field Value Scope Company Panel Link Applications > Content Show Widget in Page Builder No Enable Comments in Page Builder Yes Enable Indexed Search No
Now that you’ve created and configured the distributor validation object, you’ll create fields conforming to the third-party’s PATCH request structure
-
For the Distributor Validation object, click Add Field or Relationship, and select Add Field.
-
Enter these values and click Save.
Field Value Label Business Legal Name
Field Name businessLegalName
Type Text Enable Entry Translation No Mandatory No Accept Unique Values Only No -
Click Add Field or Relationship, and select Add Field.
-
Enter these values and click Save.
Field Value Label Validated Tax ID
Field Name validatedBusinessEIN
Type Text Enable Entry Translation No Mandatory No Accept Unique Values Only No
This esures the headless API schema can ingest validatedBusinessEIN data sent by the third party service, while the field’s label remains consistent with Liferay’s applications UI and broad support of a variety of different tax id formats.It's a best practice to finalize fields and configurations before publishing objects. To expedite these exercises, you'll automate populating the remaining fields in a later step. -
From the Model Builder UI, click Publish.
-
Check Distributor Validation and click Publish Objects.
-
Navigate to the API Explorer at http://localhost:8080/o/api
-
In the upper right, select REST Applications > c/distributorvalidations
This displays the list of APIs generated when publishing the object, including its batch endpoints. -
Scroll to the bottom of the page and expand the DistributorValidation schema to verify that the
businessLegalName
andvalidatedBusinessEIN
fields are represented.
-
Open a terminal and navigate to the
/client-extensions/distributor-validator-batch
folder in your course workspace. -
Run this command to build and deploy the batch client extension:
This finishes configuring the object definition, defines its relationships, and populates initial data.
-
Verify it deploys successfully.
-
In your Liferay instance, open the Global Menu ([INSERT ICON]), go to the Control Panel tab, and click Objects.
-
Click on the Distributor Management folder and select Distributor Application.
-
Within the Relationships tab, verify that the Application to Validations one to many relationship (one Distributor Application to many Distributor Validations) was created.
-
Navigate back to the Distributor Management folder and select Distributor Validation.
-
Within the Fields tab, verify that the following fields were created:
-
Business Type
-
Verification Status
-
Credit Score
-
Credit Risk Level
-
-
Navigate to the API Explorer at http://localhost:8080/o/api
-
In the upper right, select REST Applications > c/distributorapplications
-
Expand the
getDistributorApplicationApplicationToValidationsDistributorValidationPage
endpoint.
-
Enter 63247 within the
distributorApplicationId
field. -
Click Execute.
This returns information about existing distributor validations tied to an application for the applicant ID of 63247, including verification statuses, ERCs, and other related fields.
Great! You’ve set up Clarity’s Distributor Validation object to leverage the third-party PATCH request’s payload and reviewed the object’s automatically generated APIs.
Exercise: Updating Clarity’s Application Layout
Clarity’s Distributor Application object has a custom object layout defined, but it does not yet include the newly created relationship. Here, you’ll modify this layout to include distributor validations.
-
Open the Global Menu (
), go to the Control Panel tab, and click Objects. -
Click on the Distributor Management folder and select Distributor Application.
-
On the Layouts tab, select Basic Layout.
-
On the Layout tab, select Add Tab.
-
Enter these values and click Save.
Field Value Label Validations Type Relationships Relationship Application to Validations
Great! You can now view and edit Distributor Validation records while viewing their corresponding Distributor Application.
Exercise: Simulating Clarity’s Application Validations
With the Distributor Validation APIs populated, the system is ready to handle incoming validations. For each request, Clarity sends data to the third-party solution in the following format:
When received, the third party system replies with a response similar to the following:
As submission validations take an indeterminate amount of time, the third party assigns a “trace” number for each submission. Clarity sets this trace as the ERC of the submitted validation’s object entry, which associates incoming API calls from the third party with the appropriate distributor information.
In this exercise, you’ll simulate incoming PATCH requests from the third party service to the callbackURL
from the original request.
-
Navigate to the API Explorer at http://localhost:8080/o/api
-
In the upper right, select REST Applications > c/distributorvalidations
-
Expand the
patchByExternalReferenceCode
endpoint.
-
Set
j8p8he2a-e7a4-4919-b003-957b39b14f65
for theexternalReferenceCode
parameter. -
Remove the existing sample content from the Request body field.
-
Copy and paste the following JSON payload into the Request body field.
-
Click Execute.
-
Validate that a 200 response code and request URL are displayed under Responses.
For non-simulated distributor validations, API calls with a similar JSON payload will be submitted directly to Clarity. This is made using request URLs with the same structure displayed on this page with the appropriate ERC for the submitted validation. -
Expand the
getByExternalReferenceCode
endpoint. -
Set
j8p8he2a-e7a4-4919-b003-957b39b14f65
for theexternalReferenceCode
parameter. -
Review the server response contents to verify that the payload information from step 6 is now reflected within the sample user’s distributor validation.
Conclusion
Congratulations! You’ve created no-code APIs through Clarity’s Distributor Validations object and explored receiving webhook responses from third parties using its mapped field values and associated APIs.
Next, you’ll learn about producing custom APIs with fine-grained control over endpoints and business logic.
Capabilities
Product
Education
Contact Us