File Coverage

blib/lib/WG/API/WoWs.pm
Criterion Covered Total %
statement 6 35 17.1
branch n/a
condition n/a
subroutine 2 30 6.6
pod 27 27 100.0
total 35 92 38.0


line stmt bran cond sub pod time code
1             package WG::API::WoWs;
2              
3 2     2   451 use Const::Fast;
  2         1031  
  2         12  
4              
5 2     2   134 use Moo;
  2         4  
  2         11  
6              
7             with 'WG::API::Base';
8              
9             =head1 NAME
10              
11             WG::API::WoWs - Module for work with Wargaming.net Public API for Worlf of Warships
12              
13             =head1 VERSION
14              
15             Version v0.13
16              
17             =cut
18              
19             our $VERSION = 'v0.13';
20              
21             const my $api_uri => '//api.worldofwarships.ru/';
22              
23             sub _api_uri {
24 0     0     my ($self) = @_;
25              
26 0           return $api_uri;
27             }
28              
29             =head1 SYNOPSIS
30              
31             Wargaming.net Public API is a set of API methods that provide access to Wargaming.net content, including in-game and game-related content, as well as player statistics.
32              
33             This module provide access to WG Public API
34              
35             use WG::API;
36              
37             my $wows = WG::API->new( application_id => 'demo' )->wows();
38             ...
39             my $player = $wows->account_info( account_id => '1' );
40              
41             =head1 CONSTRUCTOR
42              
43             =head2 new
44              
45             Create new object with params. Rerquired application id: L<https://developers.wargaming.net/documentation/guide/getting-started/>
46              
47             Params:
48              
49             - application_id *
50             - languare
51             - api_uri
52              
53             =head1 METHODS
54              
55             =head2 Account
56              
57             =over 1
58              
59             =item B<account_list( [ %params ] )>
60              
61             Method returns partial list of players. The list is filtered by initial characters of user name and sorted alphabetically.
62              
63             =over 2
64              
65             =item I<required fields:>
66              
67             search - Player name search string. Parameter "type" defines minimum length and type of search. Using the exact search type, you can enter several names, separated with commas. Maximum length: 24.
68              
69             =back
70              
71             =cut
72              
73             sub account_list {
74             return shift->_request(
75 0     0 1   'get', 'wows/account/list/', [ 'language', 'fields', 'type', 'search', 'limit' ], ['search'],
76             @_
77             );
78             }
79              
80             =item B<account_info( [ %params ] )>
81              
82             Method returns player details. Players may hide their game profiles, use field hidden_profile for determination.
83              
84             =over 2
85              
86             =item I<required fields:>
87              
88             account_id - Account ID. Max limit is 100. Min value is 1.
89              
90             =back
91              
92             =cut
93              
94             sub account_info {
95             return shift->_request(
96 0     0 1   'get', 'wows/account/info/', [ 'language', 'fields', 'access_token', 'extra', 'account_id' ],
97             ['account_id'], @_
98             );
99             }
100              
101             =item B<account_achievements( [ %params ] )>
102              
103             Method returns information about players' achievements. Accounts with hidden game profiles are excluded from response. Hidden profiles are listed in the field meta.hidden.
104              
105             =cut
106              
107             sub account_achievements {
108 0     0 1   return shift->_request( 'get', 'wows/account/achievements/', [ 'language', 'fields', 'account_id', 'access_token' ], ['account_id'], @_ );
109             }
110              
111             =item B<account_statsbydate( [ %params ] )>
112              
113             Method returns statistics slices by dates in specified time span.
114              
115             =over 2
116              
117             =item I<required fields:>
118              
119             account_id - Account ID. Max limit is 100. Min value is 1.
120              
121             =back
122              
123             =back
124              
125             =cut
126              
127             sub account_statsbydate {
128             return shift->_request(
129 0     0 1   'get', 'wows/account/statsbydate/', [ 'language', 'fields', 'dates', 'access_token', 'extra', 'account_id' ],
130             ['account_id'], @_
131             );
132             }
133              
134             =head2 Encyclopedia
135              
136             =over 1
137              
138             =item B<encyclopedia_info( [ %params ] )>
139              
140             Method returns information about encyclopedia.
141              
142             =cut
143              
144             sub encyclopedia_info {
145 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/info/', [ 'fields', 'language' ], undef, @_ );
146             }
147              
148             =item B<encyclopedia_ships( [ %params ] )>
149              
150             Method returns list of ships available.
151              
152             =cut
153              
154             sub encyclopedia_ships {
155 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/ships/', [ 'fields', 'language', 'limit', 'nation', 'page_no', 'ship_id', 'type' ], undef, @_ );
156             }
157              
158             =item B<encyclopedia_achievements( [ %params ] )>
159              
160             Method returns information about achievements.
161              
162             =cut
163              
164             sub encyclopedia_achievements {
165 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/achievements/', [ 'fields', 'language' ], undef, @_ );
166             }
167              
168             =item B<encyclopedia_shipprofile( [ %params ] )>
169              
170             Method returns parameters of ships in all existing configurations.
171              
172             =over 2
173              
174             =item I<required fields>
175              
176             ship_id - ship id
177              
178             =back
179              
180             =cut
181              
182             sub encyclopedia_shipprofile {
183             return shift->_request(
184 0     0 1   'get', 'wows/encyclopedia/shipprofile/',
185             [
186             'ship_id', 'artillery_id', 'dive_bomber_id', 'engine_id',
187             'fields', 'fighter_id', 'fire_control_id', 'flight_control_id',
188             'hull_id', 'language', 'torpedo_bomber_id', 'torpedoes_id'
189             ],
190             ['ship_id'],
191             @_
192             );
193             }
194              
195             =item B<encyclopedia_modules( [ %params ] )>
196              
197             Method returns list of available modules that can be mounted on a ship (hull, engines, etc.).
198              
199             =cut
200              
201             sub encyclopedia_modules {
202 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/modules/', [ 'fields', 'language', 'limit', 'module_id', 'page_no', 'type' ], undef, @_ );
203             }
204              
205             =item B<encyclopedia_accountlevels( [ %params ] )>
206              
207             Method returns information about Service Record levels.
208              
209             =cut
210              
211             sub encyclopedia_accountlevels {
212 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/accountlevels/', ['fields'], undef, @_ );
213             }
214              
215             =item B<encyclopedia_crews( [ %params ] )>
216              
217             Method returns information about Commanders.
218              
219             =cut
220              
221             sub encyclopedia_crews {
222 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/crews/', [ 'commander_id', 'fields', 'language' ], undef, @_ );
223             }
224              
225             =item B<encyclopedia_crewskills( [ %params ] )>
226              
227             Method returns information about Commangers' skills.
228              
229             =cut
230              
231             sub encyclopedia_crewskills {
232 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/crewskills/', [ 'fields', 'language', 'skill_id' ], undef, @_ );
233             }
234              
235             =item B<encyclopedia_crewranks( [ %params ] )>
236              
237             Method returns information about Commanders' skills.
238              
239             =cut
240              
241             sub encyclopedia_crewranks {
242 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/crewranks/', [ 'fields', 'language', 'nation' ], undef, @_ );
243             }
244              
245             =item B<encyclopedia_battletypes( [ %params ] )>
246              
247             Method returns information about battle types.
248              
249             =cut
250              
251             sub encyclopedia_battletypes {
252 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/battletypes/', [ 'fields', 'language' ], undef, @_ );
253             }
254              
255             =item B<encyclopedia_consumables( [ %params ] )>
256              
257             Method returns information about consumables: camouflages, flags, and upgrades.
258              
259             =cut
260              
261             sub encyclopedia_consumables {
262 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/consumables/', [ 'consumable_id', 'fields', 'language', 'limit', 'page_no', 'type' ], undef, @_ );
263             }
264              
265             =item B<encyclopedia_collections( [ %params ] )>
266              
267             Method returns information about collections.
268              
269             =cut
270              
271             sub encyclopedia_collections {
272 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/collections/', [ 'fields', 'language' ], undef, @_ );
273             }
274              
275             =item B<encyclopedia_collectioncards( [ %params ] )>
276              
277             Method returns information about items that are included in the collection.
278              
279             =cut
280              
281             sub encyclopedia_collectioncards {
282 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/collectioncards/', [ 'fields', 'language' ], undef, @_ );
283             }
284              
285             =item B<encyclopedia_battlearenas( [ %params ] )>
286              
287             Method returns the information about maps.
288              
289             =cut
290              
291             sub encyclopedia_battlearenas {
292 0     0 1   return shift->_request( 'get', 'wows/encyclopedia/battlearenas/', [ 'fields', 'language' ], undef, @_ );
293             }
294              
295             =back
296              
297             =head2 Warships
298              
299             =over 1
300              
301             =item B<ships_stats( [ %params ] )>
302              
303             Method returns general statistics for each ship of a player. Accounts with hidden game profiles are excluded from response. Hidden profiles are listed in the field meta.hidden.
304              
305             =over 2
306              
307             =item I<required fields:>
308              
309             account_id - Account ID. Max limit is 100. Min value is 1.
310              
311             =back
312              
313             =back
314              
315             =cut
316              
317             sub ships_stats {
318             return shift->_request(
319 0     0 1   'get', 'wows/ships/stats/',
320             [ 'language', 'fields', 'access_token', 'extra', 'account_id', 'ship_id', 'in_garage' ],
321             ['account_id'], @_
322             );
323             }
324              
325             =head2 Seasons
326              
327             =over 1
328              
329             =item B<seasons_info( [ %params ] )>
330              
331             =cut
332              
333             sub seasons_info {
334 0     0 1   return shift->_request( 'get', 'wows/seasons/info/', [ 'fields', 'language', 'season_id' ], [], @_ );
335             }
336              
337             =item B<seasons_shipstats( [ %params ] )>
338              
339             Method returns players' ships statistics in Ranked Battles seasons. Accounts with hidden game profiles are excluded from response. Hidden profiles are listed in the field meta.hidden.
340              
341             =over 2
342              
343             =item I<required_fields:>
344              
345             account_id - Account ID. Max limit is 100. Min value is 1.
346              
347             =back
348              
349             =cut
350              
351             sub seasons_shipstats {
352 0     0 1   return shift->_request( 'get', 'wows/seasons/shipstats/', [ 'account_id', 'access_token', 'fields', 'language', 'season_id', 'ship_id' ], ['account_id'], @_ );
353             }
354              
355             =item B<seasons_accountinfo( [ %params ] )>
356              
357             Method returns players' statistics in Ranked Battles seasons. Accounts with hidden game profiles are excluded from response. Hidden profiles are listed in the field meta.hidden.
358              
359             =over 2
360              
361             =item I<required_fields:>
362              
363             account_id - Account ID. Max limit is 100. Min value is 1.
364              
365             =back
366              
367             =back
368              
369             =cut
370              
371             sub seasons_accountinfo {
372 0     0 1   return shift->_request( 'get', 'wows/seasons/accountinfo/', [ 'account_id', 'access_token', 'fields', 'language', 'season_id' ], ['account_id'], @_ );
373             }
374              
375             =head2 Clans
376              
377             =over 1
378              
379             =item B<clans( [ %params ] )>
380              
381             Method searches through clans and sorts them in a specified order
382              
383             =cut
384              
385             sub clans {
386 0     0 1   return shift->_request( 'get', 'wows/clans/list/', [ 'fields', 'language', 'limit', 'page_no', 'search' ], [], @_ );
387             }
388              
389             =item B<clans_details( [ %params ] )>
390              
391             Method returns detailed clan information
392              
393             =over 2
394              
395             =item I<required_fields:>
396              
397             clan_id - Clan ID. Max limit is 100.
398              
399             =back
400              
401             =cut
402              
403             sub clans_details {
404 0     0 1   return shift->_request( 'get', 'wows/clans/info/', [ 'clan_id', 'extra', 'fields', 'language' ], ['clan_id'], @_ );
405             }
406              
407             =item B<clans_accountinfo( [ $params ] )>
408              
409             Method returns player clan data. Player clan data exist only for accounts, that were participating in clan activities: sent join requests, were clan members etc.
410              
411             =over 2
412              
413             =item I<required_fields:>
414              
415             account_id - Account ID. Max limit is 100. Min value is 1.
416              
417             =back
418              
419             =cut
420              
421             sub clans_accountinfo {
422 0     0 1   return shift->_request( 'get', 'wows/clans/accountinfo/', [ 'account_id', 'extra', 'fields', 'language' ], ['account_id'], @_ );
423             }
424              
425             =item B<clans_glossary( [ %params ] )>
426              
427             Method returns information on clan entities.
428              
429             =cut
430              
431             sub clans_glossary {
432 0     0 1   return shift->_request( 'get', 'wows/clans/glossary/', [ 'fields', 'language' ], [], @_ );
433             }
434              
435             =item B<clans_season( [ %params ] )>
436              
437             Method returns information about Clan Battles season.
438              
439             =back
440              
441             =cut
442              
443             sub clans_season {
444 0     0 1   return shift->_request( 'get', 'wows/clans/season/', [ 'fields', 'language' ], [], @_ );
445             }
446              
447             =head1 BUGS
448              
449             Please report any bugs or feature requests to C<cynovg at cpan.org>, or through the web interface at L<https://gitlab.com/cynovg/WG-API/issues>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
450              
451             =head1 SUPPORT
452              
453             You can find documentation for this module with the perldoc command.
454              
455             perldoc WG::API
456              
457             You can also look for information at:
458              
459             =over 4
460              
461             =item * RT: Gitlab's request tracker (report bugs here)
462              
463             L<https://gitlab.com/cynovg/WG-API/issues>
464              
465             =item * AnnoCPAN: Annotated CPAN documentation
466              
467             L<http://annocpan.org/dist/WG-API>
468              
469             =item * CPAN Ratings
470              
471             L<http://cpanratings.perl.org/d/WG-API>
472              
473             =item * Search CPAN
474              
475             L<https://metacpan.org/pod/WG::API>
476              
477             =back
478              
479              
480             =head1 ACKNOWLEDGEMENTS
481              
482             ...
483              
484             =head1 SEE ALSO
485              
486             WG API Reference L<https://developers.wargaming.net/>
487              
488             =head1 AUTHOR
489              
490             Cyrill Novgorodcev , C<< <cynovg at cpan.org> >>
491              
492             =head1 LICENSE AND COPYRIGHT
493              
494             Copyright 2015 Cyrill Novgorodcev.
495              
496             This program is free software; you can redistribute it and/or modify it
497             under the terms of the the Artistic License (2.0). You may obtain a
498             copy of the full license at:
499              
500             L<http://www.perlfoundation.org/artistic_license_2_0>
501              
502             Any use, modification, and distribution of the Standard or Modified
503             Versions is governed by this Artistic License. By using, modifying or
504             distributing the Package, you accept this license. Do not use, modify,
505             or distribute the Package, if you do not accept this license.
506              
507             If your Modified Version has been derived from a Modified Version made
508             by someone other than you, you are nevertheless required to ensure that
509             your Modified Version complies with the requirements of this license.
510              
511             This license does not grant you the right to use any trademark, service
512             mark, tradename, or logo of the Copyright Holder.
513              
514             This license includes the non-exclusive, worldwide, free-of-charge
515             patent license to make, have made, use, offer to sell, sell, import and
516             otherwise transfer the Package with respect to any patent claims
517             licensable by the Copyright Holder that are necessarily infringed by the
518             Package. If you institute patent litigation (including a cross-claim or
519             counterclaim) against any party alleging that the Package constitutes
520             direct or contributory patent infringement, then this Artistic License
521             to you shall terminate on the date that such litigation is filed.
522              
523             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
524             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
525             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
526             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
527             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
528             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
529             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
530             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
531              
532              
533             =cut
534              
535             1; # End of WG::API::WoWs
536