# coding: utf-8

"""
    Voucherify API

    Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details.

    The version of the OpenAPI document: v2018-08-01
    Contact: support@voucherify.io
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import date, datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from voucherify.models.loyalty_pending_points_details import LoyaltyPendingPointsDetails
from typing import Optional, Set
from typing_extensions import Self

class LoyaltyPendingPoints(BaseModel):
    """
    Contains details about the pending point entry.
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Unique identifier of the pending point entry, assigned by Voucherify.")
    voucher_id: Optional[StrictStr] = Field(default=None, description="Unique identifier of the loyalty card, assigned by Voucherify.")
    campaign_id: Optional[StrictStr] = Field(default=None, description="Unique campaign identifier, assigned by Voucherify.")
    customer_id: Optional[StrictStr] = Field(default=None, description="Unique customer identifier, assigned by Voucherify.")
    order_id: Optional[StrictStr] = Field(default=None, description="Unique order identifier, assigned by Voucherify.")
    points: Optional[StrictInt] = Field(default=None, description="Number of points in the pending state.")
    activates_at: Optional[date] = Field(default=None, description="Date when the pending points are activated and added to the customer's loyalty card.")
    details: LoyaltyPendingPointsDetails
    created_at: Optional[datetime] = Field(default=None, description="Timestamp representing the date and time when the pending point entry was created. The value is shown in the ISO 8601 format.")
    updated_at: Optional[datetime] = Field(default=None, description="Timestamp representing the date and time when the pending point entry was modified. The value is shown in the ISO 8601 format.")
    __properties: ClassVar[List[str]] = ["id", "voucher_id", "campaign_id", "customer_id", "order_id", "points", "activates_at", "details", "created_at", "updated_at"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of LoyaltyPendingPoints from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of details
        if self.details:
            _dict['details'] = self.details.to_dict()
        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['id'] = None

        # set to None if voucher_id (nullable) is None
        # and model_fields_set contains the field
        if self.voucher_id is None and "voucher_id" in self.model_fields_set:
            _dict['voucher_id'] = None

        # set to None if campaign_id (nullable) is None
        # and model_fields_set contains the field
        if self.campaign_id is None and "campaign_id" in self.model_fields_set:
            _dict['campaign_id'] = None

        # set to None if customer_id (nullable) is None
        # and model_fields_set contains the field
        if self.customer_id is None and "customer_id" in self.model_fields_set:
            _dict['customer_id'] = None

        # set to None if order_id (nullable) is None
        # and model_fields_set contains the field
        if self.order_id is None and "order_id" in self.model_fields_set:
            _dict['order_id'] = None

        # set to None if points (nullable) is None
        # and model_fields_set contains the field
        if self.points is None and "points" in self.model_fields_set:
            _dict['points'] = None

        # set to None if activates_at (nullable) is None
        # and model_fields_set contains the field
        if self.activates_at is None and "activates_at" in self.model_fields_set:
            _dict['activates_at'] = None

        # set to None if created_at (nullable) is None
        # and model_fields_set contains the field
        if self.created_at is None and "created_at" in self.model_fields_set:
            _dict['created_at'] = None

        # set to None if updated_at (nullable) is None
        # and model_fields_set contains the field
        if self.updated_at is None and "updated_at" in self.model_fields_set:
            _dict['updated_at'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of LoyaltyPendingPoints from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "voucher_id": obj.get("voucher_id"),
            "campaign_id": obj.get("campaign_id"),
            "customer_id": obj.get("customer_id"),
            "order_id": obj.get("order_id"),
            "points": obj.get("points"),
            "activates_at": obj.get("activates_at"),
            "details": LoyaltyPendingPointsDetails.from_dict(obj["details"]) if obj.get("details") is not None else None,
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


