public ApiStreamRequestHandler(IApiConfiguration configuration, ICompanyFileCredentials credentials, OAuthTokens oauth = null)
 {
     _oauth = oauth;
     _configuration = configuration;
     _credentials = credentials;
     _helper = new ApiRequestHelper();
 }
        /// <summary>
        /// GET - asynchronous - using actions as handlers
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="request"></param>
        /// <param name="onComplete"></param>
        /// <param name="onError"></param>
        /// <param name="eTag"></param>
        public void Get <T>(WebRequest request, Action <HttpStatusCode, T> onComplete, Action <Uri, Exception> onError, string eTag)
            where T : class
        {
            ApiRequestHelper.SetStandardHeaders(request, _configuration, _credentials, _oauth);
            ApiRequestHelper.SetIsNoneMatch(request, eTag);

            request.BeginGetResponse(HandleResponseCallback <RequestContext <T>, T>,
                                     new RequestContext <T>
            {
                Request    = request,
                OnComplete = (code, s, entity) => onComplete(code, entity),
                OnError    = onError,
            });
        }
 /// <summary>
 /// PUT - asynchronous - using actions as handlers
 /// </summary>
 /// <typeparam name="TRequest"></typeparam>
 /// <typeparam name="TResponse"></typeparam>
 /// <param name="request"></param>
 /// <param name="entity"></param>
 /// <param name="onComplete"></param>
 /// <param name="onError"></param>
 public void Put <TRequest, TResponse>(WebRequest request, TRequest entity, Action <HttpStatusCode, string, TResponse> onComplete,
                                       Action <Uri, Exception> onError)
     where TResponse : class
 {
     ApiRequestHelper.SetStandardHeaders(request, _configuration, _credentials, _oauth);
     request.Method      = "PUT";
     request.ContentType = "application/json";
     request.BeginGetRequestStream(HandleRequestCallback <TResponse>,
                                   new RequestContext <TResponse>
     {
         Body       = entity.ToJson(),
         Request    = request,
         OnComplete = onComplete,
         OnError    = onError,
     });
 }
 /// <summary>
 /// DELETE - async - awaitable
 /// </summary>
 /// <param name="request"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public async Task DeleteAsync(WebRequest request, CancellationToken cancellationToken)
 {
     ApiRequestHelper.SetStandardHeaders(request, _configuration, _credentials, _oauth);
     request.Method = "DELETE";
     await GetResponseTask <string>(request, cancellationToken);
 }