#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(j, "posts"); p.badges = D::reqModels(j, "badges"); p.badgeTotal = D::req(j, "badge_total"); p.badgeEarned = D::req(j, "badge_earned"); p.projects = D::reqModels(j, "projects"); p.gists = D::reqModels(j, "gists"); p.currentTab = D::req(j, "current_tab"); p.postsCount = D::req(j, "posts_count"); p.isFollowing = D::req(j, "is_following"); p.isBlocked = D::req(j, "is_blocked"); p.isMuted = D::req(j, "is_muted"); p.isOwner = D::req(j, "is_owner"); p.canViewApiKey = D::req(j, "can_view_api_key"); p.apiKey = D::req(j, "api_key"); p.aiCorrectionEnabled = D::req(j, "ai_correction_enabled"); p.aiCorrectionSync = D::req(j, "ai_correction_sync"); p.aiCorrectionPrompt = D::opt(j, "ai_correction_prompt"); p.aiModifierEnabled = D::req(j, "ai_modifier_enabled"); p.aiModifierSync = D::req(j, "ai_modifier_sync"); p.aiModifierPrompt = D::opt(j, "ai_modifier_prompt"); p.telegramPaired = D::req(j, "telegram_paired"); p.notifTelegramPaired = D::req(j, "notif_telegram_paired"); p.canManageCustomization = D::req(j, "can_manage_customization"); p.custDisableGlobal = D::req(j, "cust_disable_global"); p.custDisablePagetype = D::req(j, "cust_disable_pagetype"); p.xpProgressPercent = D::orDefault(j, "xp_progress_pct", 0); p.rank = D::opt(j, "rank"); p.followersCount = D::req(j, "followers_count"); p.followingCount = D::req(j, "following_count"); p.viewerIsAdmin = D::req(j, "viewer_is_admin"); p.media = D::reqModels(j, "media"); return p; } } // namespace dp