"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
from dub.models.components import clicksbrowsers as components_clicksbrowsers, clickscities as components_clickscities, clickscount as components_clickscount, clickscountries as components_clickscountries, clicksdevices as components_clicksdevices, clicksos as components_clicksos, clicksreferers as components_clicksreferers, clickstimeseries as components_clickstimeseries, clickstoplinks as components_clickstoplinks, clickstopurls as components_clickstopurls, countrycode as components_countrycode, leadsbrowsers as components_leadsbrowsers, leadscities as components_leadscities, leadscount as components_leadscount, leadscountries as components_leadscountries, leadsdevices as components_leadsdevices, leadsos as components_leadsos, leadsreferers as components_leadsreferers, leadstimeseries as components_leadstimeseries, leadstoplinks as components_leadstoplinks, leadstopurls as components_leadstopurls, salesbrowsers as components_salesbrowsers, salescities as components_salescities, salescount as components_salescount, salescountries as components_salescountries, salesdevices as components_salesdevices, salesos as components_salesos, salesreferers as components_salesreferers, salestimeseries as components_salestimeseries, salestoplinks as components_salestoplinks, salestopurls as components_salestopurls
from dub.types import BaseModel
from dub.utils import FieldMetadata, QueryParamMetadata
from enum import Enum
import pydantic
from typing import List, Optional, TypedDict, Union
from typing_extensions import Annotated, NotRequired


class RetrieveAnalyticsGlobalsTypedDict(TypedDict):
    workspace_id: NotRequired[str]
    

