line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Pandora::Partner; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
23290
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
521
|
use WebService::Pandora::Method; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
49
|
|
7
|
2
|
|
|
2
|
|
10
|
use Data::Dumper; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
115
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use constant WEBSERVICE_VERSION => '5'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
729
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
### constructor ### |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
1
|
12
|
my $caller = shift; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
5
|
my $class = ref( $caller ); |
18
|
2
|
50
|
|
|
|
7
|
$class = $caller if ( !$class ); |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
19
|
my $self = {'username' => undef, |
21
|
|
|
|
|
|
|
'password' => undef, |
22
|
|
|
|
|
|
|
'deviceModel' => undef, |
23
|
|
|
|
|
|
|
'decryption_key' => undef, |
24
|
|
|
|
|
|
|
'encryption_key' => undef, |
25
|
|
|
|
|
|
|
'host' => undef, |
26
|
|
|
|
|
|
|
@_}; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
4
|
bless( $self, $class ); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
22
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
### getters/setters ### |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub error { |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
2
|
1
|
393
|
my ( $self, $error ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
2
|
100
|
|
|
|
8
|
$self->{'error'} = $error if ( defined( $error ) ); |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
8
|
return $self->{'error'}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
### public methods ### |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub login { |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
1
|
1
|
5
|
my ( $self ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# make sure all arguments are given |
51
|
1
|
0
|
33
|
|
|
7
|
if ( !defined( $self->{'username'} ) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
52
|
|
|
|
|
|
|
!defined( $self->{'password'} ) || |
53
|
|
|
|
|
|
|
!defined( $self->{'deviceModel'} ) || |
54
|
|
|
|
|
|
|
!defined( $self->{'encryption_key'} ) || |
55
|
|
|
|
|
|
|
!defined( $self->{'decryption_key'} ) || |
56
|
|
|
|
|
|
|
!defined( $self->{'host'} ) ) { |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
3
|
$self->error( 'The username, password, deviceModel, encryption_key, decryption_key, and host must all be provided to the constructor.' ); |
59
|
1
|
|
|
|
|
3
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# create the auth.partnerLogin method |
63
|
|
|
|
|
|
|
my $method = WebService::Pandora::Method->new( name => 'auth.partnerLogin', |
64
|
|
|
|
|
|
|
encrypt => 0, |
65
|
|
|
|
|
|
|
ssl => 1, |
66
|
|
|
|
|
|
|
host => $self->{'host'}, |
67
|
|
|
|
|
|
|
params => {'username' => $self->{'username'}, |
68
|
|
|
|
|
|
|
'password' => $self->{'password'}, |
69
|
0
|
|
|
|
|
|
'deviceModel' => $self->{'deviceModel'}, |
70
|
|
|
|
|
|
|
'version' => "5"} ); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $result = $method->execute(); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# detect error |
75
|
0
|
0
|
|
|
|
|
if ( !$result ) { |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$self->error( $method->error() ); |
78
|
0
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $result; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |