olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
OlpClient.h
1/*
2 * Copyright (C) 2019-2024 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <functional>
23#include <map>
24#include <memory>
25#include <string>
26#include <vector>
27
28#include <olp/core/CoreApi.h>
29#include <olp/core/client/CancellationContext.h>
30#include <olp/core/client/OlpClientSettings.h>
31
32namespace olp {
33namespace client {
39class CORE_API OlpClient {
40 public:
42 using ParametersType = std::multimap<std::string, std::string>;
43
45 using RequestBodyType = std::shared_ptr<std::vector<std::uint8_t>>;
46
47 OlpClient();
48
55 OlpClient(const OlpClientSettings& settings, std::string base_url);
56 virtual ~OlpClient();
57
60
63
65 OlpClient(OlpClient&&) noexcept;
66
68 OlpClient& operator=(OlpClient&&) noexcept;
69
77 void SetBaseUrl(const std::string& base_url);
78
84 std::string GetBaseUrl() const;
85
93 ParametersType& GetMutableDefaultHeaders();
94
100 const OlpClientSettings& GetSettings() const;
101
121 CancellationToken CallApi(const std::string& path, const std::string& method,
122 const ParametersType& query_params,
123 const ParametersType& header_params,
124 const ParametersType& form_params,
125 const RequestBodyType& post_body,
126 const std::string& content_type,
127 const NetworkAsyncCallback& callback) const;
128
149 HttpResponse CallApi(std::string path, std::string method,
150 ParametersType query_params,
151 ParametersType header_params, ParametersType form_params,
152 RequestBodyType post_body, std::string content_type,
153 CancellationContext context) const;
154
174 HttpResponse CallApiStream(std::string path, std::string method,
175 ParametersType query_params,
176 ParametersType header_params,
177 http::Network::DataCallback data_callback,
178 RequestBodyType post_body,
179 std::string content_type,
180 CancellationContext context) const;
181
182 private:
183 class OlpClientImpl;
184 std::shared_ptr<OlpClientImpl> impl_;
185};
186
187} // namespace client
188} // namespace olp
A wrapper that manages the cancellation state of an asynchronous operation in a thread-safe way.
Definition CancellationContext.h:40
Cancels service requests.
Definition CancellationToken.h:33
This class represents the HTTP response created from the NetworkResponse and the request body.
Definition HttpResponse.h:89
Executes HTTP requests by using the base url and the provided parameters and body....
Definition OlpClient.h:39
OlpClient & operator=(const OlpClient &)
An assignement operator.
OlpClient(OlpClient &&) noexcept
A move constructor.
std::shared_ptr< std::vector< std::uint8_t > > RequestBodyType
An alias for the HTTP request body.
Definition OlpClient.h:45
OlpClient(const OlpClient &)
A copy constructor.
OlpClient(const OlpClientSettings &settings, std::string base_url)
Creates the OlpClient instance.
std::multimap< std::string, std::string > ParametersType
An alias for the parameters and headers type.
Definition OlpClient.h:42
std::function< void(HttpResponse)> NetworkAsyncCallback
An alias for the asynchronous network callback.
Definition OlpClientSettings.h:55
Rules all the other namespaces.
Definition AppleSignInProperties.h:24
Configures the behavior of the OlpClient class.
Definition OlpClientSettings.h:178