Skip to content
Repos

DevPlaceApp

C++ 2.0 KB45 lines Opens in site

Directory Raw Download

#include "model/Profile.hpp"

#include "core/JsonDecode.hpp"

namespace dp {

Profile Profile::fromJson(const Json& j) {
  using D = JsonDecode;
  Profile p;
  p.user = User::fromJson(D::child(j, "profile_user"));
  p.posts = D::reqModels<Post>(j, "posts");
  p.badges = D::reqModels<Badge>(j, "badges");
  p.badgeTotal = D::req<std::int64_t>(j, "badge_total");
  p.badgeEarned = D::req<std::int64_t>(j, "badge_earned");
  p.projects = D::reqModels<Project::Data>(j, "projects");
  p.gists = D::reqModels<Gist>(j, "gists");
  p.currentTab = D::req<std::string>(j, "current_tab");
  p.postsCount = D::req<std::int64_t>(j, "posts_count");
  p.isFollowing = D::req<bool>(j, "is_following");
  p.isBlocked = D::req<bool>(j, "is_blocked");
  p.isMuted = D::req<bool>(j, "is_muted");
  p.isOwner = D::req<bool>(j, "is_owner");
  p.canViewApiKey = D::req<bool>(j, "can_view_api_key");
  p.apiKey = D::req<std::string>(j, "api_key");
  p.aiCorrectionEnabled = D::req<bool>(j, "ai_correction_enabled");
  p.aiCorrectionSync = D::req<bool>(j, "ai_correction_sync");
  p.aiCorrectionPrompt = D::opt<std::string>(j, "ai_correction_prompt");
  p.aiModifierEnabled = D::req<bool>(j, "ai_modifier_enabled");
  p.aiModifierSync = D::req<bool>(j, "ai_modifier_sync");
  p.aiModifierPrompt = D::opt<std::string>(j, "ai_modifier_prompt");
  p.telegramPaired = D::req<bool>(j, "telegram_paired");
  p.notifTelegramPaired = D::req<bool>(j, "notif_telegram_paired");
  p.canManageCustomization = D::req<bool>(j, "can_manage_customization");
  p.custDisableGlobal = D::req<bool>(j, "cust_disable_global");
  p.custDisablePagetype = D::req<bool>(j, "cust_disable_pagetype");
  p.xpProgressPercent = D::orDefault<std::int64_t>(j, "xp_progress_pct", 0);
  p.rank = D::opt<std::int64_t>(j, "rank");
  p.followersCount = D::req<std::int64_t>(j, "followers_count");
  p.followingCount = D::req<std::int64_t>(j, "following_count");
  p.viewerIsAdmin = D::req<bool>(j, "viewer_is_admin");
  p.media = D::reqModels<Media>(j, "media");
  return p;
}

}  // namespace dp
21.0ms