1#pragma once
2
3/****************************************************************************************
4 ** GitQlient is an application to manage and operate one or several Git repositories. With
5 ** GitQlient you will be able to add commits, branches and manage all the options Git provides.
6 ** Copyright (C) 2021 Francesc Martinez
7 **
8 ** LinkedIn: www.linkedin.com/in/cescmm/
9 ** Web: www.francescmm.com
10 **
11 ** This program is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU Lesser General Public
13 ** License as published by the Free Software Foundation; either
14 ** version 2 of the License, or (at your option) any later version.
15 **
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** Lesser General Public License for more details.
20 **
21 ** You should have received a copy of the GNU Lesser General Public
22 ** License along with this library; if not, write to the Free Software
23 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 ***************************************************************************************/
25
26#include <IRestApi.h>
27
28namespace GitServer
29{
30
31class GitLabRestApi final : public IRestApi
32{
33 Q_OBJECT
34
35public:
36 explicit GitLabRestApi(const QString &userName, const QString &repoName, const QString &settingsKey,
37 const ServerAuthentication &auth, QObject *parent = nullptr);
38
39 QString getUserName() const override { return mUserId; }
40
41 void testConnection() override;
42 void createIssue(const Issue &issue) override;
43 void updateIssue(int issueNumber, const Issue &issue) override;
44 void updatePullRequest(int, const PullRequest &) override { }
45 void createPullRequest(const PullRequest &pr) override;
46 void requestLabels() override;
47 void requestMilestones() override;
48 void requestIssues(int) override;
49 void requestPullRequests(int) override;
50 void mergePullRequest(int, const QByteArray &) override { }
51 void requestComments(int) override { }
52 void requestReviews(int) override { }
53 void requestCommitsFromPR(int) override { }
54
55 QString getUserId() const { return mUserId; }
56
57private:
58 QString mUserName;
59 QString mRepoName;
60 QString mSettingsKey;
61 QString mUserId;
62 QString mRepoId;
63 int mPreRequisites = -1;
64 bool mTestRequested = false;
65
66 QNetworkRequest createRequest(const QString &page) const override;
67
68 void getUserInfo() const;
69 void onUserInfoReceived();
70 void getProjects();
71 void onProjectsReceived();
72 void onLabelsReceived();
73 void onMilestonesReceived();
74 void onIssueCreated();
75 void onIssueReceived();
76 void onMergeRequestCreated();
77
78 Issue issueFromJson(const QJsonObject &json) const;
79 PullRequest prFromJson(const QJsonObject &json) const;
80};
81
82}
83