Passed
Push — master ( 81593c...33129c )
by Alexey
10:12 queued 12s
created

PlayStoreUiRequest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 219
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 7
eloc 107
c 2
b 1
f 0
dl 0
loc 219
ccs 40
cts 40
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getClusterPagesRequest() 0 22 1
A getSuggestRequest() 0 27 1
A getPermissionsRequest() 0 21 1
A getTopCategoryApps() 0 22 1
A getAppsRequest() 0 23 1
A getReviewsRequest() 0 28 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) Ne-Lexa
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/google-play-scraper
12
 */
13
14
namespace Nelexa\GPlay\Scraper;
15
16
use GuzzleHttp\Psr7\Request;
17
use GuzzleHttp\Psr7\Utils;
18
use Nelexa\GPlay\Enum\SortEnum;
19
use Nelexa\GPlay\GPlayApps;
20
use Nelexa\GPlay\Model\AppId;
21
use Psr\Http\Message\RequestInterface;
22
23
/**
24
 * @internal
25
 */
26
class PlayStoreUiRequest
27
{
28
    public const LIMIT_REVIEW_ON_PAGE = 199;
29
30
    public const LIMIT_APPS_ON_PAGE = 100;
31
32
    private const RPC_ID_REVIEWS = 'UsvDTd';
33
34
    private const RPC_ID_APPS = 'qnKhOb';
35
36
    private const RPC_ID_PERMISSIONS = 'xdSrCf';
37
38
    private const RPC_ID_SUGGEST = 'IJ4APc';
39
40
    private const RPC_ID_PAGE = 'w3QCWb';
41
42
    private const RPC_ID_TOP = 'vyAe2';
43
44
    /**
45
     * @param AppId       $requestApp
46
     * @param int         $count
47
     * @param SortEnum    $sort
48
     * @param string|null $token
49
     *
50
     * @return RequestInterface
51
     */
52 1
    public static function getReviewsRequest(
53
        AppId $requestApp,
54
        int $count,
55
        SortEnum $sort,
56
        ?string $token = null
57
    ): RequestInterface {
58 1
        $limit = min(self::LIMIT_REVIEW_ON_PAGE, max(1, $count));
59
        $queryParams = [
60
            'rpcids' => self::RPC_ID_REVIEWS,
61 1
            GPlayApps::REQ_PARAM_LOCALE => $requestApp->getLocale(),
62 1
            GPlayApps::REQ_PARAM_COUNTRY => $requestApp->getCountry(),
63
            'authuser' => null,
64
            'soc-app' => 121,
65
            'soc-platform' => 1,
66
            'soc-device' => 1,
67
        ];
68 1
        $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams);
69
        $formParams = [
70 1
            'f.req' => '[[["' . self::RPC_ID_REVIEWS . '","[null,null,[2,' . $sort->value(
71 1
                ) . ',[' . $limit . ',null,' . ($token === null ? 'null' : '\\"' . $token . '\\"')
72 1
                . ']],[\\"' . $requestApp->getId() . '\\",7]]",null,"generic"]]]',
73
        ];
74
        $headers = [
75
            'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
76
        ];
77 1
        $body = Utils::streamFor(http_build_query($formParams));
78
79 1
        return new Request('POST', $url, $headers, $body);
80
    }
81
82
    /**
83
     * @param string $locale
84
     * @param string $country
85
     * @param int    $count
86
     * @param string $token
87
     *
88
     * @return RequestInterface
89
     */
90 8
    public static function getAppsRequest(string $locale, string $country, int $count, string $token): RequestInterface
91
    {
92 8
        $limit = min(self::LIMIT_APPS_ON_PAGE, max(1, $count));
93
        $queryParams = [
94
            'rpcids' => self::RPC_ID_APPS,
95
            GPlayApps::REQ_PARAM_LOCALE => $locale,
96
            GPlayApps::REQ_PARAM_COUNTRY => $country,
97
            'soc-app' => 121,
98
            'soc-platform' => 1,
99
            'soc-device' => 1,
100
        ];
101 8
        $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams);
