# 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 pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from voucherify.models.campaign_base import CampaignBase
from typing import Optional, Set
from typing_extensions import Self

class CampaignsSummaryGetResponseBody(BaseModel):
    """
    CampaignsSummaryGetResponseBody
    """ # noqa: E501
    object: Optional[StrictStr] = Field(default='campaign_summary', description="The type of the object, which is `campaign_summary`.")
    campaign: Optional[CampaignBase] = None
    redemptions: Optional[StrictInt] = Field(default=None, description="Total number of redemptions, which includes successful and failed redemptions.")
    redemptions_succeeded: Optional[StrictInt] = Field(default=None, description="Total number of successful redemptions.")
    redemptions_failed: Optional[StrictInt] = Field(default=None, description="Total number of failed redemptions.")
    rollbacks: Optional[StrictInt] = Field(default=None, description="Total number of rollbacks, which includes successful and failed rollbacks.")
    rollbacks_succeeded: Optional[StrictInt] = Field(default=None, description="Total number of successful rollbacks.")
    rollbacks_failed: Optional[StrictInt] = Field(default=None, description="Total number of failed rollbacks.")
    validations: Optional[StrictInt] = Field(default=None, description="Total number of validations, which includes successful and failed validations.")
    validations_succeeded: Optional[StrictInt] = Field(default=None, description="Total number of successful validations.")
    validations_failed: Optional[StrictInt] = Field(default=None, description="Total number of failed validations.")
    orders_amount: Optional[StrictInt] = Field(default=None, description="Total amount of orders related to the campaign. This amount is not reduced by `orders_rolledback_amount`. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    orders_rolledback_amount: Optional[StrictInt] = Field(default=None, description="Total amount of orders that were rolled back and are related to the campaign. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    vouchers_created: Optional[StrictInt] = Field(default=None, description="Total number of vouchers created within the campaign. Includes vouchers generated when the campaign was created, vouchers added manually, or vouchers generated automatically when a new customer joined the campaign.")
    vouchers_deleted: Optional[StrictInt] = Field(default=None, description="Total number of vouchers deleted within the campaign. Includes vouchers moved to the bin and vouchers deleted permanently. Vouchers moved to the bin and then deleted permanently are counted once.")
    publications: Optional[StrictInt] = Field(default=None, description="Total number of publications, which includes successful and failed publications.")
    publications_succeeded: Optional[StrictInt] = Field(default=None, description="Total number of successful publications.")
    publications_failed: Optional[StrictInt] = Field(default=None, description="Total number of failed publications.")
    discounted_amount: Optional[StrictInt] = Field(default=None, description="Total amount of discounts related to the campaign. This amount is not reduced by the `rolledback_discounted_amount`. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    rolledback_discounted_amount: Optional[StrictInt] = Field(default=None, description="Total amount of discounts orders that were rolled back and are related to the campaign. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    created_vouchers_amount: Optional[StrictInt] = Field(default=None, description="The total credit amount for all created gift cards. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    amount_added: Optional[StrictInt] = Field(default=None, description="The total credit amount that was added. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    amount_deleted: Optional[StrictInt] = Field(default=None, description="The total credit amount that was deleted by deleting gift cards. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    amount_redeemed: Optional[StrictInt] = Field(default=None, description="The total credit amount that was redeemed. This amount is not reduced by the `amount_rolledback`. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    amount_rolledback: Optional[StrictInt] = Field(default=None, description="The total credit amount that was rolled back. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    amount_subtracted: Optional[StrictInt] = Field(default=None, description="The total credit amount that was subtracted. The value is multiplied by `100` to precisely represent 2 decimal places. For example, `$10` is represented as `1000`.")
    created_vouchers_points: Optional[StrictInt] = Field(default=None, description="Total number of points added to newly created loyalty cards. This also counts points added for the loyalty cards which are created by importing a CSV file to a campaign.")
    points_deleted: Optional[StrictInt] = Field(default=None, description="Total number of points that were deleted.")
    points_subtracted: Optional[StrictInt] = Field(default=None, description="Total number of points that were subtracted.")
    points_added: Optional[StrictInt] = Field(default=None, description="Total number of points that were added. This includes points added manually or automatically by redeeming a reward that adds loyalty points to cards in this campaign.")
    points_rewarded: Optional[StrictInt] = Field(default=None, description="Total number of points that were rewarded to loyalty cards through earning rules. This includes pending points that were activated.")
    points_redeemed: Optional[StrictInt] = Field(default=None, description="Total number of points that were redeemed for rewards.")
    points_rolledback: Optional[StrictInt] = Field(default=None, description="Total number of points that were rolled back for reward redemptions.")
    points_expired: Optional[StrictInt] = Field(default=None, description="Total number of points that have expired.")
    points_transferred_out: Optional[StrictInt] = Field(default=None, description="Total number of points transferred out of loyalty cards covered by the campaign.")
    points_transferred_in: Optional[StrictInt] = Field(default=None, description="Total number of points transferred into loyalty cards covered by the campaign.")
    pending_points_added: Optional[StrictInt] = Field(default=None, description="Total number of pending points that were added either as part of earning rules or added manually to an existing pending point bucket. Pending points that were activated manually or automatically or that were canceled do not affect this number.")
    pending_points_subtracted: Optional[StrictInt] = Field(default=None, description="Total number of pending points that were subtracted from existing pending point buckets.")
    pending_points_activated: Optional[StrictInt] = Field(default=None, description="Total number of pending points that were activated manually or automatically.")
    pending_points_canceled: Optional[StrictInt] = Field(default=None, description="Total number of pending points that were canceled.")
    referred_customers: Optional[StrictInt] = Field(default=None, description="Total number of all referred customers.")
    __properties: ClassVar[List[str]] = ["object", "campaign", "redemptions", "redemptions_succeeded", "redemptions_failed", "rollbacks", "rollbacks_succeeded", "rollbacks_failed", "validations", "validations_succeeded", "validations_failed", "orders_amount", "orders_rolledback_amount", "vouchers_created", "vouchers_deleted", "publications", "publications_succeeded", "publications_failed", "discounted_amount", "rolledback_discounted_amount", "created_vouchers_amount", "amount_added", "amount_deleted", "amount_redeemed", "amount_rolledback", "amount_subtracted", "created_vouchers_points", "points_deleted", "points_subtracted", "points_added", "points_rewarded", "points_redeemed", "points_rolledback", "points_expired", "points_transferred_out", "points_transferred_in", "pending_points_added", "pending_points_subtracted", "pending_points_activated", "pending_points_canceled", "referred_customers"]

    @field_validator('object')
    def object_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['campaign_summary']):
            raise ValueError("must be one of enum values ('campaign_summary')")
        return value

    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 CampaignsSummaryGetResponseBody 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 campaign
        if self.campaign:
            _dict['campaign'] = self.campaign.to_dict()
        # set to None if object (nullable) is None
        # and model_fields_set contains the field
        if self.object is None and "object" in self.model_fields_set:
            _dict['object'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "object": obj.get("object") if obj.get("object") is not None else 'campaign_summary',
            "campaign": CampaignBase.from_dict(obj["campaign"]) if obj.get("campaign") is not None else None,
            "redemptions": obj.get("redemptions"),
            "redemptions_succeeded": obj.get("redemptions_succeeded"),
            "redemptions_failed": obj.get("redemptions_failed"),
            "rollbacks": obj.get("rollbacks"),
            "rollbacks_succeeded": obj.get("rollbacks_succeeded"),
            "rollbacks_failed": obj.get("rollbacks_failed"),
            "validations": obj.get("validations"),
            "validations_succeeded": obj.get("validations_succeeded"),
            "validations_failed": obj.get("validations_failed"),
            "orders_amount": obj.get("orders_amount"),
            "orders_rolledback_amount": obj.get("orders_rolledback_amount"),
            "vouchers_created": obj.get("vouchers_created"),
            "vouchers_deleted": obj.get("vouchers_deleted"),
            "publications": obj.get("publications"),
            "publications_succeeded": obj.get("publications_succeeded"),
            "publications_failed": obj.get("publications_failed"),
            "discounted_amount": obj.get("discounted_amount"),
            "rolledback_discounted_amount": obj.get("rolledback_discounted_amount"),
            "created_vouchers_amount": obj.get("created_vouchers_amount"),
            "amount_added": obj.get("amount_added"),
            "amount_deleted": obj.get("amount_deleted"),
            "amount_redeemed": obj.get("amount_redeemed"),
            "amount_rolledback": obj.get("amount_rolledback"),
            "amount_subtracted": obj.get("amount_subtracted"),
            "created_vouchers_points": obj.get("created_vouchers_points"),
            "points_deleted": obj.get("points_deleted"),
            "points_subtracted": obj.get("points_subtracted"),
            "points_added": obj.get("points_added"),
            "points_rewarded": obj.get("points_rewarded"),
            "points_redeemed": obj.get("points_redeemed"),
            "points_rolledback": obj.get("points_rolledback"),
            "points_expired": obj.get("points_expired"),
            "points_transferred_out": obj.get("points_transferred_out"),
            "points_transferred_in": obj.get("points_transferred_in"),
            "pending_points_added": obj.get("pending_points_added"),
            "pending_points_subtracted": obj.get("pending_points_subtracted"),
            "pending_points_activated": obj.get("pending_points_activated"),
            "pending_points_canceled": obj.get("pending_points_canceled"),
            "referred_customers": obj.get("referred_customers")
        })
        return _obj


