public async Task <HttpResponse> ExecuteApiCallAsync(HttpRequestPriority priority, HttpRequest request, int timeout = 0, params HttpStatusCode[] ignoreErrorCodes)
        {
            var response = await _client.ExecuteAsStringResponseAsync(priority, request, timeout).ConfigureAwait(false);

            if (ValidateResponse(response, true, ignoreErrorCodes))
            {
                return(response);
            }

            //try to retrive session again if token is not valid
            if (!IsSessionValid(response))
            {
                //if session request is already in progress, then await it
                var shouldRetrieveSession = await EnsureNoSessionRetrievalIsRunningAsync().ConfigureAwait(false);

                if (shouldRetrieveSession)
                {
                    var executionStatus = await RetrieveSessionAsync().ConfigureAwait(false);

                    if (executionStatus == ExecutionStatus.Completed)
                    {
                        request.WithCredentials(_membershipService);
                        response = await _client.ExecuteAsStringResponseAsync(priority, request).ConfigureAwait(false);
                    }
                }
                else
                {
                    request.WithCredentials(_membershipService);

                    response = await _client.ExecuteAsStringResponseAsync(priority, request).ConfigureAwait(false);
                }

                //if session issue is still not resolved, redirect to first install login screen, because we can't perform activities without session
                if (!IsSessionValid(response))
                {
                    return(response);
                }
            }

            ValidateResponse(response, ignoreErrorCodes: ignoreErrorCodes);

            return(response);
        }
        public async Task <HttpResponse> ExecuteApiCallAsync(HttpRequestPriority priority, HttpRequest request, int timeout = 0, params HttpStatusCode[] ignoreErrorCodes)
        {
            var response = await _client.ExecuteAsStringResponseAsync(priority, request, timeout).ConfigureAwait(false);

            if (response.IsSuccessful || ignoreErrorCodes.Contains(response.StatusCode))
            {
                return(response);
            }

            if (HttpStatusCodes.IsErrorStatus(response.StatusCode))
            {
                throw new HttpException("Error status code received", response);
            }

            return(response);
        }