102
103
        $formParams = [
104 8
            'f.req' => '[[["' . self::RPC_ID_APPS . '","[[null,[[8,[20,' . $limit . ']],true,null,[64,1,195,71,8,72,9,10,11,139,12,16,145,148,150,151,152,27,30,31,96,32,34,163,100,165,104,169,108,110,113,55,56,57,122],[null,null,[[[true],null,[[[]]],null,null,null,null,[null,2],null,null,null,null,null,null,[1],null,null,null,null,null,null,null,[1]],[null,[[[]]]],[null,[[[]]],null,[true]],[null,[[[]]]],null,null,null,null,[[[[]]]],[[[[]]]]],[[[[7,1],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,31],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,104],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,9],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,8],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,27],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,12],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,65],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,110],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,88],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,11],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,56],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,55],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,96],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,10],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,122],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,72],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,71],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,64],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,113],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,139],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,150],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,169],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,165],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,151],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,163],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,32],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,16],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,108],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,100],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[9,1],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,31],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,104],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,9],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,8],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,27],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,12],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,65],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,110],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,88],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,11],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,56],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,55],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,96],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,10],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,122],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,72],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,71],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,64],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,113],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,139],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,150],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,169],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,165],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,151],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,163],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,32],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,16],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,108],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,100],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[17,1],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,31],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,104],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,9],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,8],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,27],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,12],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,65],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,110],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,88],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,11],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,56],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,55],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,96],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,10],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,122],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,72],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,71],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,64],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,113],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,139],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,150],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,169],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,165],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,151],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,163],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,32],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,16],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,108],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,100],[[1,7,9,25,13,31,5,27,8,14,10]]],[[10,1],[[1,7,6,9]]],[[10,31],[[1,7,6,9]]],[[10,104],[[1,7,6,9]]],[[10,9],[[1,7,6,9]]],[[10,8],[[1,7,6,9]]],[[10,27],[[1,7,6,9]]],[[10,12],[[1,7,6,9]]],[[10,65],[[1,7,6,9]]],[[10,110],[[1,7,6,9]]],[[10,88],[[1,7,6,9]]],[[10,11],[[1,7,6,9]]],[[10,56],[[1,7,6,9]]],[[10,55],[[1,7,6,9]]],[[10,96],[[1,7,6,9]]],[[10,10],[[1,7,6,9]]],[[10,122],[[1,7,6,9]]],[[10,72],[[1,7,6,9]]],[[10,71],[[1,7,6,9]]],[[10,64],[[1,7,6,9]]],[[10,113],[[1,7,6,9]]],[[10,139],[[1,7,6,9]]],[[10,150],[[1,7,6,9]]],[[10,169],[[1,7,6,9]]],[[10,165],[[1,7,6,9]]],[[10,151],[[1,7,6,9]]],[[10,163],[[1,7,6,9]]],[[10,32],[[1,7,6,9]]],[[10,16],[[1,7,6,9]]],[[10,108],[[1,7,6,9]]],[[10,100],[[1,7,6,9]]],[[1,1],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,31],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,104],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,9],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,8],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,27],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,12],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,65],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,110],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,88],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,11],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,56],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,55],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,96],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,10],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,122],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,72],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,71],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,64],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,113],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,139],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,150],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,169],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,165],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,151],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,163],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,32],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,16],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,108],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,100],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[4,1],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,31],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,104],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,9],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,8],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,27],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,12],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,65],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,110],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,88],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,11],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,56],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,55],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,96],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,10],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,122],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,72],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,71],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,64],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,113],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,139],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,150],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,169],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,165],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,151],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,163],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,32],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,16],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,108],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,100],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[3,1],[[1,5,14,4,10,17]]],[[3,31],[[1,5,14,4,10,17]]],[[3,104],[[1,5,14,4,10,17]]],[[3,9],[[1,5,14,4,10,17]]],[[3,8],[[1,5,14,4,10,17]]],[[3,27],[[1,5,14,4,10,17]]],[[3,12],[[1,5,14,4,10,17]]],[[3,65],[[1,5,14,4,10,17]]],[[3,110],[[1,5,14,4,10,17]]],[[3,88],[[1,5,14,4,10,17]]],[[3,11],[[1,5,14,4,10,17]]],[[3,56],[[1,5,14,4,10,17]]],[[3,55],[[1,5,14,4,10,17]]],[[3,96],[[1,5,14,4,10,17]]],[[3,10],[[1,5,14,4,10,17]]],[[3,122],[[1,5,14,4,10,17]]],[[3,72],[[1,5,14,4,10,17]]],[[3,71],[[1,5,14,4,10,17]]],[[3,64],[[1,5,14,4,10,17]]],[[3,113],[[1,5,14,4,10,17]]],[[3,139],[[1,5,14,4,10,17]]],[[3,150],[[1,5,14,4,10,17]]],[[3,169],[[1,5,14,4,10,17]]],[[3,165],[[1,5,14,4,10,17]]],[[3,151],[[1,5,14,4,10,17]]],[[3,163],[[1,5,14,4,10,17]]],[[3,32],[[1,5,14,4,10,17]]],[[3,16],[[1,5,14,4,10,17]]],[[3,108],[[1,5,14,4,10,17]]],[[3,100],[[1,5,14,4,10,17]]],[[2,1],[[1,5,7,4,13,16,12,18]]],[[2,31],[[1,5,7,4,13,16,12,18]]],[[2,104],[[1,5,7,4,13,16,12,18]]],[[2,9],[[1,5,7,4,13,16,12,18]]],[[2,8],[[1,5,7,4,13,16,12,18]]],[[2,27],[[1,5,7,4,13,16,12,18]]],[[2,12],[[1,5,7,4,13,16,12,18]]],[[2,65],[[1,5,7,4,13,16,12,18]]],[[2,110],[[1,5,7,4,13,16,12,18]]],[[2,88],[[1,5,7,4,13,16,12,18]]],[[2,11],[[1,5,7,4,13,16,12,18]]],[[2,56],[[1,5,7,4,13,16,12,18]]],[[2,55],[[1,5,7,4,13,16,12,18]]],[[2,96],[[1,5,7,4,13,16,12,18]]],[[2,10],[[1,5,7,4,13,16,12,18]]],[[2,122],[[1,5,7,4,13,16,12,18]]],[[2,72],[[1,5,7,4,13,16,12,18]]],[[2,71],[[1,5,7,4,13,16,12,18]]],[[2,64],[[1,5,7,4,13,16,12,18]]],[[2,113],[[1,5,7,4,13,16,12,18]]],[[2,139],[[1,5,7,4,13,16,12,18]]],[[2,150],[[1,5,7,4,13,16,12,18]]],[[2,169],[[1,5,7,4,13,16,12,18]]],[[2,165],[[1,5,7,4,13,16,12,18]]],[[2,151],[[1,5,7,4,13,16,12,18]]],[[2,163],[[1,5,7,4,13,16,12,18]]],[[2,32],[[1,5,7,4,13,16,12,18]]],[[2,16],[[1,5,7,4,13,16,12,18]]],[[2,108],[[1,5,7,4,13,16,12,18]]],[[2,100],[[1,5,7,4,13,16,12,18]]]]]],null,null,[[[1,2],[10,8,9],[],[]]]],null,\"' . $token . '\"],[true]]",null,"generic"]]]',
105
        ];
