File Coverage

blib/lib/WWW/MetaForge/GameMapData/Request.pm
Criterion Covered Total %
statement 20 20 100.0
branch 3 4 75.0
condition 2 5 40.0
subroutine 6 6 100.0
pod 1 1 100.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package WWW::MetaForge::GameMapData::Request;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: HTTP request builder for MetaForge Game Map Data API
4             our $VERSION = '0.002';
5              
6 7     7   122898 use Moo;
  7         10057  
  7         60  
7 7     7   5406 use HTTP::Request;
  7         33705  
  7         377  
8 7     7   48 use URI;
  7         15  
  7         244  
9 7     7   601 use namespace::clean;
  7         20773  
  7         52  
10              
11              
12             has base_url => (
13             is => 'ro',
14             default => 'https://metaforge.app/api/game-map-data',
15             );
16              
17              
18             sub _build_request {
19 10     10   39 my ($self, %params) = @_;
20              
21 10         98 my $uri = URI->new($self->base_url);
22 10 50       26353 $uri->query_form(%params) if %params;
23              
24 10         1621 return HTTP::Request->new(GET => $uri);
25             }
26              
27             sub map_data {
28 10     10 1 381861 my ($self, %params) = @_;
29             # tableID is required for arc-raiders map data
30 10   50     85 $params{tableID} //= 'arc_map_data';
31             # Accept 'map' as alias for 'mapID'
32 10 100 33     107 $params{mapID} //= delete $params{map} if exists $params{map};
33 10         45 return $self->_build_request(%params);
34             }
35              
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             WWW::MetaForge::GameMapData::Request - HTTP request builder for MetaForge Game Map Data API
48              
49             =head1 VERSION
50              
51             version 0.002
52              
53             =head1 SYNOPSIS
54              
55             use WWW::MetaForge::GameMapData::Request;
56              
57             my $req = WWW::MetaForge::GameMapData::Request->new;
58              
59             # Build request for map data
60             my $http_req = $req->map_data(map => 'Dam');
61              
62             # With type filter
63             my $http_req = $req->map_data(map => 'Dam', type => 'loot');
64              
65             =head1 DESCRIPTION
66              
67             Builds L<HTTP::Request> objects for the MetaForge Game Map Data API.
68             Useful for integrating with async HTTP frameworks.
69              
70             =head2 base_url
71              
72             Base URL for the API. Defaults to C<https://metaforge.app/api/game-map-data>.
73              
74             =head2 map_data
75              
76             my $http_req = $req->map_data(map => 'Dam');
77              
78             Returns L<HTTP::Request> for fetching map marker data.
79              
80             =head1 SUPPORT
81              
82             =head2 Issues
83              
84             Please report bugs and feature requests on GitHub at
85             L<https://github.com/Getty/p5-www-metaforge/issues>.
86              
87             =head2 IRC
88              
89             You can reach Getty on C<irc.perl.org> for questions and support.
90              
91             =head1 CONTRIBUTING
92              
93             Contributions are welcome! Please fork the repository and submit a pull request.
94              
95             =head1 AUTHOR
96              
97             Torsten Raudssus <torsten@raudssus.de>
98              
99             =head1 COPYRIGHT AND LICENSE
100              
101             This software is copyright (c) 2026 by Torsten Raudssus.
102              
103             This is free software; you can redistribute it and/or modify it under
104             the same terms as the Perl 5 programming language system itself.
105              
106             =cut