Module zenora.models.integration

Expand source code
# Copyright (c) 2022 DevGuyAhnaf

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from zenora import Snowflake, User
from typing import Final, List, Optional, Literal
from zenora.models.snowflake import convert_snowflake

import attr

__all__: Final[List[str]] = [
    "Integration",
    "IntegrationAccount",
]


@attr.s(slots=True)
class IntegrationAccount:
    id: str = attr.ib()
    name: str = attr.ib()


@attr.s(slots=True)
class Integration:
    """An object representing a server integration"""

    _enabled: bool = attr.ib()

    id: Snowflake = attr.ib(converter=convert_snowflake)
    """ID of the integration"""

    name: str = attr.ib(kw_only=True)
    """Name of the integration"""

    type: str = attr.ib()
    """Type of the integration"""

    role_id: Snowflake = attr.ib(default=None)
    """ID of the role that this integration uses"""

    enable_emoticons: Optional[bool] = attr.ib(default=None)
    """Whether emoticons should be synced for this integration (Twitch only currently)"""

    expire_behaviour: Optional[Literal[0, 1]] = attr.ib(default=None)
    """The behaviour of expiring subscribers"""

    expire_grace_period: Optional[int] = attr.ib(default=None)
    """The grace period (in days) before expiring subscribers"""

    user: Optional[User] = attr.ib(default=None)
    """User for this integration"""

    account: Optional[IntegrationAccount] = attr.ib(
        default=None, converter=IntegrationAccount  # type: ignore[arg-type]
    )
    """Integration account information"""

    synced_at: Optional[str] = attr.ib(default=None)
    """Last synced at (ISO8601 timestamp)"""

    subscriber_count: Optional[int] = attr.ib(default=None)
    """How many subscribers this integration has"""

    application: Optional[dict] = attr.ib(default=None)
    """Bot application for Integrations"""

    _syncing: Optional[bool] = attr.ib(default=None)

    _revoked: Optional[bool] = attr.ib(default=None)

    @property
    def is_enabled(self) -> bool:
        """Whether the integration is enabled"""
        return self._enabled

    @property
    def is_syncing(self) -> Optional[bool]:
        """Whether the integration is syncing"""
        return self._syncing

    @property
    def is_revoked(self) -> Optional[bool]:
        """Has this integration been revoked"""
        return self._revoked

Classes

class Integration (enabled: bool, id, type: str, role_id: Snowflake = None, enable_emoticons: Optional[bool] = None, expire_behaviour: Optional[Literal[0, 1]] = None, expire_grace_period: Optional[int] = None, user: Optional[User] = None, account=None, synced_at: Optional[str] = None, subscriber_count: Optional[int] = None, application: Optional[dict] = None, syncing: Optional[bool] = None, revoked: Optional[bool] = None, *, name: str)

An object representing a server integration

Method generated by attrs for class Integration.

Expand source code
@attr.s(slots=True)
class Integration:
    """An object representing a server integration"""

    _enabled: bool = attr.ib()

    id: Snowflake = attr.ib(converter=convert_snowflake)
    """ID of the integration"""

    name: str = attr.ib(kw_only=True)
    """Name of the integration"""

    type: str = attr.ib()
    """Type of the integration"""

    role_id: Snowflake = attr.ib(default=None)
    """ID of the role that this integration uses"""

    enable_emoticons: Optional[bool] = attr.ib(default=None)
    """Whether emoticons should be synced for this integration (Twitch only currently)"""

    expire_behaviour: Optional[Literal[0, 1]] = attr.ib(default=None)
    """The behaviour of expiring subscribers"""

    expire_grace_period: Optional[int] = attr.ib(default=None)
    """The grace period (in days) before expiring subscribers"""

    user: Optional[User] = attr.ib(default=None)
    """User for this integration"""

    account: Optional[IntegrationAccount] = attr.ib(
        default=None, converter=IntegrationAccount  # type: ignore[arg-type]
    )
    """Integration account information"""

    synced_at: Optional[str] = attr.ib(default=None)
    """Last synced at (ISO8601 timestamp)"""

    subscriber_count: Optional[int] = attr.ib(default=None)
    """How many subscribers this integration has"""

    application: Optional[dict] = attr.ib(default=None)
    """Bot application for Integrations"""

    _syncing: Optional[bool] = attr.ib(default=None)

    _revoked: Optional[bool] = attr.ib(default=None)

    @property
    def is_enabled(self) -> bool:
        """Whether the integration is enabled"""
        return self._enabled

    @property
    def is_syncing(self) -> Optional[bool]:
        """Whether the integration is syncing"""
        return self._syncing

    @property
    def is_revoked(self) -> Optional[bool]:
        """Has this integration been revoked"""
        return self._revoked

Instance variables

var account : Optional[IntegrationAccount]

Integration account information

var application : Optional[dict]

Bot application for Integrations

var enable_emoticons : Optional[bool]

Whether emoticons should be synced for this integration (Twitch only currently)

var expire_behaviour : Optional[Literal[0, 1]]

The behaviour of expiring subscribers

var expire_grace_period : Optional[int]

The grace period (in days) before expiring subscribers

var idSnowflake

ID of the integration

var is_enabled : bool

Whether the integration is enabled

Expand source code
@property
def is_enabled(self) -> bool:
    """Whether the integration is enabled"""
    return self._enabled
var is_revoked : Optional[bool]

Has this integration been revoked

Expand source code
@property
def is_revoked(self) -> Optional[bool]:
    """Has this integration been revoked"""
    return self._revoked
var is_syncing : Optional[bool]

Whether the integration is syncing

Expand source code
@property
def is_syncing(self) -> Optional[bool]:
    """Whether the integration is syncing"""
    return self._syncing
var name : str

Name of the integration

var role_idSnowflake

ID of the role that this integration uses

var subscriber_count : Optional[int]

How many subscribers this integration has

var synced_at : Optional[str]

Last synced at (ISO8601 timestamp)

var type : str

Type of the integration

var user : Optional[User]

User for this integration

class IntegrationAccount (id: str, name: str)

Method generated by attrs for class IntegrationAccount.

Expand source code
@attr.s(slots=True)
class IntegrationAccount:
    id: str = attr.ib()
    name: str = attr.ib()

Instance variables

var id : str

Return an attribute of instance, which is of type owner.

var name : str

Return an attribute of instance, which is of type owner.