Skip to content

Commit

Permalink
Operation "trends.byWoeid" was added
Browse files Browse the repository at this point in the history
Type "Trends_Response" was added
Type "Trend" was added
  • Loading branch information
SDKgen-Bot committed Apr 24, 2024
1 parent 08840d7 commit b4240e6
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdkgen.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/BookmarkTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getAll(string $userId, ?string $expansions = null, ?int $maxResu
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down Expand Up @@ -80,6 +81,7 @@ public function create(string $userId, SingleTweet $payload): BookmarkResponse

$options = [
'query' => $this->parser->query([
], [
]),
'json' => $payload
];
Expand Down Expand Up @@ -118,6 +120,7 @@ public function delete(string $userId, string $tweetId): BookmarkResponse

$options = [
'query' => $this->parser->query([
], [
]),
];

Expand Down
8 changes: 8 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public function quote(): QuoteTag
);
}

public function trends(): TrendsTag
{
return new TrendsTag(
$this->httpClient,
$this->parser
);
}



public static function build(string $token): self
Expand Down
1 change: 1 addition & 0 deletions src/QuoteTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function getAll(string $tweetId, ?string $exclude = null, ?string $expans
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down
1 change: 1 addition & 0 deletions src/SearchTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function getRecent(?string $query = null, ?string $startTime = null, ?str
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down
49 changes: 49 additions & 0 deletions src/Trend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Trend automatically generated by SDKgen please do not edit this file manually
* @see https://sdkgen.app
*/

namespace SdkFabric\Twitter;

use PSX\Schema\Attribute\Description;
use PSX\Schema\Attribute\Key;

#[Description('')]
class Trend implements \JsonSerializable, \PSX\Record\RecordableInterface
{
#[Key('trend_name')]
#[Description('')]
protected ?string $trendName = null;
#[Key('tweet_count')]
#[Description('')]
protected ?int $tweetCount = null;
public function setTrendName(?string $trendName) : void
{
$this->trendName = $trendName;
}
public function getTrendName() : ?string
{
return $this->trendName;
}
public function setTweetCount(?int $tweetCount) : void
{
$this->tweetCount = $tweetCount;
}
public function getTweetCount() : ?int
{
return $this->tweetCount;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('trend_name', $this->trendName);
$record->put('tweet_count', $this->tweetCount);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
44 changes: 44 additions & 0 deletions src/TrendsResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* TrendsResponse automatically generated by SDKgen please do not edit this file manually
* @see https://sdkgen.app
*/

namespace SdkFabric\Twitter;

use PSX\Schema\Attribute\Description;

#[Description('')]
class TrendsResponse implements \JsonSerializable, \PSX\Record\RecordableInterface
{
/**
* @var array<Trend>|null
*/
#[Description('')]
protected ?array $data = null;
/**
* @param array<Trend>|null $data
*/
public function setData(?array $data) : void
{
$this->data = $data;
}
/**
* @return array<Trend>|null
*/
public function getData() : ?array
{
return $this->data;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('data', $this->data);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
55 changes: 55 additions & 0 deletions src/TrendsTag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* TrendsTag automatically generated by SDKgen please do not edit this file manually
* @see https://sdkgen.app
*/

namespace SdkFabric\Twitter;

use GuzzleHttp\Exception\BadResponseException;
use Sdkgen\Client\Exception\ClientException;
use Sdkgen\Client\Exception\UnknownStatusCodeException;
use Sdkgen\Client\TagAbstract;

class TrendsTag extends TagAbstract
{
/**
* The Trends lookup endpoint allow developers to get the Trends for a location, specified using the where-on-earth id (WOEID).
*
* @param string $woeid
* @return TrendsResponse
* @throws ClientException
*/
public function byWoeid(string $woeid): TrendsResponse
{
$url = $this->parser->url('/2/trends/by/woeid/:woeid', [
'woeid' => $woeid,
]);

$options = [
'query' => $this->parser->query([
], [
]),
];

try {
$response = $this->httpClient->request('GET', $url, $options);
$data = (string) $response->getBody();

return $this->parser->parse($data, TrendsResponse::class);
} catch (ClientException $e) {
throw $e;
} catch (BadResponseException $e) {
$data = (string) $e->getResponse()->getBody();

switch ($e->getResponse()->getStatusCode()) {
default:
throw new UnknownStatusCodeException('The server returned an unknown status code');
}
} catch (\Throwable $e) {
throw new ClientException('An unknown error occurred: ' . $e->getMessage());
}
}


}
5 changes: 5 additions & 0 deletions src/TweetTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function getAll(?string $ids = null, ?string $expansions = null, ?string
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down Expand Up @@ -89,6 +90,7 @@ public function get(string $tweetId, ?string $expansions = null, ?string $mediaF
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down Expand Up @@ -125,6 +127,7 @@ public function create(Tweet $payload): TweetCreateResponse

$options = [
'query' => $this->parser->query([
], [
]),
'json' => $payload
];
Expand Down Expand Up @@ -163,6 +166,7 @@ public function delete(string $tweetId): TweetDeleteResponse

$options = [
'query' => $this->parser->query([
], [
]),
];

Expand Down Expand Up @@ -201,6 +205,7 @@ public function hideReply(string $tweetId, HideReplyUpdate $payload): HideReplyR

$options = [
'query' => $this->parser->query([
], [
]),
'json' => $payload
];
Expand Down
1 change: 1 addition & 0 deletions src/UsageTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function getTweets(): TweetUsageResponse

$options = [
'query' => $this->parser->query([
], [
]),
];

Expand Down
4 changes: 4 additions & 0 deletions src/UserTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function getTimeline(string $userId, ?string $startTime = null, ?string $
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down Expand Up @@ -105,6 +106,7 @@ public function getLikedTweets(string $userId, ?string $expansions = null, ?int
'poll.fields' => $pollFields,
'tweet.fields' => $tweetFields,
'user.fields' => $userFields,
], [
]),
];

Expand Down Expand Up @@ -142,6 +144,7 @@ public function removeLike(string $userId, string $tweetId): LikeResponse

$options = [
'query' => $this->parser->query([
], [
]),
];

Expand Down Expand Up @@ -178,6 +181,7 @@ public function createLike(string $userId, SingleTweet $payload): LikeResponse

$options = [
'query' => $this->parser->query([
], [
]),
'json' => $payload
];
Expand Down

0 comments on commit b4240e6

Please sign in to comment.