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