File Coverage

blib/lib/WebService/Dropbox/Files.pm
Criterion Covered Total %
statement 12 74 16.2
branch 0 16 0.0
condition n/a
subroutine 4 22 18.1
pod 0 18 0.0
total 16 130 12.3


line stmt bran cond sub pod time code
1             package WebService::Dropbox::Files;
2 10     10   84 use strict;
  10         23  
  10         371  
3 10     10   43 use warnings;
  10         20  
  10         510  
4 10     10   47 use parent qw(Exporter);
  10         14  
  10         55  
5              
6             our @EXPORT = do {
7 10     10   810 no strict 'refs';
  10         17  
  10         9673  
8             grep { $_ =~ qr{ \A [a-z] }xms } keys %{ __PACKAGE__ . '::' };
9             };
10              
11             # https://www.dropbox.com/developers/documentation/http/documentation#files-copy
12             sub copy {
13 0     0 0   my ($self, $from_path, $to_path) = @_;
14              
15 0           my $params = {
16             from_path => $from_path,
17             to_path => $to_path,
18             };
19              
20 0           $self->api({
21             url => 'https://api.dropboxapi.com/2/files/copy',
22             params => $params,
23             });
24             }
25              
26             # https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder
27             sub create_folder {
28 0     0 0   my ($self, $path) = @_;
29              
30 0           my $params = {
31             path => $path,
32             };
33              
34 0           $self->api({
35             url => 'https://api.dropboxapi.com/2/files/create_folder',
36             params => $params,
37             });
38             }
39              
40             # https://www.dropbox.com/developers/documentation/http/documentation#files-delete
41             sub delete {
42 0     0 0   my ($self, $path) = @_;
43              
44 0           my $params = {
45             path => $path,
46             };
47              
48 0           $self->api({
49             url => 'https://api.dropboxapi.com/2/files/delete',
50             params => $params,
51             });
52             }
53              
54             # https://www.dropbox.com/developers/documentation/http/documentation#files-delete_batch
55             sub delete_batch {
56 0     0 0   my ($self, $paths) = @_;
57              
58             my $params = {
59 0           entries => [map {+{path => $_}} @$paths],
  0            
60             };
61              
62 0           $self->api({
63             url => 'https://api.dropboxapi.com/2/files/delete_batch',
64             params => $params,
65             });
66             }
67              
68             # https://www.dropbox.com/developers/documentation/http/documentation#files-delete_batch-check
69             sub delete_batch_check {
70 0     0 0   my ($self, $job_id) = @_;
71              
72 0           my $params = {
73             async_job_id => $job_id,
74             };
75              
76 0           $self->api({
77             url => 'https://api.dropboxapi.com/2/files/delete_batch/check',
78             params => $params,
79             });
80             }
81              
82             # https://www.dropbox.com/developers/documentation/http/documentation#files-download
83             sub download {
84 0     0 0   my ($self, $path, $output, $opts) = @_;
85              
86             $self->api({
87             url => 'https://content.dropboxapi.com/2/files/download',
88             params => { path => $path },
89             output => $output,
90 0 0         %{ $opts || +{} },
  0            
91             });
92             }
93              
94             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
95             sub get_metadata {
96 0     0 0   my ($self, $path, $optional_params) = @_;
97              
98             my $params = {
99             path => $path,
100 0 0         %{ $optional_params || {} },
  0            
101             };
102              
103 0           $self->api({
104             url => 'https://api.dropboxapi.com/2/files/get_metadata',
105             params => $params,
106             });
107             }
108              
109             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_preview
110             sub get_preview {
111 0     0 0   my ($self, $path, $output, $opts) = @_;
112              
113 0           my $params = {
114             path => $path,
115             };
116              
117             $self->api({
118             url => 'https://content.dropboxapi.com/2/files/get_preview',
119             params => $params,
120             output => $output,
121 0 0         %{ $opts || +{} },
  0            
122             });
123             }
124              
125             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link
126             sub get_temporary_link {
127 0     0 0   my ($self, $path) = @_;
128              
129 0           my $params = {
130             path => $path,
131             };
132              
133 0           $self->api({
134             url => 'https://api.dropboxapi.com/2/files/get_temporary_link',
135             params => $params,
136             });
137             }
138              
139             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail
140             sub get_thumbnail {
141 0     0 0   my ($self, $path, $output, $optional_params, $opts) = @_;
142              
143             my $params = {
144             path => $path,
145 0 0         %{ $optional_params || {} },
  0            
146             };
147              
148             $self->api({
149             url => 'https://content.dropboxapi.com/2/files/get_thumbnail',
150             params => $params,
151             output => $output,
152 0 0         %{ $opts || +{} },
  0            
153             });
154             }
155              
156             # https://www.dropbox.com/developers/documentation/http/documentation#files-list_revisions
157             sub list_revisions {
158 0     0 0   my ($self, $path, $optional_params) = @_;
159              
160             my $params = {
161             path => $path,
162 0 0         %{ $optional_params || {} },
  0            
163             };
164              
165 0           $self->api({
166             url => 'https://api.dropboxapi.com/2/files/list_revisions',
167             params => $params,
168             });
169             }
170              
171             # https://www.dropbox.com/developers/documentation/http/documentation#files-move
172             sub move {
173 0     0 0   my ($self, $from_path, $to_path) = @_;
174              
175 0           my $params = {
176             from_path => $from_path,
177             to_path => $to_path,
178             };
179              
180 0           $self->api({
181             url => 'https://api.dropboxapi.com/2/files/move',
182             params => $params,
183             });
184             }
185              
186             # https://www.dropbox.com/developers/documentation/http/documentation#files-permanently_delete
187             sub permanently_delete {
188 0     0 0   my ($self, $path) = @_;
189              
190 0           my $params = {
191             path => $path,
192             };
193              
194 0           $self->api({
195             url => 'https://api.dropboxapi.com/2/files/permanently_delete',
196             params => $params,
197             });
198             }
199              
200             # https://www.dropbox.com/developers/documentation/http/documentation#files-restore
201             sub restore {
202 0     0 0   my ($self, $path, $rev) = @_;
203              
204 0           my $params = {
205             path => $path,
206             rev => $rev,
207             };
208              
209 0           $self->api({
210             url => 'https://api.dropboxapi.com/2/files/restore',
211             params => $params,
212             });
213             }
214              
215             # https://www.dropbox.com/developers/documentation/http/documentation#files-save_url
216             sub save_url {
217 0     0 0   my ($self, $path, $url) = @_;
218              
219 0           my $params = {
220             path => $path,
221             url => $url,
222             };
223              
224 0           $self->api({
225             url => 'https://api.dropboxapi.com/2/files/save_url',
226             params => $params,
227             });
228             }
229              
230             # https://www.dropbox.com/developers/documentation/http/documentation#files-save_url-check_job_status
231             sub save_url_check_job_status {
232 0     0 0   my ($self, $async_job_id) = @_;
233              
234 0           my $params = {
235             async_job_id => $async_job_id,
236             };
237              
238 0           $self->api({
239             url => 'https://api.dropboxapi.com/2/files/save_url/check_job_status',
240             params => $params,
241             });
242             }
243              
244             # https://www.dropbox.com/developers/documentation/http/documentation#files-search
245             sub search {
246 0     0 0   my ($self, $path, $query, $optional_params) = @_;
247              
248             my $params = {
249             path => $path,
250             query => $query,
251 0 0         %{ $optional_params || {} },
  0            
252             };
253              
254 0           $self->api({
255             url => 'https://api.dropboxapi.com/2/files/search',
256             params => $params,
257             });
258             }
259              
260             # https://www.dropbox.com/developers/documentation/http/documentation#files-upload
261             sub upload {
262 0     0 0   my ($self, $path, $content, $optional_params) = @_;
263              
264             my $params = {
265             path => $path,
266 0 0         %{ $optional_params || {} },
  0            
267             };
268              
269 0           $self->api({
270             url => 'https://content.dropboxapi.com/2/files/upload',
271             params => $params,
272             content => $content,
273             });
274             }
275              
276             1;