File Coverage

blib/lib/RT/Client/REST/Queue.pm
Criterion Covered Total %
statement 29 35 82.8
branch n/a
condition n/a
subroutine 11 14 78.5
pod 2 2 100.0
total 42 51 82.3


line stmt bran cond sub pod time code
1             #!perl
2             # PODNAME: RT::Client::REST::Queue
3             # ABSTRACT: queue object representation.
4              
5 1     1   112717 use strict;
  1         12  
  1         29  
6 1     1   5 use warnings;
  1         2  
  1         50  
7              
8             package RT::Client::REST::Queue;
9             $RT::Client::REST::Queue::VERSION = '0.71';
10 1     1   515 use Params::Validate qw(:types);
  1         9811  
  1         216  
11 1     1   576 use RT::Client::REST;
  1         5  
  1         39  
12 1     1   586 use RT::Client::REST::Object;
  1         20  
  1         42  
13 1     1   6 use RT::Client::REST::Object::Exception;
  1         2  
  1         15  
14 1     1   60 use RT::Client::REST::SearchResult;
  1         3  
  1         22  
15 1     1   579 use RT::Client::REST::Ticket;
  1         2  
  1         30  
16 1     1   7 use parent 'RT::Client::REST::Object';
  1         2  
  1         5  
17              
18              
19             sub _attributes {{
20             id => {
21             validation => {
22             type => SCALAR,
23             },
24             form2value => sub {
25 0     0   0 shift =~ m~^queue/(\d+)$~i;
26 0         0 return $1;
27             },
28             value2form => sub {
29 0     0   0 return 'queue/' . shift;
30             },
31             },
32              
33 1     1   24 name => {
34             validation => {
35             type => SCALAR,
36             },
37             },
38              
39             description => {
40             validation => {
41             type => SCALAR,
42             },
43             },
44              
45             correspond_address => {
46             validation => {
47             type => SCALAR,
48             },
49             rest_name => 'CorrespondAddress',
50             },
51              
52             comment_address => {
53             validation => {
54             type => SCALAR,
55             },
56             rest_name => 'CommentAddress',
57             },
58              
59             initial_priority => {
60             validation => {
61             type => SCALAR,
62             },
63             rest_name => 'InitialPriority',
64             },
65              
66             final_priority => {
67             validation => {
68             type => SCALAR,
69             },
70             rest_name => 'FinalPriority',
71             },
72              
73             default_due_in => {
74             validation => {
75             type => SCALAR,
76             },
77             rest_name => 'DefaultDueIn',
78             },
79              
80             disabled => {
81             validation => {
82             type => SCALAR,
83             },
84             rest_name => 'Disabled',
85             },
86              
87             admin_cc_addresses => {
88             validation => {
89             type => SCALAR,
90             },
91             rest_name => 'AdminCcAddresses',
92             },
93              
94             cc_addresses => {
95             validation => {
96             type => SCALAR,
97             },
98             rest_name => 'CcAddresses',
99             },
100              
101             sla_disabled => {
102             validation => {
103             type => SCALAR,
104             },
105             rest_name => 'SLADisabled',
106             },
107              
108             }}
109              
110              
111             sub tickets {
112 0     0 1 0 my $self = shift;
113              
114 0         0 $self->_assert_rt_and_id;
115              
116 0         0 return RT::Client::REST::Ticket
117             ->new(rt => $self->rt)
118             ->search(limits => [
119             {attribute => 'queue', operator => '=', value => $self->id},
120             ]);
121             }
122              
123              
124 1     1 1 7540 sub rt_type { 'queue' }
125              
126              
127             __PACKAGE__->_generate_methods;
128              
129             1;
130              
131             __END__
132              
133             =pod
134              
135             =encoding UTF-8
136              
137             =head1 NAME
138              
139             RT::Client::REST::Queue - queue object representation.
140              
141             =head1 VERSION
142              
143             version 0.71
144              
145             =head1 SYNOPSIS
146              
147             my $rt = RT::Client::REST->new(server => $ENV{RTSERVER});
148              
149             my $queue = RT::Client::REST::Queue->new(
150             rt => $rt,
151             id => 'General',
152             )->retrieve;
153              
154             =head1 DESCRIPTION
155              
156             B<RT::Client::REST::Queue> is based on L<RT::Client::REST::Object>.
157             The representation allows one to retrieve, edit, comment on, and create
158             queue in RT.
159              
160             Note: RT currently does not allow REST client to search queues.
161              
162             =head1 ATTRIBUTES
163              
164             =over 2
165              
166             =item B<id>
167              
168             For retrieval, you can specify either the numeric ID of the queue or its
169             name (case-sensitive). After the retrieval, however, this attribute will
170             be set to the numeric id.
171              
172             =item B<name>
173              
174             This is the name of the queue.
175              
176             =item B<description>
177              
178             Queue description.
179              
180             =item B<correspond_address>
181              
182             Correspond address.
183              
184             =item B<comment_address>
185              
186             Comment address.
187              
188             =item B<initial_priority>
189              
190             Initial priority.
191              
192             =item B<final_priority>
193              
194             Final priority.
195              
196             =item B<default_due_in>
197              
198             Default due in.
199              
200             =item B<disabled>
201              
202             Queue is disabled
203              
204             =item B<admin_cc_addresses>
205              
206             Admin CC Addresses (comma delimited).
207              
208             =item B<cc_addresses>
209              
210             CC Addresses (comma delimited).
211              
212             =for stopwords SLA
213              
214             =item B<sla_disabled>
215              
216             Queue SLA is disabled
217              
218             =item B<cf>
219              
220             Access custom fields. Inherited from L<RT::Client::REST::Object>, where
221             you can read more details.
222              
223             Trivial example:
224              
225             my $queue = RT::Client::REST::Queue->new(
226             rt => $rt,
227             id => $queue_id
228             )->retrieve();
229             my @customfields = $queue->cf();
230             for my $f (@customfields) {
231             my $v = $queue->cf($f);
232             say "field: $f";
233             say "value: $v";
234             }
235              
236             =back
237              
238             =head1 DB METHODS
239              
240             For full explanation of these, please see B<"DB METHODS"> in
241             L<RT::Client::REST::Object> documentation.
242              
243             =over 2
244              
245             =item B<retrieve>
246              
247             Retrieve queue from database.
248              
249             =item B<store>
250              
251             Create or update the queue.
252              
253             =item B<search>
254              
255             Currently RT does not allow REST clients to search queues.
256              
257             =back
258              
259             =head1 QUEUE-SPECIFIC METHODS
260              
261             =over 2
262              
263             =item B<tickets>
264              
265             Get tickets that are in this queue (note: this may be a lot of tickets).
266             Note: tickets with status "deleted" will not be shown.
267             Object of type L<RT::Client::REST::SearchResult> is returned which then
268             can be used to get to objects of type L<RT::Client::REST::Ticket>.
269              
270             =back
271              
272             =head1 INTERNAL METHODS
273              
274             =over 2
275              
276             =item B<rt_type>
277              
278             Returns 'queue'.
279              
280             =back
281              
282             =head1 SEE ALSO
283              
284             L<RT::Client::REST>, L<RT::Client::REST::Object>,
285             L<RT::Client::REST::SearchResult>,
286             L<RT::Client::REST::Ticket>.
287              
288             =head1 AUTHOR
289              
290             Dean Hamstead <dean@fragfest.com.au>
291              
292             =head1 COPYRIGHT AND LICENSE
293              
294             This software is copyright (c) 2022, 2020 by Dmitri Tikhonov.
295              
296             This is free software; you can redistribute it and/or modify it under
297             the same terms as the Perl 5 programming language system itself.
298              
299             =cut