| 1 | package Net::Journyx; | ||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 10 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Net::Journyx::SOAP; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 10 | has site => ( | |||||||||||||||||||||||||||
| 9 | is => 'rw', | ||||||||||||||||||||||||||||
| 10 | isa => 'Str', | ||||||||||||||||||||||||||||
| 11 | required => 1, | ||||||||||||||||||||||||||||
| 12 | documentation => "The jxApi URL for your Journyx installation", | ||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | has username => ( | ||||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | isa => 'Str', | ||||||||||||||||||||||||||||
| 18 | documentation => "User name", | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | trigger => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 20 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 21 | 0 | $self->clear_session; | |||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||
| 23 | 10 | ); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 10 | has password => ( | |||||||||||||||||||||||||||
| 26 | is => 'rw', | ||||||||||||||||||||||||||||
| 27 | isa => 'Str', | ||||||||||||||||||||||||||||
| 28 | documentation => "Password", | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | has session => ( | ||||||||||||||||||||||||||||
| 32 | is => 'rw', | ||||||||||||||||||||||||||||
| 33 | isa => 'Str', | ||||||||||||||||||||||||||||
| 34 | documentation => 'Session Key, retrieved from login() sent on all other calls', | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | clearer => 'clear_session', | ||||||||||||||||||||||||||||
| 37 | predicate => 'has_session', | ||||||||||||||||||||||||||||
| 38 | lazy => 1, | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | return $self->login; | |||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||
| 43 | 10 | ); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 10 | has wsdl => ( | |||||||||||||||||||||||||||
| 46 | is => 'rw', | ||||||||||||||||||||||||||||
| 47 | isa => 'Str', | ||||||||||||||||||||||||||||
| 48 | required => 1, | ||||||||||||||||||||||||||||
| 49 | documentation => 'WSDL file to load', | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | has soap => ( | ||||||||||||||||||||||||||||
| 53 | is => 'rw', | ||||||||||||||||||||||||||||
| 54 | isa => 'Net::Journyx::SOAP', | ||||||||||||||||||||||||||||
| 55 | documentation => 'Journyx SOAP API helper functions', | ||||||||||||||||||||||||||||
| 56 | lazy => 1, | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 59 | 0 | return new Net::Journyx::SOAP jx => $self; | |||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||
| 61 | 10 | ); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # This probably wants to be !ua but | ||||||||||||||||||||||||||||
| 64 | # the soap object which is hopefully making the LWP requests | ||||||||||||||||||||||||||||
| 65 | # for us | ||||||||||||||||||||||||||||
| 66 | has ua => ( | ||||||||||||||||||||||||||||
| 67 | is => 'rw', | ||||||||||||||||||||||||||||
| 68 | isa => 'LWP::UserAgent', | ||||||||||||||||||||||||||||
| 69 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | 1 | my $args = shift; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | require LWP::UserAgent; | |||||||||||||||||||||||||||
| 73 | 1 | my $ua = LWP::UserAgent->new( keep_alive => 30 ); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | $ua->cookie_jar({}); | |||||||||||||||||||||||||||
| 76 | 1 | push @{ $ua->requests_redirectable }, qw( POST PUT DELETE ); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # Load the user's proxy settings from %ENV | ||||||||||||||||||||||||||||
| 79 | 1 | $ua->env_proxy; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | return $ua; | |||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||
| 83 | 10 | ); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 10 | has allows_utf8 => ( | |||||||||||||||||||||||||||
| 86 | is => 'rw', | ||||||||||||||||||||||||||||
| 87 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 88 | default => 0, | ||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 10 | has auto_logout => ( | |||||||||||||||||||||||||||
| 92 | is => 'rw', | ||||||||||||||||||||||||||||
| 93 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 94 | default => 0, | ||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head2 login | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | You don't need to call. Just provide username and password. | ||||||||||||||||||||||||||||
| 100 | When some Journyx need a session key you'll be logged in. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub login { | ||||||||||||||||||||||||||
|
Subroutine
login: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 106 | 0 | my %args = ( | |||||||||||||||||||||||||||
| 107 | keep_old_sessions => 1, | ||||||||||||||||||||||||||||
| 108 | @_ | ||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | my $user = $self->username; | |||||||||||||||||||||||||||
| 112 | 0 | my $pass = $self->password; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | confess "Unable to log in without a username and password." | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$user and $pass
MC/DC0%0/2
$user and $pass
$user
$pass
Truth table0%0/3
A and B
A= $userB= $pass
| |||||||||||||||||||||||||||||
| 115 | unless $user && $pass; | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | return $self->soap->basic_call( login => %args, username => $user, pwd => $pass ); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub logout { | ||||||||||||||||||||||||||
|
Subroutine
logout: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 122 | 0 | ▶ | return 1 unless $self->has_session; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | my $response = $self->soap->basic_call( logout => @_ ); | |||||||||||||||||||||||||||
| 124 | 0 | $self->clear_session; | |||||||||||||||||||||||||||
| 125 | 0 | return 1; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 10 | Net::Journyx::SOAP->install_basic('Net::Journyx' => qw( | |||||||||||||||||||||||||||
| 129 | adminEmail | ||||||||||||||||||||||||||||
| 130 | adminName | ||||||||||||||||||||||||||||
| 131 | adminTelephone | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | companyName | ||||||||||||||||||||||||||||
| 134 | customerNumber | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | whoami | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | uname | ||||||||||||||||||||||||||||
| 139 | hostname | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | licensedHost | ||||||||||||||||||||||||||||
| 142 | licensedUsers | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | installDate | ||||||||||||||||||||||||||||
| 145 | expirationDate | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | apiVersion | ||||||||||||||||||||||||||||
| 148 | version | ||||||||||||||||||||||||||||
| 149 | versionCheck | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | getCodeList | ||||||||||||||||||||||||||||
| 152 | getSubcodeList | ||||||||||||||||||||||||||||
| 153 | getSubsubcodeList | ||||||||||||||||||||||||||||
| 154 | )); | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 10 | foreach my $type (qw( | |||||||||||||||||||||||||||
| 157 | Project | ||||||||||||||||||||||||||||
| 158 | User | ||||||||||||||||||||||||||||
| 159 | Group | ||||||||||||||||||||||||||||
| 160 | Code | ||||||||||||||||||||||||||||
| 161 | Subcode | ||||||||||||||||||||||||||||
| 162 | Subsubcode | ||||||||||||||||||||||||||||
| 163 | Time | ||||||||||||||||||||||||||||
| 164 | )) { | ||||||||||||||||||||||||||||
| 165 | 70 | my $class = 'Net::Journyx::'. $type; | |||||||||||||||||||||||||||
| 166 | 70 | my $method = Net::Journyx::SOAP->nocapitals( $type ); | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $sub = eval <<END or die $@; | ||||||||||||||||||||||||||
|
Subroutine
code: not called CC=1 SCAR=5.7
Subroutine
group: not called CC=1 SCAR=5.7
Subroutine
project: not called CC=1 SCAR=5.7
Subroutine
subcode: not called CC=1 SCAR=5.7
Subroutine
subsubcode: not called CC=1 SCAR=5.7
Subroutine
time: not called CC=1 SCAR=5.7
Subroutine
user: not called CC=1 SCAR=5.7
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | sub { | ||||||||||||||||||||||||||||
| 170 | my \$self = shift; | ||||||||||||||||||||||||||||
| 171 | require $class; | ||||||||||||||||||||||||||||
| 172 | return $class->new( jx => \$self ); | ||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | END | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 70 | __PACKAGE__->meta->add_method($method => $sub); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 10 | ▶ | sub DEMOLISH { | ||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 180 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 181 | 10 | ▶ | $self->logout if $self->auto_logout; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 10 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 185 | 10 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 186 | 10 | 1; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | __END__ | ||||||||||||||||||||||||||||