olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
CatalogVersionRequest.h
1/*
2 * Copyright (C) 2019-2022 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 "DataServiceReadApi.h"
28#include "FetchOptions.h"
29
30namespace olp {
31namespace dataservice {
32namespace read {
33
37class DATASERVICE_READ_API CatalogVersionRequest final {
38 public:
48 inline int64_t GetStartVersion() const { return start_version_; }
49
59 CatalogVersionRequest& WithStartVersion(int64_t startVersion) {
60 start_version_ = startVersion;
61 return *this;
62 }
63
74 const porting::optional<std::string>& GetBillingTag() const {
75 return billing_tag_;
76 }
77
87 template <class T = porting::optional<std::string>>
89 billing_tag_ = std::forward<T>(billingTag);
90 return *this;
91 }
92
101 FetchOptions GetFetchOption() const { return fetch_option_; }
102
113 CatalogVersionRequest& WithFetchOption(FetchOptions fetchoption) {
114 fetch_option_ = fetchoption;
115 return *this;
116 }
117
123 std::string CreateKey() const {
124 std::stringstream out;
125
126 out << "@" << GetStartVersion();
127
128 if (GetBillingTag()) {
129 out << "$" << *GetBillingTag();
130 }
131
132 out << "^" << GetFetchOption();
133
134 return out.str();
135 }
136
137 private:
138 int64_t start_version_{-1};
139 porting::optional<std::string> billing_tag_;
140 FetchOptions fetch_option_{OnlineIfNotFound};
141};
142
143} // namespace read
144} // namespace dataservice
145} // namespace olp
Encapsulates the fields required to request catalog configuration.
Definition CatalogVersionRequest.h:37
const porting::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition CatalogVersionRequest.h:74
CatalogVersionRequest & WithStartVersion(int64_t startVersion)
Sets the catalog start version.
Definition CatalogVersionRequest.h:59
CatalogVersionRequest & WithFetchOption(FetchOptions fetchoption)
Sets the fetch option that you can use to set the source from which data should be fetched.
Definition CatalogVersionRequest.h:113
FetchOptions GetFetchOption() const
Gets the fetch option that controls how requests are handled.
Definition CatalogVersionRequest.h:101
int64_t GetStartVersion() const
Gets the catalog start version (exclusive) for the request.
Definition CatalogVersionRequest.h:48
std::string CreateKey() const
Creates a readable format of the request.
Definition CatalogVersionRequest.h:123
CatalogVersionRequest & WithBillingTag(T &&billingTag)
Sets the billing tag for the request.
Definition CatalogVersionRequest.h:88
Rules all the other namespaces.
Definition AppleSignInProperties.h:24