File Coverage

blib/lib/WebService/Mattermost/V4/API/Resource/Jobs.pm
Criterion Covered Total %
statement 3 14 21.4
branch 0 2 0.0
condition n/a
subroutine 1 4 25.0
pod 3 3 100.0
total 7 23 30.4


line stmt bran cond sub pod time code
1             package WebService::Mattermost::V4::API::Resource::Jobs;
2:

3: # ABSTRACT: Wrapped API methods for the jobs API endpoints. 4:
5: use Moo;
6:
7: extends 'WebService::Mattermost::V4::API::Resource';
8:
9: ################################################################################
10:
11: sub all {
12: my $self = shift;
13: my $args = shift;
14:
15: return $self->_single_view_get({
16: view => 'Job',
17: parameters => $args,
18: });
19: }
20:
21: sub create {
22: my $self = shift;
23: my $args = shift;
24:
25: return $self->_single_view_post({
26: view => 'Job',
27: parameters => $args,
28: required => [ 'type' ],
29: });
30: }
31:
32: sub get_by_type {
33: my $self = shift;
34: my $type = shift;
35:
36: unless ($type) {
37: return $self->error_return('The first argument must be a job type');
38: }
39:
40: return $self->_get({
41: view => 'Job',
42: endpoint => 'type/%s',
43: ids => [ $type ],
44: });
45: }
46:
47: ################################################################################
48:
49: 1;
50:
51: __END__
52:
53: =pod
54:
55: =encoding UTF-8
56:
57: =head1 NAME
58:
59: WebService::Mattermost::V4::API::Resource::Jobs - Wrapped API methods for the jobs API endpoints.
60:
61: =head1 VERSION
62:
63: version 0.28
64:
65: =head1 DESCRIPTION
66:
67: =head2 USAGE
68:
69: use WebService::Mattermost;
70:
71: my $mm = WebService::Mattermost->new({
72: authenticate => 1,
73: username => 'me@somewhere.com',
74: password => 'hunter2',
75: base_url => 'https://my.mattermost.server.com/api/v4/',
76: });
77:
78: my $resource = $mm->api->teams->jobs;
79:
80: =head2 METHODS
81:
82: =over 4
83:
84: =item C<all()>
85:
86: L<Get the jobs|https://api.mattermost.com/#tag/jobs%2Fpaths%2F~1jobs%2Fget>
87:
88: Get all the jobs.
89:
90: my $response = $resource->all({
91: # Optional arguments
92: page => 0,
93: per_page => 60,
94: });
95:
96: =item C<create()>
97:
98: L<Create a new job|https://api.mattermost.com/#tag/jobs%2Fpaths%2F~1jobs%2Fpost>
99:
100: my $response = $resource->create({
101: # Required arguments
102: type => 'JOB-TYPE',
103:
104: # Optional arguments
105: data => {},
106: });
107:
108: =item C<get_by_type()>
109:
110: L<https://api.mattermost.com/#tag/jobs%2Fpaths%2F~1jobs~1type~1%7Btype%7D%2Fget>
111:
112: my $response = $resource->get_by_type('JOB-TYPE-HERE');
113:
114: =back
115:
116: =head1 SEE ALSO
117:
118: =over 4
119:
120: =item L<Official Jobs documentation|https://api.mattermost.com/#tag/jobs>
121:
122: =back
123:
124: =head1 AUTHOR
125:
126: Mike Jones <mike@netsplit.org.uk>
127:
128: =head1 COPYRIGHT AND LICENSE
129:
130: This software is Copyright (c) 2020 by Mike Jones.
131:
132: This is free software, licensed under:
133:
134: The MIT (X11) License
135:
136: =cut
137: