private bool ManageServerSessions(Func<RestSharp.Method> getMethod)
{
if (clientConfig.IsSessionRequired == false)
{
return true;
}
IRestRequest updateSession = new RestSharp.RestRequest(clientConfig.SessionAddress);
if (getMethod != null)
{
updateSession.Method = getMethod();
}
else
{
throw new InvalidOperationException("Unable to manage server sessions without knowing which method to use");
}
AddAuthTokensAsNecessary(updateSession);
CleanRequest(ref updateSession);
RestSharp.IRestResponse response = client.Execute(updateSession);
SetTokenFromCookies(client);
return response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK;
}