-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Meta api
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Palpalani\BayRewards\Requests\Store; | ||
|
||
use Palpalani\BayRewards\Objects\Store; | ||
use Palpalani\BayRewards\Responses\Store\GetStoreFeaturesResponse; | ||
use Saloon\Contracts\Response; | ||
use Saloon\Enums\Method; | ||
use Saloon\Http\Request; | ||
use Saloon\Traits\Plugins\AlwaysThrowOnErrors; | ||
|
||
final class GetStoreFeaturesRequest extends Request | ||
{ | ||
use AlwaysThrowOnErrors; | ||
|
||
protected Method $method = Method::POST; | ||
|
||
public function __construct(protected string $access_token) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function resolveEndpoint(): string | ||
{ | ||
return '/account/initial'; | ||
} | ||
|
||
protected function defaultHeaders(): array | ||
{ | ||
return [ | ||
'Content-Type' => 'application/json', | ||
'Accept' => 'application/json', | ||
'Store-Access-Token' => $this->access_token, | ||
]; | ||
} | ||
|
||
public function createDtoFromResponse(Response $response): Store | ||
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / P8.3 - L10.* - prefer-lowest - ubuntu-latest
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / P8.3 - L10.* - prefer-stable - ubuntu-latest
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / P8.3 - L11.* - prefer-stable - ubuntu-latest
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / P8.3 - L11.* - prefer-lowest - ubuntu-latest
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / phpstan
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / phpstan
Check failure on line 40 in src/Requests/Store/GetStoreFeaturesRequest.php GitHub Actions / phpstan
|
||
{ | ||
return GetStoreFeaturesResponse::make($response); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Palpalani\BayRewards\Resources; | ||
|
||
use Palpalani\BayRewards\Objects\ActionData; | ||
use Palpalani\BayRewards\Requests\Store\GetStoreFeaturesRequest; | ||
|
||
final class StoreFeatureResource extends Resource | ||
{ | ||
/** | ||
* @return mixed|ActionData | ||
*/ | ||
public function post(string $access_token, array $data): mixed | ||
{ | ||
return $this->connector->send(new GetStoreFeaturesRequest($access_token, $data))->dto(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Palpalani\BayRewards\Responses\Store; | ||
|
||
use Palpalani\BayRewards\Objects\Store; | ||
use Saloon\Contracts\Response; | ||
|
||
/** | ||
* @phpstan-import-type StoreData from Store | ||
*/ | ||
final class GetStoreFeaturesResponse | ||
{ | ||
public static function make(Response $response): Store | ||
{ | ||
/** @var StoreData $data */ | ||
$data = $response->json(); | ||
|
||
return new Store(...$data); | ||
} | ||
} |