-
Notifications
You must be signed in to change notification settings - Fork 583
Dynamic Properties #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @mskutta, Thank you for the question! That portion of the API client is meant to make it easy to call any v2 Web API endpoint we have now or will release. To solve the issue you are having, we are using the concept of Helpers. You can see the first one we have developed here: https://github.com/sendgrid/sendgrid-csharp/tree/master/SendGrid/SendGrid/Helpers/Mail. It is a first iteration and we welcome suggestions on improvement and also ideas on which endpoints you would like to see have helpers also. Pull requests are also appreciated :) Further information about the design is here: https://sendgrid.com/blog/using-c-to-implement-a-fluent-interface-to-any-rest-api Please let me know if you have further questions. With Best Regards, Elmer |
To my mind this is an abuse of the As for the helper library, now that a Thanks and sorry for the rant :) |
@ohadschn we love rants! Seriously, we do. It indicates you are a passionate developer who cares about your craft. We take such feedback very seriously. As you can see, we are in the very early stages with this new library. We had to take a few steps back to support the v3 Web APIs and the plan is to iterate based on feedback from the .NET C# community. So far, we have received a nice amount of great feedback (including yours :)). You can further contribute by creating, upvoting or commenting on issues. These contributions help bump things up in our priority queue. Within a few iterations, we hope the helpers will provide easy solutions for all the main use cases for the v3 Web API, effectively hiding the lower level implementation. The Mail helper was the first example, but it's only the first in many iterations. Your feedback will help guide its completion. I like the idea about returning Thanks again for taking the time to let us know your thoughts! |
@thinkingserious I love your positive attitude :) I think the first order of business would be to merge this: sendgrid/csharp-http-client@391b060. It looks good to me. I realize this will be a breaking change, but I believe it's worth it, and better sooner than later right? I then suggest we get rid of the Finally, enabling the basic scenario of sending an email message in a type safe wrapper would become easy by adding a method like this to the
And now all the client has to do is: So now all the dynamic stuff has been hidden away, and the client has a type-safe way to send emails 💯 |
Once again, thanks for the detailed and actionable feedback. We would love to throw some swag your way! Could you please email us ([email protected]) with your T-shirt size and mailing address? Now, on to the feedback! First of all, thanks for the kind words! This stuff is great fun to me and I'm very pleased to be finally getting such detailed feedback. We don't want to create this library in a vacuum. Ticket #9 is pretty high on our backlog right now, so I think it will be fixed in short order. Thanks again for giving another set of eyes on the code! With the breaking change, we'll just bump the major version number. I'll try to add in any other breaking changes too at that point. I don't want to return Love the changes to the helper, this is exactly the direction we want to take. We do have a task for this in our backlog, but that one is a bit further down the list; however, I just added your voice to it for a bit of a priority bump. That said, the best way to get this one bumped in the near future is with a pull request. |
@thinkingserious Hi again :) Regarding the ticket, I assume you mean this one (on Regarding the Worst case scenario, the rare user that wants to use their own HTTP client can just fall back to the REST API, it's really not so hard to do something like: Consequentially, it's not that urgent for me to work on that pull request, and I do have other projects to attend to (including my RL full time job :)), but once the |
Thanks for the thoughtful and compelling feedback. Please do follow this ticket for the upcoming fix: sendgrid/csharp-http-client#9 |
Will do, and thanks for listening :) |
I just came here looking for help with the new API. I think if you're going to produce a .NET API client, it should be strongly typed for the majority of common functionality. Having everything be dynamic is neither discoverable nor testable. The helpers are a good idea, but I would really consider making the helpers to be the main API and having the dynamic objects as the internal core that is rarely used. |
You've got it right, that's the plan and this is just the beginning of many iterations. We had to take a few steps back to get the API library decoupled from the first mail/send endpoint and provide access to all v3 endpoints. The best way you can help today is by up-voting and/or commenting on issues. Pull requests are also welcome :) |
I'm actually currently working on creating objects to represent the data
being sent to SendGrid, which will be compatible with ASP.NET Core and Full
Frameworks. Once I've completed that project, I'll generate a pull request.
|
A couple of relevant comments:
var client = new HttpClient(); //this can be a static/singleton somewhere
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ApiKey);
client.BaseAddress = new Uri("https://api.sendgrid.com/v3/");
//one time setup is done, we can now call from anywhere like:
var mail = new Mail(from, subject, to, content);
await client.PostAsync(
"mail/send", new StringContent(mail.Get(), Encoding.ASCII, "application/json"));
|
Interesting. Since the SendGrid.CSharp.HTTP.Client is just a thin wrapper around HttpClient, it should not be difficult to do item 2 and it might be time to just combine the two repos. |
Thanks for putting together this API. I have a quick suggestion...
Is there a reason behind using dynamic properties? I feel like it makes the API difficult to work with. It is not easy to discover how to use the API without referring to documentation or debugging.
Thanks!
Mike
The text was updated successfully, but these errors were encountered: