feat: add categories and send_at support#26
Conversation
Wire categories and send_at extension methods to the SendGrid API payload. These fields allow organizing emails by category for analytics and scheduling emails to be sent at a specific time. - Add extra_params method to handle flexible-typed fields - Merge extra_params into JSON body during deliver - Add tests verifying categories and send_at are sent to API - Add EmailWithSendGridFeatures test fixture
jwoertink
left a comment
There was a problem hiding this comment.
Hmm.. Does it feel weird having some of the extra params added when building params and then some others added right before the delivery happens? Like, asm and template_id are already defined as extra params, but now where categories and send_at are added seem to be handled in a different area of the code. But maybe that's because of the level of the JSON where they need to be added? 🤔
|
I think overall the solution is fine. I'm just unsure if the organization of the code fits or would add more confusion to anyone looking over the code. What are your thoughts? |
|
I'm good with changing it. I don't really care either way tbh. Just ran into some typing issues trying to do things that way initially and thought it would be cleaner. I think I agree though. Let me push a patch. |
… method All SendGrid-specific optional fields (asm, template_id, content, categories, send_at) are now handled consistently in a single sendgrid_options method instead of being split between params and extra_params. This improves code organization by clearly separating core email structure (params) from SendGrid API-specific options (sendgrid_options).
jwoertink
left a comment
There was a problem hiding this comment.
Nice! Yeah, the typing can get funky on these, but I think having all of this in one spot will make it easier for anyone else that wants to add a bit. Thanks for adding this in.
|
Of course. I'm using it so I figured I might as well contribute. Don't even know if I'll use these in the near term haha. |
Summary
Adds support for SendGrid's
categoriesandsend_atAPI parameters, allowing emails to be organized by category for analytics and scheduled for future delivery.Closes #13
Changes
categoriesandsend_atextension methods toCarbon::SendGridExtensionssendgrid_optionsmethod for consistent handlingparams) from SendGrid API-specific options (sendgrid_options)EmailWithSendGridFeaturestest fixtureCode Organization
Previously, SendGrid-specific fields were inconsistently handled between
params(forasm,template_id,content) andextra_params(forcategories,send_at). This has been refactored so:params: Core email structure only (personalizations, subject, from, headers, reply_to, mail_settings, attachments)sendgrid_options: All SendGrid-specific optional fields (asm, template_id/content, categories, send_at)deliver: Cleanly merges both hashes into the final JSON payloadThis improves maintainability and makes it clear where new SendGrid features should be added.
Usage