めんどくさくなったから一括でコミットするけど許してくれ

This commit is contained in:
keita
2021-02-23 16:37:15 +09:00
parent 5cebef5d9c
commit b4497728b1
18 changed files with 148 additions and 52 deletions
+33
View File
@@ -0,0 +1,33 @@
#include <cocoatweet/api/model/tweet.h>
#include <cocoatweet/exception/tweetNotFoundException.h>
#include "nlohmann/json.hpp"
#include <iostream>
namespace CocoaTweet::API::Model {
Tweet Tweet::parse(const unsigned int _responseCode, const std::string& _json) {
auto j = nlohmann::json::parse(_json);
Tweet tweet;
if (_responseCode == 200) {
Tweet tweet;
tweet.id(j["id_str"]);
} else {
auto error = j["errors"][0]["code"];
auto message = j["errors"][0]["message"];
if (error.get<int>() == 144) {
throw CocoaTweet::Exception::TweetNotFoundException(message.get<std::string>().c_str());
}
}
return tweet;
}
void Tweet::id(const std::string& _id) {
id_ = _id;
}
const std::string& Tweet::id() const {
return id_;
}
} // namespace CocoaTweet::API::Model