Skip to content

Commit

Permalink
Merge pull request #8 from mrt1m/rc-2.1.0
Browse files Browse the repository at this point in the history
2.1.0 - 2024-01-11
  • Loading branch information
Ishmukhametov Timur authored Jan 11, 2024
2 parents 321ae22 + bd1b983 commit 45ea5bd
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.1.0 - 2024-01-11

- Added new method for get star rating information
- Added category id with all concepts
- Update parameters for RequestProductList

## 2.0.1 - 2023-06-18

- Added new method for create next page request
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: build get_catalog_ps4 get_catalog_ps5 ps_plus_deluxe ps_plus_extra ps_plus_essential get_product_by_id get_concept_by_id get_concept_by_product_id run_example

build:
docker compose build php\
docker compose build php \
&& docker compose run --rm php composer install -n

get_catalog_ps4:
Expand Down Expand Up @@ -40,6 +40,12 @@ get_pricing_data_by_concept_id:
get_add_ons_by_title_id:
make run_example name=get_add_ons_by_title_id

get_product_star_rating:
make run_example name=get_product_star_rating

get_concept_star_rating:
make run_example name=get_concept_star_rating

run_example:
docker compose run --rm php -f examples/${name}.php > response/${name}.json

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ You can get sha256Hash from browser request:
3) sha256Hash is in the extensions parameter, example:

```
https://web.np.playstation.com/api/graphql/v1//op?operationName=categoryGridRetrieve&variables={"id":"44d8bb20-653e-431e-8ad0-c0a365f68d2f","pageArgs":{"size":24,"offset":0},"sortBy":{"name":"productReleaseDate","isAscending":false},"filterBy":[],"facetOptions":[]}&extensions={"persistedQuery":{"version":1,"sha256Hash":"9845afc0dbaab4965f6563fffc703f588c8e76792000e8610843b8d3ee9c4c09"}}
https://web.np.playstation.com/api/graphql/v1/op?operationName=categoryGridRetrieve&variables={"id":"44d8bb20-653e-431e-8ad0-c0a365f68d2f","pageArgs":{"size":24,"offset":0},"sortBy":{"name":"productReleaseDate","isAscending":false},"filterBy":[],"facetOptions":[]}&extensions={"persistedQuery":{"version":1,"sha256Hash":"9845afc0dbaab4965f6563fffc703f588c8e76792000e8610843b8d3ee9c4c09"}}
```
If default sha256Hash will be blocked, you can replace the base value:
1) Get new sha256Hash value
Expand Down
20 changes: 20 additions & 0 deletions examples/get_concept_star_rating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);

use PlaystationStoreApi\Client;
use GuzzleHttp\Client as HTTPClient;
use PlaystationStoreApi\Enum\RegionEnum;
use PlaystationStoreApi\Request\RequestConceptStarRating;

require_once __DIR__ . '/../vendor/autoload.php';

const API_URL = 'https://web.np.playstation.com/api/graphql/v1/';

$client = new Client(RegionEnum::UNITED_STATES, new HTTPClient(['base_uri' => API_URL, 'timeout' => 5]));

/**
* Example for https://store.playstation.com/en-us/concept/10002694
*/
$result = $client->get(new RequestConceptStarRating('10002694'));

echo json_encode($result, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
20 changes: 20 additions & 0 deletions examples/get_product_star_rating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);

use PlaystationStoreApi\Client;
use GuzzleHttp\Client as HTTPClient;
use PlaystationStoreApi\Enum\RegionEnum;
use PlaystationStoreApi\Request\RequestProductStarRating;

require_once __DIR__ . '/../vendor/autoload.php';

const API_URL = 'https://web.np.playstation.com/api/graphql/v1/';

$client = new Client(RegionEnum::UNITED_STATES, new HTTPClient(['base_uri' => API_URL, 'timeout' => 5]));

/**
* Example for https://store.playstation.com/en-us/product/UP0082-PPSA10664_00-FF16SIEA00000002
*/
$result = $client->get(new RequestProductStarRating('UP0082-PPSA10664_00-FF16SIEA00000002'));

