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