sendinblue / APIv3-csharp-library

SendinBlue's C# library for API v3
MIT License
58 stars 26 forks source link

Allow email campaign sender with email _or_ id #44

Closed ajbeaven closed 1 year ago

ajbeaven commented 2 years ago

The documentation for CreateEmailCampaignSender states:

Sender details including id or email and name (optional). Only one of either Sender's email or Sender's ID shall be passed in one request at a time.

At present, this library requires you to specify the sender 'email' or else it fails with an InvalidDataException in the constructor. It's not currently possible then, to use this library to create a sender with an id as if you send through a CreateEmailCampaignSender with both the 'email' and 'id' specified, the API replies with a failed response:

Only one of Sender ID or Sender Email can be passed for the same request.

This PR updates the CreateEmailCampaignSender so that it complies with the documentation and the API requirements. There are now two constructors for CreateEmailCampaignSender, one for instantiating a sender based on id and another based on email and name. This should help clear up any ambiguity and will allow you to use the library to create a sender on the basis of id as per the documentation.

ajbeaven commented 2 years ago

Hmm, I see that the portal complains if you try to send an API-created campaign that specified a sender id but no name, so the id-only constructor won't work. Seems like the portal also doesn't adhere to the documentation! I'll leave it to you to assess how this should be handled :)

amitsendinblue commented 1 year ago

Fixed in latest release - v4.0.2 kindly refer the latest version.