private static double GetSessionTimeout(BunqResponse result) { var userPerson = result.Get <Model.UserPerson>(); var userCompany = result.Get <Model.UserCompany>(); var userApiKey = result.Get <Model.UserApiKey>(); if (userApiKey != null && userCompany == null && userPerson == null) { if (userApiKey.RequestedByUser.Usercompany != null) { return(userApiKey.RequestedByUser.Usercompany.SessionTimeout); } if (userApiKey.RequestedByUser.Userperson != null) { return(userApiKey.RequestedByUser.Userperson.SessionTimeout); } throw new BunqException("ErrorCouldNotDetermineSessionTimeout"); } if (userCompany != null && userApiKey == null && userPerson == null) { return(userCompany.SessionTimeout); } if (userPerson != null && userApiKey == null && userCompany == null) { return(userPerson.SessionTimeout); } throw new BunqException("ErrorCouldNotDetermineSessionTimeout"); }
private static int GetUserId(BunqResponse result) { var userPerson = result.Get <Model.UserPerson>(); var userCompany = result.Get <Model.UserCompany>(); var userApiKey = result.Get <Model.UserApiKey>(); if (userCompany != null && userApiKey == null && userPerson == null) { //Debug.Assert(sessionServer.UserCompany.Id != null, ErrorSessionserverUsercompanyIdNull); return(userCompany.Id); } else if (userPerson != null && userApiKey == null && userCompany == null) { //Debug.Assert(sessionServer.UserPerson.Id != null, ErrorsessionserverUserpersonIdNull); return(userPerson.Id); } else if (userApiKey != null && userCompany == null && userPerson == null) { //Debug.Assert(sessionServer.UserApiKey.Id != null, ErrorSessionserverUserapikeyIdNull); return(userApiKey.Id); } else { throw new BunqException("ErrorCouldNotDetermineUserId");//TODO message } }