about summary refs log tree commit diff stats
path: root/src/user.cpp
blob: f9b02a179609bc51160c76008c669caa4f7a93a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "user.h"
#include <json.hpp>
#include "codes.h"
#include "client.h"

namespace twitter {
  
  user::user(std::string data) try
    : _valid(true)
  {
    auto json = nlohmann::json::parse(data);
    _id = json["id"].get<user_id>();
    _screen_name = json["screen_name"].get<std::string>();
    _name = json["name"].get<std::string>();
  } catch (const std::invalid_argument& error)
  {
    std::throw_with_nested(malformed_object("user", data));
  } catch (const std::domain_error& error)
  {
    std::throw_with_nested(malformed_object("user", data));
  }

};