MailChimp.NET
                                
                                 MailChimp.NET copied to clipboard
                                
                                    MailChimp.NET copied to clipboard
                            
                            
                            
                        Async would be awesome
All my api is async but this piece of code. I understand you need to support old .net but what about a new branch for 4.5?
Please see this wiki article and this issue. What changes do you think we'd need to make to support async (and probably remove ServiceStack.Text at the same time)?
(FYI -- I'm asking because you seem opinionated and experienced with async)
Well, the only thing I did with this library is install it and used the subscribe method with some merge tags. So I will have to take a deep look before evaluating that. I´ve never used ServiceStack.text before. To understand it better, Is there any reason not to use Json.NET ?
I think the trick is to make this line async somehow (on MakeAPICall method) :
var resultString = fullUrl.PostJsonToUrl(args);
Then, making the method awaitable:
private async Task<T> MakeAPICall<T>(string apiAction, object args)
And then, making awaitable all the methods with calls to MakeApiCall(). For example:
public async Task<Opened> GetReportOpened(string cId, OpenedOptions opts = null)
        {
            //  Our api action:
            string apiAction = "reports/opened";
            //  Create our arguments object:
            object args = new
            {
                apikey = this.APIKey,
                cid = cId,
                opts = opts
            };
            //  Make the call:
            return await MakeAPICall<Opened>(apiAction, args);
        }
Another option would be creating an extension library with all the async method extensions, if you want to keep compatibility with 3.5. I need to make some tests
Hi again, Take a look at this:
Task<string> PostJsonToUrlAsync(...)
https://github.com/ServiceStack/ServiceStack/wiki/Http-Utils#async-http-utils
So, using that method, your code would look like this:
var resultString = await fullUrl.PostJsonToUrlAsync(args);
And I think that would be all. It seams that upgrading ServiceStack, making Mailchimp async would be easy. What do you think?
The reason we don't upgrade the ServiceStack dependency is because it's not free anymore.
I understand and so I would suggest to change the underlying REST client to something like https://github.com/paulcbetts/refit or other open source project (RestSharp?)
+1 on this. I have a scenario where i need to subscribe a single user to 3 lists. Using the current implementation, can take up to 5-10 seconds. Unfortunately MailChimp don't support a batch operation for this (only support multiple emails to 1 list, not the other way around). So i need a SubscribeAsync method. Might fork this repo and submit a PR. Agree with @xleon - suggest changing to use HttpClient