|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace XTwitterScraper\Compose; |
| 6 | + |
| 7 | +use XTwitterScraper\Core\Attributes\Optional; |
| 8 | +use XTwitterScraper\Core\Concerns\SdkModel; |
| 9 | +use XTwitterScraper\Core\Contracts\BaseModel; |
| 10 | + |
| 11 | +/** |
| 12 | + * @phpstan-type ComposeNewResponseShape = array{ |
| 13 | + * feedback?: string|null, |
| 14 | + * score?: float|null, |
| 15 | + * suggestions?: list<string>|null, |
| 16 | + * text?: string|null, |
| 17 | + * } |
| 18 | + */ |
| 19 | +final class ComposeNewResponse implements BaseModel |
| 20 | +{ |
| 21 | + /** @use SdkModel<ComposeNewResponseShape> */ |
| 22 | + use SdkModel; |
| 23 | + |
| 24 | + /** |
| 25 | + * AI feedback on the draft. |
| 26 | + */ |
| 27 | + #[Optional] |
| 28 | + public ?string $feedback; |
| 29 | + |
| 30 | + /** |
| 31 | + * Engagement score (0-100). |
| 32 | + */ |
| 33 | + #[Optional] |
| 34 | + public ?float $score; |
| 35 | + |
| 36 | + /** |
| 37 | + * Improvement suggestions. |
| 38 | + * |
| 39 | + * @var list<string>|null $suggestions |
| 40 | + */ |
| 41 | + #[Optional(list: 'string')] |
| 42 | + public ?array $suggestions; |
| 43 | + |
| 44 | + /** |
| 45 | + * Generated or refined tweet text. |
| 46 | + */ |
| 47 | + #[Optional] |
| 48 | + public ?string $text; |
| 49 | + |
| 50 | + public function __construct() |
| 51 | + { |
| 52 | + $this->initialize(); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Construct an instance from the required parameters. |
| 57 | + * |
| 58 | + * You must use named parameters to construct any parameters with a default value. |
| 59 | + * |
| 60 | + * @param list<string>|null $suggestions |
| 61 | + */ |
| 62 | + public static function with( |
| 63 | + ?string $feedback = null, |
| 64 | + ?float $score = null, |
| 65 | + ?array $suggestions = null, |
| 66 | + ?string $text = null, |
| 67 | + ): self { |
| 68 | + $self = new self; |
| 69 | + |
| 70 | + null !== $feedback && $self['feedback'] = $feedback; |
| 71 | + null !== $score && $self['score'] = $score; |
| 72 | + null !== $suggestions && $self['suggestions'] = $suggestions; |
| 73 | + null !== $text && $self['text'] = $text; |
| 74 | + |
| 75 | + return $self; |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * AI feedback on the draft. |
| 80 | + */ |
| 81 | + public function withFeedback(string $feedback): self |
| 82 | + { |
| 83 | + $self = clone $this; |
| 84 | + $self['feedback'] = $feedback; |
| 85 | + |
| 86 | + return $self; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Engagement score (0-100). |
| 91 | + */ |
| 92 | + public function withScore(float $score): self |
| 93 | + { |
| 94 | + $self = clone $this; |
| 95 | + $self['score'] = $score; |
| 96 | + |
| 97 | + return $self; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Improvement suggestions. |
| 102 | + * |
| 103 | + * @param list<string> $suggestions |
| 104 | + */ |
| 105 | + public function withSuggestions(array $suggestions): self |
| 106 | + { |
| 107 | + $self = clone $this; |
| 108 | + $self['suggestions'] = $suggestions; |
| 109 | + |
| 110 | + return $self; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Generated or refined tweet text. |
| 115 | + */ |
| 116 | + public function withText(string $text): self |
| 117 | + { |
| 118 | + $self = clone $this; |
| 119 | + $self['text'] = $text; |
| 120 | + |
| 121 | + return $self; |
| 122 | + } |
| 123 | +} |
0 commit comments