Google-Client-Collection

 view release on metacpan or  search on metacpan

lib/Google/Client/Files.pm  view on Meta::CPAN

    confess("No ID provided") unless ($id);
    my $url = $self->_url("/$id");
    $self->_request(
        method => 'DELETE',
        url => $url
    );
    return 1;
}

sub empty_trash {
    my ($self) = @_;
    $self->_request(
        method => 'DELETE',
        url => $self->_url('/trash')
    );
    return 1;
}

sub export {
    my ($self, $id, $params) = @_;
    confess("No ID provided") unless ($id);
    confess("mimeType is a required param to export files") unless ($params->{mimeType});
    my $url = $self->_url("/$id/export", $params);
    my $decoded_content = $self->_request(
        method => 'GET',
        url => $url
    );
    return $decoded_content;
}

sub generate_ids {
    my ($self, $params) = @_;
    my $url = $self->_url('/generateIds', $params);
    my $json = $self->_request(
        method => 'GET',
        url => $url
    );
    return $json;
}

sub get {
    my ($self, $id, $params) = @_;
    confess("No ID provided") unless ($id);
    my $url = $self->_url("/$id", $params);
    my $json = $self->_request(
        method => 'GET',
        url => $url
    );
}

sub list {
    my ($self, $params) = @_;
    my $url = $self->_url(undef, $params);
    my $json = $self->_request(
        method => 'GET',
        url => $url
    );
    return $json;
}

sub update_media {
    my ($self, $id, $params, $content) = @_;
    confess("No ID provided") unless ($id);
    unless ( $content && %$content ) {
        confess("No content provided to update");
    }
    my $url = $self->_url("/upload/drive/v3/files/$id", $params);
    my $json = $self->_request(
        method => 'PATCH',
        url => $url,
        content => encode_json($content)
    );
    return $json;
}

sub update {
    my ($self, $id, $params, $content) = @_;
    confess("No ID provided") unless ($id);
    unless ( $content && %$content ) {
        confess("No content provided to update");
    }
    my $url = $self->_url("/$id", $params);
    my $json = $self->_request(
        method => 'PATCH',
        url => $url,
        content => encode_json($content)
    );
    return $json;
}

sub watch {
    my ($self, $id, $params, $content) = @_;
    confess("No ID provided") unless ($id);
    my $url = $self->_url("/$id/watch", $params);
    $content = $content ? encode_json($content) : undef;
    my $json = $self->_request(
        method => 'POST',
        url => $url,
        content => $content
    );
    return $json;
}

=head1 NAME

Google::Client::Files

=head1 DESCRIPTION

A file resource client used in L<Google::Client::Collection|https://metacpan.org/pod/Google::Client::Collection> to integrate with
Googles Files REST API.

See L<https://developers.google.com/drive/v3/reference/files> for documentation.

=head2 copy(Str $id, HashRef $query_params, HashRef $post_content)

=head2 create(HashRef $query_params, HashRef $post_content)

=head2 create_media(HashRef $query_params, HashRef $post_content)

=head2 delete(Str $id)

=head2 empty_trash()

=head2 export(Str $id, HashRef $query_params)

=head2 generate_ids(HashRef $query_params)

=head2 get(Str $id, HashRef $query_params)

=head2 list(HashRef $query_params)

=head2 update(Str $id, HashRef $query_params, HashRef $post_content)

=head2 update_media(Str $id, HashRef $query_params, HashRef $post_content)



( run in 0.632 second using v1.01-cache-2.11-cpan-e1769b4cff6 )