/// <summary> /// Updates watch list object from Alpaca REST API endpoint by watch list identifier. /// </summary> /// <param name="request">Update watch list request parameters.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Updated watch list object with proper <paramref name="request.WatchListId"/> value.</returns> public async Task <IWatchList> UpdateWatchListByIdAsync( UpdateWatchListRequest request, CancellationToken cancellationToken = default) { request.EnsureNotNull(nameof(request)).Validate(); await _alpacaRestApiThrottler.WaitToProceed(cancellationToken).ConfigureAwait(false); using var content = toStringContent(request.Name, request.Assets); using var response = await _httpClient.PutAsync( new Uri ($"watchlists/{request.WatchListId:D}", UriKind.RelativeOrAbsolute), content, cancellationToken) .ConfigureAwait(false); return(await response.DeserializeAsync <IWatchList, JsonWatchList>() .ConfigureAwait(false)); }
/// <inheritdoc /> public Task <IWatchList> UpdateWatchListByIdAsync( UpdateWatchListRequest request, CancellationToken cancellationToken = default) => _httpClient.PutAsync <IWatchList, JsonWatchList, UpdateWatchListRequest>( getEndpointUri(request.EnsureNotNull(nameof(request)).Validate().WatchListId), request, cancellationToken);