diff --git a/CHANGELOG.md b/CHANGELOG.md index b586736..f9b7435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index ee6ca9b..8bd9d2b 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 diff --git a/README.md b/README.md index 5819d14..80e6856 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/get_concept_star_rating.php b/examples/get_concept_star_rating.php new file mode 100644 index 0000000..95108ab --- /dev/null +++ b/examples/get_concept_star_rating.php @@ -0,0 +1,20 @@ + 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); diff --git a/examples/get_product_star_rating.php b/examples/get_product_star_rating.php new file mode 100644 index 0000000..0eac933 --- /dev/null +++ b/examples/get_product_star_rating.php @@ -0,0 +1,20 @@ + 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); diff --git a/postman_collection/playstation api.postman_collection.json b/postman_collection/playstation api.postman_collection.json index 954c1de..64b36a4 100644 --- a/postman_collection/playstation api.postman_collection.json +++ b/postman_collection/playstation api.postman_collection.json @@ -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}}" ], @@ -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", @@ -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": { diff --git a/src/Enum/CategoryEnum.php b/src/Enum/CategoryEnum.php index 587519d..49af680 100644 --- a/src/Enum/CategoryEnum.php +++ b/src/Enum/CategoryEnum.php @@ -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'; } diff --git a/src/Enum/OperationSha256Enum.php b/src/Enum/OperationSha256Enum.php index cc7f417..e2ce5be 100644 --- a/src/Enum/OperationSha256Enum.php +++ b/src/Enum/OperationSha256Enum.php @@ -18,4 +18,8 @@ enum OperationSha256Enum: string case metGetConceptById = 'cc90404ac049d935afbd9968aef523da2b6723abfb9d586e5f77ebf7c5289006'; case metGetPricingDataByConceptId = 'abcb311ea830e679fe2b697a27f755764535d825b24510ab1239a4ca3092bd09'; + + case wcaProductStarRatingRetrive = 'cedd370c39e89da20efa7b2e55710e88cb6e6843cc2f8203f7e73ba4751e7253'; + + case wcaConceptStarRatingRetrive = 'e12dc5cef72296a437b4d71e0b130010bf3707ab981b585ba00d1d5773ce2092'; } diff --git a/src/Request/RequestAddOnsByTitleId.php b/src/Request/RequestAddOnsByTitleId.php index ba5e206..2aca800 100644 --- a/src/Request/RequestAddOnsByTitleId.php +++ b/src/Request/RequestAddOnsByTitleId.php @@ -7,6 +7,8 @@ final class RequestAddOnsByTitleId implements BaseRequest { + public const DEFAULT_PAGINATION_SIZE = 20; + public readonly Pagination $pageArgs; public function __construct( @@ -14,7 +16,7 @@ public function __construct( Pagination $pageArgs = null ) { - $this->pageArgs = $pageArgs ?? new Pagination(20); + $this->pageArgs = $pageArgs ?? new Pagination(self::DEFAULT_PAGINATION_SIZE); } } diff --git a/src/Request/RequestConceptStarRating.php b/src/Request/RequestConceptStarRating.php new file mode 100644 index 0000000..ac608fe --- /dev/null +++ b/src/Request/RequestConceptStarRating.php @@ -0,0 +1,11 @@ +value, - new Pagination(10), + $pageArgs ?? new Pagination(self::DEFAULT_PAGINATION_SIZE), Sorting::createFromCatalogSorting(CatalogSortingEnum::RELEASE_DATE) ); } diff --git a/src/Request/RequestProductStarRating.php b/src/Request/RequestProductStarRating.php new file mode 100644 index 0000000..ad08b66 --- /dev/null +++ b/src/Request/RequestProductStarRating.php @@ -0,0 +1,11 @@ +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; }