Skip to content

Commit

Permalink
Upgraded Porter to dev-v7.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Nov 5, 2022
1 parent 52d9892 commit 9cc607e
Show file tree
Hide file tree
Showing 35 changed files with 181 additions and 288 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"connectors/http": "^5",
"connectors/http": "dev-master as 6",
"eloquent/enumeration": "^5|^6",
"phpseclib/phpseclib": "^2",
"psr/log": "^1",
"scriptfusion/porter": "^6",
"scriptfusion/porter": "dev-master as 7",
"symfony/css-selector": "^5.3",
"symfony/dom-crawler": "^5.4",
"xpaw/steamid": "^2.0"
Expand Down
8 changes: 4 additions & 4 deletions src/Collection/AsyncGameReviewsRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
namespace ScriptFUSION\Porter\Provider\Steam\Collection;

use Amp\Future;
use ScriptFUSION\Porter\Collection\AsyncProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\AsyncResource;
use ScriptFUSION\Porter\Collection\ProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;

class AsyncGameReviewsRecords extends AsyncProviderRecords
class AsyncGameReviewsRecords extends ProviderRecords
{
public function __construct(\Iterator $records, private readonly Future $totalReviews, AsyncResource $resource)
public function __construct(\Iterator $records, private readonly Future $totalReviews, ProviderResource $resource)
{
parent::__construct($records, $resource);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Collection/AsyncLoginRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
namespace ScriptFUSION\Porter\Provider\Steam\Collection;

use Amp\Future;
use ScriptFUSION\Porter\Collection\AsyncProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\AsyncResource;
use ScriptFUSION\Porter\Collection\ProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;
use ScriptFUSION\Porter\Provider\Steam\Cookie\SecureLoginCookie;

class AsyncLoginRecord extends AsyncProviderRecords
class AsyncLoginRecord extends ProviderRecords
{
public function __construct(
\Iterator $records,
private readonly Future $secureLoginCookie,
AsyncResource $resource
ProviderResource $resource
) {
parent::__construct($records, $resource);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Collection/AsyncSteamStoreSessionRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
namespace ScriptFUSION\Porter\Provider\Steam\Collection;

use Amp\Future;
use ScriptFUSION\Porter\Collection\AsyncProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\AsyncResource;
use ScriptFUSION\Porter\Collection\ProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;
use ScriptFUSION\Porter\Provider\Steam\Cookie\StoreSessionCookie;

class AsyncSteamStoreSessionRecord extends AsyncProviderRecords
class AsyncSteamStoreSessionRecord extends ProviderRecords
{
public function __construct(\Iterator $records, private readonly Future $sessionCookie, AsyncResource $resource)
public function __construct(\Iterator $records, private readonly Future $sessionCookie, ProviderResource $resource)
{
parent::__construct($records, $resource);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Resource/CreateSteamStoreSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
use ScriptFUSION\Porter\Connector\ImportConnector;
use ScriptFUSION\Porter\Net\Http\AsyncHttpConnector;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Resource\AsyncResource;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;
use ScriptFUSION\Porter\Provider\Steam\Collection\AsyncSteamStoreSessionRecord;
use ScriptFUSION\Porter\Provider\Steam\Cookie\StoreSessionCookie;
use ScriptFUSION\Porter\Provider\Steam\SteamProvider;

final class CreateSteamStoreSession implements AsyncResource
final class CreateSteamStoreSession implements ProviderResource
{
public function getProviderClassName(): string
{
return SteamProvider::class;
}

public function fetchAsync(ImportConnector $connector): \Iterator
public function fetch(ImportConnector $connector): \Iterator
{
$sessionCookie = new DeferredFuture();

Expand All @@ -32,7 +32,7 @@ public function fetchAsync(ImportConnector $connector): \Iterator
throw new \InvalidArgumentException('Unexpected connector type.');
}

$connector->fetchAsync(new AsyncHttpDataSource(SteamProvider::buildStoreApiUrl('/')));
$connector->fetch(new AsyncHttpDataSource(SteamProvider::buildStoreApiUrl('/')));
} catch (\Throwable $throwable) {
$sessionCookie->error($throwable);

Expand Down
4 changes: 2 additions & 2 deletions src/Resource/Curator/CuratorList/DeleteCuratorList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorList;

use Amp\Http\Client\Body\FormBody;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Resource\SingleRecordResource;
use ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorResource;
Expand All @@ -22,7 +22,7 @@ public function __construct(CuratorSession $session, int $curatorId, string $lis
$this->listId = $listId;
}

protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
$body = new FormBody;
$body->addFields([
Expand Down
21 changes: 9 additions & 12 deletions src/Resource/Curator/CuratorList/DeleteCuratorListApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorList;

use Amp\Http\Client\Body\FormBody;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Resource\SingleRecordResource;
use ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorResource;
Expand All @@ -13,19 +13,16 @@

final class DeleteCuratorListApp extends CuratorResource implements SingleRecordResource
{
private $listId;

private $appId;

public function __construct(CuratorSession $session, int $curatorId, string $listId, int $appId)
{
public function __construct(
CuratorSession $session,
int $curatorId,
private readonly string $listId,
private readonly int $appId,
) {
parent::__construct($session, $curatorId);

$this->listId = $listId;
$this->appId = $appId;
}

protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
$body = new FormBody;
$body->addFields([
Expand All @@ -35,7 +32,7 @@ protected function getSource(): AsyncDataSource
]);

return (new AsyncHttpDataSource(
SteamProvider::buildStoreApiUrl("/curator/{$this->curatorId}/admin/ajaxremovefromlist/")
SteamProvider::buildStoreApiUrl("/curator/$this->curatorId/admin/ajaxremovefromlist/")
))
->setMethod('POST')
->setBody($body)
Expand Down
4 changes: 2 additions & 2 deletions src/Resource/Curator/CuratorList/GetCuratorLists.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorList;

use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Net\Http\HttpResponse;
use ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorResource;
use ScriptFUSION\Porter\Provider\Steam\SteamProvider;

final class GetCuratorLists extends CuratorResource
{
protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
return new AsyncHttpDataSource(
SteamProvider::buildStoreApiUrl("/curator/$this->curatorId/ajaxgetlists/?all=1")
Expand Down
19 changes: 8 additions & 11 deletions src/Resource/Curator/CuratorList/PatchCuratorListAppOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorList;

use Amp\Http\Client\Body\FormBody;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Resource\SingleRecordResource;
use ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorResource;
Expand All @@ -13,19 +13,16 @@

final class PatchCuratorListAppOrder extends CuratorResource implements SingleRecordResource
{
private $listId;

private $appIds;

public function __construct(CuratorSession $session, int $curatorId, string $listId, array $appIds)
{
public function __construct(
CuratorSession $session,
int $curatorId,
private readonly string $listId,
private readonly array $appIds,
) {
parent::__construct($session, $curatorId);

$this->listId = $listId;
$this->appIds = $appIds;
}

protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
$body = new FormBody;
$body->addFields([
Expand Down
4 changes: 2 additions & 2 deletions src/Resource/Curator/CuratorList/PutCuratorList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Amp\Http\Client\Body\FormBody;
use Amp\Http\Client\RequestBody;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Resource\SingleRecordResource;
use ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorResource;
Expand All @@ -26,7 +26,7 @@ public function __construct(CuratorSession $session, int $curatorId, CuratorList
$this->list = $list;
}

protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
return (new AsyncHttpDataSource(
SteamProvider::buildStoreApiUrl("/curator/$this->curatorId/admin/ajaxeditlist/")
Expand Down
4 changes: 2 additions & 2 deletions src/Resource/Curator/CuratorList/PutCuratorListApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorList;

use Amp\Http\Client\Body\FormBody;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Resource\SingleRecordResource;
use ScriptFUSION\Porter\Provider\Steam\Resource\Curator\CuratorResource;
Expand All @@ -25,7 +25,7 @@ public function __construct(CuratorSession $session, int $curatorId, string $lis
$this->appId = $appId;
}

protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
$body = new FormBody;
$body->addFields([
Expand Down
12 changes: 6 additions & 6 deletions src/Resource/Curator/CuratorResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator;

use Amp\Http\Client\Cookie\CookieJar;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Connector\ImportConnector;
use ScriptFUSION\Porter\Net\Http\AsyncHttpConnector;
use ScriptFUSION\Porter\Net\Http\HttpResponse;
use ScriptFUSION\Porter\Provider\Resource\AsyncResource;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;
use ScriptFUSION\Porter\Provider\Steam\SteamProvider;

abstract class CuratorResource implements AsyncResource
abstract class CuratorResource implements ProviderResource
{
public function __construct(protected CuratorSession $session, protected int $curatorId)
{
Expand All @@ -22,9 +22,9 @@ public function getProviderClassName(): string
return SteamProvider::class;
}

abstract protected function getSource(): AsyncDataSource;
abstract protected function getSource(): DataSource;

public function fetchAsync(ImportConnector $connector): \Iterator
public function fetch(ImportConnector $connector): \Iterator
{
$baseConnector = $connector->findBaseConnector();
if (!$baseConnector instanceof AsyncHttpConnector) {
Expand All @@ -33,7 +33,7 @@ public function fetchAsync(ImportConnector $connector): \Iterator

$this->applySessionCookies($baseConnector->getCookieJar());

$response = $connector->fetchAsync($this->getSource());
$response = $connector->fetch($this->getSource());

yield from $this->emitResponses($response);
}
Expand Down
11 changes: 4 additions & 7 deletions src/Resource/Curator/CuratorSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use ScriptFUSION\Porter\Provider\Steam\Cookie\StoreSessionCookie;
use ScriptFUSION\Porter\Provider\Steam\Resource\CreateSteamStoreSession;
use ScriptFUSION\Porter\Provider\Steam\Resource\SteamLogin;
use ScriptFUSION\Porter\Specification\AsyncImportSpecification;
use ScriptFUSION\Porter\Specification\AsyncImport;
use ScriptFUSION\Porter\Import\Import;

final class CuratorSession
{
Expand All @@ -28,9 +29,7 @@ public function __construct(SecureLoginCookie $secureLoginCookie, StoreSessionCo
public static function create(Porter $porter, string $username, string $password): self
{
/** @var AsyncLoginRecord $steamLogin */
$steamLogin = $porter->importAsync(new AsyncImportSpecification(
new SteamLogin($username, $password)
))->findFirstCollection();
$steamLogin = $porter->import(new Import(new SteamLogin($username, $password)))->findFirstCollection();

$secureLoginCookie = $steamLogin->getSecureLoginCookie()->await();

Expand All @@ -44,9 +43,7 @@ public static function create(Porter $porter, string $username, string $password
public static function createFromCookie(SecureLoginCookie $secureLoginCookie, Porter $porter): self
{
/** @var AsyncSteamStoreSessionRecord $storeSession */
$storeSession = $porter->importAsync(new AsyncImportSpecification(
new CreateSteamStoreSession
))->findFirstCollection();
$storeSession = $porter->import(new Import(new CreateSteamStoreSession))->findFirstCollection();

$storeSessionCookie = $storeSession->getSessionCookie()->await();

Expand Down
10 changes: 3 additions & 7 deletions src/Resource/Curator/DeleteCuratorReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@
namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator;

use Amp\Http\Client\Body\FormBody;
use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Provider\Steam\SteamProvider;

final class DeleteCuratorReviews extends CuratorResource
{
private $appIds;

public function __construct(CuratorSession $session, int $curatorId, array $appIds)
public function __construct(CuratorSession $session, int $curatorId, private readonly array $appIds)
{
parent::__construct($session, $curatorId);

$this->appIds = $appIds;
}

protected function getUrl(): string
{
return SteamProvider::buildStoreApiUrl("/curator/$this->curatorId/admin/ajaxupdatemultiplecurations/");
}

protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
$body = new FormBody;

Expand Down
4 changes: 2 additions & 2 deletions src/Resource/Curator/GetCuratorReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace ScriptFUSION\Porter\Provider\Steam\Resource\Curator;

use ScriptFUSION\Porter\Connector\AsyncDataSource;
use ScriptFUSION\Porter\Connector\DataSource;
use ScriptFUSION\Porter\Net\Http\AsyncHttpDataSource;
use ScriptFUSION\Porter\Net\Http\HttpResponse;
use ScriptFUSION\Porter\Provider\Steam\SteamProvider;

final class GetCuratorReviews extends CuratorResource
{
protected function getSource(): AsyncDataSource
protected function getSource(): DataSource
{
return new AsyncHttpDataSource(SteamProvider::buildStoreApiUrl(
"/curator/$this->curatorId/admin/ajaxgetrecommendations/?count=0x7FFFFFFF"
Expand Down

0 comments on commit 9cc607e

Please sign in to comment.