public AccessToken(string value, string?refreshToken, ITimeToLive timeToLive) { if (string.IsNullOrWhiteSpace(value)) { throw Errors.StringShouldNotBeNullOrWhiteSpace(nameof(value)); } if (refreshToken != null && string.IsNullOrWhiteSpace(refreshToken)) { throw Errors.StringShouldNotBeEmptyOrWhiteSpace(nameof(refreshToken)); } if (ReferenceEquals(timeToLive, null)) { throw new ArgumentNullException(nameof(timeToLive)); } if (timeToLive.HasExpired) { throw Errors.AccessTokenAlreadyExpired(nameof(timeToLive)); } this.value = value; this.refreshToken = refreshToken; this.timeToLive = timeToLive; }