File Coverage

blib/lib/WebService/EveOnline.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package WebService::EveOnline;
2              
3 10     10   370547 use strict;
  10         33  
  10         422  
4 10     10   62 use warnings;
  10         20  
  10         516  
5              
6 10     10   62 use base qw/ WebService::EveOnline::Base /;
  10         154  
  10         16303  
7              
8             our $VERSION = "0.62";
9             our $AGENT = 'WebService::EveOnline';
10             our $EVE_API = "http://api.eve-online.com/";
11             our $DEBUG_MODE = $ENV{EVE_DEBUG_ON} || undef;
12              
13             =head1 NAME
14              
15             WebService::EveOnline -- a wrapper intended to (eventually) provide a
16             useful interface to the MMORPG game, "Eve Online"
17              
18             (N.B. Export EVE_USER_ID and EVE_API_KEY to your environment before installing
19             to run all tests.)
20              
21             Please have a look at the example scripts:
22              
23             * examples/show_characters
24             * examples/show_corporation
25             * examples/show_transactions
26             * examples/skills_overview
27              
28             They will get you started a lot quicker than the documentation (patches welcome!) ever will,
29             which is mostly reference.
30              
31             =head1 VERSION
32              
33             0.61 - This is an incomplete implementation of the Eve Online API, but is a starting point.
34              
35             =head1 SYNOPSIS
36              
37             use WebService::EveOnline;
38            
39             my $eve = WebService::EveOnline->new({
40             user_id => ,
41             api_key => ''
42             });
43            
44             my $character = $eve->character('');
45            
46             print $character->name . " has " .
47             $character->balance . " ISK in the pot\n";
48              
49             foreach $char ($eve->characters) {
50             print $char->name . " has " . scalar($character->skills) .
51             " skills.";
52             }
53              
54             See example scripts for more ways of using the interface.
55              
56             =head1 DESCRIPTION
57              
58             L (essentially) presents a nice programatic sugar over the
59             top of the pretty cronky API that CCP games provide. The idea is that an
60             interested party (e.g. me) can keep track of what's going on with my characters
61             in a similar manner to what EveMON does.
62              
63             There is currently no item data provided with this interface (although the API
64             exposes no item data anyway, it'd be nice to have at some point).
65              
66             Also, no map or wallet information is supported although this will be added as
67             a priority over the coming weeks.
68              
69             =cut
70              
71             =head2 Initialising
72              
73             WebService::EveOnline is instantiated with a 'standard' (so much as these
74             things are) call to "new". Usually, at this point you would pass down a
75             hashref that contained the keys "user_id" and "api_key" as demonstrated in the
76             synopsis.
77              
78             You MUST specify your user_id and api_key parameters in order to get the API to
79             work, even if you're only interested in returning data where they are not
80             normally required by the API.
81              
82             You may also specify the following parameters:
83              
84             cache_type: Defaults to 'SQLite'. For now, please keep the default.
85             cache_dbname: Database to use to store cached skill data.
86             cache_user: Username of the database to use. Do not use yet.
87             cache_pass: Password of the database to use. Do not use yet.
88             cache_init: Set this to 'no' to disable caching. Not recommended.
89             cache_maxage: Maximum time (in seconds) to wait before a cache rebuild.
90              
91             Currently, only SQLite databases are supported. Using another database should
92             be fairly straightforward to add in, but isn't available yet.
93              
94             You can specify ":memory" as the cache_dbname to build the cache in memory if
95             required.
96              
97             =head1 API
98              
99             API reference as follows:
100              
101             =cut
102              
103             =head2 new
104            
105             Set up the initial object by calling the new method on it. It is important to
106             pass a valid user id and api key (available from http://api.eve-online.com/)
107             or this module will not do anything useful. That is does anything useful at
108             all is debatable, but it does let me print out my favourite character's account
109             balance, so that's pretty much all I want/need it to do at the moment... :-)
110              
111             my $eve = WebService::EveOnline->new({
112             user_id => ,
113             api_key => ''
114             });
115              
116             =cut
117              
118             =head2 SEE ALSO
119              
120             Please look at the individual WebService::EveOnline::API::* modules for
121             documentation on how to extract other data from the API.
122              
123             L
124             L
125             L
126             L
127             L
128              
129             =cut
130              
131             =head2 "ONE-LINERS"
132              
133             By setting the environment variables EVE_USER_ID and EVE_API_KEY, it is possible
134             to write short(ish) 'one-liners' returning data from your account like this:
135              
136             perl -MWebService::EveOnline \
137             -e'print WebService::EveOnline->new->character('name')->account_balance'
138            
139             perl -MWebService::EveOnline \
140             -e'print map{$_->character_name."\n"}WebService::EveOnline->new->characters'
141              
142             =cut
143              
144             sub new {
145             my ($class, $params) = @_;
146              
147             # this is surprisingly handy, as it allows for one-liners assuming
148             # the environment variables are appropriately set:
149             $params->{user_id} ||= $ENV{EVE_USER_ID};
150             $params->{api_key} ||= $ENV{EVE_API_KEY};
151              
152             unless (ref($params) eq "HASH" && $params->{user_id} && $params->{api_key}) {
153             die("Cannot instantiate without a user_id/api_key!\nPlease visit $EVE_API if you still need to get one.");
154             }
155              
156             return bless(WebService::EveOnline::Base->new($params), $class);
157             }
158              
159              
160             =head1 BUGS
161              
162             If you don't happen to have my specific user_id and api_key, you milage may
163             *seriously* vary. I've not been playing Eve Online all that long, and there
164             are probably dozens of edge cases I need to look at and resolve.
165              
166             Contributions/patches/suggestions are all gratefully received.
167              
168             A public subversion repository is available at:
169              
170             http://theantipop.org/eve
171              
172             Please report any bugs or feature requests to C, or through
173             the web interface at L. I will be notified, and then you'll
174             automatically be notified of progress on your bug as I make changes.
175              
176             =head1 MOTIVATION
177              
178             Frankly, whilst the Eve Online API is better than nothing, it's pretty horrible
179             to work with. I wanted to concentrate on my code rather than parsing results, so
180             I decided to hide the gory details away in a nice module I didn't have to look at
181             much. Having said that, by no means is this code considered anything other than a
182             quick and dirty hack that does precisely the job I want it to do (and no more).
183              
184             =head1 AUTHOR
185              
186             Chris Carline, C<< >>
187              
188             =head1 COPYRIGHT & LICENSE
189              
190             Copyright 2007-2008 Chris Carline, all rights reserved.
191              
192             This program is free software; you can redistribute it and/or modify it
193             under the same terms as Perl itself.
194              
195             =cut
196              
197             sub _debug {
198             my ($class, $params) = @_;
199              
200             $params ||= {};
201             $params->{_debug} = 1;
202             $WebService::EveOnline::DEBUG_MODE = 1;
203             warn "Switching on debugging statements:\n";
204            
205             return new($class, $params);
206             }
207              
208             1;