File Coverage

blib/lib/Stancer/Core/Iterator/Dispute.pm
Criterion Covered Total %
statement 31 31 100.0
branch 10 10 100.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 51 51 100.0


line stmt bran cond sub pod time code
1             package Stancer::Core::Iterator::Dispute;
2              
3 13     13   355668 use 5.020;
  13         57  
4 13     13   92 use strict;
  13         32  
  13         391  
5 13     13   89 use warnings;
  13         61  
  13         1209  
6              
7             # ABSTRACT: Iterate through disputes
8             our $VERSION = '1.0.3'; # VERSION
9              
10 13     13   1268 use Stancer::Dispute;
  13         34  
  13         561  
11              
12 13     13   79 use Moo;
  13         59  
  13         117  
13              
14             extends 'Stancer::Core::Iterator';
15              
16 13     13   7487 use namespace::clean;
  13         33  
  13         137  
17              
18              
19             sub _create_element {
20 32     32   2345 my ($class, @args) = @_;
21              
22 32         1235 return Stancer::Dispute->new(@args);
23             }
24              
25             sub _element_key {
26 6     6   45 return 'disputes';
27             }
28              
29              
30             sub search {
31 27     27 1 104 my ($class, @args) = @_;
32 27         68 my $data;
33 27         68 my $params = {};
34              
35 27 100       179 if (scalar @args == 1) {
36 5         32 $data = $args[0];
37             } else {
38 22         100 $data = {@args};
39             }
40              
41 27 100       297 $params->{created} = $class->_search_filter_created($data) if defined $data->{created};
42 23 100       166 $params->{created_until} = $class->_search_filter_created_until($data) if defined $data->{created_until};
43 18 100       111 $params->{limit} = $class->_search_filter_limit($data) if defined $data->{limit};
44 15 100       123 $params->{start} = $class->_search_filter_start($data) if defined $data->{start};
45              
46 13         114 return $class->SUPER::search($params);
47             }
48              
49             1;
50              
51             __END__
52              
53             =pod
54              
55             =encoding UTF-8
56              
57             =head1 NAME
58              
59             Stancer::Core::Iterator::Dispute - Iterate through disputes
60              
61             =head1 VERSION
62              
63             version 1.0.3
64              
65             =head1 DESCRIPTION
66              
67             You should not use this class directly.
68              
69             This module is an internal class, regrouping method for every API object list.
70              
71             =head1 METHODS
72              
73             =head2 C<< Stancer::Core::Iterator::Dispute->new(I<$sub>) : I<self> >>
74              
75             Create a new iterator.
76              
77             A subroutine, C<$sub> is mandatory, it will be used on every iteration.
78              
79             =head2 C<< $iterator->next() : I<Dispute>|I<undef> >>
80              
81             Return the next dispute object or C<undef> if no more element to iterate.
82              
83             =head2 C<< Stancer::Core::Iterator::Dispute->search(I<%terms>) : I<self> >>
84              
85             =head2 C<< Stancer::Core::Iterator::Dispute->search(I<\%terms>) : I<self> >>
86              
87             You may use L<Stancer::Dispute/list> instead.
88              
89             =head1 USAGE
90              
91             =head2 Logging
92              
93              
94              
95             We use the L<Log::Any> framework for logging events.
96             You may tell where it should log using any available L<Log::Any::Adapter> module.
97              
98             For example, to log everything to a file you just have to add a line to your script, like this:
99             #! /usr/bin/env perl
100             use Log::Any::Adapter (File => '/var/log/payment.log');
101             use Stancer::Core::Iterator::Dispute;
102              
103             You must import C<Log::Any::Adapter> before our libraries, to initialize the logger instance before use.
104              
105             You can choose your log level on import directly:
106             use Log::Any::Adapter (File => '/var/log/payment.log', log_level => 'info');
107              
108             Read the L<Log::Any> documentation to know what other options you have.
109              
110             =cut
111              
112             =head1 SECURITY
113              
114             =over
115              
116             =item *
117              
118             Never, never, NEVER register a card or a bank account number in your database.
119              
120             =item *
121              
122             Always uses HTTPS in card/SEPA in communication.
123              
124             =item *
125              
126             Our API will never give you a complete card/SEPA number, only the last four digits.
127             If you need to keep track, use these last four digit.
128              
129             =back
130              
131             =cut
132              
133             =head1 BUGS
134              
135             Please report any bugs or feature requests on the bugtracker website
136             L<https://gitlab.com/wearestancer/library/lib-perl/-/issues> or by email to
137             L<bug-stancer@rt.cpan.org|mailto:bug-stancer@rt.cpan.org>.
138              
139             When submitting a bug or request, please include a test-file or a
140             patch to an existing test-file that illustrates the bug or desired
141             feature.
142              
143             =head1 AUTHOR
144              
145             Joel Da Silva <jdasilva@cpan.org>
146              
147             =head1 COPYRIGHT AND LICENSE
148              
149             This software is Copyright (c) 2018-2024 by Stancer / Iliad78.
150              
151             This is free software, licensed under:
152              
153             The Artistic License 2.0 (GPL Compatible)
154              
155             =cut