-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponse.cpp
49 lines (36 loc) · 845 Bytes
/
Response.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* File: Response.cpp
* Author: saucelabs
*
* Created on December 22, 2014, 2:40 PM
*/
#include "Response.h"
#include <assert.h>
#include <iostream>
Response::Response(const std::string& responseBody, int httpStatus, const std::string& reason)
: _raw(responseBody), _json(JsonValue::create(responseBody))
{ }
//const std::shared_ptr<JsonValue> Response::json() const
//{
// return nullptr;
//}
int Response::status()
{
if( _json.isEmptyOrNull() ||
_json.type() != ValType::Object) {
return -1;
}
return _json.asObject()["status"].asInt();
}
std::string Response::sessionId()
{
if(_json.isEmptyOrNull() ||
_json.type() != ValType::Object) {
return "";
}
return _json.asObject()["sessionId"].asStr();
}
JsonValue& Response::value()
{
return _json;
}