File Coverage

lib/Google/RestApi/DriveApi3.pm
Criterion Covered Total %
statement 24 28 85.7
branch 1 2 50.0
condition n/a
subroutine 7 8 87.5
pod 0 5 0.0
total 32 43 74.4


line stmt bran cond sub pod time code
1             package Google::RestApi::DriveApi3;
2              
3             our $VERSION = '1.0.4';
4              
5 1     1   573 use Google::RestApi::Setup;
  1         2  
  1         7  
6              
7 1     1   13671 use aliased 'Google::RestApi::DriveApi3::File';
  1         9  
  1         8  
8              
9             # TODO: switch to ReadOnly
10             use constant {
11 1         470 Drive_Endpoint => "https://www.googleapis.com/drive/v3",
12             Drive_File_Id => "[a-zA-Z0-9-_]+",
13 1     1   99 };
  1         5  
14              
15             sub new {
16 10     10 0 21 my $class = shift;
17 10         24 state $check = compile_named(
18             api => HasApi,
19             endpoint => Str, { default => Drive_Endpoint },
20             );
21 10         3301 return bless $check->(@_), $class;
22             }
23              
24             sub api {
25 20     20 0 46 my $self = shift;
26 20         36 state $check = compile_named(
27             uri => Str, { optional => 1 },
28             _extra_ => slurpy Any,
29             );
30 20         4083 my $p = named_extra($check->(@_));
31 20         110 my $uri = "$self->{endpoint}/";
32 20 50       97 $uri .= delete $p->{uri} if defined $p->{uri};
33 20         108 return $self->{api}->api(%$p, uri => $uri);
34             }
35              
36             sub filter_files {
37 9     9 0 22 my $self = shift;
38 9         22 state $check = compile(Str, HashRef, { default => {} });
39 9         3099 my ($filter, $params) = $check->(@_);
40 9         185 $params->{'q'} = $filter;
41 9         34 return $self->api(params => $params, uri => 'files');
42             }
43              
44             sub upload_endpoint {
45 0     0 0 0 my $self = shift;
46 0         0 my $upload = $self->{endpoint};
47 0         0 $upload =~ s|googleapis.com/|googleapis.com/upload/|;
48 0         0 return $upload;
49             }
50              
51 11     11 0 69 sub file { File->new(drive => shift, @_); }
52              
53             1;
54              
55             __END__
56              
57             =head1 NAME
58              
59             Google::RestApi::DriveApi3 - API to Google Drive API V3.
60              
61             =head1 DESCRIPTION
62              
63             This API has been minimally developed to support the SheetsApi4 API in this
64             same package. Is it very incomplete and has no direct tests other than what
65             the SheetsApi4 package tests. It will be filled out and completed in due
66             course. Pull requests welcome.
67              
68             =head1 AUTHORS
69              
70             =over
71              
72             =item
73              
74             Robin Murray mvsjes@cpan.org
75              
76             =back
77              
78             =head1 COPYRIGHT
79              
80             Copyright (c) 2021, Robin Murray. All rights reserved.
81              
82             This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.