echo json_encode($result, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
84 changes: 82 additions & 2 deletions postman_collection/playstation api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
],
"url": {
"raw": "{{playstation_host_graphql_api}}/api/graphql/v1/op?operationName=categoryGridRetrieve&variables={\"id\":\"4cbf39e2-5749-4970-ba81-93a489e4570c\",\"pageArgs\":{\"size\":24,\"offset\":0},\"sortBy\":null,\"filterBy\":[],\"facetOptions\":[]}&extensions={\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"{{sha256Hash}}\"}}",
"raw": "{{playstation_host_graphql_api}}/api/graphql/v1/op?operationName=categoryGridRetrieve&variables={\"id\":\"4cbf39e2-5749-4970-ba81-93a489e4570c\",\"pageArgs\":{\"size\":24,\"offset\":0},\"sortBy\":null,\"filterBy\":[\"storeDisplayClassification:ADD_ON\"],\"facetOptions\":[]}&extensions={\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"{{sha256Hash}}\"}}",
"host": [
"{{playstation_host_graphql_api}}"
],
Expand All @@ -81,7 +81,7 @@
},
{
"key": "variables",
"value": "{\"id\":\"4cbf39e2-5749-4970-ba81-93a489e4570c\",\"pageArgs\":{\"size\":24,\"offset\":0},\"sortBy\":null,\"filterBy\":[],\"facetOptions\":[]}"
"value": "{\"id\":\"4cbf39e2-5749-4970-ba81-93a489e4570c\",\"pageArgs\":{\"size\":24,\"offset\":0},\"sortBy\":null,\"filterBy\":[\"storeDisplayClassification:ADD_ON\"],\"facetOptions\":[]}"
},
{
"key": "extensions",
Expand Down Expand Up @@ -582,6 +582,86 @@
},
"response": []
},
{
"name": "wcaProductStarRatingRetrive",
"request": {
"method": "GET",
"header": [
{
"key": "x-psn-store-locale-override",
"value": "{{locale}}",
"type": "text"
}
],
"url": {
"raw": "{{playstation_host_graphql_api}}/api/graphql/v1/op?operationName=wcaProductStarRatingRetrive&variables={\"productId\":\"{{productId}}\"}&extensions={\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"cedd370c39e89da20efa7b2e55710e88cb6e6843cc2f8203f7e73ba4751e7253\"}}",
"host": [
"{{playstation_host_graphql_api}}"
],
"path": [
"api",
"graphql",
"v1",
"op"
],
"query": [
{
"key": "operationName",
"value": "wcaProductStarRatingRetrive"
},
{
"key": "variables",
"value": "{\"productId\":\"{{productId}}\"}"
},
{
"key": "extensions",
"value": "{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"cedd370c39e89da20efa7b2e55710e88cb6e6843cc2f8203f7e73ba4751e7253\"}}"
}
]
}
},
"response": []
},
{
"name": "wcaConceptStarRatingRetrive",
"request": {
"method": "GET",
"header": [
{
"key": "x-psn-store-locale-override",
"value": "{{locale}}",
"type": "text"
}
],
"url": {
"raw": "{{playstation_host_graphql_api}}/api/graphql/v1/op?operationName=wcaConceptStarRatingRetrive&variables={\"conceptId\":\"{{conceptId}}\"}&extensions={\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"e12dc5cef72296a437b4d71e0b130010bf3707ab981b585ba00d1d5773ce2092\"}}",
"host": [
"{{playstation_host_graphql_api}}"
],
"path": [
"api",
"graphql",
"v1",
"op"
],
"query": [
{
"key": "operationName",
"value": "wcaConceptStarRatingRetrive"
},
{
"key": "variables",
"value": "{\"conceptId\":\"{{conceptId}}\"}"
},
{
"key": "extensions",
"value": "{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"e12dc5cef72296a437b4d71e0b130010bf3707ab981b585ba00d1d5773ce2092\"}}"
}
]
}
},
"response": []
},
{
"name": "metGetConceptByProductIdQuery",
"request": {
Expand Down
2 changes: 2 additions & 0 deletions src/Enum/CategoryEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ enum CategoryEnum: string
case FREE_GAMES = 'd9930400-c5c7-4a06-a28d-cc74888426dc';

case OFFERS = '16b8d09a-d0e3-44e3-96cb-a3b2a21b6d69';

case ALL_CONCEPTS = '28c9c2b2-cecc-415c-9a08-482a605cb104';
}
4 changes: 4 additions & 0 deletions src/Enum/OperationSha256Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ enum OperationSha256Enum: string
case metGetConceptById = 'cc90404ac049d935afbd9968aef523da2b6723abfb9d586e5f77ebf7c5289006';

case metGetPricingDataByConceptId = 'abcb311ea830e679fe2b697a27f755764535d825b24510ab1239a4ca3092bd09';

case wcaProductStarRatingRetrive = 'cedd370c39e89da20efa7b2e55710e88cb6e6843cc2f8203f7e73ba4751e7253';

case wcaConceptStarRatingRetrive = 'e12dc5cef72296a437b4d71e0b130010bf3707ab981b585ba00d1d5773ce2092';
}
4 changes: 3 additions & 1 deletion src/Request/RequestAddOnsByTitleId.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