106
107
        $headers = [
108
            'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
109
        ];
110 8
        $body = Utils::streamFor(http_build_query($formParams));
111
112 8
        return new Request('POST', $url, $headers, $body);
113
    }
114
115
    /**
116
     * @param AppId $requestApp
117
     *
118
     * @throws \Exception
119
     *
120
     * @return RequestInterface
121
     */
122 1
    public static function getPermissionsRequest(AppId $requestApp): RequestInterface
123
    {
124
        $queryParams = [
125
            'rpcids' => self::RPC_ID_PERMISSIONS,
126 1
            GPlayApps::REQ_PARAM_LOCALE => $requestApp->getLocale(),
127 1
            GPlayApps::REQ_PARAM_COUNTRY => $requestApp->getCountry(),
128
            'soc-app' => 121,
129
            'soc-platform' => 1,
130
            'soc-device' => 1,
131
        ];
132 1
        $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams);
133
        $formParams = [
134 1
            'f.req' => '[[["' . self::RPC_ID_PERMISSIONS . '","[[null,[\"'
135 1
                . $requestApp->getId() . '\",7],[]]]",null,"1"]]]',
136
        ];
137
        $headers = [
138
            'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
139
        ];
140 1
        $body = Utils::streamFor(http_build_query($formParams));
