File tree Expand file tree Collapse file tree 5 files changed +16
-2
lines changed
Expand file tree Collapse file tree 5 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ public function getTweet(string $id): Tweet
1212 {
1313 $ response = $ this ->get ('tweets/ ' . $ id , [
1414 'tweet.fields ' => $ this ->tweetFields ,
15+ 'expansions ' => $ this ->expansions ,
16+ 'media.fields ' => $ this ->mediaFields ,
1517 ]);
1618
1719 return new Tweet ($ response ->getData ());
Original file line number Diff line number Diff line change @@ -6,10 +6,12 @@ class BaseModel
66{
77 public array $ data ;
88 public array $ meta ;
9+ public array $ includes ;
910
1011 public function __construct (public array $ response )
1112 {
1213 $ this ->data = (!isset ($ response ['data ' ])) ? $ this ->data = $ response : $ this ->data = $ response ['data ' ];
1314 $ this ->meta = ($ response ['meta ' ] ?? []);
15+ $ this ->includes = ($ response ['includes ' ] ?? []);
1416 }
1517}
Original file line number Diff line number Diff line change @@ -88,4 +88,15 @@ public function getAttachments(): ?array
8888 {
8989 return (isset ($ this ->data ['attachments ' ]) ? $ this ->data ['attachments ' ] : null );
9090 }
91+
92+ public function getMedia (): ?array
93+ {
94+ return (isset ($ this ->includes ['media ' ]) ? $ this ->includes ['media ' ] : null );
95+ }
96+
97+ public function getIncludes (): ?array
98+ {
99+ return (isset ($ this ->includes ) && !empty ($ this ->includes ) ? $ this ->includes : null );
100+ }
101+
91102}
Original file line number Diff line number Diff line change 11<?php
22
33use PHPUnit \Framework \TestCase ;
4- use UtxoOne \TwitterUltimatePhp \Client \Client ;
54use UtxoOne \TwitterUltimatePhp \Models \Tweet ;
65use UtxoOne \TwitterUltimatePhp \Models \Tweets ;
76
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public function testGetTweet(): void
1212 {
1313 $ client = new TweetClient (bearerToken: $ _ENV ['TWITTER_BEARER_TOKEN ' ]);
1414
15- $ response = $ client ->getTweet ('1564986319981498368 ' );
15+ $ response = $ client ->getTweet ('1589452392348930048 ' );
1616
1717 $ this ->assertInstanceOf (Tweet::class, $ response );
1818 $ this ->assertSame ('1564986319981498368 ' , $ response ->getId ());
You can’t perform that action at this time.
0 commit comments