File Coverage

blib/lib/WebService/Dropbox/Files.pm
Criterion Covered Total %
statement 12 67 17.9
branch 0 16 0.0
condition n/a
subroutine 4 20 20.0
pod 0 16 0.0
total 16 119 13.4


line stmt bran cond sub pod time code
1             package WebService::Dropbox::Files;
2 10     10   70 use strict;
  10         22  
  10         296  
3 10     10   48 use warnings;
  10         37  
  10         310  
4 10     10   51 use parent qw(Exporter);
  10         20  
  10         51  
5              
6             our @EXPORT = do {
7 10     10   642 no strict 'refs';
  10         23  
  10         9138  
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-download
55             sub download {
56 0     0 0   my ($self, $path, $output, $opts) = @_;
57              
58             $self->api({
59             url => 'https://content.dropboxapi.com/2/files/download',
60             params => { path => $path },
61             output => $output,
62 0 0         %{ $opts || +{} },
  0            
63             });
64             }
65              
66             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
67             sub get_metadata {
68 0     0 0   my ($self, $path, $optional_params) = @_;
69              
70             my $params = {
71             path => $path,
72 0 0         %{ $optional_params || {} },
  0            
73             };
74              
75 0           $self->api({
76             url => 'https://api.dropboxapi.com/2/files/get_metadata',
77             params => $params,
78             });
79             }
80              
81             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_preview
82             sub get_preview {
83 0     0 0   my ($self, $path, $output, $opts) = @_;
84              
85 0           my $params = {
86             path => $path,
87             };
88              
89             $self->api({
90             url => 'https://content.dropboxapi.com/2/files/get_preview',
91             params => $params,
92             output => $output,
93 0 0         %{ $opts || +{} },
  0            
94             });
95             }
96              
97             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link
98             sub get_temporary_link {
99 0     0 0   my ($self, $path) = @_;
100              
101 0           my $params = {
102             path => $path,
103             };
104              
105 0           $self->api({
106             url => 'https://api.dropboxapi.com/2/files/get_temporary_link',
107             params => $params,
108             });
109             }
110              
111             # https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail
112             sub get_thumbnail {
113 0     0 0   my ($self, $path, $output, $optional_params, $opts) = @_;
114              
115             my $params = {
116             path => $path,
117 0 0         %{ $optional_params || {} },
  0            
118             };
119              
120             $self->api({
121             url => 'https://content.dropboxapi.com/2/files/get_thumbnail',
122             params => $params,
123             output => $output,
124 0 0         %{ $opts || +{} },
  0            
125             });
126             }
127              
128             # https://www.dropbox.com/developers/documentation/http/documentation#files-list_revisions
129             sub list_revisions {
130 0     0 0   my ($self, $path, $optional_params) = @_;
131              
132             my $params = {
133             path => $path,
134 0 0         %{ $optional_params || {} },
  0            
135             };
136              
137 0           $self->api({
138             url => 'https://api.dropboxapi.com/2/files/list_revisions',
139             params => $params,
140             });
141             }
142              
143             # https://www.dropbox.com/developers/documentation/http/documentation#files-move
144             sub move {
145 0     0 0   my ($self, $from_path, $to_path) = @_;
146              
147 0           my $params = {
148             from_path => $from_path,
149             to_path => $to_path,
150             };
151              
152 0           $self->api({
153             url => 'https://api.dropboxapi.com/2/files/move',
154             params => $params,
155             });
156             }
157              
158             # https://www.dropbox.com/developers/documentation/http/documentation#files-permanently_delete
159             sub permanently_delete {
160 0     0 0   my ($self, $path) = @_;
161              
162 0           my $params = {
163             path => $path,
164             };
165              
166 0           $self->api({
167             url => 'https://api.dropboxapi.com/2/files/permanently_delete',
168             params => $params,
169             });
170             }
171              
172             # https://www.dropbox.com/developers/documentation/http/documentation#files-restore
173             sub restore {
174 0     0 0   my ($self, $path, $rev) = @_;
175              
176 0           my $params = {
177             path => $path,
178             rev => $rev,
179             };
180              
181 0           $self->api({
182             url => 'https://api.dropboxapi.com/2/files/restore',
183             params => $params,
184             });
185             }
186              
187             # https://www.dropbox.com/developers/documentation/http/documentation#files-save_url
188             sub save_url {
189 0     0 0   my ($self, $path, $url) = @_;
190              
191 0           my $params = {
192             path => $path,
193             url => $url,
194             };
195              
196 0           $self->api({
197             url => 'https://api.dropboxapi.com/2/files/save_url',
198             params => $params,
199             });
200             }
201              
202             # https://www.dropbox.com/developers/documentation/http/documentation#files-save_url-check_job_status
203             sub save_url_check_job_status {
204 0     0 0   my ($self, $async_job_id) = @_;
205              
206 0           my $params = {
207             async_job_id => $async_job_id,
208             };
209              
210 0           $self->api({
211             url => 'https://api.dropboxapi.com/2/files/save_url/check_job_status',
212             params => $params,
213             });
214             }
215              
216             # https://www.dropbox.com/developers/documentation/http/documentation#files-search
217             sub search {
218 0     0 0   my ($self, $path, $query, $optional_params) = @_;
219              
220             my $params = {
221             path => $path,
222             query => $query,
223 0 0         %{ $optional_params || {} },
  0            
224             };
225              
226 0           $self->api({
227             url => 'https://api.dropboxapi.com/2/files/search',
228             params => $params,
229             });
230             }
231              
232             # https://www.dropbox.com/developers/documentation/http/documentation#files-upload
233             sub upload {
234 0     0 0   my ($self, $path, $content, $optional_params) = @_;
235              
236             my $params = {
237             path => $path,
238 0 0         %{ $optional_params || {} },
  0            
239             };
240              
241 0           $self->api({
242             url => 'https://content.dropboxapi.com/2/files/upload',
243             params => $params,
244             content => $content,
245             });
246             }
247              
248             1;