our
$VERSION
=
'1.0.4'
;
Drive_File_Id
=>
"[a-zA-Z0-9-_]+"
,
};
sub
new {
my
$class
=
shift
;
state
$check
= compile_named(
api
=> HasApi,
endpoint
=> Str, {
default
=> Drive_Endpoint },
);
return
bless
$check
->(
@_
),
$class
;
}
sub
api {
my
$self
=
shift
;
state
$check
= compile_named(
uri
=> Str, {
optional
=> 1 },
_extra_
=> slurpy Any,
);
my
$p
= named_extra(
$check
->(
@_
));
my
$uri
=
"$self->{endpoint}/"
;
$uri
.=
delete
$p
->{uri}
if
defined
$p
->{uri};
return
$self
->{api}->api(
%$p
,
uri
=>
$uri
);
}
sub
filter_files {
my
$self
=
shift
;
state
$check
= compile(Str, HashRef, {
default
=> {} });
my
(
$filter
,
$params
) =
$check
->(
@_
);
$params
->{
'q'
} =
$filter
;
return
$self
->api(
params
=>
$params
,
uri
=>
'files'
);
}
sub
upload_endpoint {
my
$self
=
shift
;
my
$upload
=
$self
->{endpoint};
$upload
=~ s|googleapis.com/|googleapis.com/upload/|;
return
$upload
;
}
sub
file { File->new(
drive
=>
shift
,
@_
); }
1;