-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
Webhooks support #291
Webhooks support #291
Conversation
Codecov Report
@@ Coverage Diff @@
## main #291 +/- ##
==========================================
+ Coverage 95.51% 96.04% +0.52%
==========================================
Files 20 21 +1
Lines 937 1138 +201
==========================================
+ Hits 895 1093 +198
- Misses 42 45 +3
|
Hi @mesozoic - thanks for doing this! I took a quick skim and it looks good to me. No imminent changes and I think it's smart to ensure additional fields do not break types/etc as the deprecation guidelines note:
|
This branch introduces models representing the webhooks API along with methods for validating notifications and for retrieving new webhook payloads. It adds the following methods and classes to the public API:
Base.add_webhook(url, spec)
Base.webhooks()
Base.webhook(id)
models.WebhookNotification
models.WebhookNotification.from_request(body, header, secret)
models.Webhook
models.Webhook.{enable,disable}_notifications()
models.Webhook.extend_expiration()
models.Webhook.payloads(cursor=1)
models.WebhookPayload
The major design decision here is to not return plain old
dict
data structures from the API, and instead to parse them into nested pydantic data models with type annotations, usingextra = "ignore"
so that it doesn't crash if Airtable adds more fields in the future.The advantage of this approach is a cleaner API and more assistance for developers who use type-aware IDEs; the disadvantage is that any new fields which Airtable adds to their API in the future will require a patch release to fully support. I've worked around this by adding a private attribute called
_raw
to every model which will be the API payload which generated the model. In a pinch, a developer could access that directly if it contains anything our models don't recognize.Tagging a few folks for input: