API/Response.pm

filter: Statementstmt 38.7% 12 / 31 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 50.0% 2 / 4 totaltotal 38.6% 17 / 44 CC 2 SCAR 9.7
CC
2
Cov
36%
reply
6.0
new
2.0
set_error
2.0
CRAP 2.6
« API/Request.pm ↑ Summary
1 package WebService::30Boxes::API::Response;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our @ISA = qw(HTTP::Response);
8 1 our $VERSION = '1.05';
9  
10 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
11 0 my ($class, $args) = @_;
12 0 my $self = new HTTP::Response;
13 0 $self->{'error_code'} = undef;
14 0 $self->{'error_msg'} = undef;
15 0 $self->{'success'} = undef;
16 0 $self->{'_xml'} = undef;
17 0 bless $self, $class;
18 0 return $self;
19 }
20  
21 0 ▶sub set_error {
Subroutine set_error: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my ($self, $code, $msg) = @_;
23 0 $self->{'success'} = 0;
24 0 $self->{'error_code'} = $code;
25 0 $self->{'error_msg'} = $msg;
26 }
27  
28 0 ▶sub set_success {
Subroutine set_success: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my ($self) = @_;
30 0 $self->{'success'} = 1;
31 0 $self->{'error_code'} = undef;
32 0 $self->{'error_msg'} = undef;
33 }
34  
35 0 ▶sub reply {
Subroutine reply: not called CC=2 SCAR=17.9
Pod documented
36 0 my ($self, $xml) = @_;
37 0 ▶ $self->{'_xml'} = $xml if($xml);
Branch: 1 branch
BranchTrueFalseTotal
if $xml 0 0 0
38 0 return $self->{'_xml'};
39 }
40  
41 1 1;
42 #################### main pod documentation begin ###################
43  
44 =head1 NAME
45  
46 WebService::30Boxes::API::Response - Response from 30Boxes REST API
47  
48 =head1 SYNOPSIS
49  
50 use WebService::30Boxes::API;
51  
52 # You always have to provide your api_key
53 my $boxes = WebService::30Boxes::API->(api_key => 'your_api_key');
54  
55 # Then you might want to lookup a user and print some info
56 my $result = $boxes->call('user.FindById', { id => 47 });
57 if($result->{'success'}) {
58 my $user = $result->reply->{'user'};
59
60 print $user->{'firstName'}, " ",
61 $user->{'lastName'}, " joined 30Boxes at ",
62 $user->{'createDate'},"\n";
63 } else {
64 print "An error occured ($result->{'error_code'}: ".
65 "$result->{'error_msg'})";
66 }
67  
68 =head1 DESCRIPTION
69  
70 C<WebService::30Boxes::API::Response>- Response from 30Boxes API
71  
72 The response object is basically a L<HTTP::Request> class, with a few
73 things added. These keys can be queried:
74  
75 =over 5
76  
77 =item success
78  
79 Was the call succesful?
80  
81 =item error_code
82  
83 If not succesful, what error code did we get?
84  
85 =item error_msg
86  
87 And the error message
88  
89 =back
90  
91 =head2 METHODS
92  
93 =head3 reply
94  
95 C<reply> returns the result of L<XML::Simple>'s parsing of the 30Boxes
96 reply. See the example above.
97  
98 =head1 SEE ALSO
99  
100 L<WebService::30Boxes::API>, L<HTTP::Request>, L<XML::Simple>
101  
102 =head1 BUGS
103  
104 Please report any bugs to L<http://rt.cpan.org/Ticket/Create.html?Queue=WebService::30Boxes::API>
105  
106 =head1 AUTHOR
107  
108 M. Blom,
109 E<lt>blom@cpan.orgE<gt>,
110 L<http://menno.b10m.net/perl/>
111  
112 =head1 COPYRIGHT AND LICENSE
113  
114 Copyright (C) 2006 by M. Blom
115  
116 This library is free software; you can redistribute it and/or modify
117 it under the same terms as Perl itself, either Perl version 5.8.6 or,
118 at your option, any later version of Perl 5 you may have available.
119  
120 =cut
121  
« API/Request.pm ↑ Summary