1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "request_model.h"
24 RequestModel::RequestModel(RequestType type) : m_type(type) {}
26 RequestType RequestModel::type() const
31 SupportedQueryParams RequestModel::getQueryParams()
36 std::vector<std::string> RequestModel::getQueryParams(const std::string &key)
38 if (m_queryParams.end() != m_queryParams.find(key))
40 return m_queryParams[key];
43 return std::vector<std::string>();
46 void RequestModel::setQueryParams(
47 const SupportedQueryParams &queryParams)
49 m_queryParams = queryParams;
52 void RequestModel::addQueryParams(const std::string &key,
53 const std::vector<std::string> &values)
55 if (0 != values.size())
56 m_queryParams[key] = values;
59 void RequestModel::addQueryParam(const std::string &key, const std::string &value)
61 m_queryParams[key].push_back(value);
64 void RequestModel::addResponseModel(int code, ResponseModelSP &responseModel)
67 m_responseList[code] = responseModel;
70 void RequestModel::setRepSchema(SimulatorResourceModelSP &repSchema)
72 m_repSchema = repSchema;
75 SimulatorResourceModelSP RequestModel::getRepSchema()
80 SimulatorResult RequestModel::validateResponse(int responseCode, const OC::OCRepresentation &rep)
82 if (m_responseList.end() == m_responseList.find(responseCode))
84 return SIMULATOR_INVALID_RESPONSE_CODE;
87 return m_responseList[responseCode]->verifyResponse(rep);