File indexing completed on 2025-02-23 04:35:13

0001 // SPDX-FileCopyrightText: 2021 Linus Jahn <lnj@kaidan.im>
0002 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
0003 // SPDX-License-Identifier: GPL-3.0-or-later
0004 
0005 #include "abstractapi.h"
0006 
0007 namespace QInvidious
0008 {
0009 
0010 AbstractApi::AbstractApi(QNetworkAccessManager *netManager, QObject *parent)
0011     : QObject(parent)
0012     , m_netManager(netManager)
0013 {
0014 }
0015 
0016 QString AbstractApi::region() const
0017 {
0018     return m_region;
0019 }
0020 
0021 void AbstractApi::setRegion(const QString &region)
0022 {
0023     m_region = region;
0024 }
0025 
0026 QString AbstractApi::language() const
0027 {
0028     return m_language;
0029 }
0030 
0031 void AbstractApi::setLanguage(const QString &language)
0032 {
0033     m_language = language;
0034 }
0035 
0036 Credentials AbstractApi::credentials() const
0037 {
0038     return m_credentials;
0039 }
0040 
0041 void AbstractApi::setCredentials(const Credentials &credentials)
0042 {
0043     m_credentials = credentials;
0044     Q_EMIT credentialsChanged();
0045 }
0046 
0047 QNetworkAccessManager *AbstractApi::net() const
0048 {
0049     return m_netManager;
0050 }
0051 
0052 QUrl AbstractApi::apiUrl(const QString &path) const
0053 {
0054     QUrl url = QUrl::fromUserInput(m_apiHost);
0055     url.setScheme(QStringLiteral("https"));
0056     url.setPath(path);
0057 
0058     return url;
0059 }
0060 
0061 void AbstractApi::setApiHost(const QString &host)
0062 {
0063     m_apiHost = host;
0064 }
0065 
0066 QString AbstractApi::apiHost() const
0067 {
0068     return m_apiHost;
0069 }
0070 }