From 3f14b684fe880c2be005467fd9e2979f7407ba85 Mon Sep 17 00:00:00 2001 From: Vinoth Kumar C Date: Mon, 4 Mar 2024 19:34:54 +0530 Subject: [PATCH 1/2] added api to fetch store features --- src/Factory.php | 6 +++ .../Store/GetStoreFeaturesRequest.php | 44 +++++++++++++++++++ src/Resources/StoreFeatureResource.php | 17 +++++++ .../Store/GetStoreFeaturesResponse.php | 20 +++++++++ 4 files changed, 87 insertions(+) create mode 100644 src/Requests/Store/GetStoreFeaturesRequest.php create mode 100644 src/Resources/StoreFeatureResource.php create mode 100644 src/Responses/Store/GetStoreFeaturesResponse.php diff --git a/src/Factory.php b/src/Factory.php index c57528c..c1a6a9f 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -7,6 +7,7 @@ use Palpalani\BayRewards\Resources\CustomerResource; use Palpalani\BayRewards\Resources\PointsResource; use Palpalani\BayRewards\Resources\StoreResource; +use Palpalani\BayRewards\Resources\StoreFeatureResource; use Saloon\Http\Connector; final class Factory extends Connector @@ -52,4 +53,9 @@ public function allCustomers(): CustomerResource { return new CustomerResource($this); } + + public function getStoreFeatures(): StoreFeatureResource + { + return new StoreFeatureResource($this); + } } diff --git a/src/Requests/Store/GetStoreFeaturesRequest.php b/src/Requests/Store/GetStoreFeaturesRequest.php new file mode 100644 index 0000000..e0b324e --- /dev/null +++ b/src/Requests/Store/GetStoreFeaturesRequest.php @@ -0,0 +1,44 @@ + 'application/json', + 'Accept' => 'application/json', + 'Store-Access-Token' => $this->access_token, + ]; + } + + public function createDtoFromResponse(Response $response): Store + { + return GetStoreFeaturesResponse::make($response); + } +} diff --git a/src/Resources/StoreFeatureResource.php b/src/Resources/StoreFeatureResource.php new file mode 100644 index 0000000..57f50f3 --- /dev/null +++ b/src/Resources/StoreFeatureResource.php @@ -0,0 +1,17 @@ +connector->send(new GetStoreFeaturesRequest($access_token, $data))->dto(); + } +} diff --git a/src/Responses/Store/GetStoreFeaturesResponse.php b/src/Responses/Store/GetStoreFeaturesResponse.php new file mode 100644 index 0000000..7ad5481 --- /dev/null +++ b/src/Responses/Store/GetStoreFeaturesResponse.php @@ -0,0 +1,20 @@ +json(); + + return new Store(...$data); + } +} From 01cf5829429f73a2f466adcc1926307f5331bb46 Mon Sep 17 00:00:00 2001 From: vinothkumar95 Date: Mon, 4 Mar 2024 14:15:17 +0000 Subject: [PATCH 2/2] Fix styling --- src/Factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Factory.php b/src/Factory.php index c1a6a9f..1d00264 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -6,8 +6,8 @@ use Palpalani\BayRewards\Resources\CreateActivityResource; use Palpalani\BayRewards\Resources\CustomerResource; use Palpalani\BayRewards\Resources\PointsResource; -use Palpalani\BayRewards\Resources\StoreResource; use Palpalani\BayRewards\Resources\StoreFeatureResource; +use Palpalani\BayRewards\Resources\StoreResource; use Saloon\Http\Connector; final class Factory extends Connector