sharee.bike-App/TINKLib/Repository/Exception/NoGPSDataException.cs

28 lines
785 B
C#
Raw Normal View History

2021-06-26 20:57:55 +02:00

2021-05-13 20:03:07 +02:00
namespace TINK.Repository.Exception
{
2022-09-06 16:08:19 +02:00
public class NoGPSDataException : InvalidResponseException
{
/// <summary> COPRI response status. </summary>
public const string RETURNBIKE_FAILURE_STATUS_MESSAGE_UPPERCASE = "FAILURE 2245: NO GPS DATA, STATE CHANGE FORBIDDEN.";
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Prevents invalid use of exception. </summary>
private NoGPSDataException() : base(typeof(NoGPSDataException).Name)
{
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public static bool IsNoGPSData(string responseState, out NoGPSDataException exception)
{
// Check if there are too many bikes requested/ booked.
if (!responseState.Trim().ToUpper().StartsWith(RETURNBIKE_FAILURE_STATUS_MESSAGE_UPPERCASE))
{
exception = null;
return false;
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
exception = new NoGPSDataException();
return true;
}
}
2021-05-13 20:03:07 +02:00
}