Mercurial > minori
comparison src/services/anilist.cc @ 231:69f4768a820c
chore: merge divergent branches
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sat, 13 Jan 2024 09:43:41 -0500 |
parents | d030b30526d5 |
children | c130f47f6f48 |
comparison
equal
deleted
inserted
replaced
230:2f5a9247e501 | 231:69f4768a820c |
---|---|
28 | 28 |
29 constexpr int CLIENT_ID = 13706; | 29 constexpr int CLIENT_ID = 13706; |
30 | 30 |
31 class Account { | 31 class Account { |
32 public: | 32 public: |
33 std::string Username() const { return session.config.auth.anilist.username; } | |
34 void SetUsername(std::string const& username) { session.config.auth.anilist.username = username; } | |
35 | |
36 int UserId() const { return session.config.auth.anilist.user_id; } | 33 int UserId() const { return session.config.auth.anilist.user_id; } |
37 void SetUserId(const int id) { session.config.auth.anilist.user_id = id; } | 34 void SetUserId(const int id) { session.config.auth.anilist.user_id = id; } |
38 | 35 |
39 std::string AuthToken() const { return session.config.auth.anilist.auth_token; } | 36 std::string AuthToken() const { return session.config.auth.anilist.auth_token; } |
40 void SetAuthToken(std::string const& auth_token) { session.config.auth.anilist.auth_token = auth_token; } | 37 void SetAuthToken(std::string const& auth_token) { session.config.auth.anilist.auth_token = auth_token; } |
298 | 295 |
299 return JSON::GetNumber(ret, "/data/SaveMediaListEntry/id"_json_pointer, 0); | 296 return JSON::GetNumber(ret, "/data/SaveMediaListEntry/id"_json_pointer, 0); |
300 } | 297 } |
301 | 298 |
302 int ParseUser(const nlohmann::json& json) { | 299 int ParseUser(const nlohmann::json& json) { |
303 account.SetUsername(JSON::GetString<std::string>(json, "/name"_json_pointer, "")); | |
304 account.SetUserId(JSON::GetNumber(json, "/id"_json_pointer, 0)); | 300 account.SetUserId(JSON::GetNumber(json, "/id"_json_pointer, 0)); |
305 return account.UserId(); | 301 return account.UserId(); |
306 } | 302 } |
307 | 303 |
308 bool AuthorizeUser() { | 304 bool AuthorizeUser() { |