141
142 1
        return new Request('POST', $url, $headers, $body);
143
    }
144
145
    /**
146
     * @param string $query
147
     * @param string $locale
148
     * @param string $country
149
     *
150
     * @throws \Exception
151
     *
152
     * @return RequestInterface
153
     */
154 2
    public static function getSuggestRequest(
155
        string $query,
156
        string $locale = GPlayApps::DEFAULT_LOCALE,
157
        string $country = GPlayApps::DEFAULT_COUNTRY
158
    ): RequestInterface {
159
        $queryParams = [
160
            'rpcids' => self::RPC_ID_SUGGEST,
161
            GPlayApps::REQ_PARAM_LOCALE => $locale,
162
            GPlayApps::REQ_PARAM_COUNTRY => $country,
163
            'source-path' => '/store/apps',
164
            'authuser' => null,
165
            'soc-app' => 121,
166
            'soc-platform' => 1,
167
            'soc-device' => 1,
168
        ];
169 2
        $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams);
170
        $formParams = [
171 2
            'f.req' => '[[["' . self::RPC_ID_SUGGEST . '","[[null,[\"'
172 2
                . str_replace('"', '\\\\\\"', $query)
173
                . '\"],[10],[2],4]]",null,"generic"]]]',
174
        ];
175
        $headers = [
176
            'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
177
        ];
178 2
        $body = Utils::streamFor(http_build_query($formParams));
179
180 2
        return new Request('POST', $url, $headers, $body);
181
    }
182
183
    /**
184
     * @param string $token
185
     * @param string $locale
186
     * @param string $country
187
     *
188
     * @return RequestInterface
189
     */
190 5
    public static function getClusterPagesRequest(string $token, string $locale, string $country): RequestInterface
191
    {
192
        $queryParams = [
193
            'rpcids' => self::RPC_ID_PAGE,
194
            GPlayApps::REQ_PARAM_LOCALE => $locale,
195
            GPlayApps::REQ_PARAM_COUNTRY => $country,
196
            'source-path' => '/store/apps',
197
            'authuser' => null,
198
            'soc-app' => 121,
199
            'soc-platform' => 1,
200
            'soc-device' => 1,
201
        ];
202 5
        $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams);
