Added Easy::Relationship
This commit is contained in:
parent
d6a208857f
commit
d4708e538f
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastodon-cpp
|
project (mastodon-cpp
|
||||||
VERSION 0.7.9
|
VERSION 0.7.10
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "easy/list.hpp"
|
#include "easy/list.hpp"
|
||||||
#include "easy/mention.hpp"
|
#include "easy/mention.hpp"
|
||||||
//#include "easy/notification.hpp"
|
//#include "easy/notification.hpp"
|
||||||
|
#include "easy/relationship.hpp"
|
||||||
#else
|
#else
|
||||||
#include <mastodon-cpp/easy.hpp>
|
#include <mastodon-cpp/easy.hpp>
|
||||||
#include <mastodon-cpp/easy/account.hpp>
|
#include <mastodon-cpp/easy/account.hpp>
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
#include <mastodon-cpp/easy/list.hpp>
|
#include <mastodon-cpp/easy/list.hpp>
|
||||||
#include <mastodon-cpp/easy/mention.hpp>
|
#include <mastodon-cpp/easy/mention.hpp>
|
||||||
//#include <mastodon-cpp/easy/notification.hpp>
|
//#include <mastodon-cpp/easy/notification.hpp>
|
||||||
|
#include <mastodon-cpp/easy/relationship.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MASTODON_CPP_EASY_ALL_HPP
|
#endif // MASTODON_CPP_EASY_ALL_HPP
|
||||||
|
|
|
@ -131,29 +131,30 @@ public:
|
||||||
*/
|
*/
|
||||||
const string error() const;
|
const string error() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as Json::Value
|
* @brief Returns the value of key as Json::Value
|
||||||
*
|
*
|
||||||
* Returns an empty object on error.
|
* Returns an empty object on error.
|
||||||
*/
|
*/
|
||||||
const Json::Value get(const string &key) const;
|
const Json::Value get(const string &key) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as std::string
|
* @brief Returns the value of key as std::string
|
||||||
*
|
*
|
||||||
* returns "" on error.
|
* returns "" on error.
|
||||||
*/
|
*/
|
||||||
const string get_string(const string &key) const;
|
const string get_string(const string &key) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as std::uint64_t
|
* @brief Returns the value of key as std::uint64_t
|
||||||
*
|
*
|
||||||
* Returns 0 on error.
|
* Returns 0 on error.
|
||||||
*/
|
*/
|
||||||
const uint64_t get_uint64(const string &key) const;
|
const uint64_t get_uint64(const string &key) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as double
|
* @brief Returns the value of key as double
|
||||||
*
|
*
|
||||||
* Returns 0.0 on error.
|
* Returns 0.0 on error.
|
||||||
*/
|
*/
|
||||||
|
@ -161,27 +162,26 @@ public:
|
||||||
|
|
||||||
// TODO: Investigate if uint8_t would be better
|
// TODO: Investigate if uint8_t would be better
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as bool
|
* @brief Returns the value of key as bool
|
||||||
*
|
*
|
||||||
* Returns false on error.
|
* Returns false on error.
|
||||||
*/
|
*/
|
||||||
const bool get_bool(const string &key) const;
|
const bool get_bool(const string &key) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as time_point
|
* @brief Returns the value of key as time_point
|
||||||
*
|
*
|
||||||
* Returns clocks epoch on error.
|
* Returns clocks epoch on error.
|
||||||
*/
|
*/
|
||||||
const system_clock::time_point get_time_point(const string &key) const;
|
const system_clock::time_point get_time_point(const string &key) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the value of node as vector
|
* @brief Returns the value of key as vector
|
||||||
*
|
*
|
||||||
* Returns false on error.
|
* Returns false on error.
|
||||||
*/
|
*/
|
||||||
const std::vector<string> get_vector(const string &key) const;
|
const std::vector<string> get_vector(const string &key) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
Json::Value _tree;
|
Json::Value _tree;
|
||||||
bool _valid;
|
bool _valid;
|
||||||
};
|
};
|
||||||
|
@ -195,6 +195,7 @@ public:
|
||||||
class List;
|
class List;
|
||||||
class Mention;
|
class Mention;
|
||||||
class Notification;
|
class Notification;
|
||||||
|
class Relationship;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "relationship.hpp"
|
||||||
|
|
||||||
|
using namespace Mastodon;
|
||||||
|
using Relationship = Easy::Relationship;
|
||||||
|
|
||||||
|
Relationship::Relationship(const string &json)
|
||||||
|
: Entity(json)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Relationship::Relationship()
|
||||||
|
: Entity()
|
||||||
|
{}
|
||||||
|
|
||||||
|
const bool Relationship::blocking() const
|
||||||
|
{
|
||||||
|
return get_bool("blocking");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Relationship::domain_blocking() const
|
||||||
|
{
|
||||||
|
return get_bool("domain_blocking");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Relationship::followed_by() const
|
||||||
|
{
|
||||||
|
return get_bool("followed_by");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Relationship::following() const
|
||||||
|
{
|
||||||
|
return get_bool("following");
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint64_t Relationship::id() const
|
||||||
|
{
|
||||||
|
return get_uint64("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Relationship::muting() const
|
||||||
|
{
|
||||||
|
return get_bool("muting");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Relationship::muting_notifications() const
|
||||||
|
{
|
||||||
|
return get_bool("muting_notifications");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Relationship::requested() const
|
||||||
|
{
|
||||||
|
return get_bool("requested");
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MASTODON_CPP_EASY_RELATIONSHIP_HPP
|
||||||
|
#define MASTODON_CPP_EASY_RELATIONSHIP_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
// If we are compiling mastodon-cpp, use another include path
|
||||||
|
#ifdef MASTODON_CPP
|
||||||
|
#include "mastodon-cpp.hpp"
|
||||||
|
#include "easy.hpp"
|
||||||
|
#else
|
||||||
|
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||||
|
#include <mastodon-cpp/easy.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using std::uint64_t;
|
||||||
|
|
||||||
|
namespace Mastodon
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* @brief Class to hold relationships
|
||||||
|
*/
|
||||||
|
class Easy::Relationship : public Easy::Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* @brief Constructs a Relationship object from a JSON string.
|
||||||
|
*
|
||||||
|
* @param json JSON string
|
||||||
|
*/
|
||||||
|
explicit Relationship(const string &json);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Constructs an empty Relationship object.
|
||||||
|
*/
|
||||||
|
Relationship();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user is blocking the account
|
||||||
|
*/
|
||||||
|
const bool blocking() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user is blocking the account's domain
|
||||||
|
*/
|
||||||
|
const bool domain_blocking() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user is being followed by the account
|
||||||
|
*/
|
||||||
|
const bool followed_by() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user is being following the account
|
||||||
|
*/
|
||||||
|
const bool following() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the target account ID
|
||||||
|
*/
|
||||||
|
const uint64_t id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user is muting the account
|
||||||
|
*/
|
||||||
|
const bool muting() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user is also muting notifications
|
||||||
|
*/
|
||||||
|
const bool muting_notifications() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the user has requested to follow the account
|
||||||
|
*/
|
||||||
|
const bool requested() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MASTODON_CPP_EASY_RELATIONSHIP_HPP
|
Reference in New Issue