# coding: utf-8

"""
    ReportingService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

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


from __future__ import annotations
from enum import Flag, auto

class DeliveredMatchTypeReportFilter(Flag):
    EXACT = auto()

    PHRASE = auto()

    BROAD = auto()

    EXACTCLOSEVARIANT = auto()

    PHRASECLOSEVARIANT = auto()

	
    def to_json(self) -> str:
        """Convert to JSON string representation"""
        return self._to_str()
	
    def __str__(self) -> str:
        """
        Return a human-readable string representation of the campaign types.
        """
        return self._to_str()

    def _to_str(self) -> str:
        """Convert the enum flags to a comma-separated string of quoted, capitalized names"""
        names = [flag.name.title() for flag in DeliveredMatchTypeReportFilter if flag & self]
        if not names:
            return "None"
        if len(names) == 1:
            # For single values, use single quotes
            return f"{names[0]}"
        # For multiple values, use double quotes with comma separation
        return ", ".join(f"{name}" for name in names)
		
    @classmethod
    def __get_validators__(cls):
        yield cls._validate
		
    @classmethod
    def _validate(cls, value, handler) -> "DeliveredMatchTypeReportFilter":
        if isinstance(value, cls):
            return value
        if isinstance(value, int):
            return cls(value)
        if isinstance(value, str):
            # Handle comma-separated campaign types
            types = [type_str.strip() for type_str in value.split(',')]
            if len(types) > 1:
                result = cls.NONE
                for type_str in types:
                    try:
                        result |= getattr(cls, type_str.upper())
                    except AttributeError:
                        raise ValueError(f"Invalid CampaignType value: {type_str}")
                return result
            else:
                # Single campaign type
                try:
                    return getattr(cls, value.strip().upper())
                except AttributeError:
                    raise ValueError(f"Invalid DeliveredMatchTypeReportFilter value: {value}")
        raise ValueError(f"Cannot convert {value} to DeliveredMatchTypeReportFilter")