203
        $formParams = [
204 5
            'f.req' => '[[["' . self::RPC_ID_PAGE . '","[[null,2,null,null,[[10,[10,50],null,\"' . $token . '\"],true,null,[96,27,8,57,30,110,11,16,1,9,31,12,104,55,56,145,51,34,10],[null,null,[[[true],null,[[[]]],null,null,null,null,[null,2],null,null,null,null,null,null,[1],null,null,null,null,null,null,null,[1]],[null,[[[]]]],[null,[[[]]],null,[true]],[null,[[[]]]],null,null,null,null,[[[[]]]],[[[[]]]]],[[[[7,1],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,31],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,104],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,9],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,8],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,27],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,12],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,65],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,110],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,88],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,11],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,56],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,55],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,96],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,10],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,122],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,72],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,71],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,64],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,113],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,139],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,150],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,169],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,165],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,151],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,163],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,32],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,16],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,108],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,100],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[9,1],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,31],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,104],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,9],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,8],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,27],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,12],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,65],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,110],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,88],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,11],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,56],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,55],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,96],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,10],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,122],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,72],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,71],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,64],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,113],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,139],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,150],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,169],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,165],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,151],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,163],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,32],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,16],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,108],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,100],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[17,1],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,31],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,104],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,9],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,8],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,27],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,12],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,65],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,110],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,88],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,11],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,56],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,55],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,96],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,10],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,122],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,72],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,71],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,64],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,113],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,139],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,150],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,169],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,165],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,151],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,163],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,32],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,16],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,108],[[1,7,9,25,13,31,5,27,8,14,10]]],[[17,100],[[1,7,9,25,13,31,5,27,8,14,10]]],[[10,1],[[1,7,6,9]]],[[10,31],[[1,7,6,9]]],[[10,104],[[1,7,6,9]]],[[10,9],[[1,7,6,9]]],[[10,8],[[1,7,6,9]]],[[10,27],[[1,7,6,9]]],[[10,12],[[1,7,6,9]]],[[10,65],[[1,7,6,9]]],[[10,110],[[1,7,6,9]]],[[10,88],[[1,7,6,9]]],[[10,11],[[1,7,6,9]]],[[10,56],[[1,7,6,9]]],[[10,55],[[1,7,6,9]]],[[10,96],[[1,7,6,9]]],[[10,10],[[1,7,6,9]]],[[10,122],[[1,7,6,9]]],[[10,72],[[1,7,6,9]]],[[10,71],[[1,7,6,9]]],[[10,64],[[1,7,6,9]]],[[10,113],[[1,7,6,9]]],[[10,139],[[1,7,6,9]]],[[10,150],[[1,7,6,9]]],[[10,169],[[1,7,6,9]]],[[10,165],[[1,7,6,9]]],[[10,151],[[1,7,6,9]]],[[10,163],[[1,7,6,9]]],[[10,32],[[1,7,6,9]]],[[10,16],[[1,7,6,9]]],[[10,108],[[1,7,6,9]]],[[10,100],[[1,7,6,9]]],[[1,1],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,31],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,104],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,9],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,8],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,27],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,12],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,65],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,110],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,88],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,11],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,56],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,55],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,96],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,10],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,122],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,72],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,71],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,64],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,113],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,139],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,150],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,169],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,165],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,151],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,163],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,32],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,16],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,108],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[1,100],[[1,5,14,38,19,29,7,34,4,12,11,6,30,43,40,42,16,10]]],[[4,1],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,31],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,104],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,9],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,8],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,27],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,12],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,65],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,110],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,88],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,11],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,56],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,55],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,96],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,10],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,122],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,72],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,71],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,64],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,113],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,139],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,150],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,169],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,165],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,151],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,163],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,32],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,16],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,108],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,100],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[3,1],[[1,5,14,4,10,17]]],[[3,31],[[1,5,14,4,10,17]]],[[3,104],[[1,5,14,4,10,17]]],[[3,9],[[1,5,14,4,10,17]]],[[3,8],[[1,5,14,4,10,17]]],[[3,27],[[1,5,14,4,10,17]]],[[3,12],[[1,5,14,4,10,17]]],[[3,65],[[1,5,14,4,10,17]]],[[3,110],[[1,5,14,4,10,17]]],[[3,88],[[1,5,14,4,10,17]]],[[3,11],[[1,5,14,4,10,17]]],[[3,56],[[1,5,14,4,10,17]]],[[3,55],[[1,5,14,4,10,17]]],[[3,96],[[1,5,14,4,10,17]]],[[3,10],[[1,5,14,4,10,17]]],[[3,122],[[1,5,14,4,10,17]]],[[3,72],[[1,5,14,4,10,17]]],[[3,71],[[1,5,14,4,10,17]]],[[3,64],[[1,5,14,4,10,17]]],[[3,113],[[1,5,14,4,10,17]]],[[3,139],[[1,5,14,4,10,17]]],[[3,150],[[1,5,14,4,10,17]]],[[3,169],[[1,5,14,4,10,17]]],[[3,165],[[1,5,14,4,10,17]]],[[3,151],[[1,5,14,4,10,17]]],[[3,163],[[1,5,14,4,10,17]]],[[3,32],[[1,5,14,4,10,17]]],[[3,16],[[1,5,14,4,10,17]]],[[3,108],[[1,5,14,4,10,17]]],[[3,100],[[1,5,14,4,10,17]]],[[2,1],[[1,5,7,18,4,13,16,12]]],[[2,31],[[1,5,7,18,4,13,16,12]]],[[2,104],[[1,5,7,18,4,13,16,12]]],[[2,9],[[1,5,7,18,4,13,16,12]]],[[2,8],[[1,5,7,18,4,13,16,12]]],[[2,27],[[1,5,7,18,4,13,16,12]]],[[2,12],[[1,5,7,18,4,13,16,12]]],[[2,65],[[1,5,7,18,4,13,16,12]]],[[2,110],[[1,5,7,18,4,13,16,12]]],[[2,88],[[1,5,7,18,4,13,16,12]]],[[2,11],[[1,5,7,18,4,13,16,12]]],[[2,56],[[1,5,7,18,4,13,16,12]]],[[2,55],[[1,5,7,18,4,13,16,12]]],[[2,96],[[1,5,7,18,4,13,16,12]]],[[2,10],[[1,5,7,18,4,13,16,12]]],[[2,122],[[1,5,7,18,4,13,16,12]]],[[2,72],[[1,5,7,18,4,13,16,12]]],[[2,71],[[1,5,7,18,4,13,16,12]]],[[2,64],[[1,5,7,18,4,13,16,12]]],[[2,113],[[1,5,7,18,4,13,16,12]]],[[2,139],[[1,5,7,18,4,13,16,12]]],[[2,150],[[1,5,7,18,4,13,16,12]]],[[2,169],[[1,5,7,18,4,13,16,12]]],[[2,165],[[1,5,7,18,4,13,16,12]]],[[2,151],[[1,5,7,18,4,13,16,12]]],[[2,163],[[1,5,7,18,4,13,16,12]]],[[2,32],[[1,5,7,18,4,13,16,12]]],[[2,16],[[1,5,7,18,4,13,16,12]]],[[2,108],[[1,5,7,18,4,13,16,12]]],[[2,100],[[1,5,7,18,4,13,16,12]]]]]]],null,2],[true]]",null,"generic"]]]',
205
        ];
