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