Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CEXT-3974/CEXT-3975: Documentation for event update and unsubscribe endpoints #307

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 87 additions & 2 deletions src/pages/events/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ The `POST /rest/<store_view_code>/V1/eventing/eventSubscribe` endpoint subscribe
}
],
"destination": "string",
"priority": true
"priority": true,
"hipaaAuditRequired": true
},
"force": true
}
Expand All @@ -48,7 +49,7 @@ After you subscribe to a `plugin-type` event, you must manually generate the mod
`Content-Type: application/json`
`Authorization: Bearer <administrator token>`

The administrator must be granted access to the `Magento_AdobeIoEventsClient::event_subscribe` resource.
The administrator must be granted access to the `Magento_AdobeCommerceEventsClient::event_subscribe` resource.

**Payload Parameters:**

Expand Down Expand Up @@ -80,6 +81,90 @@ curl -i -X POST \
'<ADOBE_COMMERCE_URL>/rest/all/V1/eventing/eventSubscribe'
```

## Update event subscriptions

The `PUT /rest/<store_view_code>/V1/eventing/eventSubscribe/<event_name>` endpoint updates an existing subscription to the specified event. The request body has the following format:

```json
{
"event": {
"parent": "string",
"fields": [
{
"name": "string",
"converter": "string"
}
],
"rules": [
{
"field": "string",
"operator": "string",
"value": "string"
}
],
"destination": "string",
"priority": true,
"hipaaAuditRequired": true
}
}
```

Field and rule configurations provided in the request body are merged with the existing field and rule configurations set for the event subscription.

**Headers:**

`Content-Type: application/json`
`Authorization: Bearer <administrator token>`

The administrator must be granted access to the `Magento_AdobeCommerceEventsClient::event_subscribe` resource.

**Payload Parameters:**

Review the [`events:subscribe` command](./commands.md#subscribe-to-an-event) to understand the possible values for each item in the request body payload.

**Example usage:**

The following cURL command updates an `observer.catalog_category_save_after` event subscription. This update adds the `parent_id` field to the existing list of subscribed fields and sets standard priority for the event.

```bash
curl -i -X PUT \
-H "Content-Type:application/json" \
-H "Authorization:Bearer <AUTH_TOKEN>" \
-d \
'{
"event": {
"name": "observer.catalog_category_save_after",
"fields": [
{
"name": "parent_id"
}
],
"priority": false
}
}' \
'<ADOBE_COMMERCE_URL>/rest/all/V1/eventing/eventSubscribe/observer.catalog_category_save_after'
```

## Unsubscribe from events

The `POST /rest/<store_view_code>/V1/eventing/eventUnsubscribe/<event_name>` endpoint unsubscribes from the specified event.

**Header:**

`Authorization: Bearer <administrator token>`

The administrator must be granted access to the `Magento_AdobeCommerceEventsClient::event_unsubscribe` resource.

**Example usage:**

The following cURL command unsubscribes from the `observer.catalog_category_save_after` event.

```bash
curl -i -X POST \
-H "Authorization:Bearer <AUTH_TOKEN>" \
'<ADOBE_COMMERCE_URL>/rest/all/V1/eventing/eventUnsubscribe/observer.catalog_category_save_after'
```

## Configure Commerce eventing

The `PUT /rest/<store_view_code>/V1/eventing/updateConfiguration` endpoint updates the Adobe I/O [eventing configuration](configure-commerce.md) originally defined on the **Stores** > Settings > **Configuration** > **Adobe Services** > **Adobe I/O Events** > **General configuration** page of the Admin.
Expand Down
Loading