# Generated by Django 4.1.7 on 2023-03-30 12:38

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Client",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amiqus_id",
                    models.CharField(
                        help_text="The id returned from the Amiqus API.",
                        max_length=40,
                        unique=True,
                        verbose_name="Amiqus ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="The timestamp returned from the Amiqus API.",
                        null=True,
                    ),
                ),
                (
                    "raw",
                    models.JSONField(
                        blank=True,
                        help_text="The raw JSON returned from the API.",
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("None", "Unknown"),
                            ("approved", "Approved"),
                            ("rejected", "Rejected"),
                            ("pending", "Needs review"),
                        ],
                        db_index=True,
                        help_text="The current status of the Client (from API).",
                        max_length=20,
                        null=True,
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="Django user that maps to this client.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="amiqus_clients",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Event",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amiqus_id",
                    models.CharField(
                        help_text="The Amiqus ID of the related resource.",
                        max_length=40,
                        verbose_name="Amiqus ID",
                    ),
                ),
                (
                    "resource_type",
                    models.CharField(
                        help_text="The resource_type returned from the API callback.",
                        max_length=20,
                    ),
                ),
                (
                    "action",
                    models.CharField(
                        help_text="The event name as returned from the API callback.",
                        max_length=20,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        help_text="The status of the object after the event.",
                        max_length=20,
                    ),
                ),
                (
                    "completed_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="The timestamp returned from the Amiqus API.",
                        null=True,
                    ),
                ),
                (
                    "received_at",
                    models.DateTimeField(
                        help_text="The timestamp when the server received the event."
                    ),
                ),
                (
                    "raw",
                    models.JSONField(
                        blank=True,
                        help_text="The raw JSON returned from the API.",
                        null=True,
                    ),
                ),
            ],
            options={
                "ordering": ["completed_at"],
            },
        ),
        migrations.CreateModel(
            name="Record",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amiqus_id",
                    models.CharField(
                        help_text="The id returned from the Amiqus API.",
                        max_length=40,
                        unique=True,
                        verbose_name="Amiqus ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="The timestamp returned from the Amiqus API.",
                        null=True,
                    ),
                ),
                (
                    "raw",
                    models.JSONField(
                        blank=True,
                        help_text="The raw JSON returned from the API.",
                        null=True,
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="The timestamp of the most recent status change (from API).",
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("pending", "Pending"),
                            ("started", "Started"),
                            ("complete", "Complete"),
                            ("incomplete", "Incomplete"),
                            ("waiting", "Waiting"),
                            ("failed", "Failed"),
                            ("empty", "Empty"),
                            ("amendments", "Amendments"),
                            ("paused", "Paused"),
                            ("reviewed", "Reviewed"),
                        ],
                        db_index=True,
                        help_text="The current status of the record / check (from API).",
                        max_length=20,
                        null=True,
                    ),
                ),
                (
                    "client",
                    models.ForeignKey(
                        help_text="The client for whom the record is being made.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="records",
                        to="amiqus.client",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="The Django user (denormalised from Client to make navigation easier).",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="amiqus_records",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Check",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amiqus_id",
                    models.CharField(
                        help_text="The id returned from the Amiqus API.",
                        max_length=40,
                        unique=True,
                        verbose_name="Amiqus ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="The timestamp returned from the Amiqus API.",
                        null=True,
                    ),
                ),
                (
                    "raw",
                    models.JSONField(
                        blank=True,
                        help_text="The raw JSON returned from the API.",
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("pending", "Pending"),
                            ("submitted", "Submitted"),
                            ("accepted", "Accepted"),
                            ("rejected", "Cancelled"),
                            ("refer", "Refer"),
                            ("paused", "Paused"),
                        ],
                        db_index=True,
                        help_text="The current status of the record / check (from API).",
                        max_length=20,
                        null=True,
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="The timestamp of the most recent status change (from API).",
                        null=True,
                    ),
                ),
                (
                    "check_type",
                    models.CharField(
                        choices=[
                            ("document", "Document"),
                            (
                                "document_with_address_information",
                                "Document with Address Information",
                            ),
                            (
                                "document_with_driving_licence_information",
                                "Document with Driving Licence Information",
                            ),
                            ("facial_similarity_photo", "Facial Similarity (photo)"),
                            (
                                "facial_similarity_photo_fully_auto",
                                "Facial Similarity (auto)",
                            ),
                            ("facial_similarity_video", "Facial Similarity (video)"),
                            ("known_faces", "Known Faces"),
                            ("identity_enhanced", "Identity (enhanced)"),
                            ("watchlist_enhanced", "Watchlist (enhanced)"),
                            ("watchlist_standard", "Watchlist"),
                            ("watchlist_peps_only", "Watchlist (PEPs only)"),
                            ("watchlist_sanctions_only", "Watchlist (sanctions only)"),
                            ("proof_of_address", "Proof of Address"),
                            ("right_to_work", "Right to Work"),
                        ],
                        help_text="The name of the check - see https://documentation.onfido.com/#checks",
                        max_length=50,
                    ),
                ),
                (
                    "amiqus_record",
                    models.ForeignKey(
                        help_text="Record to which this check is attached.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="checks",
                        to="amiqus.record",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="The Django user (denormalised from Client to make navigation easier).",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="amiqus_checks",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
    ]
