Stripe/Connect/Person.pm

filter: Statementstmt 28.3% 19 / 67 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 25.0% 8 / 32 Podpod 100% 24 / 24 totaltotal 34.2% 51 / 149 CC 11 SCAR 34.7
CC
11
Cov
22%
dob
117.5
id
2.0
object
2.0
CRAP 32.1
« Stripe/Generic.pm ↑ Summary Stripe/Connect/Account/ExternalAccounts.pm »
1 ##----------------------------------------------------------------------------
2 ## Stripe API - ~/lib/Net/API/Stripe/Connect/Person.pm
3 ## Version v0.200.0
4 ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6 ## Created 2019/11/02
7 ## Modified 2020/05/15
8 ##
9 ##----------------------------------------------------------------------------
10 package Net::API::Stripe::Connect::Person;
11 BEGIN
12 {
13 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶ use parent qw( Net::API::Stripe::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶ use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶ use DateTime::Format::Strptime;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use TryCatch;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ our( $VERSION ) = 'v0.200.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 };
20  
21 0 ▶sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
22  
23 0 ▶sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
Subroutine object: not called CC=1 SCAR=6.9
Pod documented
24  
25 0 ▶sub account { return( shift->_set_get_scalar_or_object( 'account', 'Net::API::Stripe::Connect::Account', @_ ) ); }
Subroutine account: not called CC=1 SCAR=6.9
Pod documented
26  
27 0 ▶sub address { return( shift->_set_get_object( 'address', 'Net::API::Stripe::Address', @_ ) ); }
Subroutine address: not called CC=1 SCAR=6.9
Pod documented
28  
29 0 ▶sub address_kana { return( shift->_set_get_object( 'address_kana', 'Net::API::Stripe::Address', @_ ) ); }
Subroutine address_kana: not called CC=1 SCAR=6.9
Pod documented
30  
31 0 ▶sub address_kanji { return( shift->_set_get_object( 'address_kanji', 'Net::API::Stripe::Address', @_ ) ); }
Subroutine address_kanji: not called CC=1 SCAR=6.9
Pod documented
32  
33 0 ▶sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
Subroutine created: not called CC=1 SCAR=6.9
Pod documented
34  
35 sub dob
36 {
37 0 ▶ my $self = shift( @_ );
Subroutine dob: not called CC=11 SCAR=47.7
Pod documented
38 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
39 {
40 ## There may be a hash provided with undefined values for each of the properties, so we need to check that
41 0 my $ref = shift( @_ );
42 0 my $dt;
43 0 ▶ if( $self->_is_object( $ref ) && $ref->isa( 'DateTime' ) )
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_is_object($ref) and $ref->isa('DateTime')) { } 0 0 0
elsif ($self->_is_hash($ref)) { } 0 0 0
Condition0%0/3
$self->_is_object($ref) and $ref->isa("DateTime")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_object($ref) and $ref->isa("DateTime")
$self->_is_object($ref) $ref->isa("DateTime")
Truth table0%0/3
A and B
A= $self->_is_object($ref)B= $ref->isa("DateTime")
ABresult
0X0
100
111
44 {
45 0 $dt = $ref;
46 }
47 elsif( $self->_is_hash( $ref ) )
48 {
49 0 ▶ return if( !length( $ref->{year} ) && !length( $ref->{month} ) && !length( $ref->{day} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length $ref->{"year"} or length $ref->{"month"} or length $ref->{"day"} 0 0 0
Condition0%0/6
length $ref->{"year"} or length $ref->{"month"} or length $ref->{"day"}
l!l&&r!l&&!r
000
length $ref->{"year"} or length $ref->{"month"}
l!l&&r!l&&!r
000
MC/DC0%0/3
length $ref->{"year"} or length $ref->{"month"} or length $ref->{"day"}
length $ref->{"year"} length $ref->{"month"} length $ref->{"day"}
Truth table0%0/4
A or B or C
A= length $ref->{"year"}B= length $ref->{"month"}C= length $ref->{"day"}
ABCresult
1XX1
01X1
0011
0000
50
51 0 foreach my $k ( qw( year month day ) )
52 {
53 0 ▶ return( $self->error( "Hash provided for person date of birth is missing the $k property" ) ) if( !$ref->{ $k } );
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->{$k} 0 0 0
54 }
55 0 @$ref{ qw( hour minute second ) } = ( 0, 0, 0 );
56 0 try
57 1 ▶ {
Subroutine BEGIN: called CC=1 SCAR=3.5
58 0 $dt = DateTime->new( %$ref );
59 }
60 catch( $e )
61 1 ▶ {
Subroutine BEGIN: called CC=1 SCAR=4.9
Branch: 1 branch
BranchTrueFalseTotal
if ($TryCatch::Error) 0 0 0
62 0 return( $self->error( "An error occurred while trying to create a datetime object from this person's date of birth (year = '$ref->{year}', month = '$ref->{month}', day = '$ref->{day}'." ) );
63 }
64 0 }
65 0 my $fmt = DateTime::Format::Strptime->new(
66 pattern => '%Y-%m-%d',
67 locale => 'en_GB',
68 time_zone => 'local',
69 );
70 0 $dt->set_formatter( $fmt );
71 0 $self->{dob} = $dt;
72 }
73 0 return( $self->{dob} );
74 }
75  
76 0 ▶sub email { return( shift->_set_get_scalar( 'email', @_ ) ); }
Subroutine email: not called CC=1 SCAR=6.9
Pod documented
77  
78 0 ▶sub first_name { return( shift->_set_get_scalar( 'first_name', @_ ) ); }
Subroutine first_name: not called CC=1 SCAR=6.9
Pod documented
79  
80 0 ▶sub first_name_kana { return( shift->_set_get_scalar( 'first_name_kana', @_ ) ); }
Subroutine first_name_kana: not called CC=1 SCAR=6.9
Pod documented
81  
82 0 ▶sub first_name_kanji { return( shift->_set_get_scalar( 'first_name_kanji', @_ ) ); }
Subroutine first_name_kanji: not called CC=1 SCAR=6.9
Pod documented
83  
84 0 ▶sub gender { return( shift->_set_get_scalar( 'gender', @_ ) ); }
Subroutine gender: not called CC=1 SCAR=6.9
Pod documented
85  
86 0 ▶sub id_number_provided { return( shift->_set_get_boolean( 'id_number_provided', @_ ) ); }
Subroutine id_number_provided: not called CC=1 SCAR=6.9
Pod documented
87  
88 0 ▶sub last_name { return( shift->_set_get_scalar( 'last_name', @_ ) ); }
Subroutine last_name: not called CC=1 SCAR=6.9
Pod documented
89  
90 0 ▶sub last_name_kana { return( shift->_set_get_scalar( 'last_name_kana', @_ ) ); }
Subroutine last_name_kana: not called CC=1 SCAR=6.9
Pod documented
91  
92 0 ▶sub last_name_kanji { return( shift->_set_get_scalar( 'last_name_kanji', @_ ) ); }
Subroutine last_name_kanji: not called CC=1 SCAR=6.9
Pod documented
93  
94 0 ▶sub maiden_name { return( shift->_set_get_scalar( 'maiden_name', @_ ) ); }
Subroutine maiden_name: not called CC=1 SCAR=6.9
Pod documented
95  
96 0 ▶sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
Subroutine metadata: not called CC=1 SCAR=6.9
Pod documented
97  
98 0 ▶sub phone { return( shift->_set_get_scalar( 'phone', @_ ) ); }
Subroutine phone: not called CC=1 SCAR=6.9
Pod documented
99  
100 0 ▶sub relationship { return( shift->_set_get_object( 'relationship', 'Net::API::Stripe::Connect::Account::Relationship', @_ ) ); }
Subroutine relationship: not called CC=1 SCAR=6.9
Pod documented
101  
102 0 ▶sub requirements { return( shift->_set_get_object( 'requirements', 'Net::API::Stripe::Connect::Account::Requirements', @_ ) ); }
Subroutine requirements: not called CC=1 SCAR=6.9
Pod documented
103  
104 0 ▶sub ssn_last_4_provided { return( shift->_set_get_boolean( 'ssn_last_4_provided', @_ ) ); }
Subroutine ssn_last_4_provided: not called CC=1 SCAR=6.9
Pod documented
105  
106 0 ▶sub verification { return( shift->_set_get_object( 'verification', 'Net::API::Stripe::Connect::Account::Verification', @_ ) ); }
Subroutine verification: not called CC=1 SCAR=6.9
Pod documented
107  
108 1 1;
109  
110 __END__
111  
112 =encoding utf8
113  
114 =head1 NAME
115  
116 Net::API::Stripe::Connect::Person - A Stripe Person Object
117  
118 =head1 SYNOPSIS
119  
120 my $pers = $stripe->person({
121 account => $account_object,
122 address => $address_object,
123 address_kana => $address_kana_object,
124 address_kanji => $address_kanji_object,
125 # or:
126 # dob => DateTime->new( year => 1985, month => 8, day => 15 )
127 dob =>
128 {
129 day => 15
130 month => 8,
131 year => 1985,
132 },
133 email => 'nadeshiko.yamato@example.com',
134 first_name => 'Nadeshiko',
135 last_name => 'Yamato',
136 first_name_kana => 'なでしこ',
137 last_name_kana => 'やまと',
138 first_name_kanji => '撫子',
139 last_name_kanji => '大和',
140 gender => 'female',
141 metadata => { transaction_id => 123, customer_id => 456 },
142 phone => '+81-(0)90-1234-5678',
143 });
144  
145 See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
146  
147 =head1 VERSION
148  
149 v0.200.0
150  
151 =head1 DESCRIPTION
152  
153 This is an object representing a person associated with a Stripe account.
154  
155 =head1 CONSTRUCTOR
156  
157 =over 4
158  
159 =item B<new>( %ARG )
160  
161 Creates a new L<Net::API::Stripe::Connect::Person> object.
162 It may also take an hash like arguments, that also are method of the same name.
163  
164 =back
165  
166 =head1 METHODS
167  
168 =over 4
169  
170 =item B<id> string
171  
172 Unique identifier for the object.
173  
174 =item B<object> string, value is "person"
175  
176 String representing the object’s type. Objects of the same type share the same value.
177  
178 =item B<account> string
179  
180 The account the person is associated with. If expanded (currently not implemented in Stripe API), this will be a L<Net::API::Stripe::Connect::Account> object.
181  
182 =item B<address> hash
183  
184 The person’s address.
185  
186 This is L<Net::API::Stripe::Address> object.
187  
188 =item B<address_kana> hash
189  
190 The Kana variation of the person’s address (Japan only).
191  
192 This is L<Net::API::Stripe::Address> object.
193  
194 =item B<address_kanji> hash
195  
196 The Kanji variation of the person’s address (Japan only).
197  
198 This is L<Net::API::Stripe::Address> object.
199  
200 =item B<created> timestamp
201  
202 Time at which the object was created. Measured in seconds since the Unix epoch.
203  
204 =item B<dob> L<DateTime> object or hash
205  
206 The person’s date of birth.
207  
208 This returns a C<DateTime> object. It can take either a L<DateTime> object or an hash with the following properties:
209  
210 =over 8
211  
212 =item I<day> positive integer
213  
214 The day of birth, between 1 and 31.
215  
216 =item I<month> positive integer
217  
218 The month of birth, between 1 and 12.
219  
220 =item I<year> positive integer
221  
222 The four-digit year of birth.
223  
224 =back
225  
226 =item B<email> string
227  
228 The person’s email address.
229  
230 =item B<first_name> string
231  
232 The person’s first name.
233  
234 =item B<first_name_kana> string
235  
236 The Kana variation of the person’s first name (Japan only).
237  
238 =item B<first_name_kanji> string
239  
240 The Kanji variation of the person’s first name (Japan only).
241  
242 =item B<gender> string
243  
244 The person’s gender (International regulations require either “male” or “female”).
245  
246 =item B<id_number_provided> boolean
247  
248 Whether the person’s id_number was provided.
249  
250 =item B<last_name> string
251  
252 The person’s last name.
253  
254 =item B<last_name_kana> string
255  
256 The Kana variation of the person’s last name (Japan only).
257  
258 =item B<last_name_kanji> string
259  
260 The Kanji variation of the person’s last name (Japan only).
261  
262 =item B<maiden_name> string
263  
264 The person’s maiden name.
265  
266 =item B<metadata> hash
267  
268 Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
269  
270 =item B<phone> string
271  
272 The person’s phone number.
273  
274 =item B<relationship> hash
275  
276 Describes the person’s relationship to the account.
277  
278 This is a L<Net::API::Stripe::Connect::Account::Relationship> object.
279  
280 =item B<requirements> hash
281  
282 Information about the requirements for this person, including what information needs to be collected, and by when.
283  
284 This is a L<Net::API::Stripe::Connect::Account::Requirements> object.
285  
286 =item B<ssn_last_4_provided> boolean
287  
288 Whether the last 4 digits of this person’s SSN have been provided.
289  
290 =item B<verification> hash
291  
292 The persons’s verification status.
293  
294 This is a L<Net::API::Stripe::Connect::Account::Verification> object.
295  
296 =back
297  
298 =head1 API SAMPLE
299  
300 {
301 "id": "person_fake123456789",
302 "object": "person",
303 "account": "acct_fake123456789",
304 "created": 1571602397,
305 "dob": {
306 "day": null,
307 "month": null,
308 "year": null
309 },
310 "first_name_kana": null,
311 "first_name_kanji": null,
312 "gender": null,
313 "last_name_kana": null,
314 "last_name_kanji": null,
315 "metadata": {},
316 "relationship": {
317 "director": false,
318 "executive": false,
319 "owner": false,
320 "percent_ownership": null,
321 "representative": false,
322 "title": null
323 },
324 "requirements": {
325 "currently_due": [],
326 "eventually_due": [],
327 "past_due": [],
328 "pending_verification": []
329 },
330 "verification": {
331 "additional_document": {
332 "back": null,
333 "details": null,
334 "details_code": null,
335 "front": null
336 },
337 "details": null,
338 "details_code": null,
339 "document": {
340 "back": null,
341 "details": null,
342 "details_code": null,
343 "front": null
344 },
345 "status": "unverified"
346 }
347 }
348  
349 =head1 HISTORY
350  
351 =head2 v0.1
352  
353 Initial version
354  
355 =head2 v0.2
356  
357 Update the method B<dob> to accept L<DateTime> objects
358  
359 =head1 AUTHOR
360  
361 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
362  
363 =head1 SEE ALSO
364  
365 Stripe API documentation:
366  
367 L<https://stripe.com/docs/api/persons/object>, L<https://stripe.com/docs/connect/identity-verification-api#person-information>
368  
369 =head1 COPYRIGHT & LICENSE
370  
371 Copyright (c) 2020-2020 DEGUEST Pte. Ltd.
372  
373 You can use, copy, modify and redistribute this package and associated
374 files under the same terms as Perl itself.
375  
376 =cut
« Stripe/Generic.pm ↑ Summary Stripe/Connect/Account/ExternalAccounts.pm »