1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Seaony\ValorantApi\Endpoints; |
4
|
|
|
|
5
|
|
|
trait PVPEndpoints |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Get a list of seasons, acts, and events |
9
|
|
|
* |
10
|
|
|
* @param string $shard |
11
|
|
|
* |
12
|
|
|
* @return mixed |
13
|
|
|
*/ |
14
|
|
|
public function fetchContent(string $shard) |
15
|
|
|
{ |
16
|
|
|
return $this->request('GET', "https://shared.{$shard}.a.pvp.net/content-service/v3/content"); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get the account level, XP, and XP history for the given player |
21
|
|
|
* |
22
|
|
|
* @param string $shard |
23
|
|
|
* @param string $puuid |
24
|
|
|
* |
25
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
26
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
27
|
|
|
*/ |
28
|
|
|
public function accountXP(string $shard, string $puuid) |
29
|
|
|
{ |
30
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/account-xp/v1/players/{$puuid}"); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get the player's current loadout. Only works for your own PUUID. |
35
|
|
|
* |
36
|
|
|
* @param string $shard |
37
|
|
|
* @param string $puuid |
38
|
|
|
* |
39
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
40
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
41
|
|
|
*/ |
42
|
|
|
public function playerLoadout(string $shard, string $puuid) |
43
|
|
|
{ |
44
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/personalization/v2/players/{$puuid}/playerloadout"); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Set the player's current loadout. |
49
|
|
|
* |
50
|
|
|
* @param string $shard |
51
|
|
|
* @param string $puuid |
52
|
|
|
* @param array $params |
53
|
|
|
* |
54
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
55
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
56
|
|
|
*/ |
57
|
|
|
public function setPlayerLoadout(string $shard, string $puuid, array $params) |
58
|
|
|
{ |
59
|
|
|
return $this->request('PUT', "https://pd.{$shard}.a.pvp.net/personalization/v2/players/{$puuid}/playerloadout", ['json' => $params]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get a player's MMR and history |
64
|
|
|
* |
65
|
|
|
* @param string $shard |
66
|
|
|
* @param string $puuid |
67
|
|
|
* |
68
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
69
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
70
|
|
|
*/ |
71
|
|
|
public function playerMMR(string $shard, string $puuid) |
72
|
|
|
{ |
73
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/mmr/v1/players/{$puuid}"); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the match history for the given player |
78
|
|
|
* |
79
|
|
|
* @param string $shard |
80
|
|
|
* @param string $puuid |
81
|
|
|
* @param int $startIndex |
82
|
|
|
* @param int $endIndex |
83
|
|
|
* @param string $queue |
84
|
|
|
* |
85
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
86
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
87
|
|
|
*/ |
88
|
|
|
public function matchHistory(string $shard, string $puuid, int $startIndex = 0, int $endIndex = 20, string $queue = '') |
89
|
|
|
{ |
90
|
|
|
$query = array_filter([ |
91
|
|
|
'startIndex' => $startIndex, |
92
|
|
|
'endIndex' => $endIndex, |
93
|
|
|
'queue' => $queue, |
94
|
|
|
]); |
95
|
|
|
|
96
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/match-history/v1/history/{$puuid}", ['query' => $query]); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Get the details of a match after it ends |
101
|
|
|
* |
102
|
|
|
* @param string $shard |
103
|
|
|
* @param string $matchID |
104
|
|
|
* |
105
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
106
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
107
|
|
|
*/ |
108
|
|
|
public function matchDetails(string $shard, string $matchID) |
109
|
|
|
{ |
110
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/match-details/v1/matches/{$matchID}"); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get recent games and how they changed ranking |
115
|
|
|
* |
116
|
|
|
* @param string $shard |
117
|
|
|
* @param string $puuid |
118
|
|
|
* @param int $startIndex |
119
|
|
|
* @param int $endIndex |
120
|
|
|
* @param string $queue |
121
|
|
|
* |
122
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
123
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
124
|
|
|
*/ |
125
|
|
|
public function competitiveUpdates(string $shard, string $puuid, int $startIndex = 0, int $endIndex = 20, string $queue = '') |
126
|
|
|
{ |
127
|
|
|
$query = array_filter([ |
128
|
|
|
'startIndex' => $startIndex, |
129
|
|
|
'endIndex' => $endIndex, |
130
|
|
|
'queue' => $queue, |
131
|
|
|
]); |
132
|
|
|
|
133
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/mmr/v1/players/{$puuid}/competitiveupdates", ['query' => $query]); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Get the leaderboard for a given season |
138
|
|
|
* |
139
|
|
|
* @param string $shard |
140
|
|
|
* @param string $seasonId |
141
|
|
|
* @param int $startIndex |
142
|
|
|
* @param int $size |
143
|
|
|
* @param string $query |
144
|
|
|
* |
145
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
146
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
147
|
|
|
*/ |
148
|
|
|
public function leaderboard(string $shard, string $seasonId, int $startIndex = 0, int $size = 510, string $query = '') |
149
|
|
|
{ |
150
|
|
|
$params = array_filter([ |
151
|
|
|
'startIndex' => $startIndex, |
152
|
|
|
'size' => $size, |
153
|
|
|
'query' => $query, |
154
|
|
|
]); |
155
|
|
|
|
156
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/mmr/v1/leaderboards/affinity/${shard}/queue/competitive/season/{$seasonId}", ['query' => $params]); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Get the matchmaking penalties for the given player |
161
|
|
|
* |
162
|
|
|
* @param string $shard |
163
|
|
|
* |
164
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
165
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
166
|
|
|
*/ |
167
|
|
|
public function penalties(string $shard) |
168
|
|
|
{ |
169
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/restrictions/v3/penalties"); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Get the config for the given player |
174
|
|
|
* |
175
|
|
|
* @param string $shard |
176
|
|
|
* @param string $region |
177
|
|
|
* |
178
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
179
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
180
|
|
|
*/ |
181
|
|
|
public function config(string $shard, string $region) |
182
|
|
|
{ |
183
|
|
|
return $this->request('GET', "https://pd.{$shard}.a.pvp.net/v1/config/{$region}"); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $shard |
188
|
|
|
* @param array $nameServiceBody |
189
|
|
|
* |
190
|
|
|
* @return mixed|\Psr\Http\Message\ResponseInterface |
191
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
192
|
|
|
*/ |
193
|
|
|
public function nameService(string $shard, array $nameServiceBody = []) |
194
|
|
|
{ |
195
|
|
|
return $this->request('PUT', "https://pd.{$shard}.a.pvp.net/name-service/v2/players", ['json' => $nameServiceBody]); |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|