Bye bye api.flashii.net
This commit is contained in:
parent
c39b43acf8
commit
ca0755b1e1
4 changed files with 6 additions and 32 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.4.1
|
||||
0.5.0
|
||||
|
|
|
@ -19,18 +19,10 @@ final class FlashiiUrls {
|
|||
public const PROD_URL = 'https://flashii.net';
|
||||
|
||||
/**
|
||||
* Production API base URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const PROD_API_URL = 'https://api.flashii.net';
|
||||
|
||||
/**
|
||||
* @param string $apiUrl API base URL, without trailing /.
|
||||
* @param string $url Base URL, without trailing /.
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $url,
|
||||
private readonly string $apiUrl
|
||||
private readonly string $url
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
@ -51,30 +43,12 @@ final class FlashiiUrls {
|
|||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a prefixed API URL.
|
||||
*
|
||||
* @param string $path Path to append to the URL.
|
||||
* @param array<string, Stringable|scalar|null|list<Stringable|scalar|null>> $args Query arguments to append to the URL.
|
||||
* @return string
|
||||
*/
|
||||
public function getApiUrl(string $path = '', array $args = []): string {
|
||||
$url = $this->apiUrl . $path;
|
||||
|
||||
if(!empty($args)) {
|
||||
$url .= str_contains($url, '?') ? '&' : '?';
|
||||
$url .= UriQuery::encode($args);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance with the production URLs preset.
|
||||
*
|
||||
* @return FlashiiUrls
|
||||
*/
|
||||
public static function production(): self {
|
||||
return new static(self::PROD_URL, self::PROD_API_URL);
|
||||
return new static(self::PROD_URL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class V1EmotesClient {
|
|||
$args['include_order'] = '1';
|
||||
|
||||
$response = $this->client->sendRequest(
|
||||
new GuzzleHttpRequest('GET', $this->urls->getApiUrl('/v1/emotes', $args))
|
||||
new GuzzleHttpRequest('GET', $this->urls->getUrl('/v1/emotes', $args))
|
||||
);
|
||||
|
||||
$emotes = Json::decode($response->getBody());
|
||||
|
|
|
@ -36,7 +36,7 @@ class V1Client {
|
|||
*/
|
||||
public function me(): ?V1User {
|
||||
$response = $this->client->sendRequest(
|
||||
new GuzzleHttpRequest('GET', $this->urls->getApiUrl('/v1/me'))
|
||||
new GuzzleHttpRequest('GET', $this->urls->getUrl('/v1/me'))
|
||||
);
|
||||
if($response->getStatusCode() !== 200)
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue