Skip to content

Commit 4bb3fde

Browse files
authored
Merge pull request AdobeDocs#101 from ryanjcohen/webhooks-converters-from-external
CEXT-2455: fromExternalFormat method in converter classes
2 parents dbcb542 + be3f27f commit 4bb3fde

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pages/webhooks/hooks.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ The following example configures the webhook described above.
138138

139139
You can implement a converter class to convert a field to a different data type. For example, Commerce stores order IDs as numeric values. If the hook endpoint expects order IDs to be text values, you must convert the numeric value to a string representation before sending the payload.
140140

141-
All converter classes must implement `Magento\AdobeCommerceWebhooks\Model\Filter\Converter\FieldConverterInterface`.
141+
All converter classes must implement `Magento\AdobeCommerceWebhooks\Model\Filter\Converter\FieldConverterInterface`. The `toExternalFormat` method of a converter class converts a field value before sending a request to the hook endpoint.
142142

143143
```xml
144144
<fields>
@@ -147,6 +147,10 @@ All converter classes must implement `Magento\AdobeCommerceWebhooks\Model\Filter
147147
</fields>
148148
```
149149

150+
A converter class can also convert the value in a hook endpoint response object that has an operation status of `replace`. A value in a `replace` response object will be converted only if the path in the object corresponds to the source of a field with a configured converter class.
151+
152+
For example, given the above hook field configuration, conversion occurs only if a `replace` response object specifies a path of `data/order/status`. In this case, the `fromExternalFormat` method of the configured converter class will be called to convert the value in the response object.
153+
150154
### Context fields
151155

152156
You can add to the webhook payload values from the application context:

0 commit comments

Comments
 (0)