Skip to content
Repos

DevPlaceApp

C++ 914 B41 lines Opens in site

Directory Raw Download

#pragma once
// Spec: models.md Gist. Wire wrapper: gist, author?, my_vote, comment_count, recent_comments.
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include "core/Date.hpp"
#include "core/Json.hpp"
#include "model/Comment.hpp"
#include "model/User.hpp"
#include "model/Vote.hpp"

namespace dp {

struct Gist {
  struct Data {
    std::string id;
    std::string slug;
    std::string userId;
    std::string title;
    std::string description;
    std::string sourceCode;
    std::string language;
    std::int64_t stars = 0;
    Date createdAt{};
    std::optional<Date> updatedAt;
    static Data fromJson(const Json& j);
  };

  Data data;
  std::optional<User> author;
  Vote myVote;
  std::int64_t commentCount = 0;
  std::vector<Comment> recentComments;

  static Gist fromJson(const Json& j);
  std::string id() const { return "gist:" + data.id; }
};

}  // namespace dp
41.9ms