public bool validateToken() { if (Hub.Authenticate == null) { try { var newToken = new AuthenticateService(); var credentials = new AuthenticateContent() { name = "BisPay_RealTime", password = "******" }; Hub.Authenticate = newToken.authenticate(credentials); if(Hub.Authenticate.ExpirationDate <= DateTime.Now || Hub.Authenticate == null) { return false; } else { return true; } } catch { return false; } } else { if(Hub.Authenticate.ExpirationDate <= DateTime.Now) { try { var newToken = new AuthenticateService(); var credentials = new AuthenticateContent() { name = "BisPay_RealTime", password = "******" }; Hub.Authenticate = newToken.authenticate(credentials); if (Hub.Authenticate.ExpirationDate <= DateTime.Now || Hub.Authenticate == null) { return false; } else { return true; } } catch { return false; } } } return true; }
public Authenticate authenticate(AuthenticateContent content) { try { var auth = RestService.For <IAuthenticate>(urlBase); var result = JsonConvert.DeserializeObject <Authenticate>(JsonConvert.SerializeObject(auth.authenticate(content).Result)); return(result); } catch { return(null); } }