File indexing completed on 2024-05-12 04:45:55

0001 #pragma once
0002 
0003 #include "abstractnotesprovider.h"
0004 #include <QObject>
0005 #include <QString>
0006 #include <functional>
0007 /**
0008  * @brief The NextNote class follows the NextCloud API specification
0009  *  for syncing notes.
0010  */
0011 
0012 class NextNote : public AbstractNotesProvider
0013 {
0014     Q_OBJECT
0015 public:
0016     explicit NextNote(QObject *parent = nullptr);
0017     ~NextNote() override final;
0018     void getNote(const QString &id) override final;
0019     void getBooklet(const QString &id) override final;
0020 
0021     void getNotes() override final;
0022     void getBooklets() override final;
0023 
0024     void insertNote(const FMH::MODEL &note) override final;
0025     void insertBooklet(const FMH::MODEL &booklet) override final;
0026 
0027     void updateNote(const QString &id, const FMH::MODEL &note) override final;
0028     void updateBooklet(const QString &id, const FMH::MODEL &booklet) override final;
0029 
0030     void removeNote(const QString &id) override final;
0031     void removeBooklet(const QString &id) override final;
0032 
0033 private:
0034     const static QString API;
0035     static const QString formatUrl(const QString &user, const QString &password, const QString &provider);
0036     static const FMH::MODEL_LIST parseNotes(const QByteArray &array);
0037 
0038     //    template<typename T>
0039     //    void request(const QString &url, const QMap<QString, QString> &header, T cb);
0040     //    void request(const QString &url, const QMap<QString, QString> &header,  std::function<void (QByteArray)>cb);
0041 
0042 public Q_SLOTS:
0043     void sendNotes(QByteArray array);
0044 };