#include "model/Feed.hpp" #include "core/JsonDecode.hpp" namespace dp { Feed Feed::fromJson(const Json& j) { using D = JsonDecode; Feed f; f.posts = D::reqModels(j, "posts"); f.currentTab = D::req(j, "current_tab"); f.currentTopic = D::opt(j, "current_topic"); f.search = D::req(j, "search"); f.nextCursor = D::optDate(j, "next_cursor"); f.totalMembers = D::req(j, "total_members"); f.postsToday = D::req(j, "posts_today"); f.totalProjects = D::req(j, "total_projects"); f.totalGists = D::req(j, "total_gists"); f.topAuthors = D::reqModels(j, "top_authors"); return f; } Feed Feed::replacingPosts(const std::vector& newPosts) const { Feed out = *this; out.posts = newPosts; return out; } } // namespace dp