Permalink
Browse files

Add set list support.

  • Loading branch information...
1 parent 1f61a19 commit d080fa240d455fb4608f11c5caa001ba540dad5c @davorg committed Aug 26, 2010
Showing with 142 additions and 0 deletions.
  1. +2 −0 MANIFEST
  2. +81 −0 lib/Net/Songkick/SetList.pm
  3. +59 −0 lib/Net/Songkick/SetListItem.pm
View
@@ -6,6 +6,8 @@ lib/Net/Songkick/Event.pm
lib/Net/Songkick/Location.pm
lib/Net/Songkick/MetroArea.pm
lib/Net/Songkick/Performance.pm
+lib/Net/Songkick/SetList.pm
+lib/Net/Songkick/SetListItem.pm
lib/Net/Songkick/Venue.pm
MANIFEST This list of files
README
@@ -0,0 +1,81 @@
+=head1 NAME
+
+Net::Songkick::SetList - Models a set list in the Songkick API
+
+=cut
+
+package Net::Songkick::SetList;
+
+use strict;
+use warnings;
+
+use Moose;
+
+use Net::Songkick::Artist;
+use Net::Songkick::SetListItem;
+
+has $_ => (
+ is => 'ro',
+ isa => 'Str',
+) for qw[displayName id];
+
+has artist => (
+ is => 'ro',
+ isa => 'Net::Songkick::Artist',
+);
+
+has setlist_items => (
+ is => 'ro',
+ isa => 'ArrayRef[Net::Songkick::SetListItem]',
+);
+
+=head1 METHODS
+
+=head2 Net::Songkick::SetList->new_from_xml
+
+Creates a new Net::Songkick::SetList object from an XML::Element object that
+has been created from a <setlist> ... </setlist> element in the XML returned
+from a Songkick API request.
+
+=cut
+
+sub new_from_xml {
+ my $class = shift;
+ my ($xml) = @_;
+
+ my $self = {};
+
+ foreach (qw[displayName id]) {
+ $self->{$_} = $xml->findvalue("\@$_");
+ }
+
+ $self->{artist} = Net::Songkick::Artist->new_from_xml(
+ ($xml->findnodes('artist'))[0]
+);
+
+ foreach ($xml->findnodes('setlistItem')) {
+ push @{$self->{setlist_items}},
+ Net::Songkick::SetListItem->new_from_xml($_);
+ }
+
+ return $class->new($self);
+}
+
+=head1 AUTHOR
+
+Dave Cross <dave@mag-sol.com>
+
+=head1 SEE ALSO
+
+perl(1), L<http://www.songkick.com/>, L<http://developer.songkick.com/>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2010, Magnum Solutions Ltd. All Rights Reserved.
+
+This script is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
@@ -0,0 +1,59 @@
+=head1 NAME
+
+Net::Songkick::SetListItem - Models a location in the Songkick API
+
+=cut
+
+package Net::Songkick::SetListItem;
+
+use strict;
+use warnings;
+
+use Moose;
+
+has $_ => (
+ is => 'ro',
+ isa => 'Str',
+) foreach qw[name encore];
+
+=head1 METHODS
+
+=head2 Net::Songkick::SetListItem->new_from_xml
+
+Creates a new Net::Songkick::SetListItem object from an XML::Element object
+that has been created from a <setlistItem> ... </setlistItem> element in the
+XML returned from a Songkick API request.
+
+=cut
+
+sub new_from_xml {
+ my $class = shift;
+ my ($xml) = @_;
+
+ my $self = {};
+
+ foreach (qw[name encore]) {
+ $self->{$_} = $xml->findvalue("\@$_");
+ }
+
+ return $class->new($self);
+}
+
+=head1 AUTHOR
+
+Dave Cross <dave@mag-sol.com>
+
+=head1 SEE ALSO
+
+perl(1), L<http://www.songkick.com/>, L<http://developer.songkick.com/>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2010, Magnum Solutions Ltd. All Rights Reserved.
+
+This script is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;

0 comments on commit d080fa2

Please sign in to comment.