Expanding the Headless Admin User API

Introduction:

In a bid to improve our services, the Headless Admin User API has undergone significant enhancements. Specifically, we have expanded our API to include POST, PUT, DELETE, and PATCH endpoints for managing postal addresses associated with user accounts. This development aims to provide more comprehensive functionality and greater flexibility for our users. Additionally, we've made crucial changes to the UserAccount schema and related methods to allow users to manage user status efficiently.

 

GET Method Modification:

 

The endpoint /headless-admin-user/v1.0/accounts/{accountId}/postal-addresses has been modified.

The GET method now retrieves the phoneNumber from the postal Address, adding more data accessibility.

 

POST Method Creation:

 

A new POST method has been introduced at /headless-admin-user/v1.0/accounts/{accountId}/postal-addresses for creating postal addresses.

The Postal Address schema, as defined in the YAML, includes fields such as addressCountry and addressRegion, which are linked to Country and Region entities respectively.

To create these entities, it is required to retrieve the country and region through their titles.

Additionally, the addressType field can have values such as billing-and-shipping, billing, or shipping, which are defined in the database and are related to the ListType entity. These values must match existing values in the database.

 

PUT and PATCH Methods Creation:

 

PUT and PATCH methods have been created to update postal addresses.

The URL structure for these methods remains /headless-admin-user/v1.0/accounts/{accountId}/postal-addresses/{postalAddressId}.

To ensure data integrity, several validations have been implemented:

Checking the existence of the postal address with the provided ID.

Verifying if the postal address is associated with the specified account.

Validating the existence of the country and region based on their titles.

Ensuring that the provided address type matches the predefined values.

 

DELETE Method:

 

The DELETE method operates on a pattern: /v1.0/organizations/{organizationId}/accounts.

It takes the accountId as a parameter and a requestBody containing postalAddressId(s).

The following validations are performed:

Checking if a Postal Address with the given ID exists.

Verifying if the Postal Address is associated with the Account.

If all validations pass, the Postal Address is deleted. However, if any postalAddressId in the list is invalid, an exception is returned, and no entries will be deleted.

 

Note:

Country, Region, and Type fields must already exist; they are not created through these methods.

 

UserAccount Status Management:

 

The schema of UserAccount has been updated to include a 'status' parameter with values:

  • Active

  • Inactive

The method putUserAccount in the class UserAccountResourceImpl.java has been modified to parse:

  • Active → WorkflowConstants.STATUS_APPROVED

  • Inactive → WorkflowConstants.STATUS_INACTIVE

 

It's important to note that to change the status of users, especially if you have an active workflow for the user, you should use the workflow Headless API (headless-admin-workflow).

 

Changes Made:

 

  • Added 'status' to the UserAccount schema.

  • Built REST for status updates.

  • Active status is now assigned as STATUS_APPROVED, and Inactive status as STATUS_INACTIVE.

  • Any other value will return an exception, following a pattern used in the portal.

  • The method description now emphasizes that to change user statuses, particularly with an active workflow, the workflow Headless API (headless-admin-workflow) should be used.
     

In the endpoint /user-accounts/{userAccountId}, both the PUT and PATCH methods can now update the status of the user, with the same emphasis on using the workflow Headless API for workflow-related status changes.

 

These comprehensive enhancements to the Headless Admin User API not only provide more flexibility for managing postal addresses but also streamline the management of user statuses, ensuring a smoother user experience.

 

This feature will be available in the upcoming Q4 quarterly release.