| 1 | package Catmandu::AlephX::Op::BorInfoscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/; |
| 2 | use Catmandu::Sanescip-perl cpan Catmandu-AlephX 1.073 Catmandu/Sane/; |
| 3 | use Catmandu::Utilscip-perl cpan Catmandu-AlephX 1.073 Catmandu/Util/ qw(:check :is); |
| 4 | use Mooscip-perl cpan Catmandu-AlephX 1.073 Moo/; |
| 5 | |
| 6 | our $VERSIONscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/$VERSION. = "1.073"; |
| 7 | |
| 8 | extendsscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/extends().('Catmandu::AlephX::Op::BorAuth'); |
| 9 | withscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/with().('Catmandu::AlephX::Response'); |
| 10 | |
| 11 | hasscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/has(). item_l => ( |
| 12 | is => 'ro', |
| 13 | lazy => 1, |
| 14 | isa => sub { check_array_refscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/check_array_ref().($_scip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/`@_`.[0]); }, |
| 15 | default => sub { |
| 16 | [] |
| 17 | } |
| 18 | ); |
| 19 | hasscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/has(). item_h => ( |
| 20 | is => 'ro', |
| 21 | lazy => 1, |
| 22 | isa => sub { check_array_refscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/check_array_ref().($_scip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/`@_`.[0]); }, |
| 23 | default => sub { |
| 24 | [] |
| 25 | } |
| 26 | ); |
| 27 | |
| 28 | hasscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/has(). balance => ( |
| 29 | is => 'ro' |
| 30 | ); |
| 31 | hasscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/has(). sign => ( |
| 32 | is => 'ro' |
| 33 | ); |
| 34 | hasscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/has(). fine => ( |
| 35 | is => 'ro', |
| 36 | lazy => 1, |
| 37 | isa => sub { |
| 38 | check_array_refscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/check_array_ref().($_scip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/`@_`.[0]); |
| 39 | }, |
| 40 | default => sub { |
| 41 | [] |
| 42 | } |
| 43 | ); |
| 44 | |
| 45 | sub opscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/op(). { 'bor-info' } |
| 46 | |
| 47 | my $config = { |
| 48 | fine => [qw(z31 z30 z13)], |
| 49 | 'item-h' => [qw(z37 z30 z13)] |
| 50 | }; |
| 51 | |
| 52 | sub parsescip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/parse(). { |
| 53 | my($class,$str_ref) = @_scip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/`@_`.; |
| 54 | my $xpath = xpathscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/xpath().($str_ref); |
| 55 | |
| 56 | my $op = opscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/op().(); |
| 57 | |
| 58 | my $args = {}; |
| 59 | |
| 60 | for my $zkey(qw(z303 z304 z305)){ |
| 61 | my($l) = $xpath->findscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/find().("/$op/$zkey")->get_nodelistscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_nodelist().(); |
| 62 | $args->{$zkey} = $l ? get_childrenscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_children().($l,1) : {}; |
| 63 | } |
| 64 | |
| 65 | for my $child($xpath->findscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/find().("/$op/item-l")->get_nodelistscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_nodelist().()){ |
| 66 | $args->{'item_l'} //= []; |
| 67 | |
| 68 | my $item_l = {}; |
| 69 | $item_l->{due_date} = $child->findvaluescip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/findvalue().('./due-date'); |
| 70 | $item_l->{due_hour} = $child->findvaluescip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/findvalue().('./due-hour'); |
| 71 | |
| 72 | for my $key(qw(z36 z30 z13)){ |
| 73 | for my $data($child->findscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/find().("./$key")->get_nodelistscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_nodelist().()){ |
| 74 | $item_l->{ $key } = get_childrenscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_children().($data,1); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | pushscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/push(). @{ $args->{'item_l'} },$item_l; |
| 79 | |
| 80 | } |
| 81 | |
| 82 | |
| 83 | for my $key(keysscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/keys(). %$config){ |
| 84 | for my $child($xpath->findscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/find().("/$op/$key")->get_nodelistscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_nodelist().()){ |
| 85 | my $n = $key; |
| 86 | $n =~ s/-/_/go; |
| 87 | $args->{$n} //= []; |
| 88 | |
| 89 | my %result = mapscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/map(). { |
| 90 | my($l) = $child->findscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/find().("./$_")->get_nodelistscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_nodelist().(); |
| 91 | $l ? ($_scip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/$_. => get_childrenscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/get_children().($l,1 )) : ($_scip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/$_. => {}); |
| 92 | } @{ $config->{ $key } }; |
| 93 | |
| 94 | pushscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/push(). @{ $args->{$n} },\%result; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | __PACKAGE__->newscip-perl cpan Catmandu-AlephX 1.073 __PACKAGE__/new().( |
| 99 | %$args, |
| 100 | balance => $xpath->findvaluescip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/findvalue().("/$op/balance"), |
| 101 | sign => $xpath->findvaluescip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/findvalue().("/$op/sign"), |
| 102 | session_id => $xpath->findvaluescip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/findvalue().("/$op/session-id"), |
| 103 | errors => $class->parse_errorsscip-perl cpan Catmandu-AlephX 1.073 Catmandu/AlephX/Op/BorInfo/parse_errors().($xpath), |
| 104 | content_ref => $str_ref |
| 105 | ); |
| 106 | |
| 107 | } |
| 108 | |
| 109 | 1; |