Added /api/v1/conversations.
This commit is contained in:
parent
c3e00e2e31
commit
14a1d92442
|
@ -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
|
** [x] POST /api/v1/statuses/:id/unpin
|
||||||
* Timelines
|
* Timelines
|
||||||
** [x] GET /api/v1/timelines/home
|
** [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/public
|
||||||
** [x] GET /api/v1/timelines/tag/:hashtag
|
** [x] GET /api/v1/timelines/tag/:hashtag
|
||||||
** [x] GET /api/v1/timelines/list/:list_id
|
** [x] GET /api/v1/timelines/list/:list_id
|
||||||
|
|
|
@ -236,6 +236,11 @@ const return_call API::get(const Mastodon::API::v1 &call,
|
||||||
strcall = "/api/v1/polls/" + strid;
|
strcall = "/api/v1/polls/" + strid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case v1::conversations:
|
||||||
|
{
|
||||||
|
strcall = "/api/v1/conversations";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ttdebug << "ERROR: Invalid argument.\n";
|
ttdebug << "ERROR: Invalid argument.\n";
|
||||||
|
|
|
@ -264,7 +264,7 @@ namespace Mastodon
|
||||||
statuses_id_unpin,
|
statuses_id_unpin,
|
||||||
|
|
||||||
timelines_home,
|
timelines_home,
|
||||||
// timelines_conversations,
|
conversations,
|
||||||
timelines_public,
|
timelines_public,
|
||||||
timelines_tag_hashtag,
|
timelines_tag_hashtag,
|
||||||
timelines_list_list_id,
|
timelines_list_list_id,
|
||||||
|
|
|
@ -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() != "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue