aboutsummaryrefslogtreecommitdiffstats
path: root/lib/WWW/StrawViewer/Activities.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WWW/StrawViewer/Activities.pm')
-rw-r--r--lib/WWW/StrawViewer/Activities.pm93
1 files changed, 93 insertions, 0 deletions
diff --git a/lib/WWW/StrawViewer/Activities.pm b/lib/WWW/StrawViewer/Activities.pm
new file mode 100644
index 0000000..39a6a3d
--- /dev/null
+++ b/lib/WWW/StrawViewer/Activities.pm
@@ -0,0 +1,93 @@
+package WWW::StrawViewer::Activities;
+
+use utf8;
+use 5.014;
+use warnings;
+
+=head1 NAME
+
+WWW::StrawViewer::Activities - list of channel activity events that match the request criteria.
+
+=head1 SYNOPSIS
+
+ use WWW::StrawViewer;
+ my $obj = WWW::StrawViewer->new(%opts);
+ my $activities = $obj->activities($channel_id);
+
+=head1 SUBROUTINES/METHODS
+
+=cut
+
+sub _make_activities_url {
+ my ($self, %opts) = @_;
+ $self->_make_feed_url('activities', part => 'snippet,contentDetails', %opts);
+}
+
+=head2 activities($channel_id)
+
+Get activities for channel ID.
+
+=cut
+
+sub activities {
+ my ($self, $channel_id) = @_;
+
+ if ($channel_id eq 'mine') {
+ return $self->my_activities;
+ }
+
+ if ($channel_id !~ /^UC/) {
+ $channel_id = $self->channel_id_from_username($channel_id) // $channel_id;
+ }
+
+ $self->_get_results($self->_make_activities_url(channelId => $channel_id));
+}
+
+=head2 activities_from_username($username)
+
+Get activities for username.
+
+=cut
+
+sub activities_from_username {
+ my ($self, $username) = @_;
+ return $self->activities($username);
+}
+
+=head2 my_activities()
+
+Get authenticated user's activities.
+
+=cut
+
+sub my_activities {
+ my ($self) = @_;
+ $self->get_access_token() // return;
+ $self->_get_results($self->_make_activities_url(mine => 'true'));
+}
+
+=head1 AUTHOR
+
+Trizen, C<< <echo dHJpemVuQHByb3Rvbm1haWwuY29tCg== | base64 -d> >>
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc WWW::StrawViewer::Activities
+
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright 2013-2015 Trizen.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See L<http://dev.perl.org/licenses/> for more information.
+
+=cut
+
+1; # End of WWW::StrawViewer::Activities