Newer
Older
saori / saoridon.h
/***

The MIT License

Copyright (c) 2018 Teppei Tamra (TAM)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

***/

#ifndef SAORIDON_H
#define SAORIDON_H

#include <QObject>
#include <QUrl>
#include <QList>
#include <QJsonObject>

class Saoridon : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QUrl instance READ instance WRITE setInstance NOTIFY instanceChanged)
    Q_PROPERTY(QString clientId READ clientId WRITE setClientId NOTIFY clientIdChanged)
    Q_PROPERTY(QString clientSecret READ clientSecret WRITE setClientSecret NOTIFY clientSecretChanged)

public:
    Saoridon(QUrl instanceUrl,QObject *parent = nullptr);
    const QUrl instance();
    void setInstance(const QUrl instanceUrl);
    const QString clientId();
    void setClientId(const QString id);
    const QString clientSecret();
    void setClientSecret(const QString secret);
    bool clientRedistration();
    const QUrl getAuthorizedUrl();
    const QString getAccessToken(const QString code);
    const QJsonValue instanceInfo(const QString key);
    const QUrl timelineUrl(const QString timeline);
    static const QUrl addQuery(const QUrl url,const QString key,const QString value);
    static const QUrl addQuery(const QUrl url,const QUrlQuery query);

protected:
    void getInstanceInfomation();

protected:
    QUrl m_instance;
    QString m_clientId;
    QString m_clientSecret;
    QJsonObject m_instanceInfo;
    QMap<QString,QUrl> m_timelineMap;

signals:
    void instanceChanged(QUrl);
    void clientIdChanged(QString);
    void clientSecretChanged(QString);
    void instanceInfomationChanged();

public slots:
};

#endif // SAORIDON_H