1######################################################################
2package Net::Amazon::Property::VideoGames;
3######################################################################
4use warnings;
5use strict;
6use base qw(Net::Amazon::Property);
7use Log::Log4perl qw(:easy get_logger);
8
9__PACKAGE__->make_accessor($_) for qw(brand ean esrb_rating label upc
10manufacturer media nummedia publisher studio);
11__PACKAGE__->make_array_accessor($_) for qw(platforms authors);
12
13
14##################################################
15sub new {
16##################################################
17    my($class, %options) = @_;
18
19    my $self = $class->SUPER::new(%options);
20    bless $self, $class; # Bless into this class
21
22    if(exists $options{xmlref}) {
23        $self->init_via_xmlref($options{xmlref});
24    }
25
26    return $self;
27}
28
29##################################################
30sub init_via_xmlref {
31##################################################
32    my($self, $xmlref) = @_;
33
34    $self->SUPER::init_via_xmlref($xmlref);
35
36    my $ref = $xmlref->{ItemAttributes};
37
38    $self->brand($ref->{Brand});
39    $self->ean($ref->{EAN});
40    $self->esrb_rating($ref->{ESRBAgeRating});
41    $self->label($ref->{Label});
42    $self->authors($ref->{Author});
43    $self->platforms($ref->{Platform});
44    $self->publisher($ref->{Publisher});
45    $self->manufacturer($ref->{Publisher});
46    $self->studio($ref->{Studio});
47    $self->upc($ref->{UPC});
48
49    $self->media($ref->{NumberOfItems});
50
51    $self->NumMedia($ref->{NumberOfItems});
52    $self->nummedia($ref->{NumberOfItems});
53
54    my $year = 0;
55    if (exists $ref->{ReleaseDate}) {
56        $year =  (split(/\-/, $ref->{ReleaseDate}))[0];
57    }
58    $self->year($year);
59}
60
61##################################################
62sub platform {
63##################################################
64    my($self, $nameref) = @_;
65
66    # Only return the first platform
67    return ($self->platforms($nameref))[0];
68}
69
70
71##################################################
72sub author {
73##################################################
74    my($self, $nameref) = @_;
75
76    # Only return the first author
77    return ($self->authors($nameref))[0];
78}
79
80##################################################
81sub as_string {
82##################################################
83    my($self) = @_;
84
85    return join('/', $self->platforms) . ", " .
86      '"' . $self->title . '"' . ", " .
87      $self->_best_effort_price() . ", " .
88      $self->ASIN;
89}
90
911;
92
93__END__
94
95=head1 NAME
96
97Net::Amazon::Property::VideoGames - Class for software on amazon.com
98
99=head1 SYNOPSIS
100
101  use Net::Amazon;
102
103  # ...
104
105  if($resp->is_success()) {
106      for my $prop ($resp->properties) {
107          print join("/", $prop->platforms()), " ",
108                $prop->title(), " ",
109                $prop->publisher(), "\n";
110  }
111
112=head1 DESCRIPTION
113
114C<Net::Amazon::Property::VideoGames> is derived from
115C<Net::Amazon::Property> and on top of the all-purpose
116methods the base class provides, it offers specialized accessors for
117software parameters.
118
119=head2 METHODS
120
121=over 4
122
123=item platforms()
124
125Returns a list of the software's platforms. There's also a C<platform()> method
126which just returns the I<first> platform.
127
128=item publisher()
129
130Returns the software's publishing company as a string.
131
132=item title()
133
134Returns the software's title as a string.
135
136=item ean()
137
138Returns the software's EAN number.
139
140=item media()
141
142Returns the video games's media type as a string.
143
144=item label()
145
146Returns the video games's label type as a string.
147
148=item studio()
149
150Returns the video games's studio type as a string.
151
152=item brand()
153
154Returns the video games's brand type as a string.
155
156=item manufacturer()
157
158Returns the video games's manufacturer type as a string.
159
160=item esrb_rating()
161
162Returns the video games's ESRB age rating type as a string.
163
164=item media()
165
166Returns the video games's media type as a string.
167
168=item nummedia()
169
170Returns the video games's number of media (number of discs) as a string.
171
172=item upc()
173
174Returns the video games's UPC as a string.
175
176
177=item new(xmlref => $xmlref)
178
179Initializes an object by passing a hash of hashes structure containing
180the XML data returned from the service. Usually, this is just used by
181C<Net::Amazon> internally to initialize objects for on backcoming
182data.
183
184=back
185
186Check out L<Net::Amazon::Property> for all-purpose accessors, like
187C<year>, C<OurPrice>, C<ListPrice>, etc.
188
189=head1 AUTHOR
190
191Christopher Boumenot, E<lt>boumenot@gmail.comE<gt>
192
193=head1 COPYRIGHT AND LICENSE
194
195Copyright 2006 by Christopher Boumenot <lt>boumenot@gmail.comE<gt>
196
197This library is free software; you can redistribute it and/or modify
198it under the same terms as Perl itself.
199
200=cut
201