Added /api/v1/conversations.

This commit is contained in:
tastytea 2019-09-20 02:26:47 +02:00
parent c3e00e2e31
commit 14a1d92442
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
4 changed files with 81 additions and 2 deletions

View File

@ -370,7 +370,7 @@ strings and you can use unsupported fields in an `Entity` by converting it to
** [x] POST /api/v1/statuses/:id/unpin
* Timelines
** [x] GET /api/v1/timelines/home
** [ ] GET /api/v1/conversations
** [x] GET /api/v1/conversations
** [x] GET /api/v1/timelines/public
** [x] GET /api/v1/timelines/tag/:hashtag
** [x] GET /api/v1/timelines/list/:list_id

View File

@ -236,6 +236,11 @@ const return_call API::get(const Mastodon::API::v1 &call,
strcall = "/api/v1/polls/" + strid;
break;
}
case v1::conversations:
{
strcall = "/api/v1/conversations";
break;
}
default:
{
ttdebug << "ERROR: Invalid argument.\n";

View File

@ -264,7 +264,7 @@ namespace Mastodon
statuses_id_unpin,
timelines_home,
// timelines_conversations,
conversations,
timelines_public,
timelines_tag_hashtag,
timelines_list_list_id,

View File

@ -0,0 +1,74 @@
/* This file is part of mastodon-cpp.
* Copyright © 2019 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <exception>
#include <string>
#include <catch.hpp>
#include "mastodon-cpp.hpp"
#include "easy/easy.hpp"
#include "easy/entities/conversation.hpp"
#include "../environment_variables.hpp"
using namespace Mastodon;
SCENARIO ("/api/v1/conversations can be called successfully",
"[api][auth][mastodon][glitch-soc]")
{
REQUIRE (access_token != nullptr);
GIVEN ("instance = " + instance)
{
Mastodon::Easy::API masto(instance, access_token);
return_call ret;
Easy::Conversation conversation;
bool exception = false;
WHEN ("GET /api/v1/conversations is called")
{
try
{
ret = masto.get(API::v1::conversations, {{ "limit", { "2" }}});
if (ret.answer == "[]")
{
WARN("No Conversations found.");
}
else
{
conversation.from_string(
Easy::json_array_to_vector(ret.answer).front());
}
}
catch (const std::exception &e)
{
exception = true;
WARN(e.what());
}
THEN("No exception is thrown")
AND_THEN ("No error is returned")
AND_THEN ("Answer is valid")
{
REQUIRE_FALSE(exception);
REQUIRE(ret.error_code == 0);
REQUIRE(ret.http_error_code == 200);
REQUIRE(conversation.valid());
REQUIRE(conversation.id() != "");
}
}
}
}