diff --git a/src/easy/account.hpp b/src/easy/account.hpp index 703d7dc..9b617d8 100644 --- a/src/easy/account.hpp +++ b/src/easy/account.hpp @@ -33,6 +33,7 @@ using std::string; using std::uint64_t; +using std::chrono::system_clock; namespace Mastodon { @@ -75,7 +76,7 @@ namespace Mastodon /*! * @brief Returns time of creation */ - const std::chrono::system_clock::time_point created_at() const; + const system_clock::time_point created_at() const; /*! * @brief Returns display name diff --git a/src/easy/all.hpp b/src/easy/all.hpp index 535e3f2..e32a10f 100644 --- a/src/easy/all.hpp +++ b/src/easy/all.hpp @@ -26,6 +26,8 @@ #include "easy/emoji.hpp" #include "easy/instance.hpp" #include "easy/list.hpp" + #include "easy/mention.hpp" + //#include "easy/notification.hpp" #else #include #include @@ -34,7 +36,9 @@ #include //#include #include - #include "easy/list.hpp" + #include + #include + //#include #endif #endif // MASTODON_CPP_EASY_ALL_HPP diff --git a/src/easy/easy.hpp b/src/easy/easy.hpp index 2f36729..233b0f8 100644 --- a/src/easy/easy.hpp +++ b/src/easy/easy.hpp @@ -80,6 +80,18 @@ public: unknown }; + /*! + * @brief Describes the notification type + */ + enum class notification_type + { + mention, + reblog, + favourite, + follow, + unknown + }; + /*! * @brief Constructs a new Easy object. * @@ -181,6 +193,8 @@ public: class Emoji; class Instance; class List; + class Mention; + class Notification; }; } diff --git a/src/easy/list.hpp b/src/easy/list.hpp index 49d8e6b..2e8a5e3 100644 --- a/src/easy/list.hpp +++ b/src/easy/list.hpp @@ -19,6 +19,7 @@ #include #include +#include // If we are compiling mastodon-cpp, use another include path #ifdef MASTODON_CPP @@ -30,6 +31,7 @@ #endif using std::string; +using std::uint64_t; namespace Mastodon { diff --git a/src/easy/mention.cpp b/src/easy/mention.cpp new file mode 100644 index 0000000..aaeba8a --- /dev/null +++ b/src/easy/mention.cpp @@ -0,0 +1,52 @@ +/* This file is part of mastodon-cpp. + * Copyright © 2018 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "mention.hpp" +#include "macros.hpp" + +using namespace Mastodon; +using Mention = Easy::Mention; +using std::string; +using std::uint64_t; + +Mention::Mention(const string &json) +: Entity(json) +{} + +Mention::Mention() +: Entity() +{} + +const string Mention::acct() const +{ + return get_string("acct"); +} + +const uint64_t Mention::id() const +{ + return get_uint64("id"); +} + +const string Mention::url() const +{ + return get_string("url"); +} + +const string Mention::username() const +{ + return get_string("username"); +} diff --git a/src/easy/mention.hpp b/src/easy/mention.hpp new file mode 100644 index 0000000..95cd7dc --- /dev/null +++ b/src/easy/mention.hpp @@ -0,0 +1,78 @@ +/* This file is part of mastodon-cpp. + * Copyright © 2018 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MASTODON_CPP_EASY_MENTION_HPP +#define MASTODON_CPP_EASY_MENTION_HPP + +#include +#include + +// If we are compiling mastodon-cpp, use another include path +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" + #include "easy.hpp" +#else + #include + #include +#endif + +using std::string; +using std::uint64_t; +using std::chrono::system_clock; + +namespace Mastodon +{ + /*! + * @brief Class to hold mentions + */ + class Easy::Mention : public Easy::Entity + { + public: + /*! + * @brief Constructs a Mention object from a JSON string. + * + * @param json JSON string + */ + explicit Mention(const string &json); + + /*! + * @brief Constructs an empty Mention object. + */ + Mention(); + + /*! + * @brief Returns acct + */ + const string acct() const; + + /*! + * @brief Returns account ID + */ + const uint64_t id() const; + + /*! + * @brief Returns the URL of user's profile + */ + const string url() const; + + /*! + * @brief Returns the username of the account + */ + const string username() const; + }; +} + +#endif // MASTODON_CPP_EASY_MENTION_HPP