Response Mappers

Response mappers are critical for any API, with the sole purpose of converting the external API response to the Gravity Standard Response Format.

This makes all relevant data available for every subsequent step within an app, and is accomplished with the Response Mapper utility.

Response Type

The first step is to define the data type that is returned by the API, which allows automation to convert it to the standard camelCase JSON format used throughout Gravity. In most cases, you can leave it on Auto-detect, but you can set it manually as needed.

Error Detection

Error detection is critical, as many API responses report on errors differently. Each type of error outlined allows you to write a code snippet to extract the error from the response and return the error properly.

Example Error Handling

Resource Extraction

If the data is nested or structured in an unusual way, here you can configure where the resource data is located and adjust the configuration as needed. See the example below with the data returned properly.

Code

If you need to make further adjustments to the mapper to account for additional edge cases, you can edit a code snippet here.

Data Types

If the API response handles primitive datatypes in an unusual way (including country), you can account for that here with custom code.

Example Data Type Mapping

Here you can see an example of converting an arbitrary date format to the standard JS ISO date format.

Custom Code Response Mappers

Some older apps have custom code response mappers, which are still supported but are now deprecated. If you delete the existing custom code mappers within an App, it will enable the new Response Mapper system as above.