File Coverage

blib/lib/Net/Twitter/Role/API/Upload.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Net::Twitter::Role::API::Upload;
2             $Net::Twitter::Role::API::Upload::VERSION = '4.01010';
3 26     26   14491 use Moose::Role;
  26         40  
  26         168  
4 26     26   89949 use Net::Twitter::API;
  26         44  
  26         143  
5 26     26   14253 use DateTime::Format::Strptime;
  26         44  
  26         837  
6 26     26   104 use URI;
  26         36  
  26         4278  
7              
8             has upload_url => isa => 'Str', is => 'ro', default => 'http://upload.twitter.com/1';
9              
10             after BUILD => sub {
11             my $self = shift;
12              
13             $self->{upload_url} =~ s/^http:/https:/ if $self->ssl;
14             };
15              
16             base_url 'upload_url';
17             authenticate 1;
18              
19             our $DATETIME_PARSER = DateTime::Format::Strptime->new(pattern => '%a %b %d %T %z %Y');
20             datetime_parser $DATETIME_PARSER;
21              
22             twitter_api_method update_with_media => (
23             path => 'statuses/update_with_media',
24             method => 'POST',
25             params => [qw/
26             status media[] possibly_sensitive in_reply_to_status_id lat long place_id display_coordinates
27             /],
28             required => [qw/status media/],
29             booleans => [qw/possibly_sensitive display_coordinates/],
30             returns => 'Status',
31             description => <<'EOT',
32             Updates the authenticating user's status and attaches media for upload.
33              
34             The C<media[]> parameter is an arrayref with the following interpretation:
35              
36             [ $file ]
37             [ $file, $filename ]
38             [ $file, $filename, Content_Type => $mime_type ]
39             [ undef, $filename, Content_Type => $mime_type, Content => $raw_image_data ]
40              
41             The first value of the array (C<$file>) is the name of a file to open. The
42             second value (C<$filename>) is the name given to Twitter for the file. If
43             C<$filename> is not provided, the basename portion of C<$file> is used. If
44             C<$mime_type> is not provided, it will be provided automatically using
45             L<LWP::MediaTypes::guess_media_type()>.
46              
47             C<$raw_image_data> can be provided, rather than opening a file, by passing
48             C<undef> as the first array value.
49              
50             The Tweet text will be rewritten to include the media URL(s), which will reduce
51             the number of characters allowed in the Tweet text. If the URL(s) cannot be
52             appended without text truncation, the tweet will be rejected and this method
53             will return an HTTP 403 error.
54             EOT
55              
56             );
57              
58             1;
59              
60             __END__
61              
62             =head1 NAME
63              
64             Net::Twitter::Role::API::Upload - A definition of the Twitter Upload API as a Moose role
65              
66             =head1 VERSION
67              
68             version 4.01010
69              
70             =head1 SYNOPSIS
71              
72             package My::Twitter;
73             use Moose;
74             with 'Net::Twitter::API::Upload';
75              
76             =head1 DESCRIPTION
77              
78             This module provides definitions the Twitter Upload API methods.
79              
80             =head1 AUTHOR
81              
82             Allen Haim <allen@netherrealm.net>
83              
84             Marc Mims <marc@questright.com>
85              
86             =head1 LICENSE
87              
88             Copyright (c) 2011 Marc Mims
89              
90             The Twitter API itself, and the description text used in this module is:
91              
92             Copyright (c) 2011 Twitter
93              
94             This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.