From be546301b6a33799764d72d11994237c47e26d83 Mon Sep 17 00:00:00 2001 From: spla Date: Fri, 12 Aug 2022 21:39:51 +0200 Subject: [PATCH] Added four new endpoints: notifications_new, repos_issues_search, repos_owner_repo_issues and repos_owner_repo_issues_comments --- Gitea.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/Gitea.py b/Gitea.py index 56f29d2..213a5a3 100644 --- a/Gitea.py +++ b/Gitea.py @@ -1,7 +1,6 @@ import os import sys import requests -import pdb class Gitea: @@ -66,6 +65,68 @@ class Gitea: return (response_ok, user_list) + def notifications_new(self): + + data = { + } + + endpoint = self._Gitea__api_base_url + f'/api/v1/notifications/new?token={self._Gitea__access_token}' + + response = self.__api_request('GET', endpoint, data) + + response_ok = response.ok + + notifications = response.json() + + return (response_ok, notifications) + + def repos_issues_search(self, username): + + data = { + } + + endpoint = self._Gitea__api_base_url + f'/api/v1/repos/issues/search?state=open&owner={username}&token={self._Gitea__access_token}' + + response = self.__api_request('GET', endpoint, data) + + response_ok = response.ok + + notifications = response.json() + + return (response_ok, notifications) + + def repos_owner_repo_issues(self, username, repo): + + data = { + } + + endpoint = self._Gitea__api_base_url + f'/api/v1/repos/{username}/{repo}/issues?state=all&token={self._Gitea__access_token}' + + response = self.__api_request('GET', endpoint, data) + + response_ok = response.ok + + notifications = response.json() + + return (response_ok, notifications) + + def repos_owner_repo_issues_comments(self, username, repo): + + data = { + } + + endpoint = self._Gitea__api_base_url + f'/api/v1/repos/{username}/{repo}/issues/comments?token={self._Gitea__access_token}' + + response = self.__api_request('GET', endpoint, data) + + response_ok = response.ok + + notifications = response.json() + + return (response_ok, notifications) + + + @staticmethod def __check_setup(self): @@ -110,6 +171,8 @@ class Gitea: def __api_request(self, method, endpoint, data): + response = None + try: response = self.session.request(method, url = endpoint, data = data)