class RetrieveAnalyticsGlobals(BaseModel):
    workspace_id: Annotated[Optional[str], pydantic.Field(deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.", alias="workspaceId"), FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    

class Event(str, Enum):
    r"""The type of event to retrieve analytics for. Defaults to 'clicks'."""
    CLICKS = "clicks"
    LEADS = "leads"
    SALES = "sales"
    COMPOSITE = "composite"


class QueryParamGroupBy(str, Enum):
    r"""The parameter to group the analytics data points by. Defaults to 'count' if undefined."""
    COUNT = "count"
    TIMESERIES = "timeseries"
    COUNTRIES = "countries"
    CITIES = "cities"
    DEVICES = "devices"
    BROWSERS = "browsers"
    OS = "os"
    REFERERS = "referers"
    TOP_LINKS = "top_links"
    TOP_URLS = "top_urls"
    TRIGGER = "trigger"


class Interval(str, Enum):
    r"""The interval to retrieve analytics for. Takes precedence over start and end. If undefined, defaults to 24h."""
    TWENTY_FOURH = "24h"
    SEVEND = "7d"
    THIRTYD = "30d"
    NINETYD = "90d"
    YTD = "ytd"
    ONEY = "1y"
    ALL = "all"
    ALL_UNFILTERED = "all_unfiltered"


class RetrieveAnalyticsRequestTypedDict(TypedDict):
    event: NotRequired[Event]
    r"""The type of event to retrieve analytics for. Defaults to 'clicks'."""
    group_by: NotRequired[QueryParamGroupBy]
    r"""The parameter to group the analytics data points by. Defaults to 'count' if undefined."""
    domain: NotRequired[str]
    r"""The domain to filter analytics for."""
    key: NotRequired[str]
    r"""The short link slug."""
    link_id: NotRequired[str]
    r"""The unique ID of the short link on Dub."""
    external_id: NotRequired[str]
    r"""This is the ID of the link in the your database. Must be prefixed with 'ext_' when passed as a query parameter."""
    interval: NotRequired[Interval]
    r"""The interval to retrieve analytics for. Takes precedence over start and end. If undefined, defaults to 24h."""
    start: NotRequired[str]
    r"""The start date and time when to retrieve analytics from."""
    end: NotRequired[str]
    r"""The end date and time when to retrieve analytics from. If not provided, defaults to the current date."""
    timezone: NotRequired[str]
    r"""The IANA time zone code for aligning timeseries granularity (e.g. America/New_York). Defaults to UTC."""
    country: NotRequired[components_countrycode.CountryCode]
    r"""The country to retrieve analytics for."""
    city: NotRequired[str]
    r"""The city to retrieve analytics for."""
    device: NotRequired[str]
    r"""The device to retrieve analytics for."""
    browser: NotRequired[str]
    r"""The browser to retrieve analytics for."""
    os: NotRequired[str]
    r"""The OS to retrieve analytics for."""
    referer: NotRequired[str]
    r"""The referer to retrieve analytics for."""
    url: NotRequired[str]
    r"""The URL to retrieve analytics for."""
    tag_id: NotRequired[str]
    r"""The tag ID to retrieve analytics for."""
    qr: NotRequired[bool]
    r"""Filter for QR code scans. If true, filter for QR codes only. If false, filter for links only. If undefined, return both."""
    root: NotRequired[bool]
    r"""Filter for root domains. If true, filter for domains only. If false, filter for links only. If undefined, return both."""
    

class RetrieveAnalyticsRequest(BaseModel):
    event: Annotated[Optional[Event], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = Event.CLICKS
    r"""The type of event to retrieve analytics for. Defaults to 'clicks'."""
    group_by: Annotated[Optional[QueryParamGroupBy], pydantic.Field(alias="groupBy"), FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = QueryParamGroupBy.COUNT
    r"""The parameter to group the analytics data points by. Defaults to 'count' if undefined."""
    domain: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The domain to filter analytics for."""
    key: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The short link slug."""
    link_id: Annotated[Optional[str], pydantic.Field(alias="linkId"), FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The unique ID of the short link on Dub."""
    external_id: Annotated[Optional[str], pydantic.Field(alias="externalId"), FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""This is the ID of the link in the your database. Must be prefixed with 'ext_' when passed as a query parameter."""
    interval: Annotated[Optional[Interval], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The interval to retrieve analytics for. Takes precedence over start and end. If undefined, defaults to 24h."""
    start: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The start date and time when to retrieve analytics from."""
    end: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The end date and time when to retrieve analytics from. If not provided, defaults to the current date."""
    timezone: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = "UTC"
    r"""The IANA time zone code for aligning timeseries granularity (e.g. America/New_York). Defaults to UTC."""
    country: Annotated[Optional[components_countrycode.CountryCode], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The country to retrieve analytics for."""
    city: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The city to retrieve analytics for."""
    device: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The device to retrieve analytics for."""
    browser: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The browser to retrieve analytics for."""
    os: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The OS to retrieve analytics for."""
    referer: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The referer to retrieve analytics for."""
    url: Annotated[Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The URL to retrieve analytics for."""
    tag_id: Annotated[Optional[str], pydantic.Field(alias="tagId"), FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""The tag ID to retrieve analytics for."""
    qr: Annotated[Optional[bool], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""Filter for QR code scans. If true, filter for QR codes only. If false, filter for links only. If undefined, return both."""
    root: Annotated[Optional[bool], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = None
    r"""Filter for root domains. If true, filter for domains only. If false, filter for links only. If undefined, return both."""
    

RetrieveAnalyticsResponseBodyTypedDict = Union[components_leadscount.LeadsCountTypedDict, components_clickscount.ClicksCountTypedDict, components_salescount.SalesCountTypedDict, List[components_leadsdevices.LeadsDevicesTypedDict], List[components_leadsos.LeadsOSTypedDict], List[components_clicksbrowsers.ClicksBrowsersTypedDict], List[components_clicksos.ClicksOSTypedDict], List[components_clicksreferers.ClicksReferersTypedDict], List[components_clickstoplinks.ClicksTopLinksTypedDict], List[components_clickstopurls.ClicksTopUrlsTypedDict], List[components_clickscities.ClicksCitiesTypedDict], List[components_leadstimeseries.LeadsTimeseriesTypedDict], List[components_leadscountries.LeadsCountriesTypedDict], List[components_leadscities.LeadsCitiesTypedDict], List[components_clickscountries.ClicksCountriesTypedDict], List[components_leadsbrowsers.LeadsBrowsersTypedDict], List[components_clicksdevices.ClicksDevicesTypedDict], List[components_leadsreferers.LeadsReferersTypedDict], List[components_leadstoplinks.LeadsTopLinksTypedDict], List[components_leadstopurls.LeadsTopUrlsTypedDict], List[components_clickstimeseries.ClicksTimeseriesTypedDict], List[components_salestimeseries.SalesTimeseriesTypedDict], List[components_salescountries.SalesCountriesTypedDict], List[components_salescities.SalesCitiesTypedDict], List[components_salesdevices.SalesDevicesTypedDict], List[components_salesbrowsers.SalesBrowsersTypedDict], List[components_salesos.SalesOSTypedDict], List[components_salesreferers.SalesReferersTypedDict], List[components_salestoplinks.SalesTopLinksTypedDict], List[components_salestopurls.SalesTopUrlsTypedDict]]
r"""Analytics data"""


RetrieveAnalyticsResponseBody = Union[components_leadscount.LeadsCount, components_clickscount.ClicksCount, components_salescount.SalesCount, List[components_leadsdevices.LeadsDevices], List[components_leadsos.LeadsOS], List[components_clicksbrowsers.ClicksBrowsers], List[components_clicksos.ClicksOS], List[components_clicksreferers.ClicksReferers], List[components_clickstoplinks.ClicksTopLinks], List[components_clickstopurls.ClicksTopUrls], List[components_clickscities.ClicksCities], List[components_leadstimeseries.LeadsTimeseries], List[components_leadscountries.LeadsCountries], List[components_leadscities.LeadsCities], List[components_clickscountries.ClicksCountries], List[components_leadsbrowsers.LeadsBrowsers], List[components_clicksdevices.ClicksDevices], List[components_leadsreferers.LeadsReferers], List[components_leadstoplinks.LeadsTopLinks], List[components_leadstopurls.LeadsTopUrls], List[components_clickstimeseries.ClicksTimeseries], List[components_salestimeseries.SalesTimeseries], List[components_salescountries.SalesCountries], List[components_salescities.SalesCities], List[components_salesdevices.SalesDevices], List[components_salesbrowsers.SalesBrowsers], List[components_salesos.SalesOS], List[components_salesreferers.SalesReferers], List[components_salestoplinks.SalesTopLinks], List[components_salestopurls.SalesTopUrls]]
r"""Analytics data"""

