SFDC/Tooling.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 81 CC 6 SCAR 20.0
CC
6
Cov
0%
executeAnonymous
20.0
_prepareSObjects
12.0
_extractURL
2.0
CRAP 7.4
1 package WWW::SFDC::Tooling;
2 # ABSTRACT: Interface to the Salesforce.com Tooling API
3  
4 use 5.12.0;
5 use strict;
6 use warnings;
7  
8 use Log::Log4perl ':easy';
9 use WWW::SFDC::SessionManager;
10  
11 use Scalar::Util 'blessed';
12  
13 use Moo;
14 with 'MooX::Singleton', 'WWW::SFDC::Role::Session', 'WWW::SFDC::Role::CRUD';
15  
16  
17 has 'uri',
18 is => 'ro',
19 default => 'urn:tooling.soap.sforce.com';
20  
21 sub _extractURL {
22 return $_[1]->{serverUrl} =~ s{/u/}{/T/}r;
23 }
24  
25  
26 sub _prepareSObjects {
27 my $self = shift;
28 # prepares an array of objects for an update or insert call by converting
29 # it to an array of SOAP::Data
30  
31 # THIS IMPLEMENTATION IS DIFFERENT TO THE EQUIVALENT PARTNER API IMPLEMENTATION
32  
33 TRACE "objects for operation" => \@_;
34  
35 return map {
36 my $obj = $_;
37 my $type;
38 if ($obj->{type}) {
39 $type = $obj->{type};
40 delete $obj->{type};
41 }
42  
43 SOAP::Data->name(sObjects => \SOAP::Data->value(
44 map {
45 (blessed ($obj->{$_}) and blessed ($obj->{$_}) eq 'SOAP::Data')
46 ? $obj->{$_}
47 : SOAP::Data->name($_ => $obj->{$_})
48 } keys %$obj
49 ))->type($type)
50 } @_;
51 }
52  
53  
54 sub describeGlobal {
55 ...
56 }
57  
58  
59 sub describeSObjects {
60 ...
61 }
62  
63  
64 sub executeAnonymous {
65 my ($self, $code, %options) = @_;
66 my $result = $self->_call(
67 'executeAnonymous',
68 SOAP::Data->name(string => $code),
69 $options{debug} ? SOAP::Header->name('DebuggingHeader' => \SOAP::Data->name(
70 debugLevel => 'DEBUGONLY'
71 )) : (),
72 );
73  
74 LOGDIE "ExecuteAnonymous failed to compile: " . $result->{compileProblem}
75 if $result->{compiled} eq "false";
76  
77 LOGDIE "ExecuteAnonymous failed to complete: " . $result->{exceptionMessage}
78 if $result->{success} eq "false";
79  
80 return $result;
81 }
82  
83  
84 sub runTests {
85 my ($self, @names) = @_;
86  
87 return $self->_call(
88 'runTests',
89 map {\SOAP::Data->name(classes => $_)} @names
90 );
91 }
92  
93  
94 sub runTestsAsynchronous {
95 my ($self, @ids) = @_;
96  
97 return $self->_call('runTestsAsynchronous', join ",", @ids);
98 }
99  
100 1;
101  
102 __END__
103  
104 =pod
105  
106 =head1 NAME
107  
108 WWW::SFDC::Tooling - Interface to the Salesforce.com Tooling API
109  
110 =head1 VERSION
111  
112 version 0.22
113  
114 =head1 SYNOPSIS
115  
116 my $result = SFDC::tooling->instance(creds => {
117 username => $USER,
118 password => $PASS,
119 url => $URL
120 })->executeAnonymous("System.debug(1);");
121  
122 Note that $URL is the _login_ URL, not the Tooling API endpoint URL - which gets calculated internally.
123  
124 =head1 METHODS
125  
126 =head2 create
127  
128 =head2 describeGlobal
129  
130 =head2 describeSObjects
131  
132 =head2 executeAnonymous
133  
134 WWW::SFDC::Tooling->instance()->executeAnonymous("system.debug(1);")
135  
136 =head2 runTests
137  
138 SFDC::Tooling->instance()->runTests('name','name2');
139  
140 =head2 runTestsAsynchronous
141  
142 =head1 BUGS
143  
144 Please report any bugs or feature requests at L<https://github.com/alexander-brett/WWW-SFDC/issues>.
145  
146 =head1 SUPPORT
147  
148 You can find documentation for this module with the perldoc command.
149  
150 perldoc WWW::SFDC::Tooling
151  
152 You can also look for information at L<https://github.com/alexander-brett/WWW-SFDC>
153  
154 =head1 AUTHOR
155  
156 Alexander Brett <alexander.brett@sophos.com>
157  
158 =head1 COPYRIGHT AND LICENSE
159  
160 This software is Copyright (c) 2015 by Sophos Limited.
161  
162 This is free software, licensed under:
163  
164 The MIT (X11) License
165  
166 The full text of the license can be found in the
167 F<LICENSE> file included with this distribution.
168  
169 =cut