olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
CatalogRequest.h
1/*
2 * Copyright (C) 2019-2020 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 <sstream>
23#include <string>
24#include <utility>
25
26#include <olp/core/porting/optional.h>
27#include <olp/dataservice/read/DataServiceReadApi.h>
28#include <olp/dataservice/read/FetchOptions.h>
29
30namespace olp {
31namespace dataservice {
32namespace read {
33
37class DATASERVICE_READ_API CatalogRequest final {
38 public:
49 const porting::optional<std::string>& GetBillingTag() const {
50 return billing_tag_;
51 }
52
62 template <class T = porting::optional<std::string>>
64 billing_tag_ = std::forward<T>(tag);
65 return *this;
66 }
67
76 FetchOptions GetFetchOption() const { return fetch_option_; }
77
88 CatalogRequest& WithFetchOption(const FetchOptions fetch_option) {
89 fetch_option_ = fetch_option;
90 return *this;
91 }
92
98 std::string CreateKey() const {
99 std::stringstream out;
100 if (GetBillingTag()) {
101 out << "$" << *GetBillingTag();
102 }
103 out << "^" << GetFetchOption();
104 return out.str();
105 }
106
107 private:
108 porting::optional<std::string> billing_tag_;
109 FetchOptions fetch_option_{OnlineIfNotFound};
110};
111
112} // namespace read
113} // namespace dataservice
114} // namespace olp
Encapsulates the fields required to request catalog configuration.
Definition CatalogRequest.h:37
FetchOptions GetFetchOption() const
Gets the fetch option that controls how requests are handled.
Definition CatalogRequest.h:76
const porting::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition CatalogRequest.h:49
std::string CreateKey() const
Creates a readable format of the request.
Definition CatalogRequest.h:98
CatalogRequest & WithBillingTag(T &&tag)
Sets the billing tag for the request.
Definition CatalogRequest.h:63
CatalogRequest & WithFetchOption(const FetchOptions fetch_option)
Sets the fetch option that you can use to set the source from which data should be fetched.
Definition CatalogRequest.h:88
Rules all the other namespaces.
Definition AppleSignInProperties.h:24