RestLink 2.2.0
Powerfull Rest Client for Qt
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
RestLink::Api Class Reference

Represents an API interface that manages configuration, requests, and parameters. More...

#include <api.h>

Inherits RestLink::ApiBase.

Public Member Functions

 Api (QObject *parent=nullptr)
 Constructs an Api object with an optional parent.
 
 ~Api ()
 
QString name () const
 Returns the name of the API.
 
Q_SLOT void setName (const QString &name)
 Sets the name of the API.
 
Q_SIGNAL void nameChanged (const QString &name)
 
QVersionNumber version () const
 Returns the version of the API.
 
Q_SLOT void setVersion (const QVersionNumber &version)
 Sets the version of the API.
 
Q_SIGNAL void versionChanged ()
 
QUrl url () const override
 Returns the URL of the API.
 
Q_SLOT void setUrl (const QUrl &url)
 Sets the URL of the API.
 
Q_SIGNAL void urlChanged (const QUrl &url)
 Emitted when the API URL changes.
 
QLocale locale () const override
 Returns the api locale.
 
Q_SLOT void setLocale (const QLocale &locale)
 
Q_SIGNAL void localeChanged (const QLocale &locale)
 
QString bearerToken () const
 
Q_SLOT void setBearerToken (const QString &token)
 
Q_SIGNAL void bearerTokenChanged (const QString &token)
 
QString userAgent () const override
 Returns the user agent for the API.
 
Q_SLOT void setUserAgent (const QString &agent)
 Sets the user agent for the API.
 
Q_SIGNAL void userAgentChanged (const QString &agent)
 Emitted when the user agent changes.
 
Q_SLOT void configure (const QUrl &url)
 Configures the API with the given URL.
 
bool configure (const QJsonObject &config)
 Configures the API with the given JSON configuration.
 
Q_SIGNAL void configurationCompleted ()
 Emitted when the API configuration is completed.
 
Q_SIGNAL void configurationFailed ()
 Emitted when the API configuration fails.
 
Responsesend (AbstractRequestHandler::Method method, const Request &request, const Body &body) override
 

Properties

QString name
 
QString version
 
QUrl url
 
QLocale locale
 
QString bearerToken
 
QString userAgent
 

Additional Inherited Members

Detailed Description

Represents an API interface that manages configuration, requests, and parameters.

The Api class is responsible for creating network requests and managing response data. It supports adding parameters to requests, configuring the API from different sources, and emitting signals for configuration changes and network error events.

Constructor & Destructor Documentation

◆ Api()

RestLink::Api::Api ( QObject *  parent = nullptr)
explicit

Constructs an Api object with an optional parent.

This constructor initializes the API object, setting the parent if provided. The API object is ready to be configured and used to make requests. The parent object is passed to the QObject constructor, which manages the object's memory and lifecycle.

Parameters
parentThe parent QObject, or nullptr if no parent is specified.

◆ ~Api()

RestLink::Api::~Api ( )

Member Function Documentation

◆ name()

QString RestLink::Api::name ( ) const

Returns the name of the API.

This method retrieves the current name of the API as a string. The API name typically represents the identity or label associated with the API.

Returns
A QString containing the name of the API.

◆ setName()

void RestLink::Api::setName ( const QString &  name)

Sets the name of the API.

This method sets a new name for the API. The API name is typically used for identification or labeling purposes.

Parameters
nameThe new name of the API.

◆ nameChanged()

void RestLink::Api::nameChanged ( const QString &  name)

Emitted when the API name changes.

◆ version()

QVersionNumber RestLink::Api::version ( ) const

Returns the version of the API.

This method retrieves the current version of the API. The version is represented as an QVersionNumber and can be used to manage different versions of the API.

Returns
The integer version number of the API.

◆ setVersion()

void RestLink::Api::setVersion ( const QVersionNumber &  version)

Sets the version of the API.

This method sets a new version number for the API. The version number is typically used to track API updates and compatibility.

Parameters
versionThe new version number for the API.

◆ versionChanged()

void RestLink::Api::versionChanged ( )

Emitted when the API version changes.

◆ url()

QUrl RestLink::Api::url ( ) const
overridevirtual

Returns the URL of the API.

This method retrieves the current URL of the API, which is used to define the endpoint for API requests.

Returns
A QUrl representing the API URL.

Implements RestLink::ApiBase.

◆ setUrl()

void RestLink::Api::setUrl ( const QUrl &  url)

Sets the URL of the API.

This method sets a new URL for the API, which will be used for making API requests.

Parameters
urlThe new URL of the API.

◆ urlChanged()

void RestLink::Api::urlChanged ( const QUrl &  url)

Emitted when the API URL changes.

◆ locale()

QLocale RestLink::Api::locale ( ) const
overridevirtual

Returns the api locale.

Returns
QLocale representing the api locale.
Note
This locale is used to set ACCEPT-LANGUAGE header only, if you want to pass it to the API you are using, you must do it manually according to the used API documentation.

Reimplemented from RestLink::ApiBase.

◆ setLocale()

void RestLink::Api::setLocale ( const QLocale &  locale)

◆ localeChanged()

Q_SIGNAL void RestLink::Api::localeChanged ( const QLocale &  locale)

◆ bearerToken()

QString RestLink::Api::bearerToken ( ) const

◆ setBearerToken()

void RestLink::Api::setBearerToken ( const QString &  token)

◆ bearerTokenChanged()

Q_SIGNAL void RestLink::Api::bearerTokenChanged ( const QString &  token)

◆ userAgent()

QString RestLink::Api::userAgent ( ) const
overridevirtual

Returns the user agent for the API.

This method retrieves the current user agent string used for API requests. The user agent identifies the client software making the request.

Returns
A QString representing the user agent for the API.

Reimplemented from RestLink::ApiBase.

◆ setUserAgent()

void RestLink::Api::setUserAgent ( const QString &  agent)

Sets the user agent for the API.

This method sets the user agent string used for API requests. The user agent identifies the client software making the request.

Parameters
agentThe user agent string to be used for the API.

◆ userAgentChanged()

void RestLink::Api::userAgentChanged ( const QString &  agent)

Emitted when the user agent changes.

◆ configure() [1/2]

void RestLink::Api::configure ( const QUrl &  url)

Configures the API with the given URL.

This method configures the API by setting the URL to the given one, which is used for making API requests.

Parameters
urlThe URL to be set for the API.

◆ configure() [2/2]

bool RestLink::Api::configure ( const QJsonObject &  config)

Configures the API with the given JSON configuration.

This method configures the API using a JSON object. The configuration can include parameters like the API URL, version, and other settings.

Parameters
configA QJsonObject containing the configuration data for the API.
Returns
Returns true if the configuration was successful, false otherwise.

◆ configurationCompleted()

void RestLink::Api::configurationCompleted ( )

Emitted when the API configuration is completed.

◆ configurationFailed()

void RestLink::Api::configurationFailed ( )

Emitted when the API configuration fails.

See also
ApiBase, Request, RequestParameter

◆ send()

Response * RestLink::Api::send ( AbstractRequestHandler::Method  method,
const Request request,
const Body body 
)
overridevirtual

Reimplemented from RestLink::ApiBase.

Property Documentation

◆ name

QString RestLink::Api::name
readwrite

◆ version

QString RestLink::Api::version
readwrite

◆ url

QUrl RestLink::Api::url
readwrite

◆ locale

QLocale RestLink::Api::locale
readwrite

◆ bearerToken

QString RestLink::Api::bearerToken
readwrite

◆ userAgent

QString RestLink::Api::userAgent
readwrite