| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Business::BancaSella::Decode::Gateway; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | push @ISA,'Business::BancaSella::Gateway'; | 
| 4 | 2 |  |  | 2 |  | 5042 | use Business::BancaSella::Gateway; | 
|  | 2 |  |  |  |  | 6 |  | 
|  | 2 |  |  |  |  | 71 |  | 
| 5 | 2 |  |  | 2 |  | 1165 | use URI; | 
|  | 2 |  |  |  |  | 13518 |  | 
|  | 2 |  |  |  |  | 60 |  | 
| 6 | 2 |  |  | 2 |  | 19 | use Carp; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 268 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | $VERSION = "0.11"; | 
| 10 | 0 |  |  | 0 | 0 | 0 | sub Version { $VERSION; } | 
| 11 |  |  |  |  |  |  | require 5.004; | 
| 12 | 2 |  |  | 2 |  | 12 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 76 |  | 
| 13 | 2 |  |  | 2 |  | 11 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 1017 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | my %fields 	= | 
| 16 |  |  |  |  |  |  | ( | 
| 17 |  |  |  |  |  |  | query_string		=>		undef | 
| 18 |  |  |  |  |  |  | ); | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | my @fields_req	= qw/query_string/; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub new | 
| 23 |  |  |  |  |  |  | { | 
| 24 | 2 |  |  | 2 | 1 | 32 | my $proto = shift; | 
| 25 | 2 |  | 33 |  |  | 16 | my $class = ref($proto) || $proto; | 
| 26 | 2 |  |  |  |  | 5 | my $self = {}; | 
| 27 | 2 |  |  |  |  | 8 | bless $self,$class; | 
| 28 | 2 |  |  |  |  | 9 | $self->init(@_); | 
| 29 | 2 |  |  |  |  | 8 | return $self; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | sub init { | 
| 33 | 3 |  |  | 3 | 0 | 7 | my $self = shift; | 
| 34 | 3 |  |  |  |  | 11 | my (%options) = @_; | 
| 35 |  |  |  |  |  |  | # Assign default options | 
| 36 | 3 |  |  |  |  | 20 | while (my ($key,$value) = each(%fields)) { | 
| 37 | 3 |  | 66 |  |  | 49 | $self->{$key} = $self->{$key} || $value; | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  | # Assign options | 
| 40 | 3 |  |  |  |  | 15 | while (my ($key,$value) = each(%options)) { | 
| 41 | 4 |  |  |  |  | 17 | $self->{$key} = $value; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | # Check required params | 
| 44 | 3 |  |  |  |  | 10 | foreach (@fields_req) { | 
| 45 | 3 | 50 |  |  |  | 18 | croak "You must declare '$_' in " . ref($self) . "::new" | 
| 46 |  |  |  |  |  |  | if (!defined $self->{$_}); | 
| 47 |  |  |  |  |  |  | } | 
| 48 | 3 |  |  |  |  | 16 | $self->_split_uri; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | sub _split_uri { | 
| 52 | 3 |  |  | 3 |  | 5 | my $self = shift; | 
| 53 | 3 |  |  |  |  | 15 | my $qs	= '?' . $self->query_string; | 
| 54 | 3 |  |  |  |  | 27 | my %qs = URI->new($qs)->query_form; | 
| 55 | 3 | 50 | 33 |  |  | 14133 | die "Malformed uri definition: " . $self->{uri} | 
| 56 |  |  |  |  |  |  | if (!(exists $qs{a} && exists $qs{b})); | 
| 57 | 3 |  |  |  |  | 14 | $self->{result} = $qs{a}; | 
| 58 | 3 |  |  |  |  | 11 | $self->{id}		= $qs{b}; | 
| 59 | 3 |  |  |  |  | 8 | $self->{otp}	= $qs{c}; | 
| 60 | 3 | 100 |  |  |  | 22 | if ($self->{result} ne 'KO') { | 
| 61 | 1 |  |  |  |  | 7 | $self->{authcode} = $qs{a}; | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | sub result { | 
| 67 | 5 |  |  | 5 | 1 | 59 | my $self = shift; | 
| 68 | 5 | 50 |  |  |  | 17 | if (@_) { $self->SUPER::result(shift) }; | 
|  | 0 |  |  |  |  | 0 |  | 
| 69 | 5 |  |  |  |  | 52 | return $self->SUPER::result ne 'KO'; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 3 | 50 |  | 3 | 0 | 4 | sub query_string { my $s=shift; return @_ ? ($s->{query_string}=shift) : $s->{query_string} } | 
|  | 3 |  |  |  |  | 20 |  | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | # Preloaded methods go here. | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | 1; | 
| 77 |  |  |  |  |  |  | __END__ |