line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OpenSocial::Client::Protocol::Builder; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use Any::Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2225
|
use OAuth::Lite::Token; |
|
1
|
|
|
|
|
30575
|
|
|
1
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
608
|
use Net::OpenSocial::Client::HTTPRequestBuilder::OAuth; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
12
|
|
8
|
1
|
|
|
1
|
|
763
|
use Net::OpenSocial::Client::HTTPRequestBuilder::ST; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
819
|
use Net::OpenSocial::Client::Protocol::REST; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
11
|
1
|
|
|
1
|
|
514
|
use Net::OpenSocial::Client::Protocol::RPC; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
505
|
use Net::OpenSocial::Client::Formatter::JSON; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
593
|
use Net::OpenSocial::Client::Type::Protocol qw(REST RPC); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
83
|
|
16
|
1
|
|
|
1
|
|
832
|
use Net::OpenSocial::Client::Type::Auth qw(OAUTH ST); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
72
|
|
17
|
1
|
|
|
1
|
|
679
|
use Net::OpenSocial::Client::Type::Format qw(JSON XML ATOM); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
725
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with 'Net::OpenSocial::Client::ErrorHandler'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'protocol_type' => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => 'Str', |
24
|
|
|
|
|
|
|
default => REST, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'auth_type' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => 'Str', |
30
|
|
|
|
|
|
|
default => OAUTH, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'format_type' => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'Str', |
36
|
|
|
|
|
|
|
default => JSON, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has 'consumer_key' => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => 'Str', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'consumer_secret' => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => 'Str', |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has 'token' => ( |
50
|
|
|
|
|
|
|
is => 'ro', |
51
|
|
|
|
|
|
|
isa => 'OAuth::Lite::Token', |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'requestor' => ( |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
isa => 'Str', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'st' => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
isa => 'Str', |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has 'agent' => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
default => sub { LWP::UserAgent->new }, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub build_protocol { |
70
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
71
|
0
|
0
|
|
|
|
|
my $request_builder = $self->_build_request_builder() |
72
|
|
|
|
|
|
|
or return; |
73
|
0
|
0
|
|
|
|
|
my $formatter = $self->_build_formatter() |
74
|
|
|
|
|
|
|
or return; |
75
|
0
|
0
|
|
|
|
|
if ( $self->protocol_type eq REST ) { |
|
|
0
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return Net::OpenSocial::Client::Protocol::REST->new( |
77
|
|
|
|
|
|
|
request_builder => $request_builder, |
78
|
|
|
|
|
|
|
formatter => $formatter, |
79
|
|
|
|
|
|
|
agent => $self->agent, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ( $self->protocol_type eq RPC ) { |
83
|
0
|
|
|
|
|
|
return Net::OpenSocial::Client::Protocol::RPC->new( |
84
|
|
|
|
|
|
|
request_builder => $request_builder, |
85
|
|
|
|
|
|
|
formatter => $formatter, |
86
|
|
|
|
|
|
|
agent => $self->agent, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
return $self->ERROR(q{Unknown protocol type.}); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _build_formatter { |
93
|
0
|
|
|
0
|
|
|
my $self = shift; |
94
|
0
|
0
|
|
|
|
|
if ( $self->format_type eq JSON ) { |
95
|
0
|
|
|
|
|
|
return Net::OpenSocial::Client::Formatter::JSON->new; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# XXX: not supported yet |
99
|
|
|
|
|
|
|
#elsif ( $self->format_type eq XML ) { |
100
|
|
|
|
|
|
|
# return Net::OpenSocial::Client::Formatter::XML->new; |
101
|
|
|
|
|
|
|
#} |
102
|
|
|
|
|
|
|
#elsif ( $self->format_type eq ATOM ) { |
103
|
|
|
|
|
|
|
# return $self->ERROR(q{Atom format is not supported on RPC protocol.}) |
104
|
|
|
|
|
|
|
# if ( $self->protocol_type eq RPC ); |
105
|
|
|
|
|
|
|
# return Net::OpenSocial::Client::Formatter::Atom->new; |
106
|
|
|
|
|
|
|
#} |
107
|
0
|
|
|
|
|
|
return $self->ERROR(q{Unknown format type.}); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _build_request_builder { |
111
|
0
|
|
|
0
|
|
|
my $self = shift; |
112
|
0
|
0
|
|
|
|
|
if ( $self->auth_type eq OAUTH ) { |
|
|
0
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
|
return $self->ERROR( |
114
|
|
|
|
|
|
|
q{When you set OAUTH as auth_type, you should set both 'consumer_key' and 'consumer_secret'.} |
115
|
|
|
|
|
|
|
) |
116
|
|
|
|
|
|
|
unless ( defined $self->consumer_key |
117
|
|
|
|
|
|
|
&& defined $self->consumer_secret ); |
118
|
0
|
|
|
|
|
|
my %args = ( |
119
|
|
|
|
|
|
|
consumer_key => $self->consumer_key, |
120
|
|
|
|
|
|
|
consumer_secret => $self->consumer_secret, |
121
|
|
|
|
|
|
|
); |
122
|
0
|
0
|
|
|
|
|
if ( $self->token ) { |
|
|
0
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$args{token} = $self->token; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
elsif ( $self->requestor ) { |
126
|
0
|
|
|
|
|
|
$args{requestor} = $self->requestor; |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
return Net::OpenSocial::Client::HTTPRequestBuilder::OAuth->new(%args); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
elsif ( $self->auth_type eq ST ) { |
131
|
0
|
0
|
|
|
|
|
return $self->ERROR( |
132
|
|
|
|
|
|
|
q{When you set ST as auth_type, you should set parameter 'st' for security token value.} |
133
|
|
|
|
|
|
|
) unless ( defined $self->st ); |
134
|
0
|
|
|
|
|
|
return Net::OpenSocial::Client::HTTPRequestBuilder::ST->new( |
135
|
|
|
|
|
|
|
st => $self->st ); |
136
|
|
|
|
|
|
|
} |
137
|
0
|
|
|
|
|
|
return $self->ERROR(q{Unknown auth type.}); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
1
|
|
7
|
no Any::Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
141
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
142
|
|
|
|
|
|
|
1; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 NAME |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Net::OpenSocial::Client::Protocol::Builder - Protocol builder |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SYNOPSIS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my $builder = Net::OpenSocial::Client::Protocol::Builder->new(); |
151
|
|
|
|
|
|
|
my $protocol = $builder->build_protocol(); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 DESCRIPTION |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Protocol builder. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 METHODS |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 build_protocol |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SEE ALSO |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
L |
165
|
|
|
|
|
|
|
L |
166
|
|
|
|
|
|
|
L |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Copyright (C) 2009 by Lyo Kato |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
177
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
178
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |