From 07140aa08f75a65b6eccff4f39ffe86324d8deea Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 15:44:37 -0400 Subject: [PATCH] Added RevenueWithdrawalState objects --- .../Enums/Types/RevenueWithdrawalType.php | 10 +++ .../Payments/RevenueWithdrawalState.php | 44 +++++++++++++ .../RevenueWithdrawalStateFailed.php | 36 +++++++++++ .../RevenueWithdrawalStatePending.php | 36 +++++++++++ .../RevenueWithdrawalStateSucceeded.php | 63 +++++++++++++++++++ 5 files changed, 189 insertions(+) create mode 100644 src/TgBotLib/Enums/Types/RevenueWithdrawalType.php create mode 100644 src/TgBotLib/Objects/Payments/RevenueWithdrawalState.php create mode 100644 src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateFailed.php create mode 100644 src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStatePending.php create mode 100644 src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateSucceeded.php diff --git a/src/TgBotLib/Enums/Types/RevenueWithdrawalType.php b/src/TgBotLib/Enums/Types/RevenueWithdrawalType.php new file mode 100644 index 0000000..ce494a0 --- /dev/null +++ b/src/TgBotLib/Enums/Types/RevenueWithdrawalType.php @@ -0,0 +1,10 @@ + RevenueWithdrawalStateSucceeded::fromArray($data), + RevenueWithdrawalType::FAILED => RevenueWithdrawalStateFailed::fromArray($data), + RevenueWithdrawalType::PENDING => RevenueWithdrawalStatePending::fromArray($data), + default => throw new InvalidArgumentException('Unknown RevenueWithdrawalType') + }; + } + } \ No newline at end of file diff --git a/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateFailed.php b/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateFailed.php new file mode 100644 index 0000000..93f0f2a --- /dev/null +++ b/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateFailed.php @@ -0,0 +1,36 @@ + $this->type->value, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?RevenueWithdrawalStateFailed + { + if (is_null($data)) + { + return null; + } + + $object = new self(); + $object->type = RevenueWithdrawalType::FAILED; + + return $object; + } + } \ No newline at end of file diff --git a/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStatePending.php b/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStatePending.php new file mode 100644 index 0000000..afd8441 --- /dev/null +++ b/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStatePending.php @@ -0,0 +1,36 @@ + $this->type->value, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?RevenueWithdrawalStatePending + { + if (is_null($data)) + { + return null; + } + + $object = new self(); + $object->type = RevenueWithdrawalType::PENDING; + + return $object; + } + } \ No newline at end of file diff --git a/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateSucceeded.php b/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateSucceeded.php new file mode 100644 index 0000000..3515ad6 --- /dev/null +++ b/src/TgBotLib/Objects/Payments/RevenueWithdrawalState/RevenueWithdrawalStateSucceeded.php @@ -0,0 +1,63 @@ +date; + } + + /** + * An HTTPS URL that can be used to see transaction details + * + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @inheritDoc + */ + public function toArray(): ?array + { + return [ + 'type' => $this->type->value, + 'date' => $this->date, + 'url' => $this->url, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?RevenueWithdrawalStateSucceeded + { + if (is_null($data)) + { + return null; + } + + $object = new self(); + $object->type = RevenueWithdrawalType::SUCCEEDED; + $object->date = $data['date']; + $object->url = $data['url']; + + return $object; + } + } \ No newline at end of file