LibrePCB Developers Documentation
apiendpoint.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_APIENDPOINT_H
21#define LIBREPCB_CORE_APIENDPOINT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33/*******************************************************************************
34 * Class ApiEndpoint
35 ******************************************************************************/
36
42class ApiEndpoint final : public QObject {
43 Q_OBJECT
44
45public:
46 // Types
47 struct Part {
48 QString mpn;
49 QString manufacturer;
50 };
51
52 // Constructors / Destructor
53 ApiEndpoint() = delete;
54 ApiEndpoint(const ApiEndpoint& other) = delete;
55 explicit ApiEndpoint(const QUrl& url) noexcept;
56 ~ApiEndpoint() noexcept;
57
58 // Getters
59 const QUrl& getUrl() const noexcept { return mUrl; }
60
61 // General Methods
62 void requestLibraryList() const noexcept;
63 void requestPartsInformationStatus() const noexcept;
64 void requestPartsInformation(const QUrl& url,
65 const QVector<Part>& parts) const noexcept;
66
67 // Operators
68 ApiEndpoint& operator=(const ApiEndpoint& rhs) = delete;
69
70signals:
71 void libraryListReceived(const QJsonArray& libs);
72 void errorWhileFetchingLibraryList(const QString& errorMsg);
73 void errorWhileFetchingPartsInformationStatus(const QString& errorMsg);
74 void partsInformationStatusReceived(const QJsonObject& status);
75 void partsInformationReceived(const QJsonObject& info);
76 void errorWhileFetchingPartsInformation(const QString& errorMsg);
77
78private: // Methods
79 void requestLibraryList(const QUrl& url) const noexcept;
80 void libraryListResponseReceived(const QByteArray& data) noexcept;
81 void partsInformationStatusResponseReceived(const QByteArray& data) noexcept;
82 void partsInformationResponseReceived(const QByteArray& data) noexcept;
83
84private: // Data
85 QUrl mUrl;
86};
87
88/*******************************************************************************
89 * End of File
90 ******************************************************************************/
91
92} // namespace librepcb
93
94#endif
Access to a LibrePCB API endpoint.
Definition: apiendpoint.h:42
QUrl mUrl
Definition: apiendpoint.h:85
void requestLibraryList() const noexcept
Definition: apiendpoint.cpp:51
ApiEndpoint(const ApiEndpoint &other)=delete
void errorWhileFetchingPartsInformationStatus(const QString &errorMsg)
void partsInformationResponseReceived(const QByteArray &data) noexcept
Definition: apiendpoint.cpp:155
void errorWhileFetchingPartsInformation(const QString &errorMsg)
void libraryListResponseReceived(const QByteArray &data) noexcept
Definition: apiendpoint.cpp:115
void partsInformationStatusResponseReceived(const QByteArray &data) noexcept
Definition: apiendpoint.cpp:144
void libraryListReceived(const QJsonArray &libs)
~ApiEndpoint() noexcept
Definition: apiendpoint.cpp:44
void requestPartsInformationStatus() const noexcept
Definition: apiendpoint.cpp:57
void requestPartsInformation(const QUrl &url, const QVector< Part > &parts) const noexcept
Definition: apiendpoint.cpp:71
const QUrl & getUrl() const noexcept
Definition: apiendpoint.h:59
void partsInformationReceived(const QJsonObject &info)
void errorWhileFetchingLibraryList(const QString &errorMsg)
void partsInformationStatusReceived(const QJsonObject &status)
The Part class.
Definition: part.h:46
Definition: occmodel.cpp:77
Definition: apiendpoint.h:47
QString mpn
Definition: apiendpoint.h:48
QString manufacturer
Definition: apiendpoint.h:49