ICustomerManagementPATCH Apex Interface

The ICustomerManagementPATCH interface supports extensibility for PATCH operations by allowing validation, transformation, and post-processing of update requests. Implementations can enforce business rules, adjust mutation payloads, and refine the resulting responses maintaining TMF-compliant behavior.

This interface supports the following hooks.

These hook are not used for the Customer Management API. If implemented, the method may be invoked, but its return values are ignored.

  • configureDefaultValidations
  • customiseGraphQLQuery

The following table lists common use cases and hooks required for PATCH operation.

Use CaseHook(s)Description
Example Scenarios
Benefit
Enforce Status TransitionsapplyCustomValidationsValidates requested status changes before updating the record to ensure transitions adhere to defined lifecycle rules, regulatory constraints, or business policies. Stops invalid or unauthorized state changes.• Prevent transition from InactiveActive without required approvals• Block changes to Suspended unless preconditions are met• Enforce linear lifecycle progression (e.g., PendingActive, but not ClosedActive)Prevents invalid or noncompliant state transitions and preserves data integrity
Maintain Audit TrailcustomiseMutationPayloadAutomatically enriches the update payload with audit metadata before persistence. Ensures all modifications are traceable and compliant with auditing standards.• Add “modifiedBy” and timestamp fields• Track system-initiated vs. user-initiated changes• Add audit IDs for downstream monitoring systemsProvides a complete and reliable audit trail for internal governance and external compliance needs
Validate Data FormatapplyCustomValidationsEnsures updated data—such as contact details, identifiers, or structured fields—meets required formatting rules before the update is processed. Prevents malformed or inconsistent data from entering the system.• Validate phone number format• Confirm email structure and domain correctness• Ensure address fields follow standardized formatsImproves data quality, prevents inconsistencies, and enhances downstream system reliability

This hook transforms the request context before processing any operation. It is invoked early in the request lifecycle, allowing implementers to adjust the context for subsequent extensibility hooks.

Map<String, Object> transformRequest(Map<String, Object> context)

This hook validates custom business logic before updating a customer data. If validation fails, rejects the request and returns an error response.

The handler processes return values as follows.

Success:

  • Return a map with validationStatus set to any value other than "fail" (case-insensitive).
  • The API request continues normally.
  • Other fields in the map are logged but not used.

Failure:

  • Return a map with validationStatus set to "fail" (case-insensitive).
  • The API request is terminated immediately.
  • Raise a ValidationException containing
    • message: value from validationMessage key (or "Validation failed" by default)
    • details: value from validationDetails key (optional)
  • The client receives an HTTP 400 error response.

Map<String, Object> applyCustomValidations(Map<String, Object> context)

This hook modifies the mutation payload before updating a customer record. Use this to add computed fields, transform values, or apply business logic transformations.

Map<String, Object> customiseMutationPayload(Map<String, Object> request, Map<String, Object> context)

This hook post-processes and transforms the API response after data is updated.

Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)

Here's a complete sample Apex implementation using all supported hooks.

Update mutations modify existing records and return the updated records with the specified output fields.

Original Mutation (GraphQL):

Transformation Instructions (JSON):

Result (GraphQL):

Original Mutation (GraphQL):

Transformation Instructions (JSON - Add Input Fields):

Result (GraphQL):

Transformation Instructions (JSON):

Result (GraphQL):