Problem:
Coupon lifecycle (create/update/destroy) never fires webhooks, unlike sibling catalog
resources Plan, BillableMetric, and Feature, which all fire .created/.updated/.deleted
webhooks. External integrations have no way to be notified when a coupon is created,
updated, or deleted.
The coupon.created/coupon.updated/coupon.deleted event names already exist in the
codebase -- they were added for activity logs (app/services/coupons/{create,update,destroy}_service.rb's
activity_loggable calls) -- but the webhook half of that parity was never done. There are
zero coupon. entries in SendWebhookJob::WEBHOOK_SERVICES.
Solution:
Add Webhooks::Coupons::{Created,Updated,Deleted}Service, mirroring the existing
Webhooks::BillableMetrics::*Service classes, register them in
SendWebhookJob::WEBHOOK_SERVICES, and fire them from Coupons::{Create,Update,Destroy}Service
the same way Plans/BillableMetrics services already do.
Alternatives:
N/A -- this mirrors an existing, already-proven pattern used by three other catalog
resources; no new architecture needed.
Additional context:
Opened a PR with the implementation, verified against a real Postgres+Redis test
environment (101 RSpec examples passing, rubocop clean): #6306
Problem:
Coupon lifecycle (create/update/destroy) never fires webhooks, unlike sibling catalog
resources Plan, BillableMetric, and Feature, which all fire .created/.updated/.deleted
webhooks. External integrations have no way to be notified when a coupon is created,
updated, or deleted.
The coupon.created/coupon.updated/coupon.deleted event names already exist in the
codebase -- they were added for activity logs (app/services/coupons/{create,update,destroy}_service.rb's
activity_loggable calls) -- but the webhook half of that parity was never done. There are
zero coupon. entries in SendWebhookJob::WEBHOOK_SERVICES.
Solution:
Add Webhooks::Coupons::{Created,Updated,Deleted}Service, mirroring the existing
Webhooks::BillableMetrics::*Service classes, register them in
SendWebhookJob::WEBHOOK_SERVICES, and fire them from Coupons::{Create,Update,Destroy}Service
the same way Plans/BillableMetrics services already do.
Alternatives:
N/A -- this mirrors an existing, already-proven pattern used by three other catalog
resources; no new architecture needed.
Additional context:
Opened a PR with the implementation, verified against a real Postgres+Redis test
environment (101 RSpec examples passing, rubocop clean): #6306