#ifndef YOURLSCLIENT_H #define YOURLSCLIENT_H #include #include class QNetworkAccessManager; /** * @brief Small value object describing YOURLS API settings. */ struct YourlsSettings { QString apiUrl; QString signature; }; /** * @brief Client responsible for communication with the YOURLS API. * * The class builds a signed YOURLS request, sends it over HTTP(S), * parses the JSON response and returns either a short URL or a detailed * error string. */ class YourlsClient : public QObject { Q_OBJECT public: /** * @brief Constructs the client. * @param parent QObject parent. */ explicit YourlsClient (QObject *parent = nullptr); /** * @brief Requests a short URL from the YOURLS API. * @param settings API endpoint and signature. * @param longUrl Source URL to shorten. */ void shortenUrl (const YourlsSettings &settings, const QUrl &longUrl); signals: /** * @brief Emitted when the short URL has been created successfully. * @param shortUrl Generated short URL. */ void shortenSucceeded (const QUrl &shortUrl); /** * @brief Emitted when the request fails. * @param details Human-readable error details. */ void shortenFailed (const QString &details); private: QNetworkAccessManager *m_networkAccessManager; }; #endif // YOURLSCLIENT_H