summaryrefslogtreecommitdiff
path: root/kodereviewer/data.py
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer/data.py')
-rw-r--r--kodereviewer/data.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/kodereviewer/data.py b/kodereviewer/data.py
new file mode 100644
index 0000000..7d3b73a
--- /dev/null
+++ b/kodereviewer/data.py
@@ -0,0 +1,70 @@
+from datetime import datetime
+from enum import Enum
+from typing import Any, Optional
+
+from PySide6.QtCore import QObject, QSettings, Signal, Slot, Property, qDebug
+from PySide6.QtNetwork import QHttpHeaders, QNetworkAccessManager, QNetworkReply, QNetworkRequestFactory
+from PySide6.QtQml import QmlElement
+
+
+class User(QObject):
+ username: str
+ avatar_url: str
+
+ def __init__(self, data: dict[str, Any]):
+ super().__init__()
+ self.username = data['login']
+ self.avatar_url = data['avatar_url']
+
+
+class Label(QObject):
+ name: str
+ color: str
+ description: str
+
+ def __init__(self, data: dict[str, Any]):
+ super().__init__()
+ self.name = data['name']
+ self.color = data['color']
+ self.description = data['description']
+
+
+
+class State(Enum):
+ OPEN = 'open'
+ CLOSED = 'closed'
+ DRAFT = 'draft'
+
+
+class PullRequest(QObject):
+
+ number: int
+ title: str
+ state: State
+ url: str
+ body: str | None
+ created_at: datetime
+ updated_at: datetime
+
+ user: User
+ assignee: User | None
+ labels: list[str]
+
+
+ def __init__(self, data: dict[str, Any]):
+ super().__init__()
+ self.number = data['number']
+ self.state = data['state']
+ self.title = data['title']
+ self.url = data['html_url']
+ self.body = data['body']
+ self.created_at = datetime.fromisoformat(data['created_at'])
+ self.updated_at = datetime.fromisoformat(data['updated_at'])
+
+ self.user = User(data['user'])
+ self.assignee = None
+ if data['assignee'] is not None:
+ self.assignee = User(data['assignee'])
+
+ labels = [Label(label) for label in data['labels']]
+