File Coverage

blib/lib/WebService/Dropbox/Sharing.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 2 0.0
condition n/a
subroutine 4 8 50.0
pod 0 4 0.0
total 16 41 39.0


line stmt bran cond sub pod time code
1             package WebService::Dropbox::Sharing;
2 10     10   65 use strict;
  10         21  
  10         281  
3 10     10   50 use warnings;
  10         25  
  10         317  
4 10     10   51 use parent qw(Exporter);
  10         28  
  10         49  
5              
6             ## preliminary version with support for creating and managing links
7             ## to shared files. more to follow...
8              
9             our @EXPORT = do {
10 10     10   649 no strict 'refs';
  10         21  
  10         3155  
11             grep { $_ =~ qr{ \A [a-z] }xms } keys %{ __PACKAGE__ . '::' };
12             };
13              
14             # https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings
15             sub create_shared_link_with_settings {
16 0     0 0   my ($self, $path, $settings) = @_;
17              
18 0           my $params = {
19             path => $path,
20             settings => $settings,
21             };
22              
23 0           $self->api({
24             url => 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings',
25             params => $params,
26             });
27             }
28              
29             # https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links
30             sub list_shared_links {
31 0     0 0   my ($self, $path) = @_;
32              
33 0           my $params = {
34             path => $path,
35             };
36              
37 0           $self->api({
38             url => 'https://api.dropboxapi.com/2/sharing/list_shared_links',
39             params => $params,
40             });
41             }
42              
43             # https://www.dropbox.com/developers/documentation/http/documentation#sharing-modify_shared_link_settings
44             sub modify_shared_link_settings {
45 0     0 0   my ($self, $path, $settings, $remove_expiration) = @_;
46              
47             # this assumes the api converts 1 and 0 to JSON::true and JSON::false accordingly
48 0 0         if ($remove_expiration) {
49 0           $remove_expiration = 1;
50             } else {
51 0           $remove_expiration = 0;
52             }
53              
54 0           my $params = {
55             path => $path,
56             settings => $settings,
57             remove_expiration => $remove_expiration,
58             };
59              
60 0           $self->api({
61             url => 'https://api.dropboxapi.com/2/sharing/modify_shared_link_settings',
62             params => $params,
63             });
64             }
65              
66             # https://www.dropbox.com/developers/documentation/http/documentation#sharing-revoke_shared_link
67             sub revoke_shared_link {
68 0     0 0   my ($self, $url) = @_;
69              
70 0           my $params = {
71             url => $url,
72             };
73              
74 0           $self->api({
75             url => 'https://api.dropboxapi.com/2/sharing/revoke_shared_link',
76             params => $params,
77             });
78             }
79              
80             1;