final class RequestAddOnsByTitleId implements BaseRequest
{
public const DEFAULT_PAGINATION_SIZE = 20;

public readonly Pagination $pageArgs;

public function __construct(
public readonly string $npTitleId,
Pagination $pageArgs = null
)
{
$this->pageArgs = $pageArgs ?? new Pagination(20);
$this->pageArgs = $pageArgs ?? new Pagination(self::DEFAULT_PAGINATION_SIZE);
}
}

11 changes: 11 additions & 0 deletions src/Request/RequestConceptStarRating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);

namespace PlaystationStoreApi\Request;

final class RequestConceptStarRating implements BaseRequest
{
public function __construct(public readonly string $conceptId)
{
}
}
10 changes: 7 additions & 3 deletions src/Request/RequestProductList.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@

final class RequestProductList implements BaseRequest
{
public const DEFAULT_PAGINATION_SIZE = 20;

public array $filterBy = [];

public array $facetOptions = [];

public static function createFromCategory(CategoryEnum $categoryEnum): RequestProductList
{
public static function createFromCategory(
CategoryEnum $categoryEnum,
Pagination $pageArgs = null
): RequestProductList {
return new self(
$categoryEnum->value,
new Pagination(10),
$pageArgs ?? new Pagination(self::DEFAULT_PAGINATION_SIZE),
Sorting::createFromCatalogSorting(CatalogSortingEnum::RELEASE_DATE)
);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Request/RequestProductStarRating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);

namespace PlaystationStoreApi\Request;

final class RequestProductStarRating implements BaseRequest
{
public function __construct(public readonly string $productId)
{
}
}
4 changes: 4 additions & 0 deletions src/RequestLocatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use PlaystationStoreApi\Request\RequestProductById;
use PlaystationStoreApi\Request\RequestProductList;
use PlaystationStoreApi\Request\RequestPSPlusTier;
use PlaystationStoreApi\Request\RequestProductStarRating;
use PlaystationStoreApi\Request\RequestConceptStarRating;
use StringBackedEnum;

final class RequestLocatorService
Expand All @@ -33,6 +35,8 @@ public static function default(): self
$locator->set(RequestConceptByProductId::class, OperationSha256Enum::metGetConceptByProductIdQuery);
$locator->set(RequestPricingDataByConceptId::class, OperationSha256Enum::metGetPricingDataByConceptId);
$locator->set(RequestAddOnsByTitleId::class, OperationSha256Enum::metGetAddOnsByTitleId);
$locator->set(RequestProductStarRating::class, OperationSha256Enum::wcaProductStarRatingRetrive);
$locator->set(RequestConceptStarRating::class, OperationSha256Enum::wcaConceptStarRatingRetrive);

return $locator;
}
Expand Down

0 comments on commit 45ea5bd

Please sign in to comment.