-
Notifications
You must be signed in to change notification settings - Fork 165
Closed
Description
Since all the API SDK methods make HTTP calls (via RestSharp), they should also allow a CancellationToken to be passed in as a parameter. Given that API calls may vary significantly in the time they take to complete (some may query for a quick status and others may download megabytes of documents), it may be quite common to have different timeout expectations for different methods. Accepting a CancellationToken would improve the API by:
- Allowing for a timeout to be set by method invocation while still sharing a common Configuration instance.
- Allowing the request to be cancelled by a user action.
It is quite common to make the CancellationToken an optional parameter, which I think would make sense here. For example
public async Task<Envelope> GetEnvelopeAsync(
string accountId,
string envelopeId,
EnvelopesApi.GetEnvelopeOptions options = null,
CancellationToken cancellationToken = default(CancellationToken))
smarts