-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Npldevfr\Liquipedia; | ||
|
||
use GuzzleHttp\Client; | ||
use Npldevfr\Liquipedia\Query\QueryParameters; | ||
|
||
final class Liquipedia | ||
{ | ||
private readonly string $apiKey; | ||
|
||
private readonly LiquipediaBuilder $builder; | ||
|
||
public function __construct( | ||
string $apiKey, | ||
?LiquipediaBuilder $builder = null | ||
) { | ||
|
||
if ($apiKey === '' || $apiKey === '0') { | ||
throw new \InvalidArgumentException('[Liquipedia] Api key is required'); | ||
} | ||
|
||
$this->apiKey = $apiKey; | ||
$this->builder = $builder ?? new LiquipediaBuilder( | ||
params: [], | ||
client: new Client([ | ||
'base_uri' => 'https://api.liquipedia.net/api/v3/', | ||
'headers' => [ | ||
'Authorization' => "Apikey {$this->apiKey}", | ||
], | ||
] | ||
)); | ||
|
||
} | ||
|
||
public function query(array $params = [], ?QueryParameters $queryParameters = null, ?Client $client = null): LiquipediaBuilder | ||
Check failure on line 36 in src/Liquipedia.php GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest
|
||
{ | ||
|
||
return (new self($this->apiKey))->builder->query($params, $queryParameters, $client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Npldevfr\Liquipedia\ConditionsBuilder; | ||
use Npldevfr\Liquipedia\Liquipedia; | ||
use Npldevfr\Liquipedia\Meta\Endpoint; | ||
|
||
it('can query liquipedia api', function () { | ||
|
||
$liquipedia = new Liquipedia('myapikey'); | ||
dd($liquipedia | ||
->query() | ||
->endpoint(Endpoint::MATCHES) | ||
->rawConditions( | ||
ConditionsBuilder::build( | ||
'opponent', | ||
'::', | ||
'Karmine Corp' | ||
)->toValue() | ||
) | ||
->limit(10) | ||
->get()); | ||
|
||
})->only(); |
Binary file not shown.