You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two big ones we miss out on are categories and attachments. There's a few small issues with adding these though. As I was digging around, I noticed some of the docs were actually wrong. For example, one key saying it was a string, but should have said object. The next hurdle is with most of these keys being optional, the compiler starts to get finicky with how they are added.
You can either define the content with local templates OR use the dynamic templates, but you can't use both. Sendgrid doesn't really like that. So for this, there's basically an if condition to say if these have a value, then do that otherwise fallback to local templates.
I wanted to avoid requiring you to override 50 methods just to get the customization you need on every single email, but the Crystal compiler doesn't really like when you try to define a hash of random unknown types. We can't use JSON::Any because that doesn't allow you to build dynamically e.g. json["extra_args"] = [] of String.
Proposal
I think maybe we could look at breaking this out more like the Bugsnag shard, and each key becomes a new class defined. Then this hash becomes something like Hash(String, Carbon::SendgridAdapter::Value). That could just be a module in each of these classes.
Now, how to hook it in.... I'm not so sure... What does this look like? 🤷♂️
classSomeEmail < Carbon::Emaildefinitialize(@recipient)
end
to @recipient
subject "Hey"# does it look like this?
categories Carbon::SendgridAdapter::Categories.new("1", "2")
# maybe you take advantage of the new callbacks?
before_send do# `append_data` would have to be a SendgridAdapter specific method
adapter.append_data("categories", Carbon::SendgridAdapter::Categories.new("1", "2"))
endend
The text was updated successfully, but these errors were encountered:
The Sendgrid API has a lot more options than what we're passing currently https://docs.sendgrid.com/api-reference/mail-send/mail-send
Two big ones we miss out on are categories and attachments. There's a few small issues with adding these though. As I was digging around, I noticed some of the docs were actually wrong. For example, one key saying it was a string, but should have said object. The next hurdle is with most of these keys being optional, the compiler starts to get finicky with how they are added.
For example, with the dynamic templates:
carbon_sendgrid_adapter/src/carbon_sendgrid_extensions.cr
Lines 8 to 19 in a340557
You can either define the
content
with local templates OR use the dynamic templates, but you can't use both. Sendgrid doesn't really like that. So for this, there's basically anif
condition to say if these have a value, then do that otherwise fallback to local templates.I wanted to avoid requiring you to override 50 methods just to get the customization you need on every single email, but the Crystal compiler doesn't really like when you try to define a hash of random unknown types. We can't use JSON::Any because that doesn't allow you to build dynamically
e.g. json["extra_args"] = [] of String
.Proposal
I think maybe we could look at breaking this out more like the Bugsnag shard, and each key becomes a new class defined. Then this hash becomes something like
Hash(String, Carbon::SendgridAdapter::Value)
. That could just be a module in each of these classes.Now, how to hook it in.... I'm not so sure... What does this look like? 🤷♂️
The text was updated successfully, but these errors were encountered: