From bc893794c5e7ec1a968c00a8538241278e8c8d34 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 6 Aug 2018 16:06:12 -0400 Subject: User objects now contain whether the user is protected --- src/user.cpp | 3 ++- src/user.h | 38 +++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/user.cpp b/src/user.cpp index f9b02a1..d2fa592 100644 --- a/src/user.cpp +++ b/src/user.cpp @@ -4,7 +4,7 @@ #include "client.h" namespace twitter { - + user::user(std::string data) try : _valid(true) { @@ -12,6 +12,7 @@ namespace twitter { _id = json["id"].get(); _screen_name = json["screen_name"].get(); _name = json["name"].get(); + _protected = json["protected"].get(); } catch (const std::invalid_argument& error) { std::throw_with_nested(malformed_object("user", data)); diff --git a/src/user.h b/src/user.h index ef7d72e..acd62d0 100644 --- a/src/user.h +++ b/src/user.h @@ -6,56 +6,64 @@ #include namespace twitter { - + class client; - + typedef unsigned long long user_id; - + class user { public: - + user() {} user(std::string data); - + user_id getID() const { assert(_valid); - + return _id; } - + std::string getScreenName() const { assert(_valid); - + return _screen_name; } - + std::string getName() const { assert(_valid); - + return _name; } - + + bool isProtected() const + { + assert(_valid); + + return _protected; + } + bool operator==(const user& other) const { return _id == other._id; } - + bool operator!=(const user& other) const { return _id != other._id; } - + private: - + bool _valid = false; user_id _id; std::string _screen_name; std::string _name; + bool _protected = false; }; - + }; #endif /* end of include guard: USER_H_BF3AB38C */ -- cgit 1.4.1