diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..6b7b74c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 58aca93..68ba24f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 115 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-3b2c6c771ad1da0bbfeb0af115972929ed2c7fcd5e47a79556d66cd21431b224.yml -openapi_spec_hash: de2890233b68387bf5f9b6d19e7d87dc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-93bb7d4f1475c8043af464ec88244a034456c549136c8477f284f0a33192e1c9.yml +openapi_spec_hash: 74dca63c872249274ad99b111dea0833 config_hash: 8894c96caeb6df84c9394518810221bd diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a7467..a21e6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.3.0 (2026-04-01) + +Full Changelog: [v0.2.0...v0.3.0](https://github.com/Xquik-dev/x-twitter-scraper-php/compare/v0.2.0...v0.3.0) + +### Features + +* **api:** api update ([f236745](https://github.com/Xquik-dev/x-twitter-scraper-php/commit/f2367453aa8f6982522697df842e60e4b95f7ff1)) + ## 0.2.0 (2026-04-01) Full Changelog: [v0.1.0...v0.2.0](https://github.com/Xquik-dev/x-twitter-scraper-php/compare/v0.1.0...v0.2.0) diff --git a/src/Compose/ComposeNewResponse.php b/src/Compose/ComposeNewResponse.php new file mode 100644 index 0000000..debed1a --- /dev/null +++ b/src/Compose/ComposeNewResponse.php @@ -0,0 +1,123 @@ +|null, + * text?: string|null, + * } + */ +final class ComposeNewResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * AI feedback on the draft. + */ + #[Optional] + public ?string $feedback; + + /** + * Engagement score (0-100). + */ + #[Optional] + public ?float $score; + + /** + * Improvement suggestions. + * + * @var list|null $suggestions + */ + #[Optional(list: 'string')] + public ?array $suggestions; + + /** + * Generated or refined tweet text. + */ + #[Optional] + public ?string $text; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list|null $suggestions + */ + public static function with( + ?string $feedback = null, + ?float $score = null, + ?array $suggestions = null, + ?string $text = null, + ): self { + $self = new self; + + null !== $feedback && $self['feedback'] = $feedback; + null !== $score && $self['score'] = $score; + null !== $suggestions && $self['suggestions'] = $suggestions; + null !== $text && $self['text'] = $text; + + return $self; + } + + /** + * AI feedback on the draft. + */ + public function withFeedback(string $feedback): self + { + $self = clone $this; + $self['feedback'] = $feedback; + + return $self; + } + + /** + * Engagement score (0-100). + */ + public function withScore(float $score): self + { + $self = clone $this; + $self['score'] = $score; + + return $self; + } + + /** + * Improvement suggestions. + * + * @param list $suggestions + */ + public function withSuggestions(array $suggestions): self + { + $self = clone $this; + $self['suggestions'] = $suggestions; + + return $self; + } + + /** + * Generated or refined tweet text. + */ + public function withText(string $text): self + { + $self = clone $this; + $self['text'] = $text; + + return $self; + } +} diff --git a/src/Events/EventDetail.php b/src/Events/EventDetail.php index b1df6ad..0d66df9 100644 --- a/src/Events/EventDetail.php +++ b/src/Events/EventDetail.php @@ -29,7 +29,11 @@ final class EventDetail implements BaseModel #[Required] public string $id; - /** @var array $data */ + /** + * Event payload — shape varies by event type (JSON). + * + * @var array $data + */ #[Required(map: 'mixed')] public array $data; @@ -116,6 +120,8 @@ public function withID(string $id): self } /** + * Event payload — shape varies by event type (JSON). + * * @param array $data */ public function withData(array $data): self diff --git a/src/Events/EventGetResponse.php b/src/Events/EventGetResponse.php index d47d877..abc95b5 100644 --- a/src/Events/EventGetResponse.php +++ b/src/Events/EventGetResponse.php @@ -29,7 +29,11 @@ final class EventGetResponse implements BaseModel #[Required] public string $id; - /** @var array $data */ + /** + * Event payload — shape varies by event type (JSON). + * + * @var array $data + */ #[Required(map: 'mixed')] public array $data; @@ -116,6 +120,8 @@ public function withID(string $id): self } /** + * Event payload — shape varies by event type (JSON). + * * @param array $data */ public function withData(array $data): self diff --git a/src/Extractions/ExtractionGetResponse.php b/src/Extractions/ExtractionGetResponse.php index 767ccae..6e6808d 100644 --- a/src/Extractions/ExtractionGetResponse.php +++ b/src/Extractions/ExtractionGetResponse.php @@ -26,7 +26,11 @@ final class ExtractionGetResponse implements BaseModel #[Required] public bool $hasMore; - /** @var array $job */ + /** + * Extraction job metadata — shape varies by tool type (JSON). + * + * @var array $job + */ #[Required(map: 'mixed')] public array $job; @@ -90,6 +94,8 @@ public function withHasMore(bool $hasMore): self } /** + * Extraction job metadata — shape varies by tool type (JSON). + * * @param array $job */ public function withJob(array $job): self diff --git a/src/Integrations/Integration.php b/src/Integrations/Integration.php index 7c7de55..397ee5c 100644 --- a/src/Integrations/Integration.php +++ b/src/Integrations/Integration.php @@ -34,7 +34,11 @@ final class Integration implements BaseModel #[Required] public string $id; - /** @var array $config */ + /** + * Integration config — shape varies by type (JSON). + * + * @var array $config + */ #[Required(map: 'mixed')] public array $config; @@ -55,7 +59,11 @@ final class Integration implements BaseModel #[Required(enum: Type::class)] public string $type; - /** @var array|null $filters */ + /** + * Event filter rules (JSON). + * + * @var array|null $filters + */ #[Optional(map: 'mixed')] public ?array $filters; @@ -152,6 +160,8 @@ public function withID(string $id): self } /** + * Integration config — shape varies by type (JSON). + * * @param array $config */ public function withConfig(array $config): self @@ -209,6 +219,8 @@ public function withType(Type|string $type): self } /** + * Event filter rules (JSON). + * * @param array $filters */ public function withFilters(array $filters): self diff --git a/src/Integrations/IntegrationGetResponse.php b/src/Integrations/IntegrationGetResponse.php index 80da08e..be18270 100644 --- a/src/Integrations/IntegrationGetResponse.php +++ b/src/Integrations/IntegrationGetResponse.php @@ -34,7 +34,11 @@ final class IntegrationGetResponse implements BaseModel #[Required] public string $id; - /** @var array $config */ + /** + * Integration config — shape varies by type (JSON). + * + * @var array $config + */ #[Required(map: 'mixed')] public array $config; @@ -55,7 +59,11 @@ final class IntegrationGetResponse implements BaseModel #[Required(enum: Type::class)] public string $type; - /** @var array|null $filters */ + /** + * Event filter rules (JSON). + * + * @var array|null $filters + */ #[Optional(map: 'mixed')] public ?array $filters; @@ -152,6 +160,8 @@ public function withID(string $id): self } /** + * Integration config — shape varies by type (JSON). + * * @param array $config */ public function withConfig(array $config): self @@ -209,6 +219,8 @@ public function withType(Type|string $type): self } /** + * Event filter rules (JSON). + * * @param array $filters */ public function withFilters(array $filters): self diff --git a/src/Integrations/IntegrationListResponse/Integration.php b/src/Integrations/IntegrationListResponse/Integration.php index 10d7b77..e3fa610 100644 --- a/src/Integrations/IntegrationListResponse/Integration.php +++ b/src/Integrations/IntegrationListResponse/Integration.php @@ -34,7 +34,11 @@ final class Integration implements BaseModel #[Required] public string $id; - /** @var array $config */ + /** + * Integration config — shape varies by type (JSON). + * + * @var array $config + */ #[Required(map: 'mixed')] public array $config; @@ -55,7 +59,11 @@ final class Integration implements BaseModel #[Required(enum: Type::class)] public string $type; - /** @var array|null $filters */ + /** + * Event filter rules (JSON). + * + * @var array|null $filters + */ #[Optional(map: 'mixed')] public ?array $filters; @@ -152,6 +160,8 @@ public function withID(string $id): self } /** + * Integration config — shape varies by type (JSON). + * * @param array $config */ public function withConfig(array $config): self @@ -209,6 +219,8 @@ public function withType(Type|string $type): self } /** + * Event filter rules (JSON). + * * @param array $filters */ public function withFilters(array $filters): self diff --git a/src/Integrations/IntegrationNewResponse.php b/src/Integrations/IntegrationNewResponse.php index 84db85d..1958f38 100644 --- a/src/Integrations/IntegrationNewResponse.php +++ b/src/Integrations/IntegrationNewResponse.php @@ -34,7 +34,11 @@ final class IntegrationNewResponse implements BaseModel #[Required] public string $id; - /** @var array $config */ + /** + * Integration config — shape varies by type (JSON). + * + * @var array $config + */ #[Required(map: 'mixed')] public array $config; @@ -55,7 +59,11 @@ final class IntegrationNewResponse implements BaseModel #[Required(enum: Type::class)] public string $type; - /** @var array|null $filters */ + /** + * Event filter rules (JSON). + * + * @var array|null $filters + */ #[Optional(map: 'mixed')] public ?array $filters; @@ -152,6 +160,8 @@ public function withID(string $id): self } /** + * Integration config — shape varies by type (JSON). + * * @param array $config */ public function withConfig(array $config): self @@ -209,6 +219,8 @@ public function withType(Type|string $type): self } /** + * Event filter rules (JSON). + * * @param array $filters */ public function withFilters(array $filters): self diff --git a/src/Integrations/IntegrationUpdateParams.php b/src/Integrations/IntegrationUpdateParams.php index 317991d..93f36a0 100644 --- a/src/Integrations/IntegrationUpdateParams.php +++ b/src/Integrations/IntegrationUpdateParams.php @@ -35,14 +35,22 @@ final class IntegrationUpdateParams implements BaseModel #[Optional(list: EventType::class)] public ?array $eventTypes; - /** @var array|null $filters */ + /** + * Event filter rules (JSON). + * + * @var array|null $filters + */ #[Optional(map: 'mixed')] public ?array $filters; #[Optional] public ?bool $isActive; - /** @var array|null $messageTemplate */ + /** + * Custom message template (JSON). + * + * @var array|null $messageTemplate + */ #[Optional(map: 'mixed')] public ?array $messageTemplate; @@ -103,6 +111,8 @@ public function withEventTypes(array $eventTypes): self } /** + * Event filter rules (JSON). + * * @param array $filters */ public function withFilters(array $filters): self @@ -122,6 +132,8 @@ public function withIsActive(bool $isActive): self } /** + * Custom message template (JSON). + * * @param array $messageTemplate */ public function withMessageTemplate(array $messageTemplate): self diff --git a/src/Integrations/IntegrationUpdateResponse.php b/src/Integrations/IntegrationUpdateResponse.php index 1cc6332..bcd8be9 100644 --- a/src/Integrations/IntegrationUpdateResponse.php +++ b/src/Integrations/IntegrationUpdateResponse.php @@ -34,7 +34,11 @@ final class IntegrationUpdateResponse implements BaseModel #[Required] public string $id; - /** @var array $config */ + /** + * Integration config — shape varies by type (JSON). + * + * @var array $config + */ #[Required(map: 'mixed')] public array $config; @@ -55,7 +59,11 @@ final class IntegrationUpdateResponse implements BaseModel #[Required(enum: Type::class)] public string $type; - /** @var array|null $filters */ + /** + * Event filter rules (JSON). + * + * @var array|null $filters + */ #[Optional(map: 'mixed')] public ?array $filters; @@ -152,6 +160,8 @@ public function withID(string $id): self } /** + * Integration config — shape varies by type (JSON). + * * @param array $config */ public function withConfig(array $config): self @@ -209,6 +219,8 @@ public function withType(Type|string $type): self } /** + * Event filter rules (JSON). + * * @param array $filters */ public function withFilters(array $filters): self diff --git a/src/ServiceContracts/ComposeContract.php b/src/ServiceContracts/ComposeContract.php index bbb19e7..75aba17 100644 --- a/src/ServiceContracts/ComposeContract.php +++ b/src/ServiceContracts/ComposeContract.php @@ -7,6 +7,7 @@ use XTwitterScraper\Compose\ComposeCreateParams\Goal; use XTwitterScraper\Compose\ComposeCreateParams\MediaType; use XTwitterScraper\Compose\ComposeCreateParams\Step; +use XTwitterScraper\Compose\ComposeNewResponse; use XTwitterScraper\Core\Exceptions\APIException; use XTwitterScraper\RequestOptions; @@ -31,8 +32,6 @@ interface ComposeContract * @param string $topic Tweet topic (compose, refine) * @param RequestOpts|null $requestOptions * - * @return array - * * @throws APIException */ public function create( @@ -48,5 +47,5 @@ public function create( ?string $tone = null, ?string $topic = null, RequestOptions|array|null $requestOptions = null, - ): array; + ): ComposeNewResponse; } diff --git a/src/ServiceContracts/ComposeRawContract.php b/src/ServiceContracts/ComposeRawContract.php index 55d99bd..0456776 100644 --- a/src/ServiceContracts/ComposeRawContract.php +++ b/src/ServiceContracts/ComposeRawContract.php @@ -5,6 +5,7 @@ namespace XTwitterScraper\ServiceContracts; use XTwitterScraper\Compose\ComposeCreateParams; +use XTwitterScraper\Compose\ComposeNewResponse; use XTwitterScraper\Core\Contracts\BaseResponse; use XTwitterScraper\Core\Exceptions\APIException; use XTwitterScraper\RequestOptions; @@ -20,7 +21,7 @@ interface ComposeRawContract * @param array|ComposeCreateParams $params * @param RequestOpts|null $requestOptions * - * @return BaseResponse> + * @return BaseResponse * * @throws APIException */ diff --git a/src/ServiceContracts/IntegrationsContract.php b/src/ServiceContracts/IntegrationsContract.php index 1992037..77a6b02 100644 --- a/src/ServiceContracts/IntegrationsContract.php +++ b/src/ServiceContracts/IntegrationsContract.php @@ -59,8 +59,8 @@ public function retrieve( * * @param string $id Resource ID (stringified bigint) * @param list<\XTwitterScraper\Integrations\IntegrationUpdateParams\EventType|value-of<\XTwitterScraper\Integrations\IntegrationUpdateParams\EventType>> $eventTypes - * @param array $filters - * @param array $messageTemplate + * @param array $filters Event filter rules (JSON) + * @param array $messageTemplate Custom message template (JSON) * @param RequestOpts|null $requestOptions * * @throws APIException diff --git a/src/Services/APIKeysRawService.php b/src/Services/APIKeysRawService.php index d45176a..2a9543b 100644 --- a/src/Services/APIKeysRawService.php +++ b/src/Services/APIKeysRawService.php @@ -55,7 +55,7 @@ public function create( body: (object) $parsed, options: $options, convert: APIKeyNewResponse::class, - security: [], + security: ['apiKey' => true], ); } @@ -79,7 +79,7 @@ public function list( path: 'api-keys', options: $requestOptions, convert: APIKeyListResponse::class, - security: [], + security: ['apiKey' => true], ); } @@ -105,7 +105,7 @@ public function revoke( path: ['api-keys/%1$s', $id], options: $requestOptions, convert: APIKeyRevokeResponse::class, - security: [], + security: ['apiKey' => true], ); } } diff --git a/src/Services/AccountRawService.php b/src/Services/AccountRawService.php index edfe056..e841100 100644 --- a/src/Services/AccountRawService.php +++ b/src/Services/AccountRawService.php @@ -112,7 +112,7 @@ public function updateLocale( body: (object) $parsed, options: $options, convert: AccountUpdateLocaleResponse::class, - security: [], + security: ['apiKey' => true], ); } } diff --git a/src/Services/ComposeRawService.php b/src/Services/ComposeRawService.php index 7553a13..0dd419a 100644 --- a/src/Services/ComposeRawService.php +++ b/src/Services/ComposeRawService.php @@ -9,8 +9,8 @@ use XTwitterScraper\Compose\ComposeCreateParams\Goal; use XTwitterScraper\Compose\ComposeCreateParams\MediaType; use XTwitterScraper\Compose\ComposeCreateParams\Step; +use XTwitterScraper\Compose\ComposeNewResponse; use XTwitterScraper\Core\Contracts\BaseResponse; -use XTwitterScraper\Core\Conversion\MapOf; use XTwitterScraper\Core\Exceptions\APIException; use XTwitterScraper\RequestOptions; use XTwitterScraper\ServiceContracts\ComposeRawContract; @@ -48,7 +48,7 @@ public function __construct(private Client $client) {} * }|ComposeCreateParams $params * @param RequestOpts|null $requestOptions * - * @return BaseResponse> + * @return BaseResponse * * @throws APIException */ @@ -67,7 +67,7 @@ public function create( path: 'compose', body: (object) $parsed, options: $options, - convert: new MapOf('mixed'), + convert: ComposeNewResponse::class, ); } } diff --git a/src/Services/ComposeService.php b/src/Services/ComposeService.php index 6f48e5d..96d3ece 100644 --- a/src/Services/ComposeService.php +++ b/src/Services/ComposeService.php @@ -8,6 +8,7 @@ use XTwitterScraper\Compose\ComposeCreateParams\Goal; use XTwitterScraper\Compose\ComposeCreateParams\MediaType; use XTwitterScraper\Compose\ComposeCreateParams\Step; +use XTwitterScraper\Compose\ComposeNewResponse; use XTwitterScraper\Core\Exceptions\APIException; use XTwitterScraper\Core\Util; use XTwitterScraper\RequestOptions; @@ -51,8 +52,6 @@ public function __construct(private Client $client) * @param string $topic Tweet topic (compose, refine) * @param RequestOpts|null $requestOptions * - * @return array - * * @throws APIException */ public function create( @@ -68,7 +67,7 @@ public function create( ?string $tone = null, ?string $topic = null, RequestOptions|array|null $requestOptions = null, - ): array { + ): ComposeNewResponse { $params = Util::removeNulls( [ 'step' => $step, diff --git a/src/Services/IntegrationsService.php b/src/Services/IntegrationsService.php index 1a40a7e..e168462 100644 --- a/src/Services/IntegrationsService.php +++ b/src/Services/IntegrationsService.php @@ -102,8 +102,8 @@ public function retrieve( * * @param string $id Resource ID (stringified bigint) * @param list<\XTwitterScraper\Integrations\IntegrationUpdateParams\EventType|value-of<\XTwitterScraper\Integrations\IntegrationUpdateParams\EventType>> $eventTypes - * @param array $filters - * @param array $messageTemplate + * @param array $filters Event filter rules (JSON) + * @param array $messageTemplate Custom message template (JSON) * @param RequestOpts|null $requestOptions * * @throws APIException diff --git a/src/Services/X/AccountsRawService.php b/src/Services/X/AccountsRawService.php index 1fbfa93..f2c36c8 100644 --- a/src/Services/X/AccountsRawService.php +++ b/src/Services/X/AccountsRawService.php @@ -64,7 +64,7 @@ public function create( body: (object) $parsed, options: $options, convert: AccountNewResponse::class, - security: [], + security: ['apiKey' => true], ); } @@ -90,7 +90,7 @@ public function retrieve( path: ['x/accounts/%1$s', $id], options: $requestOptions, convert: AccountGetResponse::class, - security: [], + security: ['apiKey' => true], ); } @@ -114,7 +114,7 @@ public function list( path: 'x/accounts', options: $requestOptions, convert: AccountListResponse::class, - security: [], + security: ['apiKey' => true], ); } @@ -140,7 +140,7 @@ public function delete( path: ['x/accounts/%1$s', $id], options: $requestOptions, convert: AccountDeleteResponse::class, - security: [], + security: ['apiKey' => true], ); } @@ -174,7 +174,7 @@ public function reauth( body: (object) $parsed, options: $options, convert: AccountReauthResponse::class, - security: [], + security: ['apiKey' => true], ); } } diff --git a/src/Version.php b/src/Version.php index 99e08cc..07faa59 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace XTwitterScraper; // x-release-please-start-version -const VERSION = '0.2.0'; +const VERSION = '0.3.0'; // x-release-please-end diff --git a/src/X/Communities/CommunityGetInfoResponse.php b/src/X/Communities/CommunityGetInfoResponse.php index aac5cd7..c63c0e4 100644 --- a/src/X/Communities/CommunityGetInfoResponse.php +++ b/src/X/Communities/CommunityGetInfoResponse.php @@ -7,9 +7,14 @@ use XTwitterScraper\Core\Attributes\Required; use XTwitterScraper\Core\Concerns\SdkModel; use XTwitterScraper\Core\Contracts\BaseModel; +use XTwitterScraper\X\Communities\CommunityGetInfoResponse\Community; /** - * @phpstan-type CommunityGetInfoResponseShape = array{community: mixed} + * @phpstan-import-type CommunityShape from \XTwitterScraper\X\Communities\CommunityGetInfoResponse\Community + * + * @phpstan-type CommunityGetInfoResponseShape = array{ + * community: Community|CommunityShape + * } */ final class CommunityGetInfoResponse implements BaseModel { @@ -20,7 +25,7 @@ final class CommunityGetInfoResponse implements BaseModel * Community info object. */ #[Required] - public mixed $community; + public Community $community; /** * `new CommunityGetInfoResponse()` is missing required properties by the API. @@ -45,8 +50,10 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param Community|CommunityShape $community */ - public static function with(mixed $community): self + public static function with(Community|array $community): self { $self = new self; @@ -57,8 +64,10 @@ public static function with(mixed $community): self /** * Community info object. + * + * @param Community|CommunityShape $community */ - public function withCommunity(mixed $community): self + public function withCommunity(Community|array $community): self { $self = clone $this; $self['community'] = $community; diff --git a/src/X/Communities/CommunityGetInfoResponse/Community.php b/src/X/Communities/CommunityGetInfoResponse/Community.php new file mode 100644 index 0000000..043dc88 --- /dev/null +++ b/src/X/Communities/CommunityGetInfoResponse/Community.php @@ -0,0 +1,269 @@ +|null, + * } + */ +final class Community implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Community ID. + */ + #[Required] + public string $id; + + /** + * Community banner image URL. + */ + #[Optional('banner_url')] + public ?string $bannerURL; + + /** + * Community creation timestamp. + */ + #[Optional('created_at')] + public ?string $createdAt; + + /** + * Community description. + */ + #[Optional] + public ?string $description; + + /** + * Join policy (open or restricted). + */ + #[Optional('join_policy')] + public ?string $joinPolicy; + + /** + * Total member count. + */ + #[Optional('member_count')] + public ?int $memberCount; + + /** + * Total moderator count. + */ + #[Optional('moderator_count')] + public ?int $moderatorCount; + + /** + * Community name. + */ + #[Optional] + public ?string $name; + + /** + * Primary topic. + */ + #[Optional('primary_topic')] + public ?PrimaryTopic $primaryTopic; + + /** + * Community rules. + * + * @var list|null $rules + */ + #[Optional(list: Rule::class)] + public ?array $rules; + + /** + * `new Community()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Community::with(id: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Community)->withID(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param PrimaryTopic|PrimaryTopicShape|null $primaryTopic + * @param list|null $rules + */ + public static function with( + string $id, + ?string $bannerURL = null, + ?string $createdAt = null, + ?string $description = null, + ?string $joinPolicy = null, + ?int $memberCount = null, + ?int $moderatorCount = null, + ?string $name = null, + PrimaryTopic|array|null $primaryTopic = null, + ?array $rules = null, + ): self { + $self = new self; + + $self['id'] = $id; + + null !== $bannerURL && $self['bannerURL'] = $bannerURL; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $description && $self['description'] = $description; + null !== $joinPolicy && $self['joinPolicy'] = $joinPolicy; + null !== $memberCount && $self['memberCount'] = $memberCount; + null !== $moderatorCount && $self['moderatorCount'] = $moderatorCount; + null !== $name && $self['name'] = $name; + null !== $primaryTopic && $self['primaryTopic'] = $primaryTopic; + null !== $rules && $self['rules'] = $rules; + + return $self; + } + + /** + * Community ID. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Community banner image URL. + */ + public function withBannerURL(string $bannerURL): self + { + $self = clone $this; + $self['bannerURL'] = $bannerURL; + + return $self; + } + + /** + * Community creation timestamp. + */ + public function withCreatedAt(string $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * Community description. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Join policy (open or restricted). + */ + public function withJoinPolicy(string $joinPolicy): self + { + $self = clone $this; + $self['joinPolicy'] = $joinPolicy; + + return $self; + } + + /** + * Total member count. + */ + public function withMemberCount(int $memberCount): self + { + $self = clone $this; + $self['memberCount'] = $memberCount; + + return $self; + } + + /** + * Total moderator count. + */ + public function withModeratorCount(int $moderatorCount): self + { + $self = clone $this; + $self['moderatorCount'] = $moderatorCount; + + return $self; + } + + /** + * Community name. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Primary topic. + * + * @param PrimaryTopic|PrimaryTopicShape $primaryTopic + */ + public function withPrimaryTopic(PrimaryTopic|array $primaryTopic): self + { + $self = clone $this; + $self['primaryTopic'] = $primaryTopic; + + return $self; + } + + /** + * Community rules. + * + * @param list $rules + */ + public function withRules(array $rules): self + { + $self = clone $this; + $self['rules'] = $rules; + + return $self; + } +} diff --git a/src/X/Communities/CommunityGetInfoResponse/Community/PrimaryTopic.php b/src/X/Communities/CommunityGetInfoResponse/Community/PrimaryTopic.php new file mode 100644 index 0000000..3939d3f --- /dev/null +++ b/src/X/Communities/CommunityGetInfoResponse/Community/PrimaryTopic.php @@ -0,0 +1,62 @@ + */ + use SdkModel; + + #[Optional] + public ?string $id; + + #[Optional] + public ?string $name; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(?string $id = null, ?string $name = null): self + { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $name && $self['name'] = $name; + + return $self; + } + + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/X/Communities/CommunityGetInfoResponse/Community/Rule.php b/src/X/Communities/CommunityGetInfoResponse/Community/Rule.php new file mode 100644 index 0000000..ad617be --- /dev/null +++ b/src/X/Communities/CommunityGetInfoResponse/Community/Rule.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + #[Optional] + public ?string $id; + + #[Optional] + public ?string $description; + + #[Optional] + public ?string $name; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?string $id = null, + ?string $description = null, + ?string $name = null + ): self { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $description && $self['description'] = $description; + null !== $name && $self['name'] = $name; + + return $self; + } + + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/tests/Services/ComposeTest.php b/tests/Services/ComposeTest.php index a08e58d..914e2a9 100644 --- a/tests/Services/ComposeTest.php +++ b/tests/Services/ComposeTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use Tests\UnsupportedMockTests; use XTwitterScraper\Client; +use XTwitterScraper\Compose\ComposeNewResponse; use XTwitterScraper\Core\Util; /** @@ -41,7 +42,7 @@ public function testCreate(): void $result = $this->client->compose->create(step: 'compose'); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertIsArray($result); + $this->assertInstanceOf(ComposeNewResponse::class, $result); } #[Test] @@ -66,6 +67,6 @@ public function testCreateWithOptionalParams(): void ); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertIsArray($result); + $this->assertInstanceOf(ComposeNewResponse::class, $result); } }