This repository has been archived on 2020-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-cpp/src/easy/entities/card.cpp

108 lines
2.2 KiB
C++
Raw Permalink Normal View History

2018-03-25 19:43:48 +02:00
/* This file is part of mastodon-cpp.
2019-03-20 06:15:43 +01:00
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
2019-03-29 14:44:39 +01:00
*
2018-03-25 19:43:48 +02:00
* This program is free software: you can redistribute it and/or modify
2019-08-15 22:53:38 +02:00
* it under the terms of the GNU Affero General Public License as published by
2018-03-25 19:43:48 +02:00
* 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
2019-08-15 22:53:38 +02:00
* GNU Affero General Public License for more details.
2018-03-25 19:43:48 +02:00
*
2019-08-15 22:53:38 +02:00
* You should have received a copy of the GNU Affero General Public License
2018-03-25 19:43:48 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "card.hpp"
2019-02-22 11:35:06 +01:00
#include "debug.hpp"
2018-03-25 19:43:48 +02:00
using namespace Mastodon;
using Card = Easy::Card;
2018-12-04 11:26:28 +01:00
bool Card::valid() const
{
return Entity::check_valid(
{
"url",
"title",
"description",
"type"
});
}
2018-03-25 19:43:48 +02:00
const string Card::author_name() const
{
2018-03-25 22:46:38 +02:00
return get_string("author_name");
2018-03-25 19:43:48 +02:00
}
const string Card::author_url() const
{
2018-03-25 22:46:38 +02:00
return get_string("author_url");
2018-03-25 19:43:48 +02:00
}
const string Card::description() const
{
2018-03-25 22:46:38 +02:00
return get_string("description");
2018-03-25 19:43:48 +02:00
}
const string Card::embed_url() const
{
return get_string("embed_url");
}
uint64_t Card::height() const
2018-03-25 19:43:48 +02:00
{
2018-03-25 22:46:38 +02:00
return get_uint64("height");
2018-03-25 19:43:48 +02:00
}
const string Card::html() const
{
2018-03-25 22:46:38 +02:00
return get_string("html");
2018-03-25 19:43:48 +02:00
}
const string Card::image() const
{
2018-03-25 22:46:38 +02:00
return get_string("image");
2018-03-25 19:43:48 +02:00
}
const string Card::provider_name() const
{
2018-03-25 22:46:38 +02:00
return get_string("provider_name");
2018-03-25 19:43:48 +02:00
}
const string Card::provider_url() const
{
2018-03-25 22:46:38 +02:00
return get_string("provider_url");
2018-03-25 19:43:48 +02:00
}
const string Card::title() const
{
2018-03-25 22:46:38 +02:00
return get_string("title");
2018-03-25 19:43:48 +02:00
}
2018-12-04 11:26:28 +01:00
Easy::card_type Card::type() const
2018-03-25 19:43:48 +02:00
{
2018-03-25 22:46:38 +02:00
const string strtype = get_string("type");
if (strtype == "link")
2018-04-01 05:14:02 +02:00
return card_type::Link;
else if (strtype == "photo")
2018-04-01 05:14:02 +02:00
return card_type::Photo;
else if (strtype == "video")
2018-04-01 05:14:02 +02:00
return card_type::Video;
else if (strtype == "rich")
2018-04-01 05:14:02 +02:00
return card_type::Rich;
else
return card_type::Undefined;
2018-03-25 19:43:48 +02:00
}
const string Card::url() const
{
2018-03-25 22:46:38 +02:00
return get_string("url");
2018-03-25 19:43:48 +02:00
}
uint64_t Card::width() const
2018-03-25 19:43:48 +02:00
{
2018-03-25 22:46:38 +02:00
return get_uint64("width");
2018-03-25 19:43:48 +02:00
}