Skip to content
Repos

DevPlaceApp

C++ 857 B29 lines Opens in site

Directory Raw Download

#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<Post>(j, "posts");
  f.currentTab = D::req<std::string>(j, "current_tab");
  f.currentTopic = D::opt<std::string>(j, "current_topic");
  f.search = D::req<std::string>(j, "search");
  f.nextCursor = D::optDate(j, "next_cursor");
  f.totalMembers = D::req<std::int64_t>(j, "total_members");
  f.postsToday = D::req<std::int64_t>(j, "posts_today");
  f.totalProjects = D::req<std::int64_t>(j, "total_projects");
  f.totalGists = D::req<std::int64_t>(j, "total_gists");
  f.topAuthors = D::reqModels<User>(j, "top_authors");
  return f;
}

Feed Feed::replacingPosts(const std::vector<Post>& newPosts) const {
  Feed out = *this;
  out.posts = newPosts;
  return out;
}

}  // namespace dp
32.2ms