File Coverage

blib/lib/Net/Twitter/Role/API/RESTv1_1.pm
Criterion Covered Total %
statement 21 23 91.3
branch 2 2 100.0
condition n/a
subroutine 6 7 85.7
pod n/a
total 29 32 90.6


line stmt bran cond sub pod time code
1             package Net::Twitter::Role::API::RESTv1_1;
2             $Net::Twitter::Role::API::RESTv1_1::VERSION = '4.01043';
3 7     7   6820 use Moose::Role;
  7         20798  
  7         27  
4 7     7   30686 use Carp::Clan qw/^(?:Net::Twitter|Moose|Class::MOP)/;
  7         14  
  7         45  
5 7     7   3674 use Net::Twitter::API;
  7         19  
  7         37  
6 7     7   5643 use DateTime::Format::Strptime;
  7         14  
  7         29  
7 7     7   341 use URI;
  7         14  
  7         33679  
8              
9             with 'Net::Twitter::Role::API::UploadMedia';
10              
11             # API v1.1 incorporates the Search and Upload APIs
12             excludes map "Net::Twitter::Role::$_", qw/API::Search API::Upload Net::Twitter::Role::RateLimit/;
13              
14             has apiurl => ( isa => 'Str', is => 'ro', default => 'http://api.twitter.com/1.1' );
15             has apihost => ( isa => 'Str', is => 'ro', lazy => 1, builder => '_build_apihost' );
16             has apirealm => ( isa => 'Str', is => 'ro', default => 'Twitter API' );
17              
18             sub _build_apihost {
19 0     0   0     my $uri = URI->new(shift->apiurl);
20 0         0     join ':', $uri->host, $uri->port;
21             }
22              
23             after BUILD => sub {
24                 my $self = shift;
25              
26                 $self->{apiurl} =~ s/^http:/https:/ if $self->ssl;
27             };
28              
29             base_url     'apiurl';
30             authenticate 1;
31              
32             our $DATETIME_PARSER = DateTime::Format::Strptime->new(pattern => '%a %b %d %T %z %Y');
33             datetime_parser $DATETIME_PARSER;
34              
35             twitter_api_method mentions => (
36                 description => <<'',
37             Returns the 20 most recent mentions (statuses containing @username) for the
38             authenticating user.
39            
40                 aliases => [qw/replies mentions_timeline/],
41                 path => 'statuses/mentions_timeline',
42                 method => 'GET',
43                 params => [qw/since_id max_id count trim_user include_entities contributor_details/],
44                 booleans => [qw/trim_user include_entities contributor_details/],
45                 required => [],
46                 returns => 'ArrayRef[Status]',
47             );
48              
49             twitter_api_method user_timeline => (
50                 description => <<'',
51             Returns the 20 most recent statuses posted by the authenticating user, or the
52             user specified by C<screen_name> or C<user_id>.
53            
54                 path => 'statuses/user_timeline',
55                 method => 'GET',
56                 params => [qw/user_id screen_name since_id max_id count trim_user exclude_replies include_rts contributor_details/],
57                 booleans => [qw/trim_user exclude_replies include_rts contributor_details/],
58                 required => [],
59                 returns => 'ArrayRef[Status]',
60             );
61              
62             twitter_api_method home_timeline => (
63                 description => <<'',
64             Returns the 20 most recent statuses, including retweets, posted by the
65             authenticating user and that user's friends.
66            
67                 path => 'statuses/home_timeline',
68                 method => 'GET',
69                 params => [qw/since_id max_id count exclude_replies contributor_details
70             include_entities trim_user/],
71                 booleans => [qw/skip_user exclude_replies contributor_details include_rts include_entities
72             trim_user include_my_retweet/],
73                 required => [],
74                 returns => 'ArrayRef[Status]',
75             );
76              
77             twitter_api_method friends_timeline => (
78                 description => <<'',
79             Returns the 20 most recent statuses, including retweets, posted by the
80             authenticating user and that user's friends.
81            
82                 path => 'statuses/home_timeline',
83                 aliases => [qw/following_timeline/],
84                 method => 'GET',
85                 params => [qw/since_id max_id count exclude_replies contributor_details
86             include_entities trim_user/],
87                 booleans => [qw/skip_user exclude_replies contributor_details include_rts include_entities
88             trim_user include_my_retweet/],
89                 required => [],
90                 returns => 'ArrayRef[Status]',
91                 deprecated => sub { carp "$_[0] DEPRECATED: using home_timeline instead" },
92             );
93              
94             twitter_api_method retweets => (
95                 description => <<'',
96             Returns up to 100 of the first retweets of a given tweet.
97            
98                 path => 'statuses/retweets/:id',
99                 method => 'GET',
100                 params => [qw/id count trim_user/],
101                 booleans => [qw/trim_user/],
102                 required => [qw/id/],
103                 returns => 'Arrayref[Status]',
104             );
105              
106             twitter_api_method show_status => (
107                 description => <<'',
108             Returns a single status, specified by the id parameter. The
109             status's author will be returned inline.
110            
111                 path => 'statuses/show/:id',
112                 method => 'GET',
113                 params => [qw/id trim_user include_entities include_my_retweet/],
114                 booleans => [qw/trim_user include_entities include_my_retweet/],
115                 required => [qw/id/],
116                 returns => 'Status',
117             );
118              
119             twitter_api_method destroy_status => (
120                 description => <<'',
121             Destroys the status specified by the required ID parameter. The
122             authenticating user must be the author of the specified status.
123            
124                 path => 'statuses/destroy/:id',
125                 method => 'POST',
126                 params => [qw/id trim_user/],
127                 booleans => [qw/trim_user/],
128                 required => [qw/id/],
129                 returns => 'Status',
130             );
131              
132             twitter_api_method update => (
133                 path => 'statuses/update',
134                 method => 'POST',
135                 params => [qw/
136             attachment_url display_coordinates in_reply_to_status_id lat long
137             media_ids place_id status trim_user
138             /],
139                 required => [qw/status/],
140                 booleans => [qw/display_coordinates trim_user/],
141                 add_source => 1,
142                 returns => 'Status',
143                 description => <<EOT,
144            
145             Updates the authenticating user's status. Requires the status parameter
146             specified. A status update with text identical to the authenticating
147             user's current status will be ignored.
148            
149             \=over 4
150            
151             \=item status
152            
153             Required. The text of your status update. URL encode as necessary. Statuses
154             over 140 characters will cause a 403 error to be returned from the API.
155            
156             \=item in_reply_to_status_id
157            
158             Optional. The ID of an existing status that the update is in reply to. o Note:
159             This parameter will be ignored unless the author of the tweet this parameter
160             references is mentioned within the status text. Therefore, you must include
161             \@username, where username is the author of the referenced tweet, within the
162             update.
163            
164             \=item lat
165            
166             Optional. The location's latitude that this tweet refers to. The valid ranges
167             for latitude is -90.0 to +90.0 (North is positive) inclusive. This parameter
168             will be ignored if outside that range, if it is not a number, if geo_enabled is
169             disabled, or if there not a corresponding long parameter with this tweet.
170            
171             \=item long
172            
173             Optional. The location's longitude that this tweet refers to. The valid ranges
174             for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter
175             will be ignored if outside that range, if it is not a number, if geo_enabled is
176             disabled, or if there not a corresponding lat parameter with this tweet.
177            
178             \=item place_id
179            
180             Optional. The place to attach to this status update. Valid place_ids can be
181             found by querying C<reverse_geocode>.
182            
183             \=item display_coordinates
184            
185             Optional. By default, geo-tweets will have their coordinates exposed in the
186             status object (to remain backwards compatible with existing API applications).
187             To turn off the display of the precise latitude and longitude (but keep the
188             contextual location information), pass C<display_coordinates => 0> on the
189             status update.
190            
191             \=back
192            
193             EOT
194              
195             );
196              
197             twitter_api_method retweet => (
198                 description => <<'',
199             Retweets a tweet.
200            
201                 path => 'statuses/retweet/:id',
202                 method => 'POST',
203                 params => [qw/idtrim_user/],
204                 booleans => [qw/trim_user/],
205                 required => [qw/id/],
206                 returns => 'Status',
207             );
208              
209             twitter_api_method update_with_media => (
210                 deprecated => 1,
211                 path => 'statuses/update_with_media',
212                 method => 'POST',
213                 params => [qw/
214             status media[] possibly_sensitive in_reply_to_status_id lat long place_id display_coordinates
215             /],
216                 required => [qw/status media[]/],
217                 booleans => [qw/possibly_sensitive display_coordinates/],
218                 returns => 'Status',
219                 description => <<'EOT',
220             Updates the authenticating user's status and attaches media for upload.
221            
222             Note that Twitter has marked this endpoint as B<deprecated>, and recommends
223             instead calling C<upload>, then (optionally) C<create_media_metadata>, then
224             C<update>.
225            
226             The C<media[]> parameter is an arrayref with the following interpretation:
227            
228             [ $file ]
229             [ $file, $filename ]
230             [ $file, $filename, Content_Type => $mime_type ]
231             [ undef, $filename, Content_Type => $mime_type, Content => $raw_image_data ]
232            
233             The first value of the array (C<$file>) is the name of a file to open. The
234             second value (C<$filename>) is the name given to Twitter for the file. If
235             C<$filename> is not provided, the basename portion of C<$file> is used. If
236             C<$mime_type> is not provided, it will be provided automatically using
237             L<LWP::MediaTypes::guess_media_type()>.
238            
239             C<$raw_image_data> can be provided, rather than opening a file, by passing
240             C<undef> as the first array value.
241            
242             The Tweet text will be rewritten to include the media URL(s), which will reduce
243             the number of characters allowed in the Tweet text. If the URL(s) cannot be
244             appended without text truncation, the tweet will be rejected and this method
245             will return an HTTP 403 error.
246             EOT
247              
248             );
249              
250             twitter_api_method oembed => (
251                 description => <<'EOT',
252             Returns information allowing the creation of an embedded representation of a
253             Tweet on third party sites. See the L<oEmbed|http://oembed.com/> specification
254             for information about the response format.
255            
256             While this endpoint allows a bit of customization for the final appearance of
257             the embedded Tweet, be aware that the appearance of the rendered Tweet may
258             change over time to be consistent with Twitter's L<Display
259             Requirements|https://dev.twitter.com/terms/display-requirements>. Do not rely
260             on any class or id parameters to stay constant in the returned markup.
261            
262             EOT
263              
264                 method => 'GET',
265                 path => 'statuses/oembed',
266                 params => [qw/id url maxwidth hide_media hide_thread omit_script align related lang/],
267                 required => [qw//],
268                 booleans => [qw/hide_media hide_thread omit_script/],
269                 returns => 'Status',
270             );
271              
272             twitter_api_method retweeters_ids => (
273                 description => <<'EOT',
274             Returns a collection of up to 100 user IDs belonging to users who have
275             retweeted the tweet specified by the id parameter.
276            
277             This method offers similar data to C<retweets> and replaces API v1's
278             C<retweeted_by_ids> method.
279             EOT
280                 method => 'GET',
281                 path => 'statuses/retweeters/ids',
282                 params => [qw/id cursor stringify_ids/],
283                 required => [qw/id/],
284                 booleans => [qw/stringify_ids/],
285                 returns => 'HashRef',
286             );
287              
288             twitter_api_method search => (
289                 description => <<'EOT',
290             Returns a HASH reference with some meta-data about the query including the
291             C<next_page>, C<refresh_url>, and C<max_id>. The statuses are returned in
292             C<results>. To iterate over the results, use something similar to:
293            
294             my $r = $nt->search($search_term);
295             for my $status ( @{$r->{statuses}} ) {
296             print "$status->{text}\n";
297             }
298             EOT
299              
300                 path => 'search/tweets',
301                 method => 'GET',
302                 params => [qw/q count callback lang locale rpp since_id max_id until geocode result_type include_entities/],
303                 required => [qw/q/],
304                 booleans => [qw/include_entities/],
305                 returns => 'HashRef',
306             );
307              
308             twitter_api_method direct_messages => (
309                 description => <<'EOT',
310             Returns a list of the 20 most recent direct messages sent to the authenticating
311             user including detailed information about the sending and recipient users.
312            
313             Important: this method requires an access token with RWD (read, write, and
314             direct message) permissions.
315             EOT
316              
317                 path => 'direct_messages',
318                 method => 'GET',
319                 params => [qw/since_id max_id count page include_entities skip_status/],
320                 required => [],
321                 booleans => [qw/include_entities skip_status/],
322                 returns => 'ArrayRef[DirectMessage]',
323             );
324              
325             twitter_api_method sent_direct_messages => (
326                 description => <<'EOT',
327             Returns a list of the 20 most recent direct messages sent by the authenticating
328             user including detailed information about the sending and recipient users.
329            
330             Important: this method requires an access token with RWD (read, write, and
331             direct message) permissions.
332             EOT
333              
334                 aliases => [qw/direct_messages_sent/],
335                 path => 'direct_messages/sent',
336                 method => 'GET',
337                 params => [qw/since_id max_id page count include_entities/],
338                 booleans => [qw/include_entities/],
339                 required => [qw//],
340                 returns => 'ArrayRef[DirectMessage]',
341             );
342              
343             twitter_api_method show_direct_message => (
344                 description => <<'EOT',
345             Returns a single direct message, specified by an id parameter. Like
346             the C<direct_messages> request, this method will include the
347             user objects of the sender and recipient. Requires authentication.
348            
349             Important: this method requires an access token with RWD (read, write, and
350             direct message) permissions.
351             EOT
352              
353                 path => 'direct_messages/show',
354                 method => 'GET',
355                 params => [qw/id/],
356                 booleans => [],
357                 required => [qw/id/],
358                 returns => 'HashRef',
359             );
360              
361             twitter_api_method destroy_direct_message => (
362                 description => <<'EOT',
363             Destroys the direct message specified in the required ID parameter.
364             The authenticating user must be the recipient of the specified direct
365             message.
366            
367             Important: this method requires an access token with RWD (read, write, and
368             direct message) permissions.
369             EOT
370              
371                 path => 'direct_messages/destroy',
372                 method => 'POST',
373                 params => [qw/id include_entities/],
374                 booleans => [qw/include_entities/],
375                 required => [qw/id/],
376                 returns => 'DirectMessage',
377             );
378              
379             twitter_api_method new_direct_message => (
380                 description => <<'EOT',
381             Sends a new direct message to the specified user from the authenticating user.
382             Requires both the user and text parameters. Returns the sent message when
383             successful. In order to support numeric screen names, the C<screen_name> or
384             C<user_id> parameters may be used instead of C<user>.
385            
386             Important: this method requires an access token with RWD (read, write, and
387             direct message) permissions.
388             EOT
389              
390                 path => 'direct_messages/new',
391                 method => 'POST',
392                 params => [qw/user_id screen_name text/],
393                 booleans => [qw//],
394                 required => [qw/text/],
395                 returns => 'DirectMessage',
396             );
397              
398             around new_direct_message => sub {
399                 my $orig = shift;
400                 my $self = shift;
401              
402                 my $args = ref $_[-1] eq ref {} ? pop : {};
403                 $args->{user} = shift unless exists $args->{user} || exists $args->{screen_name} || exists $args->{user_id};
404                 $args->{text} = shift unless exists $args->{text};
405              
406                 croak "too many args" if @_;
407              
408                 if ( my $user = delete $args->{user} ) {
409                     warn "user argument to new_direct_message deprecated; use screen_name or user_id";
410              
411                     if ( $user =~ /^\d+$/ ) {
412                         $args->{user_id} = $user;
413                     }
414                     else {
415                         $args->{screen_name} = $user;
416                     }
417                 }
418              
419                 return $self->$orig($args);
420             };
421              
422             twitter_api_method friends_ids => (
423                 description => <<'EOT',
424             Returns a reference to an array of numeric IDs for every user followed by the
425             specified user. The order of the IDs is reverse chronological.
426            
427             Use the optional C<cursor> parameter to retrieve IDs in pages of 5000. When
428             the C<cursor> parameter is used, the return value is a reference to a hash with
429             keys C<previous_cursor>, C<next_cursor>, and C<ids>. The value of C<ids> is a
430             reference to an array of IDS of the user's friends. Set the optional C<cursor>
431             parameter to -1 to get the first page of IDs. Set it to the prior return's
432             value of C<previous_cursor> or C<next_cursor> to page forward or backwards.
433             When there are no prior pages, the value of C<previous_cursor> will be 0. When
434             there are no subsequent pages, the value of C<next_cursor> will be 0.
435             EOT
436              
437                 aliases => [qw/following_ids/],
438                 path => 'friends/ids',
439                 method => 'GET',
440                 params => [qw/user_id screen_name cursor stringify_ids/],
441                 required => [qw//],
442                 booleans => [qw/stringify_ids/],
443                 returns => 'HashRef|ArrayRef[Int]',
444             );
445              
446             twitter_api_method followers => (
447                 description => <<'',
448             Returns a cursored collection of user objects for users following the specified user.
449            
450                 aliases => [qw/followers_list/],
451                 path => 'followers/list',
452                 method => 'GET',
453                 params => [qw/user_id screen_name cursor/],
454                 required => [qw//],
455                 returns => 'HashRef',
456             );
457              
458             twitter_api_method friends => (
459                 description => <<'',
460             Returns a cursored collection of user objects for users followed by the specified user.
461            
462                 aliases => [qw/friends_list/],
463                 path => 'friends/list',
464                 method => 'GET',
465                 params => [qw/user_id screen_name cursor/],
466                 required => [qw//],
467                 returns => 'HashRef',
468             );
469              
470             twitter_api_method followers_ids => (
471                 description => <<'EOT',
472             Returns a reference to an array of numeric IDs for every user following the
473             specified user. The order of the IDs may change from call to call. To obtain
474             the screen names, pass the arrayref to L</lookup_users>.
475            
476             Use the optional C<cursor> parameter to retrieve IDs in pages of 5000. When
477             the C<cursor> parameter is used, the return value is a reference to a hash with
478             keys C<previous_cursor>, C<next_cursor>, and C<ids>. The value of C<ids> is a
479             reference to an array of IDS of the user's followers. Set the optional C<cursor>
480             parameter to -1 to get the first page of IDs. Set it to the prior return's
481             value of C<previous_cursor> or C<next_cursor> to page forward or backwards.
482             When there are no prior pages, the value of C<previous_cursor> will be 0. When
483             there are no subsequent pages, the value of C<next_cursor> will be 0.
484             EOT
485              
486                 path => 'followers/ids',
487                 method => 'GET',
488                 params => [qw/user_id screen_name cursor/],
489                 params => [qw/user_id screen_name cursor stringify_ids/],
490                 required => [qw//],
491                 booleans => [qw/stringify_ids/],
492                 returns => 'HashRef|ArrayRef[Int]',
493             );
494              
495             twitter_api_method lookup_friendships => (
496                 path => 'friendships/lookup',
497                 method => 'GET',
498                 params => [qw/user_id screen_name/],
499                 required => [],
500                 returns => 'ArrayRef',
501                 description => <<''
502             Returns the relationship of the authenticating user to the comma separated list
503             or ARRAY ref of up to 100 screen_names or user_ids provided. Values for
504             connections can be: following, following_requested, followed_by, none.
505             Requires authentication.
506            
507             );
508              
509             twitter_api_method friendships_incoming => (
510                 description => <<'EOT',
511             Returns an HASH ref with an array of numeric IDs in the C<ids> element for
512             every user who has a pending request to follow the authenticating user.
513             EOT
514              
515                 aliases => [qw/incoming_friendships/],
516                 path => 'friendships/incoming',
517                 method => 'GET',
518                 params => [qw/cursor stringify_ids/],
519                 required => [],
520                 booleans => [qw/stringify_ids/],
521                 returns => 'HashRef',
522             );
523              
524             twitter_api_method friendships_outgoing => (
525                 description => <<'EOT',
526             Returns an HASH ref with an array of numeric IDs in the C<ids> element for
527             every protected user for whom the authenticating user has a pending follow
528             request.
529             EOT
530              
531                 aliases => [qw/outgoing_friendships/],
532                 path => 'friendships/outgoing',
533                 method => 'GET',
534                 params => [qw/cursor stringify_ids/],
535                 required => [],
536                 booleans => [qw/stringify_ids/],
537                 returns => 'HashRef',
538              
539             );
540              
541             twitter_api_method create_friend => (
542                 description => <<'',
543             Follows the user specified in the C<user_id> or C<screen_name> parameter as the
544             authenticating user. Returns the befriended user when successful. Returns a
545             string describing the failure condition when unsuccessful.
546            
547                 aliases => [qw/follow follow_new create_friendship/],
548                 path => 'friendships/create',
549                 method => 'POST',
550                 params => [qw/user_id screen_name follow/],
551                 booleans => [qw/follow/],
552                 required => [qw//],
553                 returns => 'BasicUser',
554             );
555              
556             twitter_api_method destroy_friend => (
557                 description => <<'',
558             Discontinues friendship with the user specified in the C<user_id> or
559             C<screen_name> parameter as the authenticating user. Returns the un-friended
560             user when successful. Returns a string describing the failure condition when
561             unsuccessful.
562            
563                 aliases => [qw/unfollow destroy_friendship/],
564                 path => 'friendships/destroy',
565                 method => 'POST',
566                 params => [qw/user_id screen_name/],
567                 booleans => [qw//],
568                 required => [qw/id/],
569                 returns => 'BasicUser',
570             );
571              
572             twitter_api_method update_friendship => (
573                 path => 'friendships/update',
574                 method => 'POST',
575                 params => [qw/user_id screen_name device retweets/],
576                 required => [qw//],
577                 booleans => [qw/device retweets/],
578                 returns => 'HashRef',
579                 description => <<''
580             Allows you enable or disable retweets and device notifications from the
581             specified user. All other values are assumed to be false. Requires
582             authentication.
583            
584             );
585              
586             twitter_api_method show_friendship => (
587                 description => <<'',
588             Returns detailed information about the relationship between two users.
589            
590                 aliases => [qw/show_relationship/],
591                 path => 'friendships/show',
592                 method => 'GET',
593                 params => [qw/source_id source_screen_name target_id target_screen_name/],
594                 required => [qw//],
595                 returns => 'Relationship',
596             );
597              
598             # infer source and target from positional args for convenience
599             around show_friendship => sub {
600                 my $orig = shift;
601                 my $self = shift;
602              
603                 my $args = ref $_[-1] eq ref {} ? pop : {};
604                 if ( @_ == 2 ) {
605                     for ( qw/source target/ ) {
606                         my $id = shift;
607                         $$args{$id =~ /^\d+$/ ? "${_}_id" : "${_}_screen_name"} = $id;
608                     }
609                 }
610                 return $self->$orig(@_, $args);
611             };
612              
613             # provided for backwards compatibility
614             twitter_api_method friendship_exists => (
615                 description => <<'EOT',
616             This method is provided for backwards compatibility with Twitter API V1.0.
617             Twitter API V1.1 does not provide an endpoint for this call. Instead,
618             C<show_friendship> is called, the result is inspected, and an appropriate value
619             is returned which can be evaluated in a boolean context.
620            
621             Tests for the existence of friendship between two users. Will return true if
622             user_a follows user_b, otherwise will return false.
623            
624             Use of C<user_a> and C<user_b> is deprecated. It has been preserved for backwards
625             compatibility, and is used for the two-argument positional form:
626            
627             $nt->friendship_exists($user_a, $user_b);
628            
629             Instead, you should use one of the named argument forms:
630            
631             $nt->friendship_exists({ user_id_a => $id1, user_id_b => $id2 });
632             $nt->friendship_exists({ screen_name_a => $name1, screen_name_b => $name2 });
633            
634             Consider using C<show_friendship> instead.
635             EOT
636              
637                 aliases => [qw/relationship_exists follows/],
638                 path => 'friendships/show',
639                 method => 'GET',
640                 params => [qw/user_id_a user_id_b screen_name_a screen_name_b user_a user_b/],
641                 required => [qw/user_a user_b/],
642                 returns => 'Bool',
643                 deprecated => sub { carp "$_[0] DEPRECATED: using show_friendship instead" },
644             );
645              
646             around [qw/friendship_exists relationship_exists follows/] => sub {
647                 my $orig = shift;
648                 my $self = shift;
649              
650                 my $args = ref $_[-1] eq ref {} ? pop : {};
651                 my ( $user_a, $user_b ) = @_; # default ags, if they exist
652                 if ( $user_a ||= delete $$args{user_a} ) {
653                     if ( $user_a =~ /^\d+$/ ) {
654                         $$args{source_id} = $user_a;
655                     }
656                     else {
657                         $$args{source_screen_name} = $user_a;
658                     }
659                 }
660                 elsif ( $user_a = delete $$args{screen_name_a} ) {
661                     $$args{source_screen_name} = $user_a;
662                 }
663                 elsif ( $user_a = delete $$args{user_id_a} ) {
664                     $$args{source_user_id} = $user_a;
665                 }
666                 else {
667                     croak "source user not specified";
668                 }
669              
670                 if ( $user_b ||= delete $$args{user_b} ) {
671                     if ( $user_b =~ /^\d+$/ ) {
672                         $$args{target_id} = $user_b;
673                     }
674                     else {
675                         $$args{target_screen_name} = $user_b;
676                     }
677                 }
678                 elsif ( $user_b = delete $$args{screen_name_b} ) {
679                     $$args{target_screen_name} = $user_b;
680                 }
681                 elsif ( $user_b = delete $$args{user_id_b} ) {
682                     $$args{target_user_id} = $user_b;
683                 }
684                 else {
685                     croak "target user not specified";
686                 }
687              
688                 my $r = $self->$orig($args);
689                 return !!$$r{relationship}{target}{followed_by};
690             };
691              
692             twitter_api_method account_settings => (
693                 description => <<'',
694             Returns the current trend, geo and sleep time information for the
695             authenticating user.
696            
697                 path => 'account/settings',
698                 method => 'GET',
699                 params => [],
700                 required => [],
701                 returns => 'HashRef',
702             );
703              
704             twitter_api_method verify_credentials => (
705                 description => <<'',
706             Returns an HTTP 200 OK response code and a representation of the
707             requesting user if authentication was successful; returns a 401 status
708             code and an error message if not. Use this method to test if supplied
709             user credentials are valid.
710            
711                 path => 'account/verify_credentials',
712                 method => 'GET',
713                 params => [qw/include_entities skip_status include_email/],
714                 booleans => [qw/include_entities skip_status include_email/],
715                 required => [qw//],
716                 returns => 'ExtendedUser',
717             );
718              
719             twitter_api_method update_account_settings => (
720                 description => <<'',
721             Updates the authenticating user's settings.
722            
723                 path => 'account/settings',
724                 method => 'POST',
725                 params => [qw/trend_location_woid sleep_time_enabled start_sleep_time end_sleep_time time_zone lang/],
726                 required => [],
727                 booleans => [qw/sleep_time_enabled/],
728                 returns => 'HashRef',
729             );
730              
731             twitter_api_method update_delivery_device => (
732                 description => <<'',
733             Sets which device Twitter delivers updates to for the authenticating user.
734             Sending none as the device parameter will disable SMS updates.
735            
736                 path => 'account/update_delivery_device',
737                 method => 'POST',
738                 params => [qw/device include_entities/],
739                 required => [qw/device/],
740                 booleans => [qw/include_entities/],
741                 returns => 'BasicUser',
742             );
743              
744             twitter_api_method update_profile => (
745                 description => <<'',
746             Sets values that users are able to set under the "Account" tab of their
747             settings page. Only the parameters specified will be updated; to only
748             update the "name" attribute, for example, only include that parameter
749             in your request.
750            
751                 path => 'account/update_profile',
752                 method => 'POST',
753                 params => [qw/name url location description include_entities skip_status/],
754                 required => [qw//],
755                 booleans => [qw/include_entities skip_status/],
756                 returns => 'ExtendedUser',
757             );
758              
759             twitter_api_method update_location => (
760                 description => <<'',
761             This method has been deprecated in favor of the update_profile method.
762             Its URL will continue to work, but please consider migrating to the newer
763             and more comprehensive method of updating profile attributes.
764            
765                 path => 'account/update_profile',
766                 method => 'POST',
767                 params => [qw/location/],
768                 required => [qw/location/],
769                 returns => 'BasicUser',
770                 deprecated => sub { carp "$_[0] DEPRECATED: using update_profile instead" },
771             );
772              
773             twitter_api_method update_profile_background_image => (
774                 description => <<'',
775             Updates the authenticating user's profile background image. The C<image>
776             parameter must be an arrayref with the same interpretation as the C<image>
777             parameter in the C<update_profile_image> method. See that method's
778             documentation for details. The C<use> parameter allows you to specify whether
779             to use the uploaded profile background or not.
780            
781                 path => 'account/update_profile_background_image',
782                 method => 'POST',
783                 params => [qw/image tile include_entities skip_status use/],
784                 required => [qw//],
785                 booleans => [qw/include_entities skip_status use/],
786                 returns => 'ExtendedUser',
787             );
788              
789             twitter_api_method update_profile_colors => (
790                 description => <<'',
791             Sets one or more hex values that control the color scheme of the
792             authenticating user's profile page on twitter.com. These values are
793             also returned in the /users/show API method.
794            
795                 path => 'account/update_profile_colors',
796                 method => 'POST',
797                 params => [qw/
798             profile_background_color
799             profile_text_color
800             profile_link_color
801             profile_sidebar_fill_color
802             profile_sidebar_border_color
803             include_entities
804             skip_status
805             /],
806                 required => [qw//],
807                 booleans => [qw/include_entities skip_status/],
808                 returns => 'ExtendedUser',
809             );
810              
811             twitter_api_method update_profile_image => (
812                 description => <<'EOT',
813             Updates the authenticating user's profile image. The C<image> parameter is an
814             arrayref with the following interpretation:
815            
816             [ $file ]
817             [ $file, $filename ]
818             [ $file, $filename, Content_Type => $mime_type ]
819             [ undef, $filename, Content_Type => $mime_type, Content => $raw_image_data ]
820            
821             The first value of the array (C<$file>) is the name of a file to open. The
822             second value (C<$filename>) is the name given to Twitter for the file. If
823             C<$filename> is not provided, the basename portion of C<$file> is used. If
824             C<$mime_type> is not provided, it will be provided automatically using
825             L<LWP::MediaTypes::guess_media_type()>.
826            
827             C<$raw_image_data> can be provided, rather than opening a file, by passing
828             C<undef> as the first array value.
829             EOT
830              
831                 path => 'account/update_profile_image',
832                 method => 'POST',
833                 params => [qw/image include_entities skip_status/],
834                 required => [qw/image/],
835                 booleans => [qw/include_entities skip_status/],
836                 returns => 'ExtendedUser',
837             );
838              
839             twitter_api_method blocking => (
840                 description => <<'',
841             Returns an array of user objects that the authenticating user is blocking.
842            
843                 path => 'blocks/list',
844                 aliases => [qw/blocks_list/],
845                 method => 'GET',
846                 params => [qw/cursor include_entities skip_status/],
847                 required => [qw//],
848                 returns => 'ArrayRef[BasicUser]',
849             );
850              
851             twitter_api_method blocking_ids => (
852                 description => <<'',
853             Returns an array of numeric user ids the authenticating user is blocking.
854            
855                 path => 'blocks/ids',
856                 aliases => [qw/blocks_ids/],
857                 method => 'GET',
858                 params => [qw/cursor stringify_ids/],
859                 required => [qw//],
860                 booleans => [qw/stringify_ids/],
861                 returns => 'ArrayRef[Int]',
862             );
863              
864             twitter_api_method create_block => (
865                 description => <<'',
866             Blocks the user specified in the C<user_id> or C<screen_name> parameter as the
867             authenticating user. Returns the blocked user when successful. You can find
868             out more about blocking in the Twitter Support Knowledge Base.
869            
870                 path => 'blocks/create',
871                 method => 'POST',
872                 params => [qw/user_id screen_name include_entities skip_status/],
873                 booleans => [qw/include_entities skip_status/],
874                 required => [qw/id/],
875                 returns => 'BasicUser',
876             );
877              
878             twitter_api_method destroy_block => (
879                 description => <<'',
880             Un-blocks the user specified in the C<user_id> or C<screen_name> parameter as
881             the authenticating user. Returns the un-blocked user when successful.
882            
883                 path => 'blocks/destroy',
884                 method => 'POST',
885                 params => [qw/user_id screen_name include_entities skip_status/],
886                 booleans => [qw/include_entities skip_status/],
887                 required => [qw/id/],
888                 returns => 'BasicUser',
889             );
890              
891             twitter_api_method lookup_users => (
892                 description => <<'EOT',
893             Return up to 100 users worth of extended information, specified by either ID,
894             screen name, or combination of the two. The author's most recent status (if the
895             authenticating user has permission) will be returned inline. This method is
896             rate limited to 1000 calls per hour.
897            
898             This method will accept user IDs or screen names as either a comma delimited
899             string, or as an ARRAY ref. It will also accept arguments in the normal
900             HASHREF form or as a simple list of named arguments. I.e., any of the
901             following forms are acceptable:
902            
903             $nt->lookup_users({ user_id => '1234,6543,3333' });
904             $nt->lookup_users(user_id => '1234,6543,3333');
905             $nt->lookup_users({ user_id => [ 1234, 6543, 3333 ] });
906             $nt->lookup_users({ screen_name => 'fred,barney,wilma' });
907             $nt->lookup_users(screen_name => ['fred', 'barney', 'wilma']);
908            
909             $nt->lookup_users(
910             screen_name => ['fred', 'barney' ],
911             user_id => '4321,6789',
912             );
913             EOT
914              
915                 path => 'users/lookup',
916                 method => 'GET',
917                 params => [qw/user_id screen_name include_entities/],
918                 booleans => [qw/include_entities/],
919                 required => [],
920                 returns => 'ArrayRef[User]',
921             );
922              
923             twitter_api_method show_user => (
924                 description => <<'',
925             Returns extended information of a given user, specified by ID or screen
926             name as per the required id parameter. This information includes
927             design settings, so third party developers can theme their widgets
928             according to a given user's preferences. You must be properly
929             authenticated to request the page of a protected user.
930            
931                 path => 'users/show',
932                 method => 'GET',
933                 params => [qw/user_id screen_name include_entities/],
934                 booleans => [qw/include_entities/],
935                 required => [qw//],
936                 returns => 'ExtendedUser',
937             );
938              
939             twitter_api_method users_search => (
940                 description => <<'',
941             Run a search for users similar to Find People button on Twitter.com; the same
942             results returned by people search on Twitter.com will be returned by using this
943             API (about being listed in the People Search). It is only possible to retrieve
944             the first 1000 matches from this API.
945            
946                 aliases => [qw/find_people search_users/],
947                 path => 'users/search',
948                 method => 'GET',
949                 params => [qw/q per_page page count include_entities/],
950                 booleans => [qw/include_entities/],
951                 required => [qw/q/],
952                 returns => 'ArrayRef[Users]',
953             );
954              
955             twitter_api_method contributees => (
956                 deprecated => 1,
957                 path => 'users/contributees',
958                 method => 'GET',
959                 params => [qw/user_id screen_name include_entities skip_satus/],
960                 required => [],
961                 booleans => [qw/include_entities skip_satus/],
962                 returns => 'ArrayRef[User]',
963                 description => <<'',
964             Returns an array of users that the specified user can contribute to.
965            
966             );
967              
968             twitter_api_method contributors => (
969                 deprecated => 1,
970                 path => 'users/contributors',
971                 method => 'GET',
972                 params => [qw/user_id screen_name include_entities skip_satus/],
973                 required => [],
974                 booleans => [qw/include_entities skip_satus/],
975                 returns => 'ArrayRef[User]',
976                 description => <<'',
977             Returns an array of users who can contribute to the specified account.
978            
979             );
980              
981             twitter_api_method suggestion_categories => (
982                 path => 'users/suggestions',
983                 method => 'GET',
984                 params => [],
985                 required => [],
986                 returns => 'ArrayRef',
987                 description => <<''
988             Returns the list of suggested user categories. The category slug can be used in
989             the C<user_suggestions> API method get the users in that category . Does not
990             require authentication.
991            
992             );
993              
994             twitter_api_method user_suggestions_for => (
995                 aliases => [qw/follow_suggestions_for/],
996                 path => 'users/suggestions/:slug',
997                 method => 'GET',
998                 params => [qw/slug lang/],
999                 required => [qw/slug/],
1000                 returns => 'ArrayRef',
1001                 description => <<''
1002             Access the users in a given slug (category) of the Twitter suggested user list.
1003            
1004             );
1005              
1006             twitter_api_method user_suggestions => (
1007                 aliases => [qw/follow_suggestions/],
1008                 path => 'users/suggestions/:slug/members',
1009                 method => 'GET',
1010                 params => [qw/slug lang/],
1011                 required => [qw/slug/],
1012                 returns => 'ArrayRef',
1013                 description => <<''
1014             Access the users in a given slug (category) of the Twitter suggested user list
1015             and return their most recent status if they are not a protected user.
1016             Currently supported values for optional parameter C<lang> are C<en>, C<fr>,
1017             C<de>, C<es>, C<it>. Does not require authentication.
1018            
1019             );
1020              
1021             # backwards compatibility: Twitter renamed "category" to "slug"
1022             around [ qw/follow_suggestions follow_suggestions_for user_suggestions
1023             user_suggestions_for/ ] => sub {
1024                 my ( $next, $self ) = splice @_, 0, 2;
1025              
1026                 my $args = ref $_[-1] eq 'HASH' ? pop : {};
1027                 if ( exists $args->{category} ) {
1028                     $args->{slug} = delete $args->{category};
1029                 }
1030              
1031                 return $self->$next(@_, $args);
1032             };
1033              
1034             twitter_api_method favorites => (
1035                 description => <<'',
1036             Returns the 20 most recent favorite statuses for the authenticating
1037             user or user specified by the ID parameter.
1038            
1039                 path => 'favorites/list',
1040                 method => 'GET',
1041                 params => [qw/user_id screen_name count since_id max_id include_entities/],
1042                 booleans => [qw/include_entities/],
1043                 required => [qw//],
1044                 returns => 'ArrayRef[Status]',
1045             );
1046              
1047             twitter_api_method destroy_favorite => (
1048                 description => <<'',
1049             Un-favorites the status specified in the ID parameter as the
1050             authenticating user. Returns the un-favorited status.
1051            
1052                 path => 'favorites/destroy',
1053                 method => 'POST',
1054                 params => [qw/id include_entities/],
1055                 booleans => [qw/include_entities/],
1056                 required => [qw/id/],
1057                 returns => 'Status',
1058             );
1059              
1060             twitter_api_method create_favorite => (
1061                 description => <<'',
1062             Favorites the status specified in the ID parameter as the
1063             authenticating user. Returns the favorite status when successful.
1064            
1065                 path => 'favorites/create',
1066                 method => 'POST',
1067                 params => [qw/id include_entities/],
1068                 booleans => [qw/include_entities/],
1069                 required => [qw/id/],
1070                 returns => 'Status',
1071             );
1072              
1073             ### Lists ###
1074              
1075             twitter_api_method get_lists => (
1076                 description => <<'EOT',
1077             Returns all lists the authenticating or specified user subscribes to, including
1078             their own. The user is specified using the user_id or screen_name parameters.
1079             If no user is given, the authenticating user is used.
1080            
1081             A maximum of 100 results will be returned by this call. Subscribed lists are
1082             returned first, followed by owned lists. This means that if a user subscribes
1083             to 90 lists and owns 20 lists, this method returns 90 subscriptions and 10
1084             owned lists. The reverse method returns owned lists first, so with C<reverse =>
1085             1>, 20 owned lists and 80 subscriptions would be returned. If your goal is to
1086             obtain every list a user owns or subscribes to, use <list_ownerships> and/or
1087             C<list_subscriptions> instead.
1088             EOT
1089              
1090                 path => 'lists/list',
1091                 aliases => [qw/list_lists all_subscriptions/],
1092                 method => 'GET',
1093                 params => [qw/user_id screen_name reverse/],
1094                 required => [],
1095                 returns => 'Hashref',
1096             );
1097              
1098             twitter_api_method list_statuses => (
1099                 description => <<'',
1100             Returns tweet timeline for members of the specified list. Historically,
1101             retweets were not available in list timeline responses but you can now use the
1102             include_rts=true parameter to additionally receive retweet objects.
1103            
1104                 path => 'lists/statuses',
1105                 method => 'GET',
1106                 params => [qw/
1107             list_id slug owner_screen_name owner_id since_id max_id count
1108             include_entities include_rts
1109             /],
1110                 required => [],
1111                 booleans => [qw/include_entities include_rts/],
1112                 returns => 'ArrayRef[Status]',
1113             );
1114              
1115             twitter_api_method delete_list_member => (
1116                 description => <<'',
1117             Removes the specified member from the list. The authenticated user must be the
1118             list's owner to remove members from the list.
1119            
1120                 path => 'lists/members/destroy',
1121                 method => 'POST',
1122                 params => [qw/list_id slug user_id screen_name owner_screen_name owner_id/],
1123                 required => [],
1124                 returns => 'User',
1125                 aliases => [qw/remove_list_member/],
1126             );
1127              
1128             twitter_api_method list_memberships => (
1129                 description => <<'',
1130             Returns the lists the specified user has been added to. If user_id or
1131             screen_name are not provided the memberships for the authenticating user are
1132             returned.
1133            
1134                 path => 'lists/memberships',
1135                 method => 'GET',
1136                 params => [qw/user_id screen_name cursor filter_to_owned_lists/],
1137                 required => [],
1138                 booleans => [qw/filter_to_owned_lists/],
1139                 returns => 'Hashref',
1140             );
1141              
1142             twitter_api_method list_subscribers => (
1143                 path => 'lists/subscribers',
1144                 method => 'GET',
1145                 params => [qw/list_id slug owner_screen_name owner_id cursor include_entities skip_status/],
1146                 required => [],
1147                 booleans => [qw/include_entities skip_status/],
1148                 returns => 'Hashref',
1149                 description => <<'',
1150             Returns the subscribers of the specified list. Private list subscribers will
1151             only be shown if the authenticated user owns the specified list.
1152            
1153             );
1154              
1155             twitter_api_method subscribe_list => (
1156                 description => <<'',
1157             Subscribes the authenticated user to the specified list.
1158            
1159                 path => 'lists/subscribers/create',
1160                 method => 'POST',
1161                 params => [qw/owner_screen_name owner_id list_id slug/],
1162                 required => [],
1163                 returns => 'List',
1164             );
1165              
1166             twitter_api_method show_list_subscriber => (
1167                 description => <<'',
1168             Returns the user if they are a subscriber.
1169            
1170                 path => 'lists/subscribers/show',
1171                 aliases => [qw/is_list_subscriber is_subscriber_lists/],
1172                 method => 'GET',
1173                 params => [qw/
1174             owner_screen_name owner_id list_id slug user_id screen_name
1175             include_entities skip_status
1176             /],
1177                 required => [],
1178                 booleans => [qw/include_entities skip_status/],
1179                 returns => 'User',
1180             );
1181              
1182             around [qw/is_list_subscriber is_subscriber_lists/] => sub {
1183                 my $orig = shift;
1184                 my $self = shift;
1185              
1186                 $self->_user_or_undef($orig, 'subscriber', @_);
1187             };
1188              
1189             twitter_api_method unsubscribe_list => (
1190                 description => <<'',
1191             Unsubscribes the authenticated user from the specified list.
1192            
1193                 path => 'lists/subscribers/destroy',
1194                 method => 'POST',
1195                 params => [qw/list_id slug owner_screen_name owner_id/],
1196                 required => [],
1197                 returns => 'List',
1198             );
1199              
1200             twitter_api_method members_create_all => (
1201                 description => <<'',
1202             Adds multiple members to a list, by specifying a reference to an array or a
1203             comma-separated list of member ids or screen names. The authenticated user must
1204             own the list to be able to add members to it. Note that lists can't have more
1205             than 500 members, and you are limited to adding up to 100 members to a list at
1206             a time with this method.
1207            
1208                 path => 'lists/members/create_all',
1209                 method => 'POST',
1210                 params => [qw/list_id slug owner_screen_name owner_id/],
1211                 required => [],
1212                 returns => 'List',
1213                 aliases => [qw/add_list_members/],
1214             );
1215              
1216             twitter_api_method show_list_member => (
1217                 description => <<'',
1218             Check if the specified user is a member of the specified list. Returns the user or undef.
1219            
1220                 path => 'lists/members/show',
1221                 aliases => [qw/is_list_member/],
1222                 method => 'GET',
1223                 params => [qw/
1224             owner_screen_name owner_id list_id slug user_id screen_name
1225             include_entities skip_status
1226             /],
1227                 required => [],
1228                 booleans => [qw/include_entities skip_status/],
1229                 returns => 'Maybe[User]',
1230             );
1231              
1232             around is_list_member => sub {
1233                 my $orig = shift;
1234                 my $self = shift;
1235              
1236                 $self->_user_or_undef($orig, 'member', @_);
1237             };
1238              
1239             twitter_api_method list_members => (
1240                 description => <<'',
1241             Returns the members of the specified list. Private list members will only be
1242             shown if the authenticated user owns the specified list.
1243            
1244                 path => 'lists/members',
1245                 method => 'GET',
1246                 params => [qw/
1247             list_id slug owner_screen_name owner_id cursor
1248             include_entities skip_status
1249             /],
1250                 required => [],
1251                 booleans => [qw/include_entities skip_status/],
1252                 returns => 'Hashref',
1253             );
1254              
1255             twitter_api_method add_list_member => (
1256                 description => <<'',
1257             Add a member to a list. The authenticated user must own the list to be able to
1258             add members to it. Note that lists can't have more than 500 members.
1259            
1260                 path => 'lists/members/create',
1261                 method => 'POST',
1262                 params => [qw/list_id slug user_id screen_name owner_screen_name owner_id/],
1263                 required => [],
1264                 returns => 'User',
1265             );
1266              
1267             twitter_api_method delete_list => (
1268                 description => <<'',
1269             Deletes the specified list. The authenticated user must own the list to be able
1270             to destroy it.
1271            
1272                 path => 'lists/destroy',
1273                 method => 'POST',
1274                 params => [qw/owner_screen_name owner_id list_id slug/],
1275                 required => [],
1276                 returns => 'List',
1277             );
1278              
1279             twitter_api_method update_list => (
1280                 description => <<'',
1281             Updates the specified list. The authenticated user must own the list to be able
1282             to update it.
1283            
1284                 path => 'lists/update',
1285                 method => 'POST',
1286                 params => [qw/list_id slug name mode description owner_screen_name owner_id/],
1287                 required => [],
1288                 returns => 'List',
1289             );
1290              
1291             twitter_api_method create_list => (
1292                 description => <<'',
1293             Creates a new list for the authenticated user. Note that you can't create more
1294             than 20 lists per account.
1295            
1296                 path => 'lists/create',
1297                 method => 'POST',
1298                 params => [qw/list_id slug name mode description owner_screen_name owner_id/],
1299                 required => [qw/name/],
1300                 returns => 'List',
1301             );
1302              
1303             twitter_api_method get_list => (
1304                 description => <<'',
1305             Returns the specified list. Private lists will only be shown if the
1306             authenticated user owns the specified list.
1307            
1308                 aliases => [qw/show_list/],
1309                 path => 'lists/show',
1310                 method => 'GET',
1311                 params => [qw/list_id slug owner_screen_name owner_id/],
1312                 required => [],
1313                 returns => 'List',
1314             );
1315              
1316             twitter_api_method list_subscriptions => (
1317                 description => <<'',
1318             Obtain a collection of the lists the specified user is subscribed to, 20 lists
1319             per page by default. Does not include the user's own lists.
1320            
1321                 path => 'lists/subscriptions',
1322                 method => 'GET',
1323                 params => [qw/user_id screen_name count cursor/],
1324                 required => [],
1325                 returns => 'ArrayRef[List]',
1326                 aliases => [qw/subscriptions/],
1327             );
1328              
1329             twitter_api_method members_destroy_all => (
1330                 description => <<'EOT',
1331             Removes multiple members from a list, by specifying a reference to an array of
1332             member ids or screen names, or a string of comma separated user ids or screen
1333             names. The authenticated user must own the list to be able to remove members
1334             from it. Note that lists can't have more than 500 members, and you are limited
1335             to removing up to 100 members to a list at a time with this method.
1336            
1337             Please note that there can be issues with lists that rapidly remove and add
1338             memberships. Take care when using these methods such that you are not too
1339             rapidly switching between removals and adds on the same list.
1340            
1341             EOT
1342              
1343                 path => 'lists/members/destroy_all',
1344                 aliases => [qw/remove_list_members/],
1345                 method => 'POST',
1346                 params => [qw/list_id slug user_id screen_name owner_screen_name owner_id/],
1347                 required => [],
1348                 returns => 'List',
1349             );
1350              
1351             twitter_api_method list_ownerships => (
1352                 description => <<'',
1353             Obtain a collection of the lists owned by the specified Twitter user. Private
1354             lists will only be shown if the authenticated user is also the owner of the lists.
1355            
1356                 path => 'lists/ownerships',
1357                 method => 'GET',
1358                 params => [qw/user_id screen_name count cursor/],
1359                 required => [],
1360                 returns => 'ArrayRef[List]',
1361                 aliases => [],
1362             );
1363              
1364             ## saved searches ##
1365              
1366             twitter_api_method saved_searches => (
1367                 description => <<'',
1368             Returns the authenticated user's saved search queries.
1369            
1370                 path => 'saved_searches/list',
1371                 method => 'GET',
1372                 params => [],
1373                 required => [],
1374                 returns => 'ArrayRef[SavedSearch]',
1375             );
1376              
1377             twitter_api_method show_saved_search => (
1378                 description => <<'',
1379             Retrieve the data for a saved search, by C<id>, owned by the authenticating user.
1380            
1381                 path => 'saved_searches/show/:id',
1382                 method => 'GET',
1383                 params => [qw/id/],
1384                 required => [qw/id/],
1385                 returns => 'SavedSearch',
1386             );
1387              
1388             twitter_api_method create_saved_search => (
1389                 description => <<'',
1390             Creates a saved search for the authenticated user.
1391            
1392                 path => 'saved_searches/create',
1393                 method => 'POST',
1394                 params => [qw/query/],
1395                 required => [qw/query/],
1396                 returns => 'SavedSearch',
1397             );
1398              
1399             twitter_api_method destroy_saved_search => (
1400                 description => <<'',
1401             Destroys a saved search. The search, specified by C<id>, must be owned
1402             by the authenticating user.
1403            
1404                 aliases => [qw/delete_saved_search/],
1405                 path => 'saved_searches/destroy/:id',
1406                 method => 'POST',
1407                 params => [qw/id/],
1408                 required => [qw/id/],
1409                 returns => 'SavedSearch',
1410             );
1411              
1412             ## geo ##
1413              
1414             twitter_api_method geo_id => (
1415                 description => <<'',
1416             Returns details of a place returned from the C<reverse_geocode> method.
1417            
1418                 path => 'geo/id/:place_id',
1419                 method => 'GET',
1420                 params => [qw/place_id/],
1421                 required => [qw/place_id/],
1422                 returns => 'HashRef',
1423             );
1424              
1425             # backwards compat for 'geo/id/:id'
1426             # recast to 'geo/id/:place_id
1427             around geo_id => sub {
1428                 my ( $next, $self ) = splice @_, 0, 2;
1429              
1430                 my $args = ref $_[-1] eq 'HASH' ? pop @_ : {};
1431              
1432                 if ( exists $args->{id} ) {
1433                     $args->{place_id} = delete $args->{id};
1434                 }
1435              
1436                 return $self->$next(@_, $args);
1437             };
1438              
1439             twitter_api_method reverse_geocode => (
1440                 description => <<EOT,
1441             Search for places (cities and neighborhoods) that can be attached to a
1442             statuses/update. Given a latitude and a longitude, return a list of all the
1443             valid places that can be used as a place_id when updating a status.
1444             Conceptually, a query can be made from the user's location, retrieve a list of
1445             places, have the user validate the location he or she is at, and then send the
1446             ID of this location up with a call to statuses/update.
1447            
1448             There are multiple granularities of places that can be returned --
1449             "neighborhoods", "cities", etc. At this time, only United States data is
1450             available through this method.
1451            
1452             \=over 4
1453            
1454             \=item lat
1455            
1456             Required. The latitude to query about. Valid ranges are -90.0 to +90.0 (North
1457             is positive) inclusive.
1458            
1459             \=item long
1460            
1461             Required. The longitude to query about. Valid ranges are -180.0 to +180.0
1462             (East is positive) inclusive.
1463            
1464             \=item accuracy
1465            
1466             Optional. A hint on the "region" in which to search. If a number, then this is
1467             a radius in meters, but it can also take a string that is suffixed with ft to
1468             specify feet. If this is not passed in, then it is assumed to be 0m. If
1469             coming from a device, in practice, this value is whatever accuracy the device
1470             has measuring its location (whether it be coming from a GPS, WiFi
1471             triangulation, etc.).
1472            
1473             \=item granularity
1474            
1475             Optional. The minimal granularity of data to return. If this is not passed
1476             in, then C<neighborhood> is assumed. C<city> can also be passed.
1477            
1478             \=item max_results
1479            
1480             Optional. A hint as to the number of results to return. This does not
1481             guarantee that the number of results returned will equal max_results, but
1482             instead informs how many "nearby" results to return. Ideally, only pass in the
1483             number of places you intend to display to the user here.
1484            
1485             \=back
1486            
1487             EOT
1488              
1489                 path => 'geo/reverse_geocode',
1490                 method => 'GET',
1491                 params => [qw/lat long accuracy granularity max_results callback/],
1492                 required => [qw/lat long/],
1493                 returns => 'HashRef',
1494             );
1495              
1496             twitter_api_method geo_search => (
1497                 description => <<'EOT',
1498             Search for places that can be attached to a statuses/update. Given a latitude
1499             and a longitude pair, an IP address, or a name, this request will return a list
1500             of all the valid places that can be used as the place_id when updating a
1501             status.
1502            
1503             Conceptually, a query can be made from the user's location, retrieve a list of
1504             places, have the user validate the location he or she is at, and then send the
1505             ID of this location with a call to statuses/update.
1506            
1507             This is the recommended method to use find places that can be attached to
1508             statuses/update. Unlike geo/reverse_geocode which provides raw data access,
1509             this endpoint can potentially re-order places with regards to the user who
1510             is authenticated. This approach is also preferred for interactive place
1511             matching with the user.
1512             EOT
1513              
1514                 path => 'geo/search',
1515                 method => 'GET',
1516                 params => [qw/
1517             lat long query ip granularity accuracy max_results
1518             contained_within attribute:street_address callback
1519             /],
1520                 required => [],
1521                 returns => 'HashRef',
1522             );
1523              
1524             twitter_api_method similar_places => (
1525                 description => <<'EOT',
1526             Locates places near the given coordinates which are similar in name.
1527            
1528             Conceptually you would use this method to get a list of known places to choose
1529             from first. Then, if the desired place doesn't exist, make a request to
1530             C<add_place> to create a new one.
1531            
1532             The token contained in the response is the token needed to be able to create a
1533             new place.
1534             EOT
1535              
1536                 path => 'geo/similar_places',
1537                 method => 'GET',
1538                 params => [qw/lat long name contained_within attribute:street_address callback/],
1539                 required => [qw/lat long name/],
1540                 returns => 'HashRef',
1541             );
1542              
1543             twitter_api_method add_place => (
1544                 description => <<'EOT',
1545             Creates a new place object at the given latitude and longitude.
1546            
1547             Before creating a place you need to query C<similar_places> with the latitude,
1548             longitude and name of the place you wish to create. The query will return an
1549             array of places which are similar to the one you wish to create, and a token.
1550             If the place you wish to create isn't in the returned array you can use the
1551             token with this method to create a new one.
1552             EOT
1553              
1554                 path => 'geo/place',
1555                 method => 'POST',
1556                 params => [qw/name contained_within token lat long attribute:street_address callback/],
1557                 required => [qw/name contained_within token lat long/],
1558                 returns => 'Place',
1559             );
1560              
1561             ## trends ##
1562              
1563             twitter_api_method trends_place => (
1564                 description => <<'',
1565             Returns the top 10 trending topics for a specific WOEID. The response is an
1566             array of "trend" objects that encode the name of the trending topic, the query
1567             parameter that can be used to search for the topic on Search, and the direct
1568             URL that can be issued against Search. This information is cached for five
1569             minutes, and therefore users are discouraged from querying these endpoints
1570             faster than once every five minutes. Global trends information is also
1571             available from this API by using a WOEID of 1.
1572            
1573                 path => 'trends/place',
1574                 aliases => [qw/trends_location/],
1575                 method => 'GET',
1576                 params => [qw/id exclude/],
1577                 required => [qw/id/],
1578                 returns => 'ArrayRef[Trend]',
1579             );
1580              
1581             # accept woeid parameter for backwards compatibility with old trends/location endpoint
1582             around trends_location => sub {
1583                 my $orig = shift;
1584                 my $self = shift;
1585              
1586                 carp "trends_location DEPRECATED: using trends_place({ id => ... }) instead";
1587              
1588                 my $args = ref $_[-1] eq ref {} ? pop : {};
1589                 $$args{id} = delete $$args{woeid} || shift;
1590              
1591                 return $self->$orig($args);
1592             };
1593              
1594             twitter_api_method trends_available => (
1595                 description => <<EOT,
1596             Returns the locations with trending topic information. The response is an
1597             array of "locations" that encode the location's WOEID (a Yahoo! Where On Earth
1598             ID L<http://developer.yahoo.com/geo/geoplanet/>) and some other human-readable
1599             information such as a the location's canonical name and country.
1600            
1601             For backwards compatibility, this method accepts optional C<lat> and C<long>
1602             parameters. You should call C<trends_closest> directly, instead.
1603            
1604             Use the WOEID returned in the location object to query trends for a specific
1605             location.
1606             EOT
1607              
1608                 path => 'trends/available',
1609                 method => 'GET',
1610                 params => [],
1611                 required => [],
1612                 returns => 'ArrayRef[Location]',
1613             );
1614              
1615             around trends_available => sub {
1616                 my $orig = shift;
1617                 my $self = shift;
1618              
1619                 my $args = ref $_[-1] eq ref {} ? pop : {};
1620              
1621                 my $method = exists $$args{lat} || exists $$args{long} ? 'trends_closest' : $orig;
1622              
1623                 return $self->$method(@_, $args);
1624             };
1625              
1626             twitter_api_method trends_closest => (
1627                 description => <<EOT,
1628             Returns the locations with trending topic information. The response is an array
1629             of "locations" that encode the location's WOEID (a Yahoo! Where On Earth ID
1630             L<http://developer.yahoo.com/geo/geoplanet/>) and some other human-readable
1631             information such as a the location's canonical name and country. The results
1632             are sorted by distance from that location, nearest to farthest.
1633            
1634             Use the WOEID returned in the location object to query trends for a specific
1635             location.
1636             EOT
1637              
1638                 path => 'trends/closest',
1639                 method => 'GET',
1640                 params => [qw/lat long/],
1641                 required => [],
1642                 returns => 'ArrayRef[Location]',
1643             );
1644              
1645             ## spam reporting ##
1646              
1647             twitter_api_method report_spam => (
1648                 description => <<'',
1649             The user specified in the id is blocked by the authenticated user and reported as a spammer.
1650            
1651                 path => 'users/report_spam',
1652                 method => 'POST',
1653                 params => [qw/user_id screen_name/],
1654                 required => [qw/id/],
1655                 returns => 'User',
1656             );
1657              
1658             twitter_api_method get_languages => (
1659                 description => <<'',
1660             Returns the list of languages supported by Twitter along with their ISO 639-1
1661             code. The ISO 639-1 code is the two letter value to use if you include lang
1662             with any of your requests.
1663            
1664                 path => 'help/languages',
1665                 method => 'GET',
1666                 params => [],
1667                 required => [],
1668                 returns => 'ArrayRef[Lanugage]',
1669             );
1670              
1671             ## Help ##
1672              
1673             twitter_api_method get_configuration => (
1674                 description => <<'EOT',
1675             Returns the current configuration used by Twitter including twitter.com slugs
1676             which are not usernames, maximum photo resolutions, and t.co URL lengths.
1677            
1678             It is recommended applications request this endpoint when they are loaded, but
1679             no more than once a day.
1680             EOT
1681              
1682                 path => 'help/configuration',
1683                 method => 'GET',
1684                 params => [],
1685                 required => [],
1686                 returns => 'HashRef',
1687             );
1688              
1689             twitter_api_method get_privacy_policy => (
1690                 description => <<'',
1691             Returns Twitter's privacy policy.
1692            
1693                 path => 'help/privacy',
1694                 method => 'GET',
1695                 params => [],
1696                 required => [],
1697                 returns => 'HashRef',
1698             );
1699              
1700             twitter_api_method get_tos => (
1701                 description => <<'',
1702             Returns the Twitter Terms of Service. These are not the same as the Developer
1703             Rules of the Road.
1704            
1705                 path => 'help/tos',
1706                 method => 'GET',
1707                 params => [],
1708                 required => [],
1709                 returns => 'HashRef',
1710             );
1711              
1712             twitter_api_method rate_limit_status => (
1713                 description => <<'EOT',
1714             Returns the remaining number of API requests available to the
1715             authenticated user before the API limit is reached for the current hour.
1716            
1717             Use C<< ->rate_limit_status({ authenticate => 0 }) >> to force an
1718             unauthenticated call, which will return the status for the IP address rather
1719             than the authenticated user. (Note: for a web application, this is the server's
1720             IP address.)
1721             EOT
1722              
1723                 path => 'application/rate_limit_status',
1724                 method => 'GET',
1725                 params => [qw/resources/],
1726                 required => [qw//],
1727                 returns => 'RateLimitStatus',
1728             );
1729              
1730             # translate resources arrayref to a comma separated string
1731             around rate_limit_status => sub {
1732                 my $orig = shift;
1733                 my $self = shift;
1734              
1735                 my $args = ref $_[-1] eq ref {} ? pop : {};
1736                 croak "too many arguments" if @_;
1737              
1738                 if ( exists $args->{resources} && ref $args->{resources} eq ref [] ) {
1739                     $args->{resources} = join ',' => @{$args->{resources}};
1740                 }
1741              
1742                 return $self->$orig($args);
1743             };
1744              
1745             twitter_api_method test => (
1746                 description => <<'',
1747             Returns the string "ok" status code.
1748            
1749                 path => 'account/verify_credentials',
1750                 method => 'GET',
1751                 params => [qw//],
1752                 required => [qw//],
1753                 returns => 'Hash',
1754                 deprecated => sub { carp "$_[0] DEPRECATED: using verify_credentials instead" },
1755             );
1756              
1757             ## not included in API v1.1 ##
1758              
1759             twitter_api_method retweeted_by_me => (
1760                 description => <<'',
1761             Returns the 20 most recent retweets posted by the authenticating user.
1762            
1763                 path => 'statuses/retweeted_by_me',
1764                 method => 'GET',
1765                 params => [qw/since_id max_id count page trim_user include_entities/],
1766                 booleans => [qw/trim_user include_entities/],
1767                 required => [],
1768                 returns => 'ArrayRef[Status]',
1769                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1770             );
1771              
1772             twitter_api_method retweeted_to_me => (
1773                 description => <<'',
1774             Returns the 20 most recent retweets posted by the authenticating user's friends.
1775            
1776                 path => 'statuses/retweeted_to_me',
1777                 method => 'GET',
1778                 params => [qw/since_id max_id count page/],
1779                 required => [],
1780                 returns => 'ArrayRef[Status]',
1781                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1782             );
1783              
1784             twitter_api_method retweets_of_me => (
1785                 description => <<'',
1786             Returns the 20 most recent tweets of the authenticated user that have been
1787             retweeted by others.
1788            
1789                 aliases => [qw/retweeted_of_me/],
1790                 path => 'statuses/retweets_of_me',
1791                 method => 'GET',
1792                 params => [qw/since_id max_id count trim_user include_entities include_user_entities/],
1793                 booleans => [qw/trim_user include_entities/],
1794                 required => [],
1795                 returns => 'ArrayRef[Status]',
1796             );
1797              
1798             twitter_api_method no_retweet_ids => (
1799                 description => <<'',
1800             Returns an ARRAY ref of user IDs for which the authenticating user does not
1801             want to receive retweets.
1802            
1803                 aliases => [qw/no_retweets_ids/],
1804                 path => 'friendships/no_retweets/ids',
1805                 method => 'GET',
1806                 params => [],
1807                 required => [],
1808                 returns => 'ArrayRef[UserIDs]',
1809             );
1810              
1811             twitter_api_method end_session => (
1812                 description => <<'',
1813             Ends the session of the authenticating user, returning a null cookie.
1814             Use this method to sign users out of client-facing applications like
1815             widgets.
1816            
1817                 path => 'account/end_session',
1818                 method => 'POST',
1819                 params => [qw//],
1820                 required => [qw//],
1821                 returns => 'Error', # HTTP Status: 200, error content. Silly!
1822                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1823             );
1824              
1825             twitter_api_method enable_notifications => (
1826                 description => <<'',
1827             Enables notifications for updates from the specified user to the
1828             authenticating user. Returns the specified user when successful.
1829            
1830                 path => 'notifications/follow/:id',
1831                 method => 'POST',
1832                 params => [qw/id screen_name include_entities/],
1833                 booleans => [qw/include_entities/],
1834                 required => [qw/id/],
1835                 returns => 'BasicUser',
1836                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1837             );
1838              
1839             around enable_notifications => sub {
1840                 my $orig = shift;
1841                 my $self = shift;
1842              
1843                 return $self->_enable_disable_notifications(1, @_);
1844             };
1845              
1846             sub _enable_disable_notifications {
1847 4     4   6     my $self = shift;
1848 4         5     my $enable = shift;
1849              
1850 4         14     carp "enable_notifications/disable_notifications DEPRECATED: using update_friendship instead";
1851              
1852 4 100       1353     my $args = ref $_[-1] eq ref {} ? pop : {};
1853 4         11     $$args{device} = $enable;
1854 4         14     return $self->update_friendship(@_, $args);
1855             };
1856              
1857             twitter_api_method disable_notifications => (
1858                 description => <<'',
1859             Disables notifications for updates from the specified user to the
1860             authenticating user. Returns the specified user when successful.
1861            
1862                 path => 'notifications/leave/:id',
1863                 method => 'POST',
1864                 params => [qw/id screen_name include_entities/],
1865                 booleans => [qw/include_entities/],
1866                 required => [qw/id/],
1867                 returns => 'BasicUser',
1868                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1869             );
1870              
1871             around disable_notifications => sub {
1872                 my $orig = shift;
1873                 my $self = shift;
1874              
1875                 return $self->_enable_disable_notifications(0, @_);
1876             };
1877              
1878             twitter_api_method block_exists => (
1879                 description => <<'',
1880             Returns if the authenticating user is blocking a target user. Will return the blocked user's
1881             object if a block exists, and error with HTTP 404 response code otherwise.
1882            
1883                 path => 'blocks/exists/:id',
1884                 method => 'GET',
1885                 params => [qw/id user_id screen_name include_entities/],
1886                 booleans => [qw/include_entities/],
1887                 required => [qw/id/],
1888                 returns => 'BasicUser',
1889                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1890             );
1891              
1892             twitter_api_method trends_current => (
1893                 description => <<'',
1894             Returns the current top ten trending topics on Twitter. The response includes
1895             the time of the request, the name of each trending topic, and query used on
1896             Twitter Search results page for that topic.
1897            
1898                 path => 'trends/current',
1899                 method => 'GET',
1900                 params => [qw/exclude/],
1901                 required => [qw//],
1902                 returns => 'HashRef',
1903                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1904             );
1905              
1906             around trends_current => sub {
1907                 my $orig = shift;
1908                 my $self = shift;
1909              
1910                 carp "trends_current DEPRECATED: using trends_place({ id => 1 }) instead";
1911              
1912                 my $args = ref $_[-1] eq ref {} ? pop : {};
1913                 $$args{id} = 1;
1914              
1915                 return $self->trends_place($args);
1916             };
1917              
1918             twitter_api_method trends_daily => (
1919                 description => <<'',
1920             Returns the top 20 trending topics for each hour in a given day.
1921            
1922                 path => 'trends/daily',
1923                 method => 'GET',
1924                 params => [qw/date exclude/],
1925                 required => [qw//],
1926                 returns => 'HashRef',
1927                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1928             );
1929              
1930             twitter_api_method trends_weekly => (
1931                 description => <<'',
1932             Returns the top 30 trending topics for each day in a given week.
1933            
1934                 path => 'trends/weekly',
1935                 method => 'GET',
1936                 params => [qw/date exclude/],
1937                 required => [qw//],
1938                 returns => 'HashRef',
1939                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1940             );
1941              
1942             twitter_api_method retweeted_by => (
1943                 description => <<'',
1944             Returns up to 100 users who retweeted the status identified by C<id>.
1945            
1946                 path => 'statuses/:id/retweeted_by',
1947                 method => 'GET',
1948                 params => [qw/id count page trim_user include_entities/],
1949                 booleans => [qw/include_entities trim_user/],
1950                 required => [qw/id/],
1951                 returns => 'ArrayRef[User]',
1952                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1953             );
1954              
1955             twitter_api_method retweeted_by_ids => (
1956                 description => <<'',
1957             Returns the IDs of up to 100 users who retweeted the status identified by C<id>.
1958            
1959                 path => 'statuses/:id/retweeted_by/ids',
1960                 method => 'GET',
1961                 params => [qw/id count page trim_user include_entities/],
1962                 booleans => [qw/include_entities trim_user/],
1963                 required => [qw/id/],
1964                 returns => 'ArrayRef[User]',
1965                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1966             );
1967              
1968             # new in 3.17001 2010-10-19
1969              
1970             twitter_api_method account_totals => (
1971                 description => <<'',
1972             Returns the current count of friends, followers, updates (statuses)
1973             and favorites of the authenticating user.
1974            
1975                 path => 'account/totals',
1976                 method => 'GET',
1977                 params => [],
1978                 required => [],
1979                 returns => 'HashRef',
1980                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1981             );
1982              
1983             twitter_api_method retweeted_to_user => (
1984                 description => <<'',
1985             Returns the 20 most recent retweets posted by users the specified user
1986             follows. The user is specified using the user_id or screen_name
1987             parameters. This method is identical to C<retweeted_to_me>
1988             except you can choose the user to view.
1989             Does not require authentication, unless the user is protected.
1990            
1991                 path => 'statuses/retweeted_to_user',
1992                 method => 'GET',
1993                 params => [qw/id user_id screen_name/],
1994                 required => [qw/id/],
1995                 returns => 'ArrayRef',
1996                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
1997             );
1998              
1999             twitter_api_method retweeted_by_user => (
2000                 description => <<'',
2001             Returns the 20 most recent retweets posted by the specified user. The user is
2002             specified using the user_id or screen_name parameters. This method is identical
2003             to C<retweeted_by_me> except you can choose the user to view. Does not require
2004             authentication, unless the user is protected.
2005            
2006                 path => 'statuses/retweeted_by_user',
2007                 method => 'GET',
2008                 params => [qw/id user_id screen_name/],
2009                 required => [qw/id/],
2010                 returns => 'ArrayRef',
2011                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
2012             );
2013              
2014             twitter_api_method related_results => (
2015                 description => <<'',
2016             If available, returns an array of replies and mentions related to the specified
2017             status. There is no guarantee there will be any replies or mentions in the
2018             response. This method is only available to users who have access to
2019             #newtwitter. Requires authentication.
2020            
2021                 path => 'related_results/show/:id',
2022                 method => 'GET',
2023                 params => [qw/id/],
2024                 required => [qw/id/],
2025                 returns => 'ArrayRef[Status]',
2026                 deprecated => sub { croak "$_[0] not available in Twitter API V1.1" },
2027             );
2028              
2029             twitter_api_method remove_profile_banner => (
2030                 description => <<'',
2031             Removes the uploaded profile banner for the authenticating user.
2032            
2033                 path => 'account/remove_profile_banner',
2034                 method => 'POST',
2035                 params => [qw//],
2036                 required => [qw//],
2037                 returns => 'Nothing',
2038             );
2039              
2040             twitter_api_method update_profile_banner => (
2041                 description => <<'EOT',
2042             Uploads a profile banner on behalf of the authenticating user. The C<image>
2043             parameter is an arrayref with the following interpretation:
2044            
2045             [ $file ]
2046             [ $file, $filename ]
2047             [ $file, $filename, Content_Type => $mime_type ]
2048             [ undef, $filename, Content_Type => $mime_type, Content => $raw_image_data ]
2049            
2050             The first value of the array (C<$file>) is the name of a file to open. The
2051             second value (C<$filename>) is the name given to Twitter for the file. If
2052             C<$filename> is not provided, the basename portion of C<$file> is used. If
2053             C<$mime_type> is not provided, it will be provided automatically using
2054             L<LWP::MediaTypes::guess_media_type()>.
2055            
2056             C<$raw_image_data> can be provided, rather than opening a file, by passing
2057             C<undef> as the first array value.
2058             EOT
2059              
2060                 path => 'account/update_profile_banner',
2061                 method => 'POST',
2062                 params => [qw/banner width height offset_left offset_top/],
2063                 required => [qw/banner/],
2064                 returns => 'Nothing',
2065             );
2066              
2067             twitter_api_method profile_banner => (
2068                 description => <<'',
2069             Returns a hash reference mapping available size variations to URLs that can be
2070             used to retrieve each variation of the banner.
2071            
2072                 path => 'users/profile_banner',
2073                 method => 'GET',
2074                 params => [qw/user_id screen_name/],
2075                 required => [qw//],
2076                 returns => 'HashRef',
2077             );
2078              
2079             twitter_api_method mutes => (
2080                 description => <<'',
2081             Returns an array of numeric user ids the authenticating user has muted.
2082            
2083                 path => 'mutes/users/ids',
2084                 aliases => [qw/muting_ids muted_ids/],
2085                 method => 'GET',
2086                 params => [qw/cursor/],
2087                 required => [qw//],
2088                 booleans => [qw//],
2089                 returns => 'ArrayRef[Int]',
2090             );
2091              
2092             twitter_api_method muting => (
2093                 description => <<'',
2094             Returns an array of user objects that the authenticating user is muting.
2095            
2096                 path => 'mutes/users/list',
2097                 aliases => [qw/mutes_list/],
2098                 method => 'GET',
2099                 params => [qw/cursor include_entities skip_status/],
2100                 required => [qw//],
2101                 returns => 'ArrayRef[BasicUser]',
2102             );
2103              
2104             twitter_api_method create_mute => (
2105                 description => <<'',
2106             Mutes the user specified in the C<user_id> or C<screen_name> parameter as the
2107             authenticating user. Returns the muted user when successful. You can find
2108             out more about muting in the Twitter Support Knowledge Base.
2109            
2110                 path => 'mutes/users/create',
2111                 method => 'POST',
2112                 params => [qw/user_id screen_name/],
2113                 booleans => [qw//],
2114                 required => [qw/id/],
2115                 returns => 'BasicUser',
2116             );
2117              
2118             twitter_api_method destroy_mute => (
2119                 description => <<'',
2120             Un-mutes the user specified in the C<user_id> or C<screen_name> parameter as
2121             the authenticating user. Returns the un-muted user when successful.
2122            
2123                 path => 'mutes/users/destroy',
2124                 method => 'POST',
2125                 params => [qw/user_id screen_name/],
2126                 booleans => [qw//],
2127                 required => [qw/id/],
2128                 returns => 'BasicUser',
2129             );
2130              
2131             twitter_api_method lookup_statuses => (
2132                 description => <<'',
2133             Returns a hash reference of tweets from an arbitrary set of ids.
2134            
2135                 path => 'statuses/lookup',
2136                 method => 'GET',
2137                 params => [qw/id include_entities trim_user map/],
2138                 required => [qw/id/],
2139                 returns => 'HashRef',
2140             );
2141              
2142             twitter_api_method create_media_metadata => (
2143                 path => 'media/metadata/create',
2144                 method => 'POST',
2145                 params => [qw/media_id alt_text/],
2146                 required => [qw/media_id/],
2147                 returns => 'HashRef',
2148                 content_type => 'application/json',
2149                 description => <<'EOT',
2150             Adds metadata -- alt text, in particular -- to a previously uploaded media
2151             object, specified by its ID. (One knows this ID via the return value of the
2152             preceding C<upload> call.)
2153            
2154             The C<alt_text> parameter must have as its value a hashref containing a single
2155             key-value pair. The key must be C<text>, and the value is the alt text to assign
2156             to the media object. The text must be 400 characters or fewer in length.
2157             EOT
2158             );
2159              
2160             # infer screen_name or user_id from positional args for backwards compatibility
2161             # and convenience
2162             around [qw/
2163             show_user
2164             create_friend
2165             follow_new
2166             destroy_friend
2167             unfollow
2168             friends_ids
2169             following_ids
2170             followers_ids
2171             create_block
2172             destroy_block
2173             block_exists
2174             report_spam
2175             retweeted_by_user
2176             update_friendship
2177             /] => sub {
2178                 my $orig = shift;
2179                 my $self = shift;
2180              
2181                 my $args = ref $_[-1] eq ref {} ? pop : {};
2182                 if ( @_ && !exists $$args{user_id} && !exists $$args{screen_name} ) {
2183                     my $id = shift;
2184                     $$args{$id =~ /^\d+\$/ ? 'user_id' : 'screen_name' } = $id;
2185                 }
2186              
2187                 return $self->$orig(@_, $args);
2188             };
2189              
2190             1;
2191              
2192             __END__
2193            
2194            
2195             =head1 NAME
2196            
2197             Net::Twitter::Role::API::RESTv1_1 - A definition of the Twitter REST API v1.1 as a Moose role
2198            
2199             =head1 VERSION
2200            
2201             version 4.01043
2202            
2203             =head1 SYNOPSIS
2204            
2205             package My::Twitter;
2206             use Moose;
2207             with 'Net::Twitter::API::RESTv1_1';
2208            
2209             =head1 DESCRIPTION
2210            
2211             B<Net::Twitter::Role::API::RESTv1_1> provides definitions for all the Twitter REST API
2212             v1.1 methods. Applying this role to any class provides methods for all of the
2213             Twitter REST API methods.
2214            
2215            
2216             =head1 AUTHOR
2217            
2218             Marc Mims <marc@questright.com>
2219            
2220             =head1 LICENSE
2221            
2222             Copyright (c) 2016 Marc Mims
2223            
2224             The Twitter API itself, and the description text used in this module is:
2225            
2226             Copyright (c) 2009 Twitter
2227            
2228             This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2229            
2230             =head1 DISCLAIMER OF WARRANTY
2231            
2232             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
2233             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
2234             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
2235             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
2236             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2237             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
2238             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
2239             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
2240             NECESSARY SERVICING, REPAIR, OR CORRECTION.
2241            
2242             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
2243             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
2244             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
2245             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
2246             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
2247             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
2248             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
2249             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
2250             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
2251             SUCH DAMAGES.
2252