"""mindbodypublicapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper


class PurchasedItem(object):
    """Implementation of the 'PurchasedItem' model.

    Attributes:
        sale_detail_id (int): The ID which gets assigned to the item when item is
            added to the cart.
        id (int): The ID of the purchased item. Use this ID when calling the GET
            Services or GET Products endpoint.
        is_service (bool): When `true`, indicates that the purchased item was a
            pricing option for a service.
        barcode_id (str): The barcode number of the purchased item. Use this ID when
            calling the GET Products endpoint.
        description (str): The description of the sale transaction/pricing option.
        contract_id (int): The contract purchased by the client. Use this ID when
            calling the GET Contract endpoint.
        category_id (int): The revenue category ID used for sale. Use this ID when
            calling the GET Categories endpoint.
        sub_category_id (int): The ID of revenue subcategory.
        unit_price (float): er Unit Price of the item purchased.
        quantity (int): Quantity of the purchased item, applicable for products only.
            Note: Negative numbers indicate returned items.
        discount_percent (float): The percent discount that was applied to the items
            subtotal.
        discount_amount (float): The total discount amount that was applied to the
            items subtotal.
        tax_1 (float): A decimal representation of the first tax rate that was
            applied to the items subtotal.
        tax_2 (float): A decimal representation of the second tax rate that was
            applied to the items subtotal.
        tax_3 (float): A decimal representation of the third tax rate that was
            applied to the items subtotal.
        tax_4 (float): A decimal representation of the fourth tax rate that was
            applied to the items subtotal.
        tax_5 (float): A decimal representation of the fifth tax rate that was
            applied to the items subtotal.
        tax_amount (float): Total tax amount that is summation of tax1, tax2, tax3,
            tax4 and tax5.
        total_amount (float): The items total, once discounts and/or tax was applied.
        notes (str): Note made by the customer while purchasing item.
        returned (bool): When `true`, indicates that the purchased item is returned,
            `false` otherwise.
        payment_ref_id (int): The payment reference ID generated during payment of
            sold item.
        exp_date (datetime): The expiration date of the pricing option purchased.
        active_date (datetime): The activation date of pricing option purchased.
        gift_card_barcode_id (str): Gift Card BarcodeId

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "sale_detail_id": "SaleDetailId",
        "id": "Id",
        "is_service": "IsService",
        "barcode_id": "BarcodeId",
        "description": "Description",
        "contract_id": "ContractId",
        "category_id": "CategoryId",
        "sub_category_id": "SubCategoryId",
        "unit_price": "UnitPrice",
        "quantity": "Quantity",
        "discount_percent": "DiscountPercent",
        "discount_amount": "DiscountAmount",
        "tax_1": "Tax1",
        "tax_2": "Tax2",
        "tax_3": "Tax3",
        "tax_4": "Tax4",
        "tax_5": "Tax5",
        "tax_amount": "TaxAmount",
        "total_amount": "TotalAmount",
        "notes": "Notes",
        "returned": "Returned",
        "payment_ref_id": "PaymentRefId",
        "exp_date": "ExpDate",
        "active_date": "ActiveDate",
        "gift_card_barcode_id": "GiftCardBarcodeId",
    }

    _optionals = [
        "sale_detail_id",
        "id",
        "is_service",
        "barcode_id",
        "description",
        "contract_id",
        "category_id",
        "sub_category_id",
        "unit_price",
        "quantity",
        "discount_percent",
        "discount_amount",
        "tax_1",
        "tax_2",
        "tax_3",
        "tax_4",
        "tax_5",
        "tax_amount",
        "total_amount",
        "notes",
        "returned",
        "payment_ref_id",
        "exp_date",
        "active_date",
        "gift_card_barcode_id",
    ]

    def __init__(
        self,
        sale_detail_id=APIHelper.SKIP,
        id=APIHelper.SKIP,
        is_service=APIHelper.SKIP,
        barcode_id=APIHelper.SKIP,
        description=APIHelper.SKIP,
        contract_id=APIHelper.SKIP,
        category_id=APIHelper.SKIP,
        sub_category_id=APIHelper.SKIP,
        unit_price=APIHelper.SKIP,
        quantity=APIHelper.SKIP,
        discount_percent=APIHelper.SKIP,
        discount_amount=APIHelper.SKIP,
        tax_1=APIHelper.SKIP,
        tax_2=APIHelper.SKIP,
        tax_3=APIHelper.SKIP,
        tax_4=APIHelper.SKIP,
        tax_5=APIHelper.SKIP,
        tax_amount=APIHelper.SKIP,
        total_amount=APIHelper.SKIP,
        notes=APIHelper.SKIP,
        returned=APIHelper.SKIP,
        payment_ref_id=APIHelper.SKIP,
        exp_date=APIHelper.SKIP,
        active_date=APIHelper.SKIP,
        gift_card_barcode_id=APIHelper.SKIP):
        """Initialize a PurchasedItem instance."""
        # Initialize members of the class
        if sale_detail_id is not APIHelper.SKIP:
            self.sale_detail_id = sale_detail_id
        if id is not APIHelper.SKIP:
            self.id = id
        if is_service is not APIHelper.SKIP:
            self.is_service = is_service
        if barcode_id is not APIHelper.SKIP:
            self.barcode_id = barcode_id
        if description is not APIHelper.SKIP:
            self.description = description
        if contract_id is not APIHelper.SKIP:
            self.contract_id = contract_id
        if category_id is not APIHelper.SKIP:
            self.category_id = category_id
        if sub_category_id is not APIHelper.SKIP:
            self.sub_category_id = sub_category_id
        if unit_price is not APIHelper.SKIP:
            self.unit_price = unit_price
        if quantity is not APIHelper.SKIP:
            self.quantity = quantity
        if discount_percent is not APIHelper.SKIP:
            self.discount_percent = discount_percent
        if discount_amount is not APIHelper.SKIP:
            self.discount_amount = discount_amount
        if tax_1 is not APIHelper.SKIP:
            self.tax_1 = tax_1
        if tax_2 is not APIHelper.SKIP:
            self.tax_2 = tax_2
        if tax_3 is not APIHelper.SKIP:
            self.tax_3 = tax_3
        if tax_4 is not APIHelper.SKIP:
            self.tax_4 = tax_4
        if tax_5 is not APIHelper.SKIP:
            self.tax_5 = tax_5
        if tax_amount is not APIHelper.SKIP:
            self.tax_amount = tax_amount
        if total_amount is not APIHelper.SKIP:
            self.total_amount = total_amount
        if notes is not APIHelper.SKIP:
            self.notes = notes
        if returned is not APIHelper.SKIP:
            self.returned = returned
        if payment_ref_id is not APIHelper.SKIP:
            self.payment_ref_id = payment_ref_id
        if exp_date is not APIHelper.SKIP:
            self.exp_date =\
                 APIHelper.apply_datetime_converter(
                exp_date, APIHelper.RFC3339DateTime)\
                 if exp_date else None
        if active_date is not APIHelper.SKIP:
            self.active_date =\
                 APIHelper.apply_datetime_converter(
                active_date, APIHelper.RFC3339DateTime)\
                 if active_date else None
        if gift_card_barcode_id is not APIHelper.SKIP:
            self.gift_card_barcode_id = gift_card_barcode_id

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        sale_detail_id =\
            dictionary.get("SaleDetailId")\
            if dictionary.get("SaleDetailId")\
                else APIHelper.SKIP
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        is_service =\
            dictionary.get("IsService")\
            if "IsService" in dictionary.keys()\
                else APIHelper.SKIP
        barcode_id =\
            dictionary.get("BarcodeId")\
            if dictionary.get("BarcodeId")\
                else APIHelper.SKIP
        description =\
            dictionary.get("Description")\
            if dictionary.get("Description")\
                else APIHelper.SKIP
        contract_id =\
            dictionary.get("ContractId")\
            if dictionary.get("ContractId")\
                else APIHelper.SKIP
        category_id =\
            dictionary.get("CategoryId")\
            if dictionary.get("CategoryId")\
                else APIHelper.SKIP
        sub_category_id =\
            dictionary.get("SubCategoryId")\
            if dictionary.get("SubCategoryId")\
                else APIHelper.SKIP
        unit_price =\
            dictionary.get("UnitPrice")\
            if dictionary.get("UnitPrice")\
                else APIHelper.SKIP
        quantity =\
            dictionary.get("Quantity")\
            if dictionary.get("Quantity")\
                else APIHelper.SKIP
        discount_percent =\
            dictionary.get("DiscountPercent")\
            if dictionary.get("DiscountPercent")\
                else APIHelper.SKIP
        discount_amount =\
            dictionary.get("DiscountAmount")\
            if dictionary.get("DiscountAmount")\
                else APIHelper.SKIP
        tax_1 =\
            dictionary.get("Tax1")\
            if dictionary.get("Tax1")\
                else APIHelper.SKIP
        tax_2 =\
            dictionary.get("Tax2")\
            if dictionary.get("Tax2")\
                else APIHelper.SKIP
        tax_3 =\
            dictionary.get("Tax3")\
            if dictionary.get("Tax3")\
                else APIHelper.SKIP
        tax_4 =\
            dictionary.get("Tax4")\
            if dictionary.get("Tax4")\
                else APIHelper.SKIP
        tax_5 =\
            dictionary.get("Tax5")\
            if dictionary.get("Tax5")\
                else APIHelper.SKIP
        tax_amount =\
            dictionary.get("TaxAmount")\
            if dictionary.get("TaxAmount")\
                else APIHelper.SKIP
        total_amount =\
            dictionary.get("TotalAmount")\
            if dictionary.get("TotalAmount")\
                else APIHelper.SKIP
        notes =\
            dictionary.get("Notes")\
            if dictionary.get("Notes")\
                else APIHelper.SKIP
        returned =\
            dictionary.get("Returned")\
            if "Returned" in dictionary.keys()\
                else APIHelper.SKIP
        payment_ref_id =\
            dictionary.get("PaymentRefId")\
            if dictionary.get("PaymentRefId")\
                else APIHelper.SKIP
        exp_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ExpDate")).datetime\
            if dictionary.get("ExpDate") else APIHelper.SKIP
        active_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ActiveDate")).datetime\
            if dictionary.get("ActiveDate") else APIHelper.SKIP
        gift_card_barcode_id =\
            dictionary.get("GiftCardBarcodeId")\
            if dictionary.get("GiftCardBarcodeId")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(sale_detail_id,
                   id,
                   is_service,
                   barcode_id,
                   description,
                   contract_id,
                   category_id,
                   sub_category_id,
                   unit_price,
                   quantity,
                   discount_percent,
                   discount_amount,
                   tax_1,
                   tax_2,
                   tax_3,
                   tax_4,
                   tax_5,
                   tax_amount,
                   total_amount,
                   notes,
                   returned,
                   payment_ref_id,
                   exp_date,
                   active_date,
                   gift_card_barcode_id)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _sale_detail_id=(
            self.sale_detail_id
            if hasattr(self, "sale_detail_id")
            else None
        )
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _is_service=(
            self.is_service
            if hasattr(self, "is_service")
            else None
        )
        _barcode_id=(
            self.barcode_id
            if hasattr(self, "barcode_id")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _contract_id=(
            self.contract_id
            if hasattr(self, "contract_id")
            else None
        )
        _category_id=(
            self.category_id
            if hasattr(self, "category_id")
            else None
        )
        _sub_category_id=(
            self.sub_category_id
            if hasattr(self, "sub_category_id")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _discount_percent=(
            self.discount_percent
            if hasattr(self, "discount_percent")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _tax_1=(
            self.tax_1
            if hasattr(self, "tax_1")
            else None
        )
        _tax_2=(
            self.tax_2
            if hasattr(self, "tax_2")
            else None
        )
        _tax_3=(
            self.tax_3
            if hasattr(self, "tax_3")
            else None
        )
        _tax_4=(
            self.tax_4
            if hasattr(self, "tax_4")
            else None
        )
        _tax_5=(
            self.tax_5
            if hasattr(self, "tax_5")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _notes=(
            self.notes
            if hasattr(self, "notes")
            else None
        )
        _returned=(
            self.returned
            if hasattr(self, "returned")
            else None
        )
        _payment_ref_id=(
            self.payment_ref_id
            if hasattr(self, "payment_ref_id")
            else None
        )
        _exp_date=(
            self.exp_date
            if hasattr(self, "exp_date")
            else None
        )
        _active_date=(
            self.active_date
            if hasattr(self, "active_date")
            else None
        )
        _gift_card_barcode_id=(
            self.gift_card_barcode_id
            if hasattr(self, "gift_card_barcode_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"sale_detail_id={_sale_detail_id!r}, "
            f"id={_id!r}, "
            f"is_service={_is_service!r}, "
            f"barcode_id={_barcode_id!r}, "
            f"description={_description!r}, "
            f"contract_id={_contract_id!r}, "
            f"category_id={_category_id!r}, "
            f"sub_category_id={_sub_category_id!r}, "
            f"unit_price={_unit_price!r}, "
            f"quantity={_quantity!r}, "
            f"discount_percent={_discount_percent!r}, "
            f"discount_amount={_discount_amount!r}, "
            f"tax_1={_tax_1!r}, "
            f"tax_2={_tax_2!r}, "
            f"tax_3={_tax_3!r}, "
            f"tax_4={_tax_4!r}, "
            f"tax_5={_tax_5!r}, "
            f"tax_amount={_tax_amount!r}, "
            f"total_amount={_total_amount!r}, "
            f"notes={_notes!r}, "
            f"returned={_returned!r}, "
            f"payment_ref_id={_payment_ref_id!r}, "
            f"exp_date={_exp_date!r}, "
            f"active_date={_active_date!r}, "
            f"gift_card_barcode_id={_gift_card_barcode_id!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _sale_detail_id=(
            self.sale_detail_id
            if hasattr(self, "sale_detail_id")
            else None
        )
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _is_service=(
            self.is_service
            if hasattr(self, "is_service")
            else None
        )
        _barcode_id=(
            self.barcode_id
            if hasattr(self, "barcode_id")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _contract_id=(
            self.contract_id
            if hasattr(self, "contract_id")
            else None
        )
        _category_id=(
            self.category_id
            if hasattr(self, "category_id")
            else None
        )
        _sub_category_id=(
            self.sub_category_id
            if hasattr(self, "sub_category_id")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _discount_percent=(
            self.discount_percent
            if hasattr(self, "discount_percent")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _tax_1=(
            self.tax_1
            if hasattr(self, "tax_1")
            else None
        )
        _tax_2=(
            self.tax_2
            if hasattr(self, "tax_2")
            else None
        )
        _tax_3=(
            self.tax_3
            if hasattr(self, "tax_3")
            else None
        )
        _tax_4=(
            self.tax_4
            if hasattr(self, "tax_4")
            else None
        )
        _tax_5=(
            self.tax_5
            if hasattr(self, "tax_5")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _notes=(
            self.notes
            if hasattr(self, "notes")
            else None
        )
        _returned=(
            self.returned
            if hasattr(self, "returned")
            else None
        )
        _payment_ref_id=(
            self.payment_ref_id
            if hasattr(self, "payment_ref_id")
            else None
        )
        _exp_date=(
            self.exp_date
            if hasattr(self, "exp_date")
            else None
        )
        _active_date=(
            self.active_date
            if hasattr(self, "active_date")
            else None
        )
        _gift_card_barcode_id=(
            self.gift_card_barcode_id
            if hasattr(self, "gift_card_barcode_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"sale_detail_id={_sale_detail_id!s}, "
            f"id={_id!s}, "
            f"is_service={_is_service!s}, "
            f"barcode_id={_barcode_id!s}, "
            f"description={_description!s}, "
            f"contract_id={_contract_id!s}, "
            f"category_id={_category_id!s}, "
            f"sub_category_id={_sub_category_id!s}, "
            f"unit_price={_unit_price!s}, "
            f"quantity={_quantity!s}, "
            f"discount_percent={_discount_percent!s}, "
            f"discount_amount={_discount_amount!s}, "
            f"tax_1={_tax_1!s}, "
            f"tax_2={_tax_2!s}, "
            f"tax_3={_tax_3!s}, "
            f"tax_4={_tax_4!s}, "
            f"tax_5={_tax_5!s}, "
            f"tax_amount={_tax_amount!s}, "
            f"total_amount={_total_amount!s}, "
            f"notes={_notes!s}, "
            f"returned={_returned!s}, "
            f"payment_ref_id={_payment_ref_id!s}, "
            f"exp_date={_exp_date!s}, "
            f"active_date={_active_date!s}, "
            f"gift_card_barcode_id={_gift_card_barcode_id!s}, "
            f")"
        )
