File Coverage

blib/lib/RT/Client/REST/Transaction.pm
Criterion Covered Total %
statement 22 26 84.6
branch n/a
condition n/a
subroutine 9 10 90.0
pod 2 2 100.0
total 33 38 86.8


line stmt bran cond sub pod time code
1             #!perl
2             # PODNAME: RT::Client::REST::Transaction
3             # ABSTRACT: transaction object representation.
4              
5 3     3   97280 use strict;
  3         11  
  3         75  
6 3     3   12 use warnings;
  3         6  
  3         120  
7              
8             $RT::Client::REST::Transaction::VERSION = '0.70';
9             use parent 'RT::Client::REST::Object';
10 3     3   456  
  3         278  
  3         29  
11             use Params::Validate qw(:types);
12 3     3   189 use RT::Client::REST::Object::Exception;
  3         4  
  3         404  
13 3     3   20  
  3         5  
  3         25  
14             id => {
15             validation => {
16 3     3   77 type => SCALAR,
17             regex => qr/^\d+$/,
18             },
19             },
20              
21             creator => {
22             validation => {
23             type => SCALAR,
24             },
25             },
26              
27             type => {
28             validation => {
29             type => SCALAR,
30             },
31             },
32              
33             old_value => {
34             validation => {
35             type => SCALAR,
36             },
37             rest_name => "OldValue",
38             },
39              
40             new_value => {
41             validation => {
42             type => SCALAR,
43             },
44             rest_name => "NewValue",
45             },
46              
47             parent_id => {
48             validation => {
49             type => SCALAR,
50             regex => qr/^\d+$/,
51             },
52             rest_name => 'Ticket',
53             },
54              
55             attachments => {
56             validation => {
57             type => SCALAR,
58             },
59             },
60              
61             time_taken => {
62             validation => {
63             type => SCALAR,
64             },
65             rest_name => 'TimeTaken',
66             },
67              
68             field => {
69             validation => {
70             type => SCALAR,
71             },
72             },
73              
74             content => {
75             validation => {
76             type => SCALAR,
77             },
78             },
79              
80             created => {
81             validation => {
82             type => SCALAR,
83             },
84             is_datetime => 1,
85             },
86              
87             description => {
88             validation => {
89             type => SCALAR|UNDEF,
90             },
91             },
92              
93             data => {
94             validation => {
95             type => SCALAR,
96             },
97             },
98             }}
99              
100              
101             my $self = shift;
102 1     1 1 773  
103             $self->from_form(
104             $self->rt->get_transaction(
105 0     0 1 0 parent_id => $self->parent_id,
106             id => $self->id,
107 0         0 ),
108             );
109              
110             $self->{__dirty} = {};
111              
112             return $self;
113             }
114 0         0  
115             # Override unsupported methods.
116 0         0 for my $method (qw(store search count)) {
117             no strict 'refs'; ## no critic (ProhibitNoStrict)
118             *$method = sub {
119             my $self = shift;
120             RT::Client::REST::Object::IllegalMethodException->throw(
121 3     3   865 ref($self) . " does not support '$method' method",
  3         11  
  3         285  
122             );
123 3     3   2101 };
124 3         33 }
125              
126             __PACKAGE__->_generate_methods;
127              
128             1;
129              
130              
131             =pod
132              
133             =encoding UTF-8
134              
135             =head1 NAME
136              
137             RT::Client::REST::Transaction - transaction object representation.
138              
139             =head1 VERSION
140              
141             version 0.70
142              
143             =head1 SYNOPSIS
144              
145             my $transactions = $ticket->transactions;
146              
147             my $count = $transactions->count;
148             print "There are $count transactions.\n";
149              
150             my $iterator = $transactions->get_iterator;
151             while (my $tr = &$iterator) {
152             print "Id: ", $tr->id, "; Type: ", $tr->type, "\n";
153             }
154              
155             =head1 DESCRIPTION
156              
157             A transaction is a second-class citizen, as it does not exist (at least
158             from the current REST protocol implementation) by itself. At the moment,
159             it is always associated with a ticket (see B<parent_id> attribute).
160             Thus, you will
161             rarely retrieve a transaction by itself; instead, you should use
162             C<transactions()> method of L<RT::Client::REST::Ticket> object to get
163             an iterator for all (or some) transactions for that ticket.
164              
165             =head1 ATTRIBUTES
166              
167             =over 2
168              
169             =item B<id>
170              
171             Numeric ID of the transaction.
172              
173             =item B<creator>
174              
175             Username of the user who created the transaction.
176              
177             =item B<parent_id>
178              
179             Numeric ID of the object the transaction is associated with.
180              
181             =item B<type>
182              
183             Type of the transactions. Please refer to L<RT::Client::REST>
184             documentation for the list of transaction types you can expect this
185             field to contain. Note that there may be some transaction types not
186             (dis)covered yet.
187              
188             =item B<old_value>
189              
190             Old value.
191              
192             =item B<new_value>
193              
194             New value.
195              
196             =item B<field>
197              
198             Name of the field the transaction is describing (if any).
199              
200             =item B<attachments>
201              
202             I have never seen it set to anything yet. (I will some day investigate this).
203              
204             =item B<created>
205              
206             Time when the transaction was created.
207              
208             =item B<content>
209              
210             Actual content of the transaction.
211              
212             =item B<description>
213              
214             Human-readable description of the transaction as provided by RT.
215              
216             =item B<data>
217              
218             Not sure what this is yet.
219              
220             =back
221              
222             =head1 METHODS
223              
224             B<RT::Client::REST::Transaction> is a read-only object, so you cannot
225             C<store()> it. Also, because it is a second-class citizen, you cannot
226             C<search()> or C<count()> it -- use C<transactions()> method provided
227             by L<RT::Client::REST::Ticket>.
228              
229             =over 2
230              
231             =item retrieve
232              
233             To retrieve a transaction, attributes B<id> and B<parent_id> must be set.
234              
235             =back
236              
237             =head1 INTERNAL METHODS
238              
239             =over 2
240              
241             =item B<rt_type>
242              
243             Returns 'transaction'.
244              
245             =back
246              
247             =head1 SEE ALSO
248              
249             L<RT::Client::REST>,
250             L<RT::Client::REST::Ticket>,
251             L<RT::Client::REST::SearchResult>.
252              
253             =head1 AUTHOR
254              
255             Dean Hamstead <dean@fragfest.com.au>
256              
257             =head1 COPYRIGHT AND LICENSE
258              
259             This software is copyright (c) 2022, 2020 by Dmitri Tikhonov.
260              
261             This is free software; you can redistribute it and/or modify it under
262             the same terms as the Perl 5 programming language system itself.
263              
264             =cut