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 #ifndef SIMULATOR_REQUEST_SENDER_H_
22 #define SIMULATOR_REQUEST_SENDER_H_
24 #include "simulator_client_types.h"
25 #include "simulator_resource_model.h"
26 #include "simulator_error_codes.h"
31 std::map<std::string, std::string> queryParams;
32 SimulatorResourceModel payLoad;
35 class GETRequestSender
38 typedef std::function<void (SimulatorResult result, const SimulatorResourceModel &resModel,
39 const RequestInfo &reqInfo)> ResponseCallback;
41 GETRequestSender(const std::shared_ptr<OC::OCResource> &ocResource);
43 SimulatorResult send(const ResponseCallback &callback);
45 SimulatorResult send(const std::map<std::string, std::string> &queryParams,
46 const ResponseCallback &callback);
48 void onResponseReceived(const OC::HeaderOptions &headerOptions,
49 const OC::OCRepresentation &rep, const int errorCode, RequestInfo &requestInfo,
50 ResponseCallback callback);
53 std::shared_ptr<OC::OCResource> m_ocResource;
56 class PUTRequestSender
59 typedef std::function<void (SimulatorResult result, const SimulatorResourceModel &resModel,
60 const RequestInfo &reqInfo)> ResponseCallback;
62 PUTRequestSender(const std::shared_ptr<OC::OCResource> &ocResource);
64 SimulatorResult send(const SimulatorResourceModel &representation,
65 const ResponseCallback &callback);
67 SimulatorResult send(const std::map<std::string, std::string> &queryParams,
68 const SimulatorResourceModel &representation,
69 const ResponseCallback &callback);
71 void onResponseReceived(const OC::HeaderOptions &headerOptions,
72 const OC::OCRepresentation &rep, const int errorCode, RequestInfo &requestInfo,
73 ResponseCallback callback);
76 std::shared_ptr<OC::OCResource> m_ocResource;
79 class POSTRequestSender
82 typedef std::function<void (SimulatorResult result, const SimulatorResourceModel &resModel,
83 const RequestInfo &reqInfo)> ResponseCallback;
85 POSTRequestSender(const std::shared_ptr<OC::OCResource> &ocResource);
87 SimulatorResult send(const SimulatorResourceModel &representation,
88 const ResponseCallback &callback);
90 SimulatorResult send(const std::map<std::string, std::string> &queryParams,
91 const SimulatorResourceModel &representation,
92 const ResponseCallback &callback);
94 void onResponseReceived(const OC::HeaderOptions &headerOptions,
95 const OC::OCRepresentation &rep, const int errorCode, RequestInfo &requestInfo,
96 ResponseCallback callback);
99 std::shared_ptr<OC::OCResource> m_ocResource;