from django.conf import settings
from measurement.measures import Weight


class DiscountValueType:
    FIXED = 'fixed'
    PERCENTAGE = 'percentage'

    CHOICES = [
        (FIXED, settings.DEFAULT_CURRENCY),
        (PERCENTAGE, '%'),
    ]


class VoucherType:
    SHIPPING = 'shipping'
    ENTIRE_ORDER = 'entire_order'
    SPECIFIC_PRODUCT = 'specific_product'

    CHOICES = [
        (ENTIRE_ORDER, 'Entire order'),
        (SHIPPING, 'Shipping'),
        (SPECIFIC_PRODUCT, 'Specific products, collections and categories'),
    ]


class OrderStatus:
    DRAFT = 'draft'  # fully editable, not finalized order created by staff users
    UNFULFILLED = 'unfulfilled'  # order with no items marked as fulfilled
    PARTIALLY_FULFILLED = (
        'partially_fulfilled'  # order with some items marked as fulfilled
    )
    FULFILLED = 'fulfilled'  # order with all items marked as fulfilled

    PARTIALLY_RETURNED = (
        'partially_returned'  # order with some items marked as returned
    )
    RETURNED = 'returned'  # order with all items marked as returned
    CANCELED = 'canceled'  # permanently canceled order

    CHOICES = [
        (DRAFT, 'Draft'),
        (UNFULFILLED, 'Unfulfilled'),
        (PARTIALLY_FULFILLED, 'Partially fulfilled'),
        (PARTIALLY_RETURNED, 'Partially returned'),
        (RETURNED, 'Returned'),
        (FULFILLED, 'Fulfilled'),
        (CANCELED, 'Canceled'),
    ]


class TransactionStatus:
    # The order was created with the specified context.
    CREATED = 'CREATED'
    # The order was saved and persisted. The order status continues to
    # be in progress until a capture is made with final_capture = true
    # for all purchase units within the order.
    SAVED = 'SAVED'
    # The customer approved the payment through the PayPal wallet or
    # another form of guest or unbranded payment. For example, a card,
    # bank account, or so on.
    APPROVED = 'APPROVED'
    # All purchase units in the order are voided.
    VOIDED = 'VOIDED'
    # The payment was authorized or the authorized payment was captured
    # for the order.
    COMPLETED = 'COMPLETED'
    # The order requires an action from the payer (e.g. 3DS authentication).
    # Redirect the payer to the 'rel':'payer-action' HATEOAS link returned as
    # part of the response prior to authorizing or capturing the order.
    PAYER_ACTION_REQUIRED = 'PAYER_ACTION_REQUIRED'

    CHOICES = [
        (CREATED, 'Created'),
        (SAVED, 'Saved'),
        (APPROVED, 'Approved'),
        (VOIDED, 'Voided'),
        (COMPLETED, 'Completed'),
        (PAYER_ACTION_REQUIRED, 'Payer action required')
    ]


class ShippingProvider:
    USPS = 'USPS'
    USPS_MAX_SHIPPING_WEIGHT = Weight(lb=70)
    # UPS = 'UPS'
    # FEDEX = 'FEDEX'

    CHOICES = [
        (USPS, 'USPS'),
        # (UPS, 'UPS'),
        # (FEDEX, 'FedEx'),
    ]


class ShippingService:
    FIRST_CLASS = 'FIRST CLASS'
    PRIORITY = 'PRIORITY'
    PRIORITY_COMMERCIAL = 'PRIORITY COMMERCIAL'

    CHOICES = [
        (FIRST_CLASS, 'First Class'),
        (PRIORITY, 'Priority'),
        (PRIORITY_COMMERCIAL, 'Priority Commercial')
    ]


