File Coverage

blib/lib/Net/Stripe/Invoice.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 6 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod n/a
total 12 30 40.0


line stmt bran cond sub pod time code
1             package Net::Stripe::Invoice;
2             $Net::Stripe::Invoice::VERSION = '0.40_005'; # TRIAL
3              
4 2     2   12 $Net::Stripe::Invoice::VERSION = '0.40005';use Moose;
  2         4  
  2         15  
5 2     2   11902 use Kavorka;
  2         2  
  2         17  
6             extends 'Net::Stripe::Resource';
7              
8             # ABSTRACT: represent an Invoice object from Stripe
9              
10             has 'id' => ( is => 'ro', isa => 'Maybe[Str]' );
11             has 'created' => ( is => 'ro', isa => 'Maybe[Int]' );
12             has 'subtotal' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
13             has 'amount_due' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
14             has 'attempt_count' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
15             has 'attempted' => ( is => 'ro', isa => 'Maybe[Bool|Object]', required => 1 );
16             has 'closed' => ( is => 'ro', isa => 'Maybe[Bool|Object]', trigger => \&_closed_change_detector);
17             has 'auto_advance' => ( is => 'ro', isa => 'Maybe[Bool]');
18             has 'created' => ( is => 'ro', isa => 'Maybe[Int]' );
19             has 'customer' => ( is => 'ro', isa => 'Maybe[Str]', required => 1 );
20             has 'date' => ( is => 'ro', isa => 'Maybe[Str]' );
21             has 'lines' => ( is => 'ro', isa => 'Net::Stripe::List', required => 1 );
22             has 'paid' => ( is => 'ro', isa => 'Maybe[Bool|Object]', required => 1 );
23             has 'period_end' => ( is => 'ro', isa => 'Maybe[Int]' );
24             has 'period_start' => ( is => 'ro', isa => 'Maybe[Int]' );
25             has 'starting_balance' => ( is => 'ro', isa => 'Maybe[Int]' );
26             has 'subtotal' => ( is => 'ro', isa => 'Maybe[Int]' );
27             has 'total' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
28             has 'charge' => ( is => 'ro', isa => 'Maybe[Str]' );
29             has 'ending_balance' => ( is => 'ro', isa => 'Maybe[Int]' );
30             has 'next_payment_attempt' => ( is => 'ro', isa => 'Maybe[Int]' );
31             has 'metadata' => ( is => 'rw', isa => 'HashRef');
32             has 'description' => (is => 'rw', isa => 'Maybe[Str]');
33              
34             sub _closed_change_detector {
35 0     0     my ($instance, $new_value, $orig_value) = @_;
36             # Strip can update invoices but only wants to see the closed flag if it has been changed.
37             # Meaning if you retrieve an invoice then try to update it, and it is already closed
38             # it will reject the update.
39 0 0 0       if (!defined($orig_value) || $new_value ne $orig_value) {
40 0           $instance->{closed_value_changed} = 1;
41             }
42 0           return;
43             }
44              
45 2 0   2   4729 method form_fields {
  2     0   12  
  2         336  
  0            
  0            
46             return $self->form_fields_for(
47             qw/description metadata auto_advance/,
48 0 0         ($self->{closed_value_changed} ? qw/closed/ : ())
49             );
50             }
51              
52             __PACKAGE__->meta->make_immutable;
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =head1 NAME
60              
61             Net::Stripe::Invoice - represent an Invoice object from Stripe
62              
63             =head1 VERSION
64              
65             version 0.40_005
66              
67             =head1 ATTRIBUTES
68              
69             =head2 amount_due
70              
71             Reader: amount_due
72              
73             Type: Maybe[Int]
74              
75             This attribute is required.
76              
77             =head2 attempt_count
78              
79             Reader: attempt_count
80              
81             Type: Maybe[Int]
82              
83             This attribute is required.
84              
85             =head2 attempted
86              
87             Reader: attempted
88              
89             Type: Maybe[Bool|Object]
90              
91             This attribute is required.
92              
93             =head2 auto_advance
94              
95             Reader: auto_advance
96              
97             Type: Maybe[Bool]
98              
99             =head2 boolean_attributes
100              
101             Reader: boolean_attributes
102              
103             Type: ArrayRef[Str]
104              
105             =head2 charge
106              
107             Reader: charge
108              
109             Type: Maybe[Str]
110              
111             =head2 closed
112              
113             Reader: closed
114              
115             Type: Maybe[Bool|Object]
116              
117             =head2 created
118              
119             Reader: created
120              
121             Type: Maybe[Int]
122              
123             =head2 customer
124              
125             Reader: customer
126              
127             Type: Maybe[Str]
128              
129             This attribute is required.
130              
131             =head2 date
132              
133             Reader: date
134              
135             Type: Maybe[Str]
136              
137             =head2 description
138              
139             Reader: description
140              
141             Writer: description
142              
143             Type: Maybe[Str]
144              
145             =head2 ending_balance
146              
147             Reader: ending_balance
148              
149             Type: Maybe[Int]
150              
151             =head2 id
152              
153             Reader: id
154              
155             Type: Maybe[Str]
156              
157             =head2 lines
158              
159             Reader: lines
160              
161             Type: Net::Stripe::List
162              
163             This attribute is required.
164              
165             =head2 metadata
166              
167             Reader: metadata
168              
169             Writer: metadata
170              
171             Type: HashRef
172              
173             =head2 next_payment_attempt
174              
175             Reader: next_payment_attempt
176              
177             Type: Maybe[Int]
178              
179             =head2 paid
180              
181             Reader: paid
182              
183             Type: Maybe[Bool|Object]
184              
185             This attribute is required.
186              
187             =head2 period_end
188              
189             Reader: period_end
190              
191             Type: Maybe[Int]
192              
193             =head2 period_start
194              
195             Reader: period_start
196              
197             Type: Maybe[Int]
198              
199             =head2 starting_balance
200              
201             Reader: starting_balance
202              
203             Type: Maybe[Int]
204              
205             =head2 subtotal
206              
207             Reader: subtotal
208              
209             Type: Maybe[Int]
210              
211             =head2 total
212              
213             Reader: total
214              
215             Type: Maybe[Int]
216              
217             This attribute is required.
218              
219             =head1 AUTHORS
220              
221             =over 4
222              
223             =item *
224              
225             Luke Closs
226              
227             =item *
228              
229             Rusty Conover
230              
231             =back
232              
233             =head1 COPYRIGHT AND LICENSE
234              
235             This software is copyright (c) 2015 by Prime Radiant, Inc., (c) copyright 2014 Lucky Dinosaur LLC.
236              
237             This is free software; you can redistribute it and/or modify it under
238             the same terms as the Perl 5 programming language system itself.
239              
240             =cut