Kgapi

bloggerservice.cpp
1/*
2 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6
7#include "bloggerservice.h"
8
9#include <QUrlQuery>
10
11inline QUrl operator%(const QUrl &url, const QString &path)
12{
13 return QUrl(url.toString() % QLatin1Char('/') % path);
14}
15
16namespace KGAPI2
17{
18namespace BloggerService
19{
20namespace Private
21{
22static const QUrl GoogleApisUrl(QStringLiteral("https://www.googleapis.com"));
23
24auto commentBasePath(const QString &blogId, const QString &postId = QString(), const QString &commentId = QString()) -> QString
25{
26 const auto post = !postId.isEmpty() ? (QLatin1StringView("/posts/") % postId) : QString();
27 const auto comment = !commentId.isEmpty() ? (QLatin1Char('/') % commentId) : QString();
28 const QString path = QLatin1StringView("blogger/v3/blogs/") % blogId % post % QLatin1StringView("/comments") % comment;
29 return path;
30}
31
32auto pageBasePath(const QString &blogId, const QString &pageId = QString()) -> QString
33{
34 const auto page = !pageId.isEmpty() ? (QLatin1Char('/') % pageId) : QString();
35 const QString path = QLatin1StringView("blogger/v3/blogs/") % blogId % QLatin1StringView("/pages") % page;
36 return path;
37}
38
39auto postBasePath(const QString &blogId, const QString &postId = QString()) -> QString
40{
41 const auto post = !postId.isEmpty() ? (QLatin1Char('/') % postId) : QString();
42 const QString path = QLatin1StringView("blogger/v3/blogs/") % blogId % QLatin1StringView("/posts") % post;
43 return path;
44}
45
46} // namespace Private
47} // namespace BloggerService
48} // namespace KGAPI2
49
50using namespace KGAPI2;
51using namespace KGAPI2::BloggerService::Private;
52
53QUrl BloggerService::fetchBlogByBlogIdUrl(const QString &blogId)
54{
55 return GoogleApisUrl % QStringLiteral("/blogger/v3/blogs/") % blogId;
56}
57
58QUrl BloggerService::fetchBlogByBlogUrlUrl(const QString &blogUrl)
59{
60 QUrl url = GoogleApisUrl % QStringLiteral("/blogger/v3/blogs/byurl");
61 QUrlQuery query(url);
62 query.addQueryItem(QStringLiteral("url"), blogUrl);
63 url.setQuery(query);
64 return url;
65}
66
67QUrl BloggerService::fetchBlogsByUserIdUrl(const QString &userId)
68{
69 return GoogleApisUrl % QStringLiteral("/blogger/v3/users/") % userId % QStringLiteral("/blogs");
70}
71
72QUrl BloggerService::fetchCommentsUrl(const QString &blogId, const QString &postId, const QString &commentId)
73{
74 return GoogleApisUrl % commentBasePath(blogId, postId, commentId);
75}
76
77QUrl BloggerService::approveCommentUrl(const QString &blogId, const QString &postId, const QString &commentId)
78{
79 return GoogleApisUrl % commentBasePath(blogId, postId, commentId) % QStringLiteral("/approve");
80}
81
82QUrl BloggerService::markCommentAsSpamUrl(const QString &blogId, const QString &postId, const QString &commentId)
83{
84 return GoogleApisUrl % commentBasePath(blogId, postId, commentId) % QStringLiteral("/spam");
85}
86
87QUrl BloggerService::deleteCommentUrl(const QString &blogId, const QString &postId, const QString &commentId)
88{
89 return GoogleApisUrl % commentBasePath(blogId, postId, commentId);
90}
91
92QUrl BloggerService::deleteCommentContentUrl(const QString &blogId, const QString &postId, const QString &commentId)
93{
94 return GoogleApisUrl % commentBasePath(blogId, postId, commentId) % QStringLiteral("/removecontent");
95}
96
97QUrl BloggerService::fetchPageUrl(const QString &blogId, const QString &pageId)
98{
99 return GoogleApisUrl % pageBasePath(blogId, pageId);
100}
101
102QUrl BloggerService::deletePageUrl(const QString &blogId, const QString &pageId)
103{
104 return GoogleApisUrl % pageBasePath(blogId, pageId);
105}
106
107QUrl BloggerService::modifyPageUrl(const QString &blogId, const QString &pageId)
108{
109 return GoogleApisUrl % pageBasePath(blogId, pageId);
110}
111
112QUrl BloggerService::createPageUrl(const QString &blogId)
113{
114 return GoogleApisUrl % pageBasePath(blogId);
115}
116
117QUrl BloggerService::fetchPostUrl(const QString &blogId, const QString &postId)
118{
119 return GoogleApisUrl % postBasePath(blogId, postId);
120}
121
122QUrl BloggerService::searchPostUrl(const QString &blogId)
123{
124 return GoogleApisUrl % postBasePath(blogId) % QStringLiteral("/search");
125}
126
127QUrl BloggerService::createPostUrl(const QString &blogId)
128{
129 return GoogleApisUrl % postBasePath(blogId);
130}
131
132QUrl BloggerService::deletePostUrl(const QString &blogId, const QString &postId)
133{
134 return GoogleApisUrl % postBasePath(blogId, postId);
135}
136
137QUrl BloggerService::modifyPostUrl(const QString &blogId, const QString &postId)
138{
139 return GoogleApisUrl % postBasePath(blogId, postId);
140}
141
142QUrl BloggerService::publishPostUrl(const QString &blogId, const QString &postId)
143{
144 return GoogleApisUrl % postBasePath(blogId, postId) % QStringLiteral("/publish");
145}
146
147QUrl BloggerService::revertPostUrl(const QString &blogId, const QString &postId)
148{
149 return GoogleApisUrl % postBasePath(blogId, postId) % QStringLiteral("/revert");
150}
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
QString path(const QString &relativePath)
bool isEmpty() const const
void setQuery(const QString &query, ParsingMode mode)
QString toString(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.