r"""
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Sample/reference Twilio API.
    This is the reference API for the rest-proxy server.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
"""

from datetime import datetime
from typing import Any, Dict, List, Optional, Union
from twilio.base import deserialize, values
from twilio.base.api_response import ApiResponse
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version


class ReportInstance(InstanceResource):

    class AccountReportAnsweringMachineDetection(object):
        """
        :ivar total_calls: Total number of calls with answering machine detection enabled (AMD).
        :ivar answered_by_human_percentage: Percentage of calls marked as answered by human.
        :ivar answered_by_machine_percentage: Percentage of calls marked as answered by machined related like the following: `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `fax`
        """

        def __init__(self, payload: Dict[str, Any]):

            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answered_by_human_percentage: Optional[float] = payload.get(
                "answered_by_human_percentage"
            )
            self.answered_by_machine_percentage: Optional[float] = payload.get(
                "answered_by_machine_percentage"
            )

        def to_dict(self):
            return {
                "total_calls": self.total_calls,
                "answered_by_human_percentage": self.answered_by_human_percentage,
                "answered_by_machine_percentage": self.answered_by_machine_percentage,
            }

    class AccountReportCallDirection(object):
        """
        :ivar outbound: Number of outbound calls
        :ivar inbound: Number of inbound calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.outbound: Optional[int] = payload.get("outbound")
            self.inbound: Optional[int] = payload.get("inbound")

        def to_dict(self):
            return {
                "outbound": self.outbound,
                "inbound": self.inbound,
            }

    class AccountReportCallState(object):
        """
        :ivar completed: Number of completed calls
        :ivar fail: Number of failed calls
        :ivar busy: Number of busy calls
        :ivar noanswer: Number of no-answer calls
        :ivar canceled: Number of canceled calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.completed: Optional[int] = payload.get("completed")
            self.fail: Optional[int] = payload.get("fail")
            self.busy: Optional[int] = payload.get("busy")
            self.noanswer: Optional[int] = payload.get("noanswer")
            self.canceled: Optional[int] = payload.get("canceled")

        def to_dict(self):
            return {
                "completed": self.completed,
                "fail": self.fail,
                "busy": self.busy,
                "noanswer": self.noanswer,
                "canceled": self.canceled,
            }

    class AccountReportCallType(object):
        """
        :ivar carrier: Number of carrier calls
        :ivar sip: Number of SIP calls
        :ivar trunking: Number of trunking calls
        :ivar client: Number of client calls
        :ivar whatsapp: Number of WhatsApp Business calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.carrier: Optional[int] = payload.get("carrier")
            self.sip: Optional[int] = payload.get("sip")
            self.trunking: Optional[int] = payload.get("trunking")
            self.client: Optional[int] = payload.get("client")
            self.whatsapp: Optional[int] = payload.get("whatsapp")

        def to_dict(self):
            return {
                "carrier": self.carrier,
                "sip": self.sip,
                "trunking": self.trunking,
                "client": self.client,
                "whatsapp": self.whatsapp,
            }

    class AccountReportKYT(object):
        """
        :ivar outbound_carrier_calling:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.outbound_carrier_calling: Optional[
                AccountReportKYTOutboundCarrierCalling
            ] = payload.get("outbound_carrier_calling")

        def to_dict(self):
            return {
                "outbound_carrier_calling": (
                    self.outbound_carrier_calling.to_dict()
                    if self.outbound_carrier_calling is not None
                    else None
                ),
            }

    class AccountReportKYTOutboundCarrierCalling(object):
        """
        :ivar unique_calling_numbers: Number of unique PSTN calling numbers to non-Twilio numbers during the report period.
        :ivar unique_called_numbers: Number of unique non-Twilio PSTN called numbers during the report period.
        :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country.
        :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured.
        :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds)
        :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers.
        :ivar branded_calling:
        :ivar voice_integrity:
        :ivar stir_shaken:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.unique_calling_numbers: Optional[int] = payload.get(
                "unique_calling_numbers"
            )
            self.unique_called_numbers: Optional[int] = payload.get(
                "unique_called_numbers"
            )
            self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = (
                payload.get("blocked_calls_by_carrier")
            )
            self.short_duration_calls_percentage: Optional[float] = payload.get(
                "short_duration_calls_percentage"
            )
            self.long_duration_calls_percentage: Optional[float] = payload.get(
                "long_duration_calls_percentage"
            )
            self.potential_robocalls_percentage: Optional[float] = payload.get(
                "potential_robocalls_percentage"
            )
            self.branded_calling: Optional[BrandedCalling] = payload.get(
                "branded_calling"
            )
            self.voice_integrity: Optional[VoiceIntegrity] = payload.get(
                "voice_integrity"
            )
            self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken")

        def to_dict(self):
            return {
                "unique_calling_numbers": self.unique_calling_numbers,
                "unique_called_numbers": self.unique_called_numbers,
                "blocked_calls_by_carrier": (
                    [
                        blocked_calls_by_carrier.to_dict()
                        for blocked_calls_by_carrier in self.blocked_calls_by_carrier
                    ]
                    if self.blocked_calls_by_carrier is not None
                    else None
                ),
                "short_duration_calls_percentage": self.short_duration_calls_percentage,
                "long_duration_calls_percentage": self.long_duration_calls_percentage,
                "potential_robocalls_percentage": self.potential_robocalls_percentage,
                "branded_calling": (
                    self.branded_calling.to_dict()
                    if self.branded_calling is not None
                    else None
                ),
                "voice_integrity": (
                    self.voice_integrity.to_dict()
                    if self.voice_integrity is not None
                    else None
                ),
                "stir_shaken": (
                    self.stir_shaken.to_dict() if self.stir_shaken is not None else None
                ),
            }

    class AccountReportNetworkIssues(object):
        """
        :ivar sdk:
        :ivar twilio_gateway:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk")
            self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = (
                payload.get("twilio_gateway")
            )

        def to_dict(self):
            return {
                "sdk": self.sdk.to_dict() if self.sdk is not None else None,
                "twilio_gateway": (
                    self.twilio_gateway.to_dict()
                    if self.twilio_gateway is not None
                    else None
                ),
            }

    class AccountReportNetworkIssuesSdk(object):
        """
        :ivar ice_failures_percentage: Percentage of ICE connection failure tag that ICE candidates have failed to find compatible connection.
        :ivar high_latency_percentage: Percentage of calls with high latency.
        :ivar high_packet_loss_percentage: Percentage of calls with high packet loss.
        :ivar high_jitter_percentage: Percentage of calls with high jitter.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.ice_failures_percentage: Optional[float] = payload.get(
                "ice_failures_percentage"
            )
            self.high_latency_percentage: Optional[float] = payload.get(
                "high_latency_percentage"
            )
            self.high_packet_loss_percentage: Optional[float] = payload.get(
                "high_packet_loss_percentage"
            )
            self.high_jitter_percentage: Optional[float] = payload.get(
                "high_jitter_percentage"
            )

        def to_dict(self):
            return {
                "ice_failures_percentage": self.ice_failures_percentage,
                "high_latency_percentage": self.high_latency_percentage,
                "high_packet_loss_percentage": self.high_packet_loss_percentage,
                "high_jitter_percentage": self.high_jitter_percentage,
            }

    class AccountReportNetworkIssuesTwilioGateway(object):
        """
        :ivar high_latency_percentage: Percentage of calls with high latency.
        :ivar high_packet_loss_percentage: Percentage of calls with high packet loss.
        :ivar high_jitter_percentage: Percentage of calls with high jitter.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.high_latency_percentage: Optional[float] = payload.get(
                "high_latency_percentage"
            )
            self.high_packet_loss_percentage: Optional[float] = payload.get(
                "high_packet_loss_percentage"
            )
            self.high_jitter_percentage: Optional[float] = payload.get(
                "high_jitter_percentage"
            )

        def to_dict(self):
            return {
                "high_latency_percentage": self.high_latency_percentage,
                "high_packet_loss_percentage": self.high_packet_loss_percentage,
                "high_jitter_percentage": self.high_jitter_percentage,
            }

    class BrandedCalling(object):
        """
        :ivar total_branded_calls: Total number of Branded bundled calls.
        :ivar percent_branded_calls: Percentage of Branded bundled calls over total outbound calls.
        :ivar answer_rate: Answer rate for Branded bundled calls.
        :ivar human_answer_rate: Rate of Branded bundled calls that were answered by Human.
        :ivar engagement_rate: Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds.
        :ivar by_use_case: Details of branded calls by use case.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.total_branded_calls: Optional[int] = payload.get("total_branded_calls")
            self.percent_branded_calls: Optional[float] = payload.get(
                "percent_branded_calls"
            )
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")
            self.engagement_rate: Optional[float] = payload.get("engagement_rate")
            self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get(
                "by_use_case"
            )

        def to_dict(self):
            return {
                "total_branded_calls": self.total_branded_calls,
                "percent_branded_calls": self.percent_branded_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
                "engagement_rate": self.engagement_rate,
                "by_use_case": (
                    [by_use_case.to_dict() for by_use_case in self.by_use_case]
                    if self.by_use_case is not None
                    else None
                ),
            }

    class BrandedUseCaseDetail(object):
        """
        :ivar use_case: The name of supported use case for Branded calls.
        :ivar enabled_phonenumbers: The number of phone numbers enabled Branded calls.
        :ivar total_calls: The number of total outbound calls for the use case.
        :ivar answer_rate: Answer rate per each use case for Branded bundled calls.
        :ivar human_answer_rate: Rate of Branded bundled calls that were answered by Human per each use case for Branded bundled calls.
        :ivar engagement_rate: Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds per each use case for Branded bundled calls.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.use_case: Optional[str] = payload.get("use_case")
            self.enabled_phonenumbers: Optional[int] = payload.get(
                "enabled_phonenumbers"
            )
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")
            self.engagement_rate: Optional[float] = payload.get("engagement_rate")

        def to_dict(self):
            return {
                "use_case": self.use_case,
                "enabled_phonenumbers": self.enabled_phonenumbers,
                "total_calls": self.total_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
                "engagement_rate": self.engagement_rate,
            }

    class CountyCarrierValueCarriers(object):
        """
        :ivar carrier: The name of the carrier.
        :ivar total_calls: Total number of outbound calls for the carrier in the country.
        :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country.
        :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.carrier: Optional[str] = payload.get("carrier")
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.blocked_calls: Optional[int] = payload.get("blocked_calls")
            self.blocked_calls_percentage: Optional[float] = payload.get(
                "blocked_calls_percentage"
            )

        def to_dict(self):
            return {
                "carrier": self.carrier,
                "total_calls": self.total_calls,
                "blocked_calls": self.blocked_calls,
                "blocked_calls_percentage": self.blocked_calls_percentage,
            }

    class InsightsV2CreateAccountReportRequest(object):
        """
        :ivar time_range:
        :ivar filters:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.time_range: Optional[
                ReportList.InsightsV2CreateAccountReportRequestTimeRange
            ] = payload.get("time_range")
            self.filters: Optional[List[ReportList.ReportFilter]] = payload.get(
                "filters"
            )

        def to_dict(self):
            return {
                "time_range": (
                    self.time_range.to_dict() if self.time_range is not None else None
                ),
                "filters": (
                    [filters.to_dict() for filters in self.filters]
                    if self.filters is not None
                    else None
                ),
            }

    class InsightsV2CreateAccountReportRequestTimeRange(object):
        """
        :ivar start_time: Start time of the report
        :ivar end_time: End time of the report
        """

        def __init__(self, payload: Dict[str, Any]):

            self.start_time: Optional[datetime] = payload.get("start_time")
            self.end_time: Optional[datetime] = payload.get("end_time")

        def to_dict(self):
            return {
                "start_time": self.start_time,
                "end_time": self.end_time,
            }

    class ReportFilter(object):
        """
        :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent'
        :ivar values: List of supported filter values for the field name
        """

        def __init__(self, payload: Dict[str, Any]):

            self.key: Optional[str] = payload.get("key")
            self.values: Optional[List[str]] = payload.get("values")

        def to_dict(self):
            return {
                "key": self.key,
                "values": self.values,
            }

    class StirShaken(object):
        """
        :ivar call_count:
        :ivar percentage:
        :ivar answer_rate:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.call_count: Optional[StirShakenCallCount] = payload.get("call_count")
            self.percentage: Optional[StirShakenPercentage] = payload.get("percentage")
            self.answer_rate: Optional[StirShakenAnswerRate] = payload.get(
                "answer_rate"
            )

        def to_dict(self):
            return {
                "call_count": (
                    self.call_count.to_dict() if self.call_count is not None else None
                ),
                "percentage": (
                    self.percentage.to_dict() if self.percentage is not None else None
                ),
                "answer_rate": (
                    self.answer_rate.to_dict() if self.answer_rate is not None else None
                ),
            }

    class StirShakenAnswerRate(object):
        """
        :ivar stsh_a: Answer rate for Stir Shaken category A.
        :ivar stsh_b: Answer rate for Stir Shaken category B.
        :ivar stsh_c: Answer rate for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[float] = payload.get("stsh_a")
            self.stsh_b: Optional[float] = payload.get("stsh_b")
            self.stsh_c: Optional[float] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class StirShakenCallCount(object):
        """
        :ivar stsh_a: Total number of calls for Stir Shaken category A.
        :ivar stsh_b: Total number of calls for Stir Shaken category B.
        :ivar stsh_c: Total number of calls for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[int] = payload.get("stsh_a")
            self.stsh_b: Optional[int] = payload.get("stsh_b")
            self.stsh_c: Optional[int] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class StirShakenPercentage(object):
        """
        :ivar stsh_a: Percentage of calls for Stir Shaken category A.
        :ivar stsh_b: Percentage of calls for Stir Shaken category B.
        :ivar stsh_c: Percentage of calls for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[float] = payload.get("stsh_a")
            self.stsh_b: Optional[float] = payload.get("stsh_b")
            self.stsh_c: Optional[float] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class VoiceIntegrity(object):
        """
        :ivar enabled_calls: Total number of calls with Voice Integrity enabled.
        :ivar enabled_percentage: Percentage of calls with Voice Integrity enabled.
        :ivar calls_per_bundle: Number of calls per Voice Integrity enabled Bundle Sid.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.enabled_calls: Optional[int] = payload.get("enabled_calls")
            self.enabled_percentage: Optional[float] = payload.get("enabled_percentage")
            self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = (
                payload.get("calls_per_bundle")
            )

        def to_dict(self):
            return {
                "enabled_calls": self.enabled_calls,
                "enabled_percentage": self.enabled_percentage,
                "calls_per_bundle": (
                    [
                        calls_per_bundle.to_dict()
                        for calls_per_bundle in self.calls_per_bundle
                    ]
                    if self.calls_per_bundle is not None
                    else None
                ),
            }

    class VoiceIntegrityCallsPerBundle(object):
        """
        :ivar bundle_sid: Voice Integrity Approved Profile Sid.
        :ivar enabled_phonenumbers: The number of Voice Integrity enabled and registered phone numbers per Bundle Sid.
        :ivar total_calls: The number of outbound calls on Voice Integrity enabled and registered number per Bundle Sid.
        :ivar answer_rate: Answer rate for calls on Voice Integrity enabled and registered number per Bundle Sid.
        :ivar human_answer_rate: Rate for calls on Voice Integrity enabled and registered number per Bundle Sid that were answered by Human per each use case for Branded bundled calls.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.bundle_sid: Optional[str] = payload.get("bundle_sid")
            self.enabled_phonenumbers: Optional[int] = payload.get(
                "enabled_phonenumbers"
            )
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")

        def to_dict(self):
            return {
                "bundle_sid": self.bundle_sid,
                "enabled_phonenumbers": self.enabled_phonenumbers,
                "total_calls": self.total_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
            }

    class ReportStatus(object):
        CREATED = "created"
        RUNNING = "running"
        COMPLETED = "completed"

    """
    :ivar account_sid: The unique SID identifier of the Account.
    :ivar report_id: The report identifier as Voice Insights Report TTID.
    :ivar status: 
    :ivar request_meta: 
    :ivar url: The URL of this resource.
    :ivar handle: Inbound phone number handle represented in the report.
    :ivar total_calls: Total number of calls made with the given handle during the report period.
    :ivar call_answer_score: The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered. 
    :ivar call_state_percentage: 
    :ivar silent_calls_percentage: Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio.
    :ivar calls_by_device_type: Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown` 
    :ivar answer_rate_device_type: Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown` 
    :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country.
    :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured.
    :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds)
    :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers.
    :ivar answering_machine_detection: 
    :ivar report: 
    """

    def __init__(
        self, version: Version, payload: Dict[str, Any], report_id: Optional[str] = None
    ):
        super().__init__(version)

        self.account_sid: Optional[str] = payload.get("account_sid")
        self.report_id: Optional[str] = payload.get("report_id")
        self.status: Optional["InboundInstance.str"] = payload.get("status")
        self.request_meta: Optional[str] = payload.get("request_meta")
        self.url: Optional[str] = payload.get("url")
        self.handle: Optional[str] = payload.get("handle")
        self.total_calls: Optional[int] = deserialize.integer(
            payload.get("total_calls")
        )
        self.call_answer_score: Optional[float] = payload.get("call_answer_score")
        self.call_state_percentage: Optional[str] = payload.get("call_state_percentage")
        self.silent_calls_percentage: Optional[float] = payload.get(
            "silent_calls_percentage"
        )
        self.calls_by_device_type: Optional[Dict[str, int]] = payload.get(
            "calls_by_device_type"
        )
        self.answer_rate_device_type: Optional[Dict[str, float]] = payload.get(
            "answer_rate_device_type"
        )
        self.blocked_calls_by_carrier: Optional[List[str]] = payload.get(
            "blocked_calls_by_carrier"
        )
        self.short_duration_calls_percentage: Optional[float] = payload.get(
            "short_duration_calls_percentage"
        )
        self.long_duration_calls_percentage: Optional[float] = payload.get(
            "long_duration_calls_percentage"
        )
        self.potential_robocalls_percentage: Optional[float] = payload.get(
            "potential_robocalls_percentage"
        )
        self.answering_machine_detection: Optional[str] = payload.get(
            "answering_machine_detection"
        )
        self.report: Optional[str] = payload.get("report")

        self._solution = {
            "report_id": report_id or self.report_id,
        }
        self._context: Optional[ReportContext] = None

    @property
    def _proxy(self) -> "ReportContext":
        """
        Generate an instance context for the instance, the context is capable of
        performing various actions. All instance actions are proxied to the context

        :returns: ReportContext for this ReportInstance
        """
        if self._context is None:
            self._context = ReportContext(
                self._version,
                report_id=self._solution["report_id"],
            )
        return self._context

    def create(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> "ReportInstance":
        """
        Create the ReportInstance

        :param insights_v2_create_account_report_request:

        :returns: The created ReportInstance
        """
        return self._proxy.create(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request,
        )

    async def create_async(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> "ReportInstance":
        """
        Asynchronous coroutine to create the ReportInstance

        :param insights_v2_create_account_report_request:

        :returns: The created ReportInstance
        """
        return await self._proxy.create_async(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request,
        )

    def create_with_http_info(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> ApiResponse:
        """
        Create the ReportInstance with HTTP info

        :param insights_v2_create_account_report_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.create_with_http_info(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request,
        )

    async def create_with_http_info_async(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> ApiResponse:
        """
        Asynchronous coroutine to create the ReportInstance with HTTP info

        :param insights_v2_create_account_report_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.create_with_http_info_async(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request,
        )

    def fetch(self) -> "ReportInstance":
        """
        Fetch the ReportInstance


        :returns: The fetched ReportInstance
        """
        return self._proxy.fetch()

    async def fetch_async(self) -> "ReportInstance":
        """
        Asynchronous coroutine to fetch the ReportInstance


        :returns: The fetched ReportInstance
        """
        return await self._proxy.fetch_async()

    def fetch_with_http_info(self) -> ApiResponse:
        """
        Fetch the ReportInstance with HTTP info


        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.fetch_with_http_info()

    async def fetch_with_http_info_async(self) -> ApiResponse:
        """
        Asynchronous coroutine to fetch the ReportInstance with HTTP info


        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.fetch_with_http_info_async()

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Insights.V2.ReportInstance {}>".format(context)


class ReportContext(InstanceContext):

    class AccountReportAnsweringMachineDetection(object):
        """
        :ivar total_calls: Total number of calls with answering machine detection enabled (AMD).
        :ivar answered_by_human_percentage: Percentage of calls marked as answered by human.
        :ivar answered_by_machine_percentage: Percentage of calls marked as answered by machined related like the following: `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `fax`
        """

        def __init__(self, payload: Dict[str, Any]):

            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answered_by_human_percentage: Optional[float] = payload.get(
                "answered_by_human_percentage"
            )
            self.answered_by_machine_percentage: Optional[float] = payload.get(
                "answered_by_machine_percentage"
            )

        def to_dict(self):
            return {
                "total_calls": self.total_calls,
                "answered_by_human_percentage": self.answered_by_human_percentage,
                "answered_by_machine_percentage": self.answered_by_machine_percentage,
            }

    class AccountReportCallDirection(object):
        """
        :ivar outbound: Number of outbound calls
        :ivar inbound: Number of inbound calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.outbound: Optional[int] = payload.get("outbound")
            self.inbound: Optional[int] = payload.get("inbound")

        def to_dict(self):
            return {
                "outbound": self.outbound,
                "inbound": self.inbound,
            }

    class AccountReportCallState(object):
        """
        :ivar completed: Number of completed calls
        :ivar fail: Number of failed calls
        :ivar busy: Number of busy calls
        :ivar noanswer: Number of no-answer calls
        :ivar canceled: Number of canceled calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.completed: Optional[int] = payload.get("completed")
            self.fail: Optional[int] = payload.get("fail")
            self.busy: Optional[int] = payload.get("busy")
            self.noanswer: Optional[int] = payload.get("noanswer")
            self.canceled: Optional[int] = payload.get("canceled")

        def to_dict(self):
            return {
                "completed": self.completed,
                "fail": self.fail,
                "busy": self.busy,
                "noanswer": self.noanswer,
                "canceled": self.canceled,
            }

    class AccountReportCallType(object):
        """
        :ivar carrier: Number of carrier calls
        :ivar sip: Number of SIP calls
        :ivar trunking: Number of trunking calls
        :ivar client: Number of client calls
        :ivar whatsapp: Number of WhatsApp Business calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.carrier: Optional[int] = payload.get("carrier")
            self.sip: Optional[int] = payload.get("sip")
            self.trunking: Optional[int] = payload.get("trunking")
            self.client: Optional[int] = payload.get("client")
            self.whatsapp: Optional[int] = payload.get("whatsapp")

        def to_dict(self):
            return {
                "carrier": self.carrier,
                "sip": self.sip,
                "trunking": self.trunking,
                "client": self.client,
                "whatsapp": self.whatsapp,
            }

    class AccountReportKYT(object):
        """
        :ivar outbound_carrier_calling:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.outbound_carrier_calling: Optional[
                AccountReportKYTOutboundCarrierCalling
            ] = payload.get("outbound_carrier_calling")

        def to_dict(self):
            return {
                "outbound_carrier_calling": (
                    self.outbound_carrier_calling.to_dict()
                    if self.outbound_carrier_calling is not None
                    else None
                ),
            }

    class AccountReportKYTOutboundCarrierCalling(object):
        """
        :ivar unique_calling_numbers: Number of unique PSTN calling numbers to non-Twilio numbers during the report period.
        :ivar unique_called_numbers: Number of unique non-Twilio PSTN called numbers during the report period.
        :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country.
        :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured.
        :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds)
        :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers.
        :ivar branded_calling:
        :ivar voice_integrity:
        :ivar stir_shaken:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.unique_calling_numbers: Optional[int] = payload.get(
                "unique_calling_numbers"
            )
            self.unique_called_numbers: Optional[int] = payload.get(
                "unique_called_numbers"
            )
            self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = (
                payload.get("blocked_calls_by_carrier")
            )
            self.short_duration_calls_percentage: Optional[float] = payload.get(
                "short_duration_calls_percentage"
            )
            self.long_duration_calls_percentage: Optional[float] = payload.get(
                "long_duration_calls_percentage"
            )
            self.potential_robocalls_percentage: Optional[float] = payload.get(
                "potential_robocalls_percentage"
            )
            self.branded_calling: Optional[BrandedCalling] = payload.get(
                "branded_calling"
            )
            self.voice_integrity: Optional[VoiceIntegrity] = payload.get(
                "voice_integrity"
            )
            self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken")

        def to_dict(self):
            return {
                "unique_calling_numbers": self.unique_calling_numbers,
                "unique_called_numbers": self.unique_called_numbers,
                "blocked_calls_by_carrier": (
                    [
                        blocked_calls_by_carrier.to_dict()
                        for blocked_calls_by_carrier in self.blocked_calls_by_carrier
                    ]
                    if self.blocked_calls_by_carrier is not None
                    else None
                ),
                "short_duration_calls_percentage": self.short_duration_calls_percentage,
                "long_duration_calls_percentage": self.long_duration_calls_percentage,
                "potential_robocalls_percentage": self.potential_robocalls_percentage,
                "branded_calling": (
                    self.branded_calling.to_dict()
                    if self.branded_calling is not None
                    else None
                ),
                "voice_integrity": (
                    self.voice_integrity.to_dict()
                    if self.voice_integrity is not None
                    else None
                ),
                "stir_shaken": (
                    self.stir_shaken.to_dict() if self.stir_shaken is not None else None
                ),
            }

    class AccountReportNetworkIssues(object):
        """
        :ivar sdk:
        :ivar twilio_gateway:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk")
            self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = (
                payload.get("twilio_gateway")
            )

        def to_dict(self):
            return {
                "sdk": self.sdk.to_dict() if self.sdk is not None else None,
                "twilio_gateway": (
                    self.twilio_gateway.to_dict()
                    if self.twilio_gateway is not None
                    else None
                ),
            }

    class AccountReportNetworkIssuesSdk(object):
        """
        :ivar ice_failures_percentage: Percentage of ICE connection failure tag that ICE candidates have failed to find compatible connection.
        :ivar high_latency_percentage: Percentage of calls with high latency.
        :ivar high_packet_loss_percentage: Percentage of calls with high packet loss.
        :ivar high_jitter_percentage: Percentage of calls with high jitter.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.ice_failures_percentage: Optional[float] = payload.get(
                "ice_failures_percentage"
            )
            self.high_latency_percentage: Optional[float] = payload.get(
                "high_latency_percentage"
            )
            self.high_packet_loss_percentage: Optional[float] = payload.get(
                "high_packet_loss_percentage"
            )
            self.high_jitter_percentage: Optional[float] = payload.get(
                "high_jitter_percentage"
            )

        def to_dict(self):
            return {
                "ice_failures_percentage": self.ice_failures_percentage,
                "high_latency_percentage": self.high_latency_percentage,
                "high_packet_loss_percentage": self.high_packet_loss_percentage,
                "high_jitter_percentage": self.high_jitter_percentage,
            }

    class AccountReportNetworkIssuesTwilioGateway(object):
        """
        :ivar high_latency_percentage: Percentage of calls with high latency.
        :ivar high_packet_loss_percentage: Percentage of calls with high packet loss.
        :ivar high_jitter_percentage: Percentage of calls with high jitter.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.high_latency_percentage: Optional[float] = payload.get(
                "high_latency_percentage"
            )
            self.high_packet_loss_percentage: Optional[float] = payload.get(
                "high_packet_loss_percentage"
            )
            self.high_jitter_percentage: Optional[float] = payload.get(
                "high_jitter_percentage"
            )

        def to_dict(self):
            return {
                "high_latency_percentage": self.high_latency_percentage,
                "high_packet_loss_percentage": self.high_packet_loss_percentage,
                "high_jitter_percentage": self.high_jitter_percentage,
            }

    class BrandedCalling(object):
        """
        :ivar total_branded_calls: Total number of Branded bundled calls.
        :ivar percent_branded_calls: Percentage of Branded bundled calls over total outbound calls.
        :ivar answer_rate: Answer rate for Branded bundled calls.
        :ivar human_answer_rate: Rate of Branded bundled calls that were answered by Human.
        :ivar engagement_rate: Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds.
        :ivar by_use_case: Details of branded calls by use case.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.total_branded_calls: Optional[int] = payload.get("total_branded_calls")
            self.percent_branded_calls: Optional[float] = payload.get(
                "percent_branded_calls"
            )
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")
            self.engagement_rate: Optional[float] = payload.get("engagement_rate")
            self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get(
                "by_use_case"
            )

        def to_dict(self):
            return {
                "total_branded_calls": self.total_branded_calls,
                "percent_branded_calls": self.percent_branded_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
                "engagement_rate": self.engagement_rate,
                "by_use_case": (
                    [by_use_case.to_dict() for by_use_case in self.by_use_case]
                    if self.by_use_case is not None
                    else None
                ),
            }

    class BrandedUseCaseDetail(object):
        """
        :ivar use_case: The name of supported use case for Branded calls.
        :ivar enabled_phonenumbers: The number of phone numbers enabled Branded calls.
        :ivar total_calls: The number of total outbound calls for the use case.
        :ivar answer_rate: Answer rate per each use case for Branded bundled calls.
        :ivar human_answer_rate: Rate of Branded bundled calls that were answered by Human per each use case for Branded bundled calls.
        :ivar engagement_rate: Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds per each use case for Branded bundled calls.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.use_case: Optional[str] = payload.get("use_case")
            self.enabled_phonenumbers: Optional[int] = payload.get(
                "enabled_phonenumbers"
            )
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")
            self.engagement_rate: Optional[float] = payload.get("engagement_rate")

        def to_dict(self):
            return {
                "use_case": self.use_case,
                "enabled_phonenumbers": self.enabled_phonenumbers,
                "total_calls": self.total_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
                "engagement_rate": self.engagement_rate,
            }

    class CountyCarrierValueCarriers(object):
        """
        :ivar carrier: The name of the carrier.
        :ivar total_calls: Total number of outbound calls for the carrier in the country.
        :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country.
        :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.carrier: Optional[str] = payload.get("carrier")
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.blocked_calls: Optional[int] = payload.get("blocked_calls")
            self.blocked_calls_percentage: Optional[float] = payload.get(
                "blocked_calls_percentage"
            )

        def to_dict(self):
            return {
                "carrier": self.carrier,
                "total_calls": self.total_calls,
                "blocked_calls": self.blocked_calls,
                "blocked_calls_percentage": self.blocked_calls_percentage,
            }

    class InsightsV2CreateAccountReportRequest(object):
        """
        :ivar time_range:
        :ivar filters:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.time_range: Optional[
                ReportList.InsightsV2CreateAccountReportRequestTimeRange
            ] = payload.get("time_range")
            self.filters: Optional[List[ReportList.ReportFilter]] = payload.get(
                "filters"
            )

        def to_dict(self):
            return {
                "time_range": (
                    self.time_range.to_dict() if self.time_range is not None else None
                ),
                "filters": (
                    [filters.to_dict() for filters in self.filters]
                    if self.filters is not None
                    else None
                ),
            }

    class InsightsV2CreateAccountReportRequestTimeRange(object):
        """
        :ivar start_time: Start time of the report
        :ivar end_time: End time of the report
        """

        def __init__(self, payload: Dict[str, Any]):

            self.start_time: Optional[datetime] = payload.get("start_time")
            self.end_time: Optional[datetime] = payload.get("end_time")

        def to_dict(self):
            return {
                "start_time": self.start_time,
                "end_time": self.end_time,
            }

    class ReportFilter(object):
        """
        :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent'
        :ivar values: List of supported filter values for the field name
        """

        def __init__(self, payload: Dict[str, Any]):

            self.key: Optional[str] = payload.get("key")
            self.values: Optional[List[str]] = payload.get("values")

        def to_dict(self):
            return {
                "key": self.key,
                "values": self.values,
            }

    class StirShaken(object):
        """
        :ivar call_count:
        :ivar percentage:
        :ivar answer_rate:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.call_count: Optional[StirShakenCallCount] = payload.get("call_count")
            self.percentage: Optional[StirShakenPercentage] = payload.get("percentage")
            self.answer_rate: Optional[StirShakenAnswerRate] = payload.get(
                "answer_rate"
            )

        def to_dict(self):
            return {
                "call_count": (
                    self.call_count.to_dict() if self.call_count is not None else None
                ),
                "percentage": (
                    self.percentage.to_dict() if self.percentage is not None else None
                ),
                "answer_rate": (
                    self.answer_rate.to_dict() if self.answer_rate is not None else None
                ),
            }

    class StirShakenAnswerRate(object):
        """
        :ivar stsh_a: Answer rate for Stir Shaken category A.
        :ivar stsh_b: Answer rate for Stir Shaken category B.
        :ivar stsh_c: Answer rate for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[float] = payload.get("stsh_a")
            self.stsh_b: Optional[float] = payload.get("stsh_b")
            self.stsh_c: Optional[float] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class StirShakenCallCount(object):
        """
        :ivar stsh_a: Total number of calls for Stir Shaken category A.
        :ivar stsh_b: Total number of calls for Stir Shaken category B.
        :ivar stsh_c: Total number of calls for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[int] = payload.get("stsh_a")
            self.stsh_b: Optional[int] = payload.get("stsh_b")
            self.stsh_c: Optional[int] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class StirShakenPercentage(object):
        """
        :ivar stsh_a: Percentage of calls for Stir Shaken category A.
        :ivar stsh_b: Percentage of calls for Stir Shaken category B.
        :ivar stsh_c: Percentage of calls for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[float] = payload.get("stsh_a")
            self.stsh_b: Optional[float] = payload.get("stsh_b")
            self.stsh_c: Optional[float] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class VoiceIntegrity(object):
        """
        :ivar enabled_calls: Total number of calls with Voice Integrity enabled.
        :ivar enabled_percentage: Percentage of calls with Voice Integrity enabled.
        :ivar calls_per_bundle: Number of calls per Voice Integrity enabled Bundle Sid.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.enabled_calls: Optional[int] = payload.get("enabled_calls")
            self.enabled_percentage: Optional[float] = payload.get("enabled_percentage")
            self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = (
                payload.get("calls_per_bundle")
            )

        def to_dict(self):
            return {
                "enabled_calls": self.enabled_calls,
                "enabled_percentage": self.enabled_percentage,
                "calls_per_bundle": (
                    [
                        calls_per_bundle.to_dict()
                        for calls_per_bundle in self.calls_per_bundle
                    ]
                    if self.calls_per_bundle is not None
                    else None
                ),
            }

    class VoiceIntegrityCallsPerBundle(object):
        """
        :ivar bundle_sid: Voice Integrity Approved Profile Sid.
        :ivar enabled_phonenumbers: The number of Voice Integrity enabled and registered phone numbers per Bundle Sid.
        :ivar total_calls: The number of outbound calls on Voice Integrity enabled and registered number per Bundle Sid.
        :ivar answer_rate: Answer rate for calls on Voice Integrity enabled and registered number per Bundle Sid.
        :ivar human_answer_rate: Rate for calls on Voice Integrity enabled and registered number per Bundle Sid that were answered by Human per each use case for Branded bundled calls.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.bundle_sid: Optional[str] = payload.get("bundle_sid")
            self.enabled_phonenumbers: Optional[int] = payload.get(
                "enabled_phonenumbers"
            )
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")

        def to_dict(self):
            return {
                "bundle_sid": self.bundle_sid,
                "enabled_phonenumbers": self.enabled_phonenumbers,
                "total_calls": self.total_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
            }

    def __init__(self, version: Version, report_id: str):
        """
        Initialize the ReportContext

        :param version: Version that contains the resource
        :param report_id: A unique request id.
        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "report_id": report_id,
        }
        self._uri = "/Voice/Reports/{report_id}".format(**self._solution)

    def _create(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> tuple:
        """
        Internal helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = insights_v2_create_account_report_request.to_dict()

        headers = values.of({})

        headers["Content-Type"] = "application/json"

        headers["Accept"] = "application/json"

        return self._version.create_with_response_info(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    def create(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> ReportInstance:
        """
        Create the ReportInstance

        :param insights_v2_create_account_report_request:

        :returns: The created ReportInstance
        """
        payload, _, _ = self._create(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request
        )
        return ReportInstance(
            self._version, payload, report_id=self._solution["report_id"]
        )

    def create_with_http_info(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> ApiResponse:
        """
        Create the ReportInstance and return response metadata

        :param insights_v2_create_account_report_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._create(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request
        )
        instance = ReportInstance(
            self._version, payload, report_id=self._solution["report_id"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _create_async(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> tuple:
        """
        Internal async helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = insights_v2_create_account_report_request.to_dict()

        headers = values.of({})

        headers["Content-Type"] = "application/json"

        headers["Accept"] = "application/json"

        return await self._version.create_with_response_info_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    async def create_async(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> ReportInstance:
        """
        Asynchronous coroutine to create the ReportInstance

        :param insights_v2_create_account_report_request:

        :returns: The created ReportInstance
        """
        payload, _, _ = await self._create_async(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request
        )
        return ReportInstance(
            self._version, payload, report_id=self._solution["report_id"]
        )

    async def create_with_http_info_async(
        self,
        insights_v2_create_account_report_request: Union[
            InsightsV2CreateAccountReportRequest, object
        ] = values.unset,
    ) -> ApiResponse:
        """
        Asynchronous coroutine to create the ReportInstance and return response metadata

        :param insights_v2_create_account_report_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            insights_v2_create_account_report_request=insights_v2_create_account_report_request
        )
        instance = ReportInstance(
            self._version, payload, report_id=self._solution["report_id"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    def _fetch(self) -> tuple:
        """
        Internal helper for fetch operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        headers = values.of({})

        headers["Accept"] = "application/json"

        return self._version.fetch_with_response_info(
            method="GET", uri=self._uri, headers=headers
        )

    def fetch(self) -> ReportInstance:
        """
        Fetch the ReportInstance


        :returns: The fetched ReportInstance
        """
        payload, _, _ = self._fetch()
        return ReportInstance(
            self._version,
            payload,
            report_id=self._solution["report_id"],
        )

    def fetch_with_http_info(self) -> ApiResponse:
        """
        Fetch the ReportInstance and return response metadata


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._fetch()
        instance = ReportInstance(
            self._version,
            payload,
            report_id=self._solution["report_id"],
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _fetch_async(self) -> tuple:
        """
        Internal async helper for fetch operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        headers = values.of({})

        headers["Accept"] = "application/json"

        return await self._version.fetch_with_response_info_async(
            method="GET", uri=self._uri, headers=headers
        )

    async def fetch_async(self) -> ReportInstance:
        """
        Asynchronous coroutine to fetch the ReportInstance


        :returns: The fetched ReportInstance
        """
        payload, _, _ = await self._fetch_async()
        return ReportInstance(
            self._version,
            payload,
            report_id=self._solution["report_id"],
        )

    async def fetch_with_http_info_async(self) -> ApiResponse:
        """
        Asynchronous coroutine to fetch the ReportInstance and return response metadata


        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._fetch_async()
        instance = ReportInstance(
            self._version,
            payload,
            report_id=self._solution["report_id"],
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Insights.V2.ReportContext {}>".format(context)


class ReportList(ListResource):

    class AccountReportAnsweringMachineDetection(object):
        """
        :ivar total_calls: Total number of calls with answering machine detection enabled (AMD).
        :ivar answered_by_human_percentage: Percentage of calls marked as answered by human.
        :ivar answered_by_machine_percentage: Percentage of calls marked as answered by machined related like the following: `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `fax`
        """

        def __init__(self, payload: Dict[str, Any]):

            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answered_by_human_percentage: Optional[float] = payload.get(
                "answered_by_human_percentage"
            )
            self.answered_by_machine_percentage: Optional[float] = payload.get(
                "answered_by_machine_percentage"
            )

        def to_dict(self):
            return {
                "total_calls": self.total_calls,
                "answered_by_human_percentage": self.answered_by_human_percentage,
                "answered_by_machine_percentage": self.answered_by_machine_percentage,
            }

    class AccountReportCallDirection(object):
        """
        :ivar outbound: Number of outbound calls
        :ivar inbound: Number of inbound calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.outbound: Optional[int] = payload.get("outbound")
            self.inbound: Optional[int] = payload.get("inbound")

        def to_dict(self):
            return {
                "outbound": self.outbound,
                "inbound": self.inbound,
            }

    class AccountReportCallState(object):
        """
        :ivar completed: Number of completed calls
        :ivar fail: Number of failed calls
        :ivar busy: Number of busy calls
        :ivar noanswer: Number of no-answer calls
        :ivar canceled: Number of canceled calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.completed: Optional[int] = payload.get("completed")
            self.fail: Optional[int] = payload.get("fail")
            self.busy: Optional[int] = payload.get("busy")
            self.noanswer: Optional[int] = payload.get("noanswer")
            self.canceled: Optional[int] = payload.get("canceled")

        def to_dict(self):
            return {
                "completed": self.completed,
                "fail": self.fail,
                "busy": self.busy,
                "noanswer": self.noanswer,
                "canceled": self.canceled,
            }

    class AccountReportCallType(object):
        """
        :ivar carrier: Number of carrier calls
        :ivar sip: Number of SIP calls
        :ivar trunking: Number of trunking calls
        :ivar client: Number of client calls
        :ivar whatsapp: Number of WhatsApp Business calls
        """

        def __init__(self, payload: Dict[str, Any]):

            self.carrier: Optional[int] = payload.get("carrier")
            self.sip: Optional[int] = payload.get("sip")
            self.trunking: Optional[int] = payload.get("trunking")
            self.client: Optional[int] = payload.get("client")
            self.whatsapp: Optional[int] = payload.get("whatsapp")

        def to_dict(self):
            return {
                "carrier": self.carrier,
                "sip": self.sip,
                "trunking": self.trunking,
                "client": self.client,
                "whatsapp": self.whatsapp,
            }

    class AccountReportKYT(object):
        """
        :ivar outbound_carrier_calling:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.outbound_carrier_calling: Optional[
                AccountReportKYTOutboundCarrierCalling
            ] = payload.get("outbound_carrier_calling")

        def to_dict(self):
            return {
                "outbound_carrier_calling": (
                    self.outbound_carrier_calling.to_dict()
                    if self.outbound_carrier_calling is not None
                    else None
                ),
            }

    class AccountReportKYTOutboundCarrierCalling(object):
        """
        :ivar unique_calling_numbers: Number of unique PSTN calling numbers to non-Twilio numbers during the report period.
        :ivar unique_called_numbers: Number of unique non-Twilio PSTN called numbers during the report period.
        :ivar blocked_calls_by_carrier: Percentage of blocked calls by carrier per country.
        :ivar short_duration_calls_percentage: Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured.
        :ivar long_duration_calls_percentage: Percentage of long duration calls ( >= 60 seconds)
        :ivar potential_robocalls_percentage: Percentage of completed outbound calls to unassigned or unallocated phone numbers.
        :ivar branded_calling:
        :ivar voice_integrity:
        :ivar stir_shaken:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.unique_calling_numbers: Optional[int] = payload.get(
                "unique_calling_numbers"
            )
            self.unique_called_numbers: Optional[int] = payload.get(
                "unique_called_numbers"
            )
            self.blocked_calls_by_carrier: Optional[List[CountyCarrierValue]] = (
                payload.get("blocked_calls_by_carrier")
            )
            self.short_duration_calls_percentage: Optional[float] = payload.get(
                "short_duration_calls_percentage"
            )
            self.long_duration_calls_percentage: Optional[float] = payload.get(
                "long_duration_calls_percentage"
            )
            self.potential_robocalls_percentage: Optional[float] = payload.get(
                "potential_robocalls_percentage"
            )
            self.branded_calling: Optional[BrandedCalling] = payload.get(
                "branded_calling"
            )
            self.voice_integrity: Optional[VoiceIntegrity] = payload.get(
                "voice_integrity"
            )
            self.stir_shaken: Optional[StirShaken] = payload.get("stir_shaken")

        def to_dict(self):
            return {
                "unique_calling_numbers": self.unique_calling_numbers,
                "unique_called_numbers": self.unique_called_numbers,
                "blocked_calls_by_carrier": (
                    [
                        blocked_calls_by_carrier.to_dict()
                        for blocked_calls_by_carrier in self.blocked_calls_by_carrier
                    ]
                    if self.blocked_calls_by_carrier is not None
                    else None
                ),
                "short_duration_calls_percentage": self.short_duration_calls_percentage,
                "long_duration_calls_percentage": self.long_duration_calls_percentage,
                "potential_robocalls_percentage": self.potential_robocalls_percentage,
                "branded_calling": (
                    self.branded_calling.to_dict()
                    if self.branded_calling is not None
                    else None
                ),
                "voice_integrity": (
                    self.voice_integrity.to_dict()
                    if self.voice_integrity is not None
                    else None
                ),
                "stir_shaken": (
                    self.stir_shaken.to_dict() if self.stir_shaken is not None else None
                ),
            }

    class AccountReportNetworkIssues(object):
        """
        :ivar sdk:
        :ivar twilio_gateway:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.sdk: Optional[AccountReportNetworkIssuesSdk] = payload.get("sdk")
            self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = (
                payload.get("twilio_gateway")
            )

        def to_dict(self):
            return {
                "sdk": self.sdk.to_dict() if self.sdk is not None else None,
                "twilio_gateway": (
                    self.twilio_gateway.to_dict()
                    if self.twilio_gateway is not None
                    else None
                ),
            }

    class AccountReportNetworkIssuesSdk(object):
        """
        :ivar ice_failures_percentage: Percentage of ICE connection failure tag that ICE candidates have failed to find compatible connection.
        :ivar high_latency_percentage: Percentage of calls with high latency.
        :ivar high_packet_loss_percentage: Percentage of calls with high packet loss.
        :ivar high_jitter_percentage: Percentage of calls with high jitter.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.ice_failures_percentage: Optional[float] = payload.get(
                "ice_failures_percentage"
            )
            self.high_latency_percentage: Optional[float] = payload.get(
                "high_latency_percentage"
            )
            self.high_packet_loss_percentage: Optional[float] = payload.get(
                "high_packet_loss_percentage"
            )
            self.high_jitter_percentage: Optional[float] = payload.get(
                "high_jitter_percentage"
            )

        def to_dict(self):
            return {
                "ice_failures_percentage": self.ice_failures_percentage,
                "high_latency_percentage": self.high_latency_percentage,
                "high_packet_loss_percentage": self.high_packet_loss_percentage,
                "high_jitter_percentage": self.high_jitter_percentage,
            }

    class AccountReportNetworkIssuesTwilioGateway(object):
        """
        :ivar high_latency_percentage: Percentage of calls with high latency.
        :ivar high_packet_loss_percentage: Percentage of calls with high packet loss.
        :ivar high_jitter_percentage: Percentage of calls with high jitter.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.high_latency_percentage: Optional[float] = payload.get(
                "high_latency_percentage"
            )
            self.high_packet_loss_percentage: Optional[float] = payload.get(
                "high_packet_loss_percentage"
            )
            self.high_jitter_percentage: Optional[float] = payload.get(
                "high_jitter_percentage"
            )

        def to_dict(self):
            return {
                "high_latency_percentage": self.high_latency_percentage,
                "high_packet_loss_percentage": self.high_packet_loss_percentage,
                "high_jitter_percentage": self.high_jitter_percentage,
            }

    class BrandedCalling(object):
        """
        :ivar total_branded_calls: Total number of Branded bundled calls.
        :ivar percent_branded_calls: Percentage of Branded bundled calls over total outbound calls.
        :ivar answer_rate: Answer rate for Branded bundled calls.
        :ivar human_answer_rate: Rate of Branded bundled calls that were answered by Human.
        :ivar engagement_rate: Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds.
        :ivar by_use_case: Details of branded calls by use case.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.total_branded_calls: Optional[int] = payload.get("total_branded_calls")
            self.percent_branded_calls: Optional[float] = payload.get(
                "percent_branded_calls"
            )
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")
            self.engagement_rate: Optional[float] = payload.get("engagement_rate")
            self.by_use_case: Optional[List[BrandedUseCaseDetail]] = payload.get(
                "by_use_case"
            )

        def to_dict(self):
            return {
                "total_branded_calls": self.total_branded_calls,
                "percent_branded_calls": self.percent_branded_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
                "engagement_rate": self.engagement_rate,
                "by_use_case": (
                    [by_use_case.to_dict() for by_use_case in self.by_use_case]
                    if self.by_use_case is not None
                    else None
                ),
            }

    class BrandedUseCaseDetail(object):
        """
        :ivar use_case: The name of supported use case for Branded calls.
        :ivar enabled_phonenumbers: The number of phone numbers enabled Branded calls.
        :ivar total_calls: The number of total outbound calls for the use case.
        :ivar answer_rate: Answer rate per each use case for Branded bundled calls.
        :ivar human_answer_rate: Rate of Branded bundled calls that were answered by Human per each use case for Branded bundled calls.
        :ivar engagement_rate: Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds per each use case for Branded bundled calls.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.use_case: Optional[str] = payload.get("use_case")
            self.enabled_phonenumbers: Optional[int] = payload.get(
                "enabled_phonenumbers"
            )
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")
            self.engagement_rate: Optional[float] = payload.get("engagement_rate")

        def to_dict(self):
            return {
                "use_case": self.use_case,
                "enabled_phonenumbers": self.enabled_phonenumbers,
                "total_calls": self.total_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
                "engagement_rate": self.engagement_rate,
            }

    class CountyCarrierValueCarriers(object):
        """
        :ivar carrier: The name of the carrier.
        :ivar total_calls: Total number of outbound calls for the carrier in the country.
        :ivar blocked_calls: Total number of blocked outbound calls for the carrier in the country.
        :ivar blocked_calls_percentage: Percentage of blocked outbound calls for the carrier in the country.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.carrier: Optional[str] = payload.get("carrier")
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.blocked_calls: Optional[int] = payload.get("blocked_calls")
            self.blocked_calls_percentage: Optional[float] = payload.get(
                "blocked_calls_percentage"
            )

        def to_dict(self):
            return {
                "carrier": self.carrier,
                "total_calls": self.total_calls,
                "blocked_calls": self.blocked_calls,
                "blocked_calls_percentage": self.blocked_calls_percentage,
            }

    class InsightsV2CreateAccountReportRequest(object):
        """
        :ivar time_range:
        :ivar filters:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.time_range: Optional[
                ReportList.InsightsV2CreateAccountReportRequestTimeRange
            ] = payload.get("time_range")
            self.filters: Optional[List[ReportList.ReportFilter]] = payload.get(
                "filters"
            )

        def to_dict(self):
            return {
                "time_range": (
                    self.time_range.to_dict() if self.time_range is not None else None
                ),
                "filters": (
                    [filters.to_dict() for filters in self.filters]
                    if self.filters is not None
                    else None
                ),
            }

    class InsightsV2CreateAccountReportRequestTimeRange(object):
        """
        :ivar start_time: Start time of the report
        :ivar end_time: End time of the report
        """

        def __init__(self, payload: Dict[str, Any]):

            self.start_time: Optional[datetime] = payload.get("start_time")
            self.end_time: Optional[datetime] = payload.get("end_time")

        def to_dict(self):
            return {
                "start_time": self.start_time,
                "end_time": self.end_time,
            }

    class ReportFilter(object):
        """
        :ivar key: The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent'
        :ivar values: List of supported filter values for the field name
        """

        def __init__(self, payload: Dict[str, Any]):

            self.key: Optional[str] = payload.get("key")
            self.values: Optional[List[str]] = payload.get("values")

        def to_dict(self):
            return {
                "key": self.key,
                "values": self.values,
            }

    class StirShaken(object):
        """
        :ivar call_count:
        :ivar percentage:
        :ivar answer_rate:
        """

        def __init__(self, payload: Dict[str, Any]):

            self.call_count: Optional[StirShakenCallCount] = payload.get("call_count")
            self.percentage: Optional[StirShakenPercentage] = payload.get("percentage")
            self.answer_rate: Optional[StirShakenAnswerRate] = payload.get(
                "answer_rate"
            )

        def to_dict(self):
            return {
                "call_count": (
                    self.call_count.to_dict() if self.call_count is not None else None
                ),
                "percentage": (
                    self.percentage.to_dict() if self.percentage is not None else None
                ),
                "answer_rate": (
                    self.answer_rate.to_dict() if self.answer_rate is not None else None
                ),
            }

    class StirShakenAnswerRate(object):
        """
        :ivar stsh_a: Answer rate for Stir Shaken category A.
        :ivar stsh_b: Answer rate for Stir Shaken category B.
        :ivar stsh_c: Answer rate for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[float] = payload.get("stsh_a")
            self.stsh_b: Optional[float] = payload.get("stsh_b")
            self.stsh_c: Optional[float] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class StirShakenCallCount(object):
        """
        :ivar stsh_a: Total number of calls for Stir Shaken category A.
        :ivar stsh_b: Total number of calls for Stir Shaken category B.
        :ivar stsh_c: Total number of calls for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[int] = payload.get("stsh_a")
            self.stsh_b: Optional[int] = payload.get("stsh_b")
            self.stsh_c: Optional[int] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class StirShakenPercentage(object):
        """
        :ivar stsh_a: Percentage of calls for Stir Shaken category A.
        :ivar stsh_b: Percentage of calls for Stir Shaken category B.
        :ivar stsh_c: Percentage of calls for Stir Shaken category C.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.stsh_a: Optional[float] = payload.get("stsh_a")
            self.stsh_b: Optional[float] = payload.get("stsh_b")
            self.stsh_c: Optional[float] = payload.get("stsh_c")

        def to_dict(self):
            return {
                "stsh_a": self.stsh_a,
                "stsh_b": self.stsh_b,
                "stsh_c": self.stsh_c,
            }

    class VoiceIntegrity(object):
        """
        :ivar enabled_calls: Total number of calls with Voice Integrity enabled.
        :ivar enabled_percentage: Percentage of calls with Voice Integrity enabled.
        :ivar calls_per_bundle: Number of calls per Voice Integrity enabled Bundle Sid.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.enabled_calls: Optional[int] = payload.get("enabled_calls")
            self.enabled_percentage: Optional[float] = payload.get("enabled_percentage")
            self.calls_per_bundle: Optional[List[VoiceIntegrityCallsPerBundle]] = (
                payload.get("calls_per_bundle")
            )

        def to_dict(self):
            return {
                "enabled_calls": self.enabled_calls,
                "enabled_percentage": self.enabled_percentage,
                "calls_per_bundle": (
                    [
                        calls_per_bundle.to_dict()
                        for calls_per_bundle in self.calls_per_bundle
                    ]
                    if self.calls_per_bundle is not None
                    else None
                ),
            }

    class VoiceIntegrityCallsPerBundle(object):
        """
        :ivar bundle_sid: Voice Integrity Approved Profile Sid.
        :ivar enabled_phonenumbers: The number of Voice Integrity enabled and registered phone numbers per Bundle Sid.
        :ivar total_calls: The number of outbound calls on Voice Integrity enabled and registered number per Bundle Sid.
        :ivar answer_rate: Answer rate for calls on Voice Integrity enabled and registered number per Bundle Sid.
        :ivar human_answer_rate: Rate for calls on Voice Integrity enabled and registered number per Bundle Sid that were answered by Human per each use case for Branded bundled calls.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.bundle_sid: Optional[str] = payload.get("bundle_sid")
            self.enabled_phonenumbers: Optional[int] = payload.get(
                "enabled_phonenumbers"
            )
            self.total_calls: Optional[int] = payload.get("total_calls")
            self.answer_rate: Optional[float] = payload.get("answer_rate")
            self.human_answer_rate: Optional[float] = payload.get("human_answer_rate")

        def to_dict(self):
            return {
                "bundle_sid": self.bundle_sid,
                "enabled_phonenumbers": self.enabled_phonenumbers,
                "total_calls": self.total_calls,
                "answer_rate": self.answer_rate,
                "human_answer_rate": self.human_answer_rate,
            }

    def __init__(self, version: Version):
        """
        Initialize the ReportList

        :param version: Version that contains the resource

        """
        super().__init__(version)

    def get(self, report_id: str) -> ReportContext:
        """
        Constructs a ReportContext

        :param report_id: A unique request id.
        """
        return ReportContext(self._version, report_id=report_id)

    def __call__(self, report_id: str) -> ReportContext:
        """
        Constructs a ReportContext

        :param report_id: A unique request id.
        """
        return ReportContext(self._version, report_id=report_id)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        return "<Twilio.Insights.V2.ReportList>"
