Skip to content

Commit

Permalink
Bugfix: Change "enabled" to "enable" to conform to Sendgrid API. (#624)
Browse files Browse the repository at this point in the history
# Problem

[A recent PR](#618) added click tracking support for the SendGrid adapter. Unfortunately, we didn't catch a typo that sends "enabled" as the param instead of "enable" as is recognized by the API. This results in the following error:

```
"{\"errors\":[{\"message\":\"The click_tracking enable parameter is required.\",\"field\":\"tracking_settings.click_tracking.enable\",\"help\":\"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.tracking_settings.click_tracking.enable\"}]}"
``` 

with these params:

```
"tracking_settings" => %{"click_tracking" => %{"enable_text" => false, "enabled" => false}
```

Where it says `"enabled" => false` in the params, it should say `"enable" => false`

# Solution

Fix the typo and update the tests.
  • Loading branch information
danadaldos authored Aug 27, 2021
1 parent 0104d71 commit 09c8eae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/bamboo/adapters/send_grid_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ defmodule Bamboo.SendGridAdapter do
tracking_settings =
body
|> Map.get(:tracking_settings, %{})
|> Map.put(:click_tracking, %{enabled: enabled, enable_text: enabled})
|> Map.put(:click_tracking, %{enable: enabled, enable_text: enabled})

body
|> Map.put(:tracking_settings, tracking_settings)
Expand Down
4 changes: 2 additions & 2 deletions test/lib/bamboo/adapters/send_grid_adapter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ defmodule Bamboo.SendGridAdapterTest do
|> SendGridAdapter.deliver(@config)

assert_receive {:fake_sendgrid, %{params: params}}
assert params["tracking_settings"]["click_tracking"]["enabled"] == true
assert params["tracking_settings"]["click_tracking"]["enable"] == true
assert params["tracking_settings"]["click_tracking"]["enable_text"] == true
end

Expand All @@ -363,7 +363,7 @@ defmodule Bamboo.SendGridAdapterTest do
|> SendGridAdapter.deliver(@config)

assert_receive {:fake_sendgrid, %{params: params}}
assert params["tracking_settings"]["click_tracking"]["enabled"] == false
assert params["tracking_settings"]["click_tracking"]["enable"] == false
assert params["tracking_settings"]["click_tracking"]["enable_text"] == false
end

Expand Down

0 comments on commit 09c8eae

Please sign in to comment.