public async Task <string> GetHeader()
        {
            if (_lastResponse == null || _dateService.Now >= _expiryTime)
            {
                var response = await _postUrlEncodedService
                               .GetPostResult <Oauth2BaseResponse>(_tokenUri,
                                                                   new Dictionary <string, string>()
                {
                    { "client_id", _clientId },
                    { "client_secret", _clientSecret },
                    { "grant_type", "client_credentials" }
                });

                response.response.ResponseTime = response.responseTime;
                _lastResponse     = response.response;
                _lastResponseTime = response.responseTime;

                _expiryTime = _dateService.Now.AddSeconds(_lastResponse.ExpiresIn - 5);

                //add to stats if configured
                _responseRecorder.RecordIfRequired(response.response);
            }

            return($"{_lastResponse.TokenType} {_lastResponse.AccessToken}");
        }
        public async Task <ResponseContentModel> InvokeEndpoint(Endpoint endpoint,
                                                                TestEnvironment testEnvironment,
                                                                Hashtable queryParams,
                                                                Hashtable pathParams,
                                                                Hashtable headerParams,
                                                                IGetAuthorisationHeaderStrategy authStrategy,
                                                                object requestBody,
                                                                bool attemptDeserializeErrorContent = false)
        {
            var queryDict  = queryParams.AsStringStringDictionary();
            var pathDict   = pathParams.AsStringStringDictionary();
            var headerDict = headerParams.AsStringStringDictionary();

            _parameterCheckService.CheckRequiredParametersPresent(endpoint,
                                                                  queryDict,
                                                                  pathDict,
                                                                  headerDict);

            using (var request = await _createMessageService.CreateMessage(endpoint,
                                                                           testEnvironment,
                                                                           queryDict,
                                                                           pathDict,
                                                                           headerDict,
                                                                           authStrategy,
                                                                           requestBody))
            {
                var responseModel = await _apiResponseService.ReturnContent(request,
                                                                            endpoint.SuccessResponseBody?.Type,
                                                                            attemptDeserializeErrorContent?
                                                                            typeof(object) :
                                                                            null);

                _responseRecorder.RecordIfRequired(responseModel);

                return(responseModel);
            }
        }