1272: wire up form to pardot - explore using form handler#800
Merged
Conversation
Test coverage89.57% line coverage reported by SimpleCov. |
6759479 to
d411b62
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new /api/subscriptions endpoint in editor-api that forwards subscription form submissions to a Pardot Form Handler, using heuristic response classification due to the lack of a structured provider API response.
Changes:
- Added
Api::SubscriptionsController#createto validate subscription payloads and return standardized success/error responses. - Implemented
Subscriptions::PardotFormHandlerSubmitterto POST URL-encoded payloads to a configured Pardot Form Handler endpoint and classify outcomes. - Wired up routing, CORS localhost subdomain support (dev/test), env/config, and added request/service specs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
app/controllers/api/subscriptions_controller.rb |
Adds POST handler to validate and forward subscription requests via submitter. |
app/services/subscriptions/pardot_form_handler_submitter.rb |
Adds Faraday-based submitter with heuristic success/rejection/ambiguous classification. |
config/routes.rb |
Exposes POST /api/subscriptions route. |
config/initializers/cors.rb |
Broadens dev/test localhost CORS origin matching to allow one subdomain level. |
config/application.rb |
Adds PARDOT_SUBSCRIPTION_URL config entry for the submitter endpoint. |
.env.example |
Documents PARDOT_SUBSCRIPTION_URL. |
spec/requests/api/subscriptions_spec.rb |
Adds request specs covering validation and provider error propagation. |
spec/services/subscriptions/pardot_form_handler_submitter_spec.rb |
Adds submitter unit specs covering response classification and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zetter-rpf
reviewed
Apr 30, 2026
zetter-rpf
reviewed
Apr 30, 2026
zetter-rpf
approved these changes
Apr 30, 2026
Contributor
zetter-rpf
left a comment
There was a problem hiding this comment.
This is great, just have a couple of minor questions/suggestions
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.
issue: 1272
Form Handler for Subscription form
Overview
This PR explores using a Pardot Form Handler on the backend to send subscription data via
editor-api.Key Considerations (Form Handler)
Because Pardot Form Handlers do not provide a standard, structured API response contract, editor-api has had to use heuristic response handling (status/body pattern checks). This means outcomes are inferred rather than definitively confirmed on every request, and frontend error detail is necessarily less precise than a typical JSON API integration.
How to Test (Postman)
Request
Headers:
Body (raw JSON):
{ "subscription": { "email": "teacher@example.com", "test_opt_in": true, "privacy_policy": true } }Expected Responses
200 OK→ valid request, provider accepted422 Unprocessable Content→ validation error503 Service Unavailable→ provider unavailable / not configured502 Bad Gateway→ provider response rejected or ambiguousInvalid Example
{ "subscription": { "email": "bad-email", "test_opt_in": true, "privacy_policy": false } }