class ShippingContainer:
    PRIORITY = 'PRIORITY'
    PRIORITY_COMMERCIAL = 'PRIORITY COMMERCIAL'

    # PRIORITY
    FLAT_RATE_ENVELOPE = 'FLAT RATE ENVELOPE'
    LEGAL_FLAT_RATE_ENVELOPE = 'LEGAL FLAT RATE ENVELOPE'
    PADDED_FLAT_RATE_ENVELOPE = 'PADDED FLAT RATE ENVELOPE'
    SM_FLAT_RATE_ENVELOPE = 'SM FLAT RATE ENVELOPE'
    WINDOW_FLAT_RATE_ENVELOPE = 'WINDOW FLAT RATE ENVELOPE'
    GIFT_CARD_FLAT_RATE_ENVELOPE = 'GIFT CARD FLAT RATE ENVELOPE'
    SM_FLAT_RATE_BOX = 'SM FLAT RATE BOX'
    MD_FLAT_RATE_BOX = 'MD FLAT RATE BOX'
    LG_FLAT_RATE_BOX = 'LG FLAT RATE BOX'
    VARIABLE = 'VARIABLE'

    # PRIORITY_COMMERCIAL
    REGIONAL_RATE_BOX_A = 'REGIONALRATEBOXA'
    REGIONAL_RATE_BOX_B = 'REGIONALRATEBOXB'

    CHOICES = [
        (
            PRIORITY, (
                (FLAT_RATE_ENVELOPE, 'Flat Rate Envelope'),
                (LEGAL_FLAT_RATE_ENVELOPE, 'Legal Flat Rate Envelope'),
                (PADDED_FLAT_RATE_ENVELOPE, 'Padded Flat Rate Envelope'),
                (SM_FLAT_RATE_ENVELOPE, 'Sm Flat Rate Envelope'),
                (WINDOW_FLAT_RATE_ENVELOPE, 'Window Flat Rate Envelope'),
                (GIFT_CARD_FLAT_RATE_ENVELOPE, 'Gift Card Flat Rate Envelope'),
                (SM_FLAT_RATE_BOX, 'Sm Flat Rate Box'),
                (MD_FLAT_RATE_BOX, 'Md Flat Rate Box'),
                (LG_FLAT_RATE_BOX, 'Lg Flat Rate Box'),
                (VARIABLE, 'Variable'),
            )
        ), (
            PRIORITY_COMMERCIAL, (
                (REGIONAL_RATE_BOX_A, 'Regional Rate Box A'),
                (REGIONAL_RATE_BOX_B, 'Regional Rate Box B'),
            )
        ),
    ]

    SERVICE_FROM_CONTAINER = {
        # PRIORITY
        FLAT_RATE_ENVELOPE: PRIORITY,
        LEGAL_FLAT_RATE_ENVELOPE: PRIORITY,
        PADDED_FLAT_RATE_ENVELOPE: PRIORITY,
        SM_FLAT_RATE_ENVELOPE: PRIORITY,
        WINDOW_FLAT_RATE_ENVELOPE: PRIORITY,
        GIFT_CARD_FLAT_RATE_ENVELOPE: PRIORITY,
        SM_FLAT_RATE_BOX: PRIORITY,
        MD_FLAT_RATE_BOX: PRIORITY,
        LG_FLAT_RATE_BOX: PRIORITY,
        VARIABLE: PRIORITY,

        # PRIORITY_COMMERCIAL
        REGIONAL_RATE_BOX_A: PRIORITY_COMMERCIAL,
        REGIONAL_RATE_BOX_B: PRIORITY_COMMERCIAL,
    }

    def get_shipping_service_from_container(container):
        return ShippingContainer.SERVICE_FROM_CONTAINER[container]


class CoffeeGrind:
    WHOLE = 'whole-beans'
    ESPRESSO = 'espresso'
    CONE_DRIP = 'cone-drip'
    BASKET_DRIP = 'basket-drip'
    FRENCH_PRESS = 'french-press'
    STOVETOP_ESPRESSO = 'stovetop-espresso'
    AEROPRESS = 'aeropress'
    PERCOLATOR = 'percolator'
    CAFE_STYLE = 'cafe-style'
    GRIND_CHOICES = [
        (WHOLE, 'Whole Beans'),
        (ESPRESSO, 'Espresso'),
        (CONE_DRIP, 'Cone Drip'),
        (BASKET_DRIP, 'Basket Drip'),
        (FRENCH_PRESS, 'French Press'),
        (STOVETOP_ESPRESSO, 'Stovetop Espresso (Moka Pot)'),
        (AEROPRESS, 'AeroPress'),
        (PERCOLATOR, 'Percolator'),
        (CAFE_STYLE, 'BLTC cafe pour over')
    ]
