Skip to content

Commit ae0e406

Browse files
committed
feat: conform the payload we send to form handler
1 parent 72dc376 commit ae0e406

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/services/subscriptions/pardot_form_handler_submitter.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(endpoint_url:)
1717
def call(form_payload:)
1818
return missing_configuration_result if endpoint_url.blank?
1919

20-
response = faraday.post(endpoint_url, form_payload)
20+
response = faraday.post(endpoint_url, provider_payload(form_payload))
2121
Rails.logger.info(
2222
"[subscriptions#provider] status=#{response.status} " \
2323
"location=#{redirect_location(response)} " \
@@ -55,6 +55,14 @@ def missing_configuration_result
5555
)
5656
end
5757

58+
def provider_payload(form_payload)
59+
# Map internal API contract to Pardot Form Handler external field names.
60+
{
61+
'email' => form_payload['email'],
62+
'Tester' => form_payload['test_opt_in']
63+
}.compact
64+
end
65+
5866
def classify_response(response)
5967
return reject_result unless SUCCESS_STATUS_CODES.include?(response.status)
6068
return Result.new(success?: true) if response.status == 200

0 commit comments

Comments
 (0)