# coding: utf-8

"""
    FinancialReports API

     Welcome to the FinancialReports API.  ### Access Levels This API is tiered based on data granularity.  | Level | Name | Description | | :--- | :--- | :--- | | **Level 1** | **Standard Access** | Access to raw PDF/XBRL metadata, company profiles, ISIC classifications, and reference data. | | **Level 2** | **Processed Filings** | Access to converted content (Markdown/JSON) and full-text search capabilities. | | **Level 3** | **Extracted Financials** | Access to specific extracted financial line items (Revenue, EBITDA, etc.) mapped to standard taxonomies. |  ### Authentication All API requests must be authenticated via the **X-API-Key** header. 

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

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


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

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class Webhook(BaseModel):
    """
    Serializer for the Webhook model. Handles create, retrieve, update, and list operations for a user's webhooks.
    """ # noqa: E501
    id: StrictInt = Field(description="The unique identifier for the webhook.")
    url: Annotated[str, Field(strict=True, max_length=500)] = Field(description="The endpoint URL (HTTPS required) to which the webhook payloads will be sent.")
    is_active: Optional[StrictBool] = Field(default=True, description="Set to 'false' to temporarily disable this webhook without deleting it.")
    include_markdown: Optional[StrictBool] = Field(default=True, description="Set to 'true' to include the full 'markdown_content' in the webhook payload. Set to 'false' to receive a payload without the markdown body.")
    include_isins: Optional[StrictBool] = Field(default=False, description="Set to 'true' to include the list of ISINs in the company object. Warning: Large companies may have thousands of ISINs, increasing payload size.")
    track_all_companies: Optional[StrictBool] = Field(default=False, description="Set to 'true' to subscribe to the Global Firehose. You will receive notifications for filings from ALL companies in the database, regardless of your Watchlist.")
    subscribed_filing_types: Optional[List[StrictStr]] = Field(default=None, description="A list of filing type codes (e.g., ['10-K', 'Annual Report']) to subscribe to. If this list is empty or omitted, you will be subscribed to all filing types.")
    secret_key: StrictStr = Field(description="Your unique secret key for verifying payload signatures. This key is generated upon creation and can be regenerated via a separate endpoint.")
    created_at: datetime
    updated_at: datetime
    __properties: ClassVar[List[str]] = ["id", "url", "is_active", "include_markdown", "include_isins", "track_all_companies", "subscribed_filing_types", "secret_key", "created_at", "updated_at"]

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


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

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

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

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

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

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

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "url": obj.get("url"),
            "is_active": obj.get("is_active") if obj.get("is_active") is not None else True,
            "include_markdown": obj.get("include_markdown") if obj.get("include_markdown") is not None else True,
            "include_isins": obj.get("include_isins") if obj.get("include_isins") is not None else False,
            "track_all_companies": obj.get("track_all_companies") if obj.get("track_all_companies") is not None else False,
            "subscribed_filing_types": obj.get("subscribed_filing_types"),
            "secret_key": obj.get("secret_key"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


