Commit 21472005 authored by Mike Jones's avatar Mike Jones 🌶

Split Compliance into Compliance and Compliance::Report

parent e9ce0cbb
Pipeline #51 passed with stage
This diff is collapsed.
......@@ -5,6 +5,7 @@ use Types::Standard qw(Str InstanceOf Int Maybe);
extends 'WebService::Mattermost::V4::API::Object';
with qw(
WebService::Mattermost::V4::API::Object::Role::APIMethods
WebService::Mattermost::V4::API::Object::Role::ID
WebService::Mattermost::V4::API::Object::Role::Status
WebService::Mattermost::V4::API::Object::Role::CreatedAt
......@@ -23,6 +24,17 @@ has [ qw(
################################################################################
sub BUILD {
my $self = shift;
$self->api_resource_name('compliance_report');
$self->available_api_methods([ 'download' ]);
return 1;
}
################################################################################
sub _build_count {
my $self = shift;
......@@ -76,6 +88,17 @@ WebService::Mattermost::V4::API::Object::Compliance::Report
=head1 DESCRIPTION
See matching methods in C<WebService::Mattermost::V4::API::Resource::Compliance::Report>
for full documentation.
ID parameters are not required:
my $response = $mattermost->api->compliance_report->get('ID-HERE')->item->download();
Is the same as:
my $response = $mattermost->api->compliance_report->download('ID-HERE');
=head2 ATTRIBUTES
=over 4
......@@ -104,6 +127,8 @@ WebService::Mattermost::V4::API::Object::Compliance::Report
=over 4
=item C<WebService::Mattermost::V4::API::Resource::Compliance::Report>
=item C<WebService::Mattermost::V4::API::Object::Role::ID>
=item C<WebService::Mattermost::V4::API::Object::Role::Status>
......
......@@ -11,14 +11,6 @@ has view_name => (is => 'ro', isa => Str, default => 'Compliance::Report');
################################################################################
around [ qw(get_report_by_id download_report_by_id) ] => sub {
my $orig = shift;
my $self = shift;
my $id = shift;
return $self->validate_id($orig, $id, @_);
};
sub create_report {
my $self = shift;
......@@ -36,28 +28,6 @@ sub get_reports {
});
}
sub get_report_by_id {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
view => 'Compliance::Report',
endpoint => 'reports/%s',
ids => [ $id ],
});
}
sub download_report_by_id {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
view => 'Compliance::Report',
endpoint => 'reports/%s/download',
ids => [ $id ],
});
}
################################################################################
1;
......@@ -102,18 +72,6 @@ Get all compliance reports.
per_page => 60,
});
=item C<get_report_by_id()>
Get a compliance report by its ID.
my $response = $resource->get_report_by_id('REPORT-ID-HERE');
=item C<download_report_by_id()>
Download a compliance report by its ID.
my $response = $resource->download_report_by_id('REPORT-ID-HERE');
=back
=head1 SEE ALSO
......
package WebService::Mattermost::V4::API::Resource::Compliance::Report;
use Moo;
use Types::Standard 'Str';
extends 'WebService::Mattermost::V4::API::Resource';
################################################################################
has view_name => (is => 'ro', isa => Str, default => 'Compliance::Report');
################################################################################
around [ qw(get download) ] => sub {
my $orig = shift;
my $self = shift;
my $id = shift;
return $self->validate_id($orig, $id, @_);
};
sub get {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
endpoint => 'reports/%s',
ids => [ $id ],
});
}
sub download {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
view => 'Binary',
endpoint => 'reports/%s/download',
ids => [ $id ],
});
}
################################################################################
1;
__END__
=head1 NAME
WebService::Mattermost::V4::API::Resource::Compliance::Report
=head1 DESCRIPTION
=head2 USAGE
use WebService::Mattermost;
my $mm = WebService::Mattermost->new({
authenticate => 1,
username => 'me@somewhere.com',
password => 'hunter2',
base_url => 'https://my.mattermost.server.com/api/v4/',
});
my $resource = $mm->api->compliance_report;
=head2 METHODS
=over 4
=item C<get()>
Get a compliance report by its ID.
my $response = $resource->get('REPORT-ID-HERE');
=item C<download()>
Download a compliance report by its ID.
my $response = $resource->download('REPORT-ID-HERE');
=back
=head1 SEE ALSO
=over 4
=item L<Official compliance documentation|https://api.mattermost.com/#tag/compliance>
=back
=head1 AUTHOR
Mike Jones L<email:mike@netsplit.org.uk>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment