1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
21 #include "Response.h"
\r
26 std::map<std::string, HeaderPtr> const &Response::getHeaders() const
\r
30 void Response::setHeader(const std::string &headerName, const HeaderPtr &header)
\r
32 m_headers[headerName] = header;
\r
34 std::string Response::getDescription() const
\r
36 return m_description;
\r
38 void Response::setDescription(const std::string &description)
\r
40 m_description = description;
\r
42 void Response::setResponseBody(const std::string &typeName)
\r
44 m_responseBody[typeName] = std::make_shared<RequestResponseBody>(typeName);
\r
46 void Response::setResponseBody(const std::string &type, const RequestResponseBodyPtr &body)
\r
48 m_responseBody[type] = body;
\r
50 std::map<std::string, RequestResponseBodyPtr> const &Response::getResponseBody() const
\r
52 return m_responseBody;
\r
54 RequestResponseBodyPtr Response::getResponseBody(const std::string &bodyType)
\r
56 return m_responseBody[bodyType];
\r
59 void Response::readResponse(const YAML::Node &yamlNode)
\r
61 for ( YAML::const_iterator it = yamlNode.begin(); it != yamlNode.end(); ++it )
\r
63 std::string key = READ_NODE_AS_STRING(it->first);
\r
65 if (key == Keys::Description)
\r
66 setDescription(READ_NODE_AS_STRING(it->second));
\r
67 else if (key == Keys::Body)
\r
69 YAML::Node responseBody = it->second;
\r
71 for ( YAML::const_iterator tt = responseBody.begin(); tt != responseBody.end(); ++tt )
\r
73 std::string type = READ_NODE_AS_STRING(tt->first);
\r
74 setResponseBody(type, std::make_shared<RequestResponseBody>(type, tt->second, m_includeResolver));
\r
77 else if (key == Keys::Headers)
\r
79 YAML::Node paramNode = it->second;
\r
80 for ( YAML::const_iterator tt = paramNode.begin(); tt != paramNode.end(); ++tt )
\r
82 setHeader(READ_NODE_AS_STRING(tt->first), std::make_shared<Header>(tt->second));
\r