olp-cpp-sdk  1.22.0
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 <boost/optional.hpp>
27 
28 #include "DataServiceReadApi.h"
29 #include "FetchOptions.h"
30 
31 namespace olp {
32 namespace dataservice {
33 namespace read {
34 
38 class DATASERVICE_READ_API CatalogVersionRequest final {
39  public:
49  inline int64_t GetStartVersion() const { return start_version_; }
50 
60  inline CatalogVersionRequest& WithStartVersion(int64_t startVersion) {
61  start_version_ = startVersion;
62  return *this;
63  }
64 
75  inline const boost::optional<std::string>& GetBillingTag() const {
76  return billing_tag_;
77  }
78 
89  boost::optional<std::string> billingTag) {
90  billing_tag_ = std::move(billingTag);
91  return *this;
92  }
93 
104  inline CatalogVersionRequest& WithBillingTag(std::string&& billingTag) {
105  billing_tag_ = std::move(billingTag);
106  return *this;
107  }
108 
117  inline FetchOptions GetFetchOption() const { return fetch_option_; }
118 
129  inline CatalogVersionRequest& WithFetchOption(FetchOptions fetchoption) {
130  fetch_option_ = fetchoption;
131  return *this;
132  }
133 
139  inline std::string CreateKey() const {
140  std::stringstream out;
141 
142  out << "@" << GetStartVersion();
143 
144  if (GetBillingTag()) {
145  out << "$" << GetBillingTag().get();
146  }
147 
148  out << "^" << GetFetchOption();
149 
150  return out.str();
151  }
152 
153  private:
154  int64_t start_version_{-1};
155  boost::optional<std::string> billing_tag_;
156  FetchOptions fetch_option_{OnlineIfNotFound};
157 };
158 
159 } // namespace read
160 } // namespace dataservice
161 } // namespace olp
Encapsulates the fields required to request catalog configuration.
Definition: CatalogVersionRequest.h:38
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:129
FetchOptions GetFetchOption() const
Gets the fetch option that controls how requests are handled.
Definition: CatalogVersionRequest.h:117
int64_t GetStartVersion() const
Gets the catalog start version (exclusive) for the request.
Definition: CatalogVersionRequest.h:49
std::string CreateKey() const
Creates a readable format of the request.
Definition: CatalogVersionRequest.h:139
CatalogVersionRequest & WithBillingTag(boost::optional< std::string > billingTag)
Sets the billing tag for the request.
Definition: CatalogVersionRequest.h:88
const boost::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition: CatalogVersionRequest.h:75
CatalogVersionRequest & WithStartVersion(int64_t startVersion)
Sets the catalog start version.
Definition: CatalogVersionRequest.h:60
CatalogVersionRequest & WithBillingTag(std::string &&billingTag)
Sets the billing tag for the request.
Definition: CatalogVersionRequest.h:104
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24