From baa1fefd5069b4787d5c37db92ae685f2e7e1829 Mon Sep 17 00:00:00 2001 From: thec0sm0s Date: Thu, 14 May 2020 20:38:59 +0530 Subject: [PATCH] Make integrations as separate entity, which might be also and entity of guild --- flask_discord/models/connections.py | 49 +---------------------------- flask_discord/models/integration.py | 42 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 48 deletions(-) create mode 100644 flask_discord/models/integration.py diff --git a/flask_discord/models/connections.py b/flask_discord/models/connections.py index 96bae74..3409dea 100644 --- a/flask_discord/models/connections.py +++ b/flask_discord/models/connections.py @@ -1,52 +1,5 @@ from .base import DiscordModelsBase - -from .user import User - - -class Integration(object): - """"Class representing discord server integrations. - - Attributes - ---------- - id : int - Integration ID. - name : str - Name of integration. - type : str - Integration type (twitch, youtube, etc). - enabled : bool - A boolean representing if this integration is enabled. - syncing : bool - A boolean representing if this integration is syncing. - role_id : int - ID that this integration uses for subscribers. - expire_behaviour : int - An integer representing the behaviour of expiring subscribers. - expire_grace_period : int - An integer representing the grace period before expiring subscribers. - user : User - Object representing user of this integration. - account : dict - A dictionary representing raw - `account `_ object. - synced_at : ISO8601 timestamp - Representing when this integration was last synced. - - """ - - def __init__(self, payload): - self._payload = payload - self.id = int(self._payload.get("id", 0)) - self.name = self._payload.get("name") - self.type = self._payload.get("type") - self.enabled = self._payload.get("enabled") - self.syncing = self._payload.get("syncing") - self.role_id = int(self._payload.get("role_id", 0)) - self.expire_behaviour = self._payload.get("expire_behaviour") - self.expire_grace_period = self._payload.get("expire_grace_period") - self.user = User(self._payload.get("user", dict())) - self.account = self._payload.get("account") - self.synced_at = self._payload.get("synced_at") +from .integration import Integration class UserConnection(DiscordModelsBase): diff --git a/flask_discord/models/integration.py b/flask_discord/models/integration.py new file mode 100644 index 0000000..f44958a --- /dev/null +++ b/flask_discord/models/integration.py @@ -0,0 +1,42 @@ +class Integration(object): + """"Class representing discord server integrations. + + Attributes + ---------- + id : int + Integration ID. + name : str + Name of integration. + type : str + Integration type (twitch, youtube, etc). + enabled : bool + A boolean representing if this integration is enabled. + syncing : bool + A boolean representing if this integration is syncing. + role_id : int + ID that this integration uses for subscribers. + expire_behaviour : int + An integer representing the behaviour of expiring subscribers. + expire_grace_period : int + An integer representing the grace period before expiring subscribers. + account : dict + A dictionary representing raw + `account `_ object. + synced_at : ISO8601 timestamp + Representing when this integration was last synced. + + """ + + def __init__(self, payload): + self._payload = payload + self.id = int(self._payload.get("id", 0)) + self.name = self._payload.get("name") + self.type = self._payload.get("type") + self.enabled = self._payload.get("enabled") + self.syncing = self._payload.get("syncing") + self.role_id = int(self._payload.get("role_id", 0)) + self.expire_behaviour = self._payload.get("expire_behaviour") + self.expire_grace_period = self._payload.get("expire_grace_period") + # self.user = User(self._payload.get("user", dict())) + self.account = self._payload.get("account") + self.synced_at = self._payload.get("synced_at")