Hey guys,
I've been setting my site up with a few webhook endpoints and the way webhook requests are currently sent is leading to having to write a _lot_ of code (including unnecessary requests back to the BreweryDB API) for reasons that seem, to me, easily solvable. One of those reasons? A lack of context surrounding a given "subAction". An easy example:
1. Receive a webhook request:
{
"attribute": "beer",
"attributeId": "hELlo",
"action": "edit",
"subAction": "socialaccount-delete"
}
2. Hit BreweryDB's API at /beer/hELlo/socialaccounts
3. Iterate over beer hELlo's social accounts locally, destroying any whose ID did not appear in the data set from above.
4. Repeat this sort of logic for every sub action (except alternate names, which I just store as an array directly on a Brewery).
It seems to me that, given an ID corresponding to the sub-action, this would be much easier and require fewer API requests to you. The same example:
1. Receive a webhook request:
{
"attribute": "beer",
"attributeId": "hELlo",
"action": "edit",
"subAction": "socialaccount-delete",
"subId": "aE4rF"
}
2. Find social account aE4rF locally, destroy it.
I love BreweryDB so far, but the webhooks really leave something to be desired. I understand the desire for allowing users to handle data updates their own way, but you can still do that by providing more context behind updates.
Thanks for reading!