From 3de87df2d977571aeef704d0c18b5f0f54aa4dd9 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 14 Feb 2023 15:31:10 -0500 Subject: [PATCH] Added \TgBotLib\Objects > LabeledPrice --- src/TgBotLib/Objects/LabeledPrice.php | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/TgBotLib/Objects/LabeledPrice.php diff --git a/src/TgBotLib/Objects/LabeledPrice.php b/src/TgBotLib/Objects/LabeledPrice.php new file mode 100644 index 0000000..ae52a16 --- /dev/null +++ b/src/TgBotLib/Objects/LabeledPrice.php @@ -0,0 +1,73 @@ +label; + } + + /** + * Price of the product in the smallest units of the currency (integer, not float/double). For example, for a + * price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits + * past the decimal point for each currency (2 for the majority of currencies). + * + * @see https://core.telegram.org/bots/payments#supported-currencies + * @see https://core.telegram.org/bots/payments/currencies.json + * @return int + */ + public function getAmount(): int + { + return $this->amount; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'label' => $this->label, + 'amount' => $this->amount, + ]; + } + + /** + * Constructs the object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->label = $data['label']; + $object->amount = $data['amount']; + + return $object; + } + } \ No newline at end of file