from django.db import models

class ASSNotification(models.Model):
    # Payload
    notificationType = models.CharField(max_length=100)
    subtype = models.CharField(max_length=100, null=True, blank=True)
    notificationUUID = models.CharField(max_length=100)
    signedDate = models.DateTimeField(null=True, blank=True)

    productId = models.CharField(max_length=100, null=True, blank=True)

    # TransactionInfo
    appAccountToken = models.CharField(max_length=100, null=True, blank=True)
    currency = models.CharField(max_length=100, null=True, blank=True)
    expiresDate = models.DateField(null=True, blank=True)
    isUpgraded = models.BooleanField(null=True, blank=True)
    originalPurchaseDate = models.DateField(null=True, blank=True)
    originalTransactionId = models.CharField(max_length=100, null=True, blank=True)
    price = models.IntegerField(null=True, blank=True)
    quantity = models.IntegerField(null=True, blank=True)
    revocationDate = models.DateField(null=True, blank=True)
    storefront = models.CharField(max_length=100, null=True, blank=True)
    transactionId = models.CharField(max_length=100, null=True, blank=True)
    transactionReason = models.CharField(max_length=50, null=True, blank=True)

    # Summary
    succeededCount = models.IntegerField(null=True, blank=True)
    failedCount = models.IntegerField(null=True, blank=True)
    requestIdentifier = models.CharField(max_length=100, null=True, blank=True)

    # Offers
    # offerDiscountType = models.CharField(max_length=100, null=True, blank=True)
    # offerIdentifier = models.CharField(max_length=100, null=True, blank=True)
    # offerType = models.IntegerField(null=True, blank=True)
    offerType = models.IntegerField(
            null=True,
            blank=True,
            choices=[
                (1, 'INTRODUCTORY_OFFER'),
                (2, 'PROMOTIONAL_OFFER'),
                (3, 'SUBSCRIPTION_OFFER_CODE'),
                (4, 'WIN_BACK_OFFER'),
            ],
            help_text="A value that represents the promotional offer type."
        )

    offerIdentifier = models.CharField(
        max_length=255,
        null=True,
        blank=True,
        help_text="The identifier that contains the promo code or the promotional offer identifier."
    )

    offerDiscountType = models.CharField(
        max_length=20,
        null=True,
        blank=True,
        choices=[
            ('FREE_TRIAL', 'FREE_TRIAL'),
            ('PAY_AS_YOU_GO', 'PAY_AS_YOU_GO'),
            ('PAY_UP_FRONT', 'PAY_UP_FRONT'),
        ],
        help_text="The payment mode for an introductory offer, promotional offer, or offer code on an auto-renewable subscription."
    )
