Initial commit. First draft v0.1

This commit is contained in:
2026-03-16 21:38:19 -04:00
parent 16b066cfea
commit 2098cb4ba9
8 changed files with 1052 additions and 0 deletions

58
yourlsclient.h Normal file
View File

@@ -0,0 +1,58 @@
#ifndef YOURLSCLIENT_H
#define YOURLSCLIENT_H
#include <QObject>
#include <QUrl>
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