206
        $headers = [
207
            'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
208
        ];
209 5
        $body = Utils::streamFor(http_build_query($formParams));
210
211 5
        return new Request('POST', $url, $headers, $body);
212
    }
213
214
    /**
215
     * @param string $topSlug
216
     * @param string $categoryName
217
     * @param int    $limit
218
     * @param string $locale
219
     * @param string $country
220
     *
221
     * @return RequestInterface
222
     */
223 12
    public static function getTopCategoryApps(string $topSlug, string $categoryName, string $locale, string $country, int $limit = 1000): RequestInterface
224
    {
225
        $queryParams = [
226
            'rpcids' => self::RPC_ID_TOP,
227
            GPlayApps::REQ_PARAM_LOCALE => $locale,
228
            GPlayApps::REQ_PARAM_COUNTRY => $country,
229
            'source-path' => '/store/apps',
230
            'authuser' => null,
231
            'soc-app' => 121,
232
            'soc-platform' => 1,
233
            'soc-device' => 1,
234
        ];
235 12
        $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams);
236
        $formParams = [
237 12
            'f.req' => '[[["' . self::RPC_ID_TOP . '","[[null,[[8,[20,' . $limit . ']],true,null,[64,1,195,71,8,72,9,10,11,139,12,16,145,148,150,151,152,27,30,31,96,32,34,163,100,165,104,169,108,110,113,55,56,57,122],[null,null,[[[true],null,[[[]]],null,null,null,null,[null,2],null,null,null,null,null,null,[1],null,null,null,null,null,null,null,[1]],[null,[[[]]]],[null,[[[]]],null,[true]],[null,[[[]]]],null,null,null,null,[[[[]]]],[[[[]]]]],[[[[7,1],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,31],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,104],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,9],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,8],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,27],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,12],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,65],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,110],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,88],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,11],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,56],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,55],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,96],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,10],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,122],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,72],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,71],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,64],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,113],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,139],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,150],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,169],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,165],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,151],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,163],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,32],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,16],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,108],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[7,100],[[1,73,96,103,97,58,50,92,52,112,69,19,31,101,123,74,49,80,20,10,14,79,43,42,139]]],[[9,1],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,31],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,104],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,9],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,8],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,27],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,12],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,65],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,110],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,88],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,11],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,56],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,55],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,96],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,10],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,122],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,72],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,71],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,64],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,113],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,139],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,150],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,169],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,165],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,151],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,163],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,32],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,16],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,108],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[9,100],[[1,7,9,24,12,31,5,15,27,8,13,10]]],[[17,1],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,31],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,104],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,9],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,8],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,27],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,12],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,65],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,110],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,88],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,11],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,56],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,55],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,96],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,10],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,122],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,72],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,71],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,64],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,113],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,139],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,150],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,169],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,165],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,151],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,163],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,32],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,16],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,108],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[17,100],[[1,7,9,25,13,31,5,41,27,8,14,10]]],[[10,1],[[1,7,6,9]]],[[10,31],[[1,7,6,9]]],[[10,104],[[1,7,6,9]]],[[10,9],[[1,7,6,9]]],[[10,8],[[1,7,6,9]]],[[10,27],[[1,7,6,9]]],[[10,12],[[1,7,6,9]]],[[10,65],[[1,7,6,9]]],[[10,110],[[1,7,6,9]]],[[10,88],[[1,7,6,9]]],[[10,11],[[1,7,6,9]]],[[10,56],[[1,7,6,9]]],[[10,55],[[1,7,6,9]]],[[10,96],[[1,7,6,9]]],[[10,10],[[1,7,6,9]]],[[10,122],[[1,7,6,9]]],[[10,72],[[1,7,6,9]]],[[10,71],[[1,7,6,9]]],[[10,64],[[1,7,6,9]]],[[10,113],[[1,7,6,9]]],[[10,139],[[1,7,6,9]]],[[10,150],[[1,7,6,9]]],[[10,169],[[1,7,6,9]]],[[10,165],[[1,7,6,9]]],[[10,151],[[1,7,6,9]]],[[10,163],[[1,7,6,9]]],[[10,32],[[1,7,6,9]]],[[10,16],[[1,7,6,9]]],[[10,108],[[1,7,6,9]]],[[10,100],[[1,7,6,9]]],[[1,1],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,31],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,104],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,9],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,8],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,27],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,12],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,65],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,110],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,88],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,11],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,56],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,55],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,96],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,10],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,122],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,72],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,71],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,64],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,113],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,139],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,150],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,169],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,165],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,151],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,163],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,32],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,16],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,108],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[1,100],[[1,5,14,38,19,29,34,4,12,11,6,30,43,40,42,16,10,7]]],[[4,1],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,31],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,104],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,9],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,8],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,27],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,12],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,65],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,110],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,88],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,11],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,56],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,55],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,96],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,10],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,122],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,72],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,71],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,64],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,113],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,139],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,150],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,169],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,165],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,151],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,163],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,32],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,16],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,108],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[4,100],[[1,3,5,4,7,6,11,19,21,17,15,12,16,20]]],[[3,1],[[1,5,14,4,10,17]]],[[3,31],[[1,5,14,4,10,17]]],[[3,104],[[1,5,14,4,10,17]]],[[3,9],[[1,5,14,4,10,17]]],[[3,8],[[1,5,14,4,10,17]]],[[3,27],[[1,5,14,4,10,17]]],[[3,12],[[1,5,14,4,10,17]]],[[3,65],[[1,5,14,4,10,17]]],[[3,110],[[1,5,14,4,10,17]]],[[3,88],[[1,5,14,4,10,17]]],[[3,11],[[1,5,14,4,10,17]]],[[3,56],[[1,5,14,4,10,17]]],[[3,55],[[1,5,14,4,10,17]]],[[3,96],[[1,5,14,4,10,17]]],[[3,10],[[1,5,14,4,10,17]]],[[3,122],[[1,5,14,4,10,17]]],[[3,72],[[1,5,14,4,10,17]]],[[3,71],[[1,5,14,4,10,17]]],[[3,64],[[1,5,14,4,10,17]]],[[3,113],[[1,5,14,4,10,17]]],[[3,139],[[1,5,14,4,10,17]]],[[3,150],[[1,5,14,4,10,17]]],[[3,169],[[1,5,14,4,10,17]]],[[3,165],[[1,5,14,4,10,17]]],[[3,151],[[1,5,14,4,10,17]]],[[3,163],[[1,5,14,4,10,17]]],[[3,32],[[1,5,14,4,10,17]]],[[3,16],[[1,5,14,4,10,17]]],[[3,108],[[1,5,14,4,10,17]]],[[3,100],[[1,5,14,4,10,17]]],[[2,1],[[1,5,7,4,13,16,12,18]]],[[2,31],[[1,5,7,4,13,16,12,18]]],[[2,104],[[1,5,7,4,13,16,12,18]]],[[2,9],[[1,5,7,4,13,16,12,18]]],[[2,8],[[1,5,7,4,13,16,12,18]]],[[2,27],[[1,5,7,4,13,16,12,18]]],[[2,12],[[1,5,7,4,13,16,12,18]]],[[2,65],[[1,5,7,4,13,16,12,18]]],[[2,110],[[1,5,7,4,13,16,12,18]]],[[2,88],[[1,5,7,4,13,16,12,18]]],[[2,11],[[1,5,7,4,13,16,12,18]]],[[2,56],[[1,5,7,4,13,16,12,18]]],[[2,55],[[1,5,7,4,13,16,12,18]]],[[2,96],[[1,5,7,4,13,16,12,18]]],[[2,10],[[1,5,7,4,13,16,12,18]]],[[2,122],[[1,5,7,4,13,16,12,18]]],[[2,72],[[1,5,7,4,13,16,12,18]]],[[2,71],[[1,5,7,4,13,16,12,18]]],[[2,64],[[1,5,7,4,13,16,12,18]]],[[2,113],[[1,5,7,4,13,16,12,18]]],[[2,139],[[1,5,7,4,13,16,12,18]]],[[2,150],[[1,5,7,4,13,16,12,18]]],[[2,169],[[1,5,7,4,13,16,12,18]]],[[2,165],[[1,5,7,4,13,16,12,18]]],[[2,151],[[1,5,7,4,13,16,12,18]]],[[2,163],[[1,5,7,4,13,16,12,18]]],[[2,32],[[1,5,7,4,13,16,12,18]]],[[2,16],[[1,5,7,4,13,16,12,18]]],[[2,108],[[1,5,7,4,13,16,12,18]]],[[2,100],[[1,5,7,4,13,16,12,18]]]]]],null,null,[[[1,2],[10,8,9],[],[]]]],[2,\"' . $topSlug . '\",\"' . $categoryName . '\"]]]",null,"generic"]]]',
238
        ];
239
        $headers = [
240
            'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
241
        ];
242 12
        $body = Utils::streamFor(http_build_query($formParams));
243
244 12
        return new Request('POST', $url, $headers, $body);
245
    }
246
}
247