# Path: api/validators.py
# def phone_number_validator(phone_number):
#     """
#     Function to validate if a phone_number is in the required format.
# 
#     Args:
#         phone_number (string): The APNS or GCM push token.
# 
#     Raises:
#         ValidationError: When the phone_number is not correctly formated.
#     """
#     phone_number_stripped = re.sub(r'[\+\(\)– - x]', '', phone_number)
# 
#     if not phone_number_stripped.isdigit():
#         raise serializers.ValidationError('Not a valid phone number.')
# 
# def token_validator(token):
#     """
#     Function to validate if a token is in the required format.
# 
#     Args:
#         token (string): The APNS or GCM push token.
# 
#     Raises:
#         ValidationError: When the token is not correctly formated.
#     """
#     if ' ' in token:
#         raise serializers.ValidationError('No whitespace allowed in token.')


from rest_framework import serializers
from .validators import phone_number_validator, token_validator
    """
    name = serializers.CharField(max_length=255, allow_blank=True, required=False)
    os_version = serializers.CharField(max_length=255, allow_blank=True, required=False)
    client_version = serializers.CharField(max_length=255, allow_blank=True, required=False)
    app = serializers.CharField(max_length=255)
    sandbox = serializers.BooleanField(default=False)
    remote_logging_id = serializers.CharField(max_length=255, allow_blank=True, required=False)


class DeleteDeviceSerializer(TokenSerializer, SipUserIdSerializer):
    """
    Serializer for the device view delete.
    """
    app = serializers.CharField(max_length=255)


class CallResponseSerializer(serializers.Serializer):
    """
    Serializer for the call response view.
    """
    unique_key = serializers.CharField(max_length=255)
    message_start_time = serializers.FloatField()
    available = serializers.BooleanField(default=True)


class IncomingCallSerializer(SipUserIdSerializer):
    """
    Serializer for the incoming call view.
    """
    caller_id = serializers.CharField(max_length=255, default='', allow_blank=True)

# Path: api/validators.py
# def phone_number_validator(phone_number):
#     """
#     Function to validate if a phone_number is in the required format.
# 
#     Args:
#         phone_number (string): The APNS or GCM push token.
# 
#     Raises:
#         ValidationError: When the phone_number is not correctly formated.
#     """
#     phone_number_stripped = re.sub(r'[\+\(\)– - x]', '', phone_number)
# 
#     if not phone_number_stripped.isdigit():
#         raise serializers.ValidationError('Not a valid phone number.')
# 
# def token_validator(token):
#     """
#     Function to validate if a token is in the required format.
# 
#     Args:
#         token (string): The APNS or GCM push token.
# 
#     Raises:
#         ValidationError: When the token is not correctly formated.
#     """
#     if ' ' in token:
#         raise serializers.ValidationError('No whitespace allowed in token.')


# Path: api/serializers.py
from rest_framework import serializers
from .validators import phone_number_validator, token_validator

    """
    name = serializers.CharField(max_length=255, allow_blank=True, required=False)
    os_version = serializers.CharField(max_length=255, allow_blank=True, required=False)
    client_version = serializers.CharField(max_length=255, allow_blank=True, required=False)
    app = serializers.CharField(max_length=255)
    sandbox = serializers.BooleanField(default=False)
    remote_logging_id = serializers.CharField(max_length=255, allow_blank=True, required=False)


class DeleteDeviceSerializer(TokenSerializer, SipUserIdSerializer):
    """
    Serializer for the device view delete.
    """
    app = serializers.CharField(max_length=255)


class CallResponseSerializer(serializers.Serializer):
    """
    Serializer for the call response view.
    """
    unique_key = serializers.CharField(max_length=255)
    message_start_time = serializers.FloatField()
    available = serializers.BooleanField(default=True)


class IncomingCallSerializer(SipUserIdSerializer):
    """
    Serializer for the incoming call view.
    """
    caller_id = serializers.CharField(max_length=255, default='', allow_blank=True)

    phonenumber = serializers.CharField(max_length=32, validators=[phone_number_validator])