-
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
1 parent
d96fb37
commit 3f14b68
Showing
4 changed files
with
87 additions
and
0 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
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,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 | ||
{ | ||
return GetStoreFeaturesResponse::make($response); | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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,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); | ||
} | ||
} |