File Coverage

blib/lib/Stancer/Sepa/Check.pm
Criterion Covered Total %
statement 34 34 100.0
branch 6 6 100.0
condition n/a
subroutine 14 14 100.0
pod 1 1 100.0
total 55 55 100.0


line stmt bran cond sub pod time code
1             package Stancer::Sepa::Check;
2              
3 17     17   265768 use 5.020;
  17         64  
4 17     17   97 use strict;
  17         37  
  17         724  
5 17     17   85 use warnings;
  17         62  
  17         1673  
6              
7             # ABSTRACT: This will SEPAmail, a french service allowing to verify bank details on SEPA.
8             our $VERSION = '1.0.3'; # VERSION
9              
10 17     17   652 use Stancer::Core::Types qw(coerce_boolean Bool Maybe Num SepaInstance Str Varchar);
  17         38  
  17         1864  
11 17     17   1324 use Stancer::Sepa;
  17         44  
  17         980  
12              
13 17     17   104 use Moo;
  17         47  
  17         347  
14              
15             extends 'Stancer::Core::Object';
16              
17 17     17   8814 use namespace::clean;
  17         45  
  17         144  
18              
19 17     17   16229 use Stancer::Sepa::Check::Status;
  17         92  
  17         8359  
20              
21             has '+_boolean' => (
22             default => sub{ [qw(date_birth)] },
23             );
24              
25             has '+endpoint' => (
26             default => 'sepa/check',
27             );
28              
29              
30             has date_birth => (
31             is => 'rwp',
32             isa => Maybe[Bool],
33 4     4   9605 builder => sub { $_[0]->_attribute_builder('date_birth') },
34             coerce => coerce_boolean(),
35             lazy => 1,
36             predicate => 1,
37             );
38              
39              
40             has response => (
41             is => 'rwp',
42             isa => Maybe[Varchar[2, 4]],
43 4     4   662 builder => sub { $_[0]->_attribute_builder('response') },
44             lazy => 1,
45             predicate => 1,
46             );
47              
48              
49             has sepa => (
50             is => 'rwp',
51             isa => Maybe[SepaInstance],
52             builder => sub {
53 3     3   96 my $self = shift;
54              
55 3 100       63 return unless $self->id;
56 1         33 return Stancer::Sepa->new($self->id);
57             },
58             lazy => 1,
59             predicate => 1,
60             );
61              
62              
63             has score_name => (
64             is => 'rwp',
65             isa => Maybe[Num],
66 4     4   683 builder => sub { $_[0]->_attribute_builder('score_name') },
67             coerce => sub {
68             my $value = shift;
69              
70             return unless defined $value;
71             return $value / 100;
72             },
73             lazy => 1,
74             predicate => 1,
75             );
76              
77              
78             has status => (
79             is => 'rwp',
80             isa => Maybe[Str],
81 4     4   141 builder => sub { $_[0]->_attribute_builder('status') },
82             lazy => 1,
83             predicate => 1,
84             );
85              
86             sub TO_JSON {
87 8     8 1 1775 my $self = shift;
88              
89 8 100       273 return {} unless defined $self->sepa;
90 6 100       185 return { id => $self->sepa->id } if defined $self->sepa->id;
91 3         91 return $self->sepa->TO_JSON();
92             }
93              
94             1;
95              
96             __END__
97              
98             =pod
99              
100             =encoding UTF-8
101              
102             =head1 NAME
103              
104             Stancer::Sepa::Check - This will SEPAmail, a french service allowing to verify bank details on SEPA.
105              
106             =head1 VERSION
107              
108             version 1.0.3
109              
110             =head1 ATTRIBUTES
111              
112             =head2 C<date_birth>
113              
114             Read-only boolean.
115              
116             Is the provided birth date verified ?
117              
118             =head2 C<response>
119              
120             Read-only 2 or 4 characters string.
121              
122             API response code.
123              
124             =head2 C<sepa>
125              
126             Read-only instance of C<Stancer::Sepa>.
127              
128             Verified SEPA.
129              
130             =head2 C<score_name>
131              
132             Read-only float.
133              
134             Distance between provided name and account name.
135              
136             Distance is a percentage, you will have a float between 0 and 1.
137              
138             =head2 C<status>
139              
140             Read-only string, should be a C<Stancer::Sepa::Check::Status> constants.
141              
142             Verification status.
143              
144             =head1 USAGE
145              
146             =head2 Logging
147              
148              
149              
150             We use the L<Log::Any> framework for logging events.
151             You may tell where it should log using any available L<Log::Any::Adapter> module.
152              
153             For example, to log everything to a file you just have to add a line to your script, like this:
154             #! /usr/bin/env perl
155             use Log::Any::Adapter (File => '/var/log/payment.log');
156             use Stancer::Sepa::Check;
157              
158             You must import C<Log::Any::Adapter> before our libraries, to initialize the logger instance before use.
159              
160             You can choose your log level on import directly:
161             use Log::Any::Adapter (File => '/var/log/payment.log', log_level => 'info');
162              
163             Read the L<Log::Any> documentation to know what other options you have.
164              
165             =cut
166              
167             =head1 SECURITY
168              
169             =over
170              
171             =item *
172              
173             Never, never, NEVER register a card or a bank account number in your database.
174              
175             =item *
176              
177             Always uses HTTPS in card/SEPA in communication.
178              
179             =item *
180              
181             Our API will never give you a complete card/SEPA number, only the last four digits.
182             If you need to keep track, use these last four digit.
183              
184             =back
185              
186             =cut
187              
188             =head1 BUGS
189              
190             Please report any bugs or feature requests on the bugtracker website
191             L<https://gitlab.com/wearestancer/library/lib-perl/-/issues> or by email to
192             L<bug-stancer@rt.cpan.org|mailto:bug-stancer@rt.cpan.org>.
193              
194             When submitting a bug or request, please include a test-file or a
195             patch to an existing test-file that illustrates the bug or desired
196             feature.
197              
198             =head1 AUTHOR
199              
200             Joel Da Silva <jdasilva@cpan.org>
201              
202             =head1 COPYRIGHT AND LICENSE
203              
204             This software is Copyright (c) 2018-2024 by Stancer / Iliad78.
205              
206             This is free software, licensed under:
207              
208             The Artistic License 2.0 (GPL Compatible)
209              
210             =cut