diff options
Diffstat (limited to 'src/user.cpp')
| -rw-r--r-- | src/user.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
| diff --git a/src/user.cpp b/src/user.cpp new file mode 100644 index 0000000..9352938 --- /dev/null +++ b/src/user.cpp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | #include "user.h" | ||
| 2 | #include <json.hpp> | ||
| 3 | |||
| 4 | using nlohmann::json; | ||
| 5 | |||
| 6 | namespace twitter { | ||
| 7 | |||
| 8 | user::user() : _valid(false) | ||
| 9 | { | ||
| 10 | |||
| 11 | } | ||
| 12 | |||
| 13 | user::user(std::string data) : _valid(true) | ||
| 14 | { | ||
| 15 | auto _data = json::parse(data); | ||
| 16 | _id = _data.at("id"); | ||
| 17 | _screen_name = _data.at("screen_name"); | ||
| 18 | _name = _data.at("name"); | ||
| 19 | } | ||
| 20 | |||
| 21 | user_id user::getID() const | ||
| 22 | { | ||
| 23 | return _id; | ||
| 24 | } | ||
| 25 | |||
| 26 | std::string user::getScreenName() const | ||
| 27 | { | ||
| 28 | return _screen_name; | ||
| 29 | } | ||
| 30 | |||
| 31 | std::string user::getName() const | ||
| 32 | { | ||
| 33 | return _name; | ||
| 34 | } | ||
| 35 | |||
| 36 | user::operator bool() const | ||
| 37 | { | ||
| 38 | return _valid; | ||
| 39 | } | ||
| 40 | |||
| 41 | bool user::operator==(const user& other) const | ||
| 42 | { | ||
| 43 | return _id == other._id; | ||
| 44 | } | ||
| 45 | |||
| 46 | }; | ||
