aboutsummaryrefslogtreecommitdiffhomepage
path: root/td
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-05 00:20:21 +0300
committerlevlam <levlam@telegram.org>2026-07-05 00:20:21 +0300
commit4466eb8354d88e966bbd55761c4f829732662012 (patch)
tree35f645100b71d4517f36b4581e3f813469a7c759 /td
parent0378024063c8bd6e008a037ec1683211fb45cacb (diff)
Add and use LabeledPricePart::get_input_labeled_prices.
Diffstat (limited to 'td')
-rw-r--r--td/telegram/InputInvoice.cpp8
-rw-r--r--td/telegram/LabeledPricePart.cpp26
-rw-r--r--td/telegram/LabeledPricePart.h12
3 files changed, 38 insertions, 8 deletions
diff --git a/td/telegram/InputInvoice.cpp b/td/telegram/InputInvoice.cpp
index 9d76016e8..9347a7d1e 100644
--- a/td/telegram/InputInvoice.cpp
+++ b/td/telegram/InputInvoice.cpp
@@ -284,13 +284,11 @@ tl_object_ptr<telegram_api::invoice> InputInvoice::Invoice::get_input_invoice()
terms_of_service_url = terms_of_service_url_;
}
- auto prices = transform(price_parts_, [](const LabeledPricePart &price) {
- return telegram_api::make_object<telegram_api::labeledPrice>(price.label, price.amount);
- });
return telegram_api::make_object<telegram_api::invoice>(
flags, is_test_, need_name_, need_phone_number_, need_email_address_, need_shipping_address_, is_flexible_,
- send_phone_number_to_provider_, send_email_address_to_provider_, is_recurring, currency_, std::move(prices),
- max_tip_amount_, vector<int64>(suggested_tip_amounts_), terms_of_service_url, subscription_period_);
+ send_phone_number_to_provider_, send_email_address_to_provider_, is_recurring, currency_,
+ LabeledPricePart::get_input_labeled_prices(price_parts_), max_tip_amount_, vector<int64>(suggested_tip_amounts_),
+ terms_of_service_url, subscription_period_);
}
static telegram_api::object_ptr<telegram_api::inputWebDocument> get_input_web_document(const FileManager *file_manager,
diff --git a/td/telegram/LabeledPricePart.cpp b/td/telegram/LabeledPricePart.cpp
new file mode 100644
index 000000000..375146272
--- /dev/null
+++ b/td/telegram/LabeledPricePart.cpp
@@ -0,0 +1,26 @@
+//
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+#include "td/telegram/LabeledPricePart.h"
+
+#include "td/utils/algorithm.h"
+
+namespace td {
+
+telegram_api::object_ptr<telegram_api::labeledPrice> LabeledPricePart::get_input_labeled_price() const {
+ return telegram_api::make_object<telegram_api::labeledPrice>(label, amount);
+}
+
+vector<telegram_api::object_ptr<telegram_api::labeledPrice>> LabeledPricePart::get_input_labeled_prices(
+ const vector<LabeledPricePart> &parts) {
+ return transform(parts, [](const LabeledPricePart &price) { return price.get_input_labeled_price(); });
+}
+
+StringBuilder &operator<<(StringBuilder &string_builder, const LabeledPricePart &labeled_price_part) {
+ return string_builder << '[' << labeled_price_part.label << ": " << labeled_price_part.amount << ']';
+}
+
+} // namespace td
diff --git a/td/telegram/LabeledPricePart.h b/td/telegram/LabeledPricePart.h
index 4fae2dc81..be97976ea 100644
--- a/td/telegram/LabeledPricePart.h
+++ b/td/telegram/LabeledPricePart.h
@@ -6,6 +6,8 @@
//
#pragma once
+#include "td/telegram/telegram_api.h"
+
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
@@ -15,10 +17,16 @@ struct LabeledPricePart {
string label;
int64 amount = 0;
+ telegram_api::object_ptr<telegram_api::labeledPrice> get_input_labeled_price() const;
+
LabeledPricePart() = default;
+
LabeledPricePart(string &&label, int64 amount) : label(std::move(label)), amount(amount) {
}
+ static vector<telegram_api::object_ptr<telegram_api::labeledPrice>> get_input_labeled_prices(
+ const vector<LabeledPricePart> &parts);
+
template <class StorerT>
void store(StorerT &storer) const {
storer.store_string(label);
@@ -40,8 +48,6 @@ inline bool operator!=(const LabeledPricePart &lhs, const LabeledPricePart &rhs)
return !(lhs == rhs);
}
-inline StringBuilder &operator<<(StringBuilder &string_builder, const LabeledPricePart &labeled_price_part) {
- return string_builder << '[' << labeled_price_part.label << ": " << labeled_price_part.amount << ']';
-}
+StringBuilder &operator<<(StringBuilder &string_builder, const LabeledPricePart &labeled_price_part);
} // namespace td