alexgaribay / sendgrid_elixir

Create and send composable emails with Elixir and SendGrid.
MIT License
86 stars 44 forks source link

Omit null values #17

Closed rohfosho closed 5 years ago

rohfosho commented 7 years ago

When you leave out send_at, attachments, content, or reply_to, the mailer errors out with

{:error,
 [%{"field" => "attachments",
    "help" => "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments",
    "message" => "Invalid type. Expected: array, given: null."},
  %{"field" => "content",
    "help" => "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content",
    "message" => "Invalid type. Expected: array, given: null."},
  %{"field" => "send_at",
    "help" => "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.send_at",
    "message" => "Invalid type. Expected: integer, given: null."},
  %{"field" => "reply_to",
    "help" => "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.reply_to",
    "message" => "Invalid type. Expected: object, given: null."}]}
rohfosho commented 7 years ago

Just kidding. It turns out custom args can't have an integer. The library should automatically convert all integers in the Email struct to strings to prevent this from happening.