|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Stagehand\Sessions; |
| 6 | + |
| 7 | +use Stagehand\Core\Attributes\Required; |
| 8 | +use Stagehand\Core\Concerns\SdkModel; |
| 9 | +use Stagehand\Core\Contracts\BaseModel; |
| 10 | +use Stagehand\Sessions\SessionReplayResponse\Data; |
| 11 | + |
| 12 | +/** |
| 13 | + * @phpstan-import-type DataShape from \Stagehand\Sessions\SessionReplayResponse\Data |
| 14 | + * |
| 15 | + * @phpstan-type SessionReplayResponseShape = array{ |
| 16 | + * data: Data|DataShape, success: bool |
| 17 | + * } |
| 18 | + */ |
| 19 | +final class SessionReplayResponse implements BaseModel |
| 20 | +{ |
| 21 | + /** @use SdkModel<SessionReplayResponseShape> */ |
| 22 | + use SdkModel; |
| 23 | + |
| 24 | + #[Required] |
| 25 | + public Data $data; |
| 26 | + |
| 27 | + /** |
| 28 | + * Indicates whether the request was successful. |
| 29 | + */ |
| 30 | + #[Required] |
| 31 | + public bool $success; |
| 32 | + |
| 33 | + /** |
| 34 | + * `new SessionReplayResponse()` is missing required properties by the API. |
| 35 | + * |
| 36 | + * To enforce required parameters use |
| 37 | + * ``` |
| 38 | + * SessionReplayResponse::with(data: ..., success: ...) |
| 39 | + * ``` |
| 40 | + * |
| 41 | + * Otherwise ensure the following setters are called |
| 42 | + * |
| 43 | + * ``` |
| 44 | + * (new SessionReplayResponse)->withData(...)->withSuccess(...) |
| 45 | + * ``` |
| 46 | + */ |
| 47 | + public function __construct() |
| 48 | + { |
| 49 | + $this->initialize(); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Construct an instance from the required parameters. |
| 54 | + * |
| 55 | + * You must use named parameters to construct any parameters with a default value. |
| 56 | + * |
| 57 | + * @param Data|DataShape $data |
| 58 | + */ |
| 59 | + public static function with(Data|array $data, bool $success): self |
| 60 | + { |
| 61 | + $self = new self; |
| 62 | + |
| 63 | + $self['data'] = $data; |
| 64 | + $self['success'] = $success; |
| 65 | + |
| 66 | + return $self; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @param Data|DataShape $data |
| 71 | + */ |
| 72 | + public function withData(Data|array $data): self |
| 73 | + { |
| 74 | + $self = clone $this; |
| 75 | + $self['data'] = $data; |
| 76 | + |
| 77 | + return $self; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Indicates whether the request was successful. |
| 82 | + */ |
| 83 | + public function withSuccess(bool $success): self |
| 84 | + { |
| 85 | + $self = clone $this; |
| 86 | + $self['success'] = $success; |
| 87 | + |
| 88 | + return $self; |
| 89 | + } |
| 90 | +} |
0 commit comments