feat(coupons): add lifecycle webhooks - #6306
Open
avanish-garg wants to merge 1 commit into
Open
Conversation
coupon.created/updated/deleted webhook event names already existed
(added for activity logs), but nothing ever fired them -- sibling
catalog resources Plan/BillableMetric/Feature all fire webhooks on
create/update/destroy, Coupon didn't.
Adds Webhooks::Coupons::{Created,Updated,Deleted}Service mirroring
the existing BillableMetrics webhook services, registers them in
SendWebhookJob::WEBHOOK_SERVICES, and wires the SendWebhookJob calls
into Coupons::{Create,Update,Destroy}Service.
Welcome, @avanish-garg!Thanks for your first contribution! Before we proceed with the review, please sign the Fiduciary License Agreement: Once signed, this PR will be automatically updated. |
Thanks, @avanish-garg! 🎉Your CLA has been signed and is now on file. We'll proceed with the review shortly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6307
Problem
Couponlifecycle (create/update/destroy) never fires webhooks, unlike sibling catalogresources
Plan,BillableMetric, andFeature, which all fire*.created/*.updated/*.deletedwebhooks. The
coupon.created/coupon.updated/coupon.deletedevent names already existed --added for activity logs (
app/services/coupons/{create,update,destroy}_service.rb'sactivity_loggablecalls) -- but the webhook half of that parity was never done.Change
Webhooks::Coupons::{Created,Updated,Deleted}Service, mirroring the existingWebhooks::BillableMetrics::*Serviceclasses exactly.SendWebhookJob::WEBHOOK_SERVICES.SendWebhookJob.perform_after_commitcalls intoCoupons::CreateService,Coupons::UpdateService, andCoupons::DestroyService, the same wayBillableMetrics::CreateService/UpdateService/DestroyServicealready do (nosend_webhook:suppression flag needed --BillableMetric, the closer sibling incomplexity, doesn't have one either; only
Plandoes, for its more complex async-destroyflow).
existing
Coupons::{Create,Update,Destroy}Servicespecs, and a new context in thedispatcher-level
send_webhook_job_spec.rb.Purely additive wiring -- no billing/pricing math touched.
Verified
spec/services/coupons/*_service_spec.rb,spec/services/webhooks/coupons/*_spec.rb,spec/jobs/send_webhook_job_spec.rb) againsta real Postgres (
getlago/postgres-partman:15.0-alpine, matching CI) + Redis environment.