betfair/TypeCheck.pm

filter: Statementstmt 83.9% 178 / 212 Branchbran 68.4% 115 / 168 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 86.6% 39 / 45 Podpod 100% 42 / 42 totaltotal 79.6% 380 / 477 CC 89 SCAR 14.9
CC
89
Cov
77%
checkGenderEnum
12.0
checkExchangeId
12.0
checkCurrencyCode
12.0
CRAP 4.4
« betfair.pm ↑ Summary betfair/Request.pm »
1 package WWW::betfair::TypeCheck;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Regexp::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 DESCRIPTION
7  
8 Used by L<WWW::betfair> to provide type checking for parameters passed to the betfair API. Includes betfair's enumerated types.
9  
10 =head2 new
11  
12 Returns a new L<WWW::betfair::Type> object. Requires no parameters.
13  
14 =cut
15  
16 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 1 my $class = shift;
18 1 my $self = {
19 typeChecks => { int => \&checkInt,
20 exchangeId => \&checkExchangeId,
21 decimal => \&checkDecimal,
22 date => \&checkDate,
23 string => \&checkString,
24 string9 => \&checkString9,
25 cardDate => \&checkCardDate,
26 cv2 => \&checkCv2,
27 username => \&checkUsername,
28 currencyCode => \&checkCurrencyCode,
29 password => \&checkPassword,
30 boolean => \&checkBoolean,
31 hash => \&checkHash,
32 arrayInt => \&checkArrayInt,
33 accountStatementEnum => \&checkAccountStatementEnum,
34 accountStatementIncludeEnum => \&checkAccountStatementIncludeEnum,
35 accountStatusEnum => \&checkAccountStatusEnum,
36 accountTypeEnum => \&checkAccountTypeEnum,
37 betCategoryTypeEnum => \&checkBetCategoryTypeEnum,
38 betPersistenceTypeEnum => \&checkBetPersistenceTypeEnum,
39 betsOrderByEnum => \&checkBetsOrderByEnum,
40 betStatusEnum => \&checkBetStatusEnum,
41 betTypeEnum => \&checkBetTypeEnum,
42 billingPeriodEnum => \&checkBillingPeriodEnum,
43 cardTypeEnum => \&checkCardTypeEnum,
44 gamcareLimitFreqEnum => \&checkGamcareLimitFreqEnum,
45 genderEnum => \&checkGenderEnum,
46 marketStatusEnum => \&checkMarketStatusEnum,
47 marketTypeEnum => \&checkMarketTypeEnum,
48 arrayMarketTypeEnum => \&checkArrayMarketTypeEnum,
49 marketTypeVariantEnum => \&checkMarketTypeVariantEnum,
50 paymentCardStatusEnum => \&checkPaymentCardStatusEnum,
51 regionEnum => \&checkRegionEnum,
52 securityQuestion1Enum => \&checkSecurityQuestion1Enum,
53 securityQuestion2Enum => \&checkSecurityQuestion2Enum,
54 serviceEnum => \&checkServiceEnum,
55 sortOrderEnum => \&checkSortOrderEnum,
56 subscriptionStatusEnum => \&checkSubscriptionStatusEnum,
57 titleEnum => \&checkTitleEnum,
58 validationErrorsEnum => \&checkValidationErrorsEnum,
59 },
60 };
61 1 return bless $self, $class;
62 }
63  
64  
65 =head2 checkParameter
66  
67 Receives a parameter and parameter type and executes the appropriate check method for that type.
68  
69 =cut
70  
71 10 ▶sub checkParameter {
Subroutine checkParameter: called CC=4 SCAR=15.2
Pod documented
72 10 my ($self, $type, $parameter) = @_;
73 10 ▶ return 0 unless (defined $type and defined $parameter);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and defined $parameter 0 10 10
Condition33%1/3
defined $type and defined $parameter
!ll&&!rl&&r
0010
MC/DC0%0/2
defined $type and defined $parameter
defined $type defined $parameter
Truth table33%1/3
A and B
A= defined $typeB= defined $parameter
ABresult
0X0
100
111
74 10 ▶ return 0 unless exists $self->{typeChecks}->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"typeChecks"}{$type} 0 10 10
75 10 my $check = $self->{typeChecks}->{$type};
76 10 return $self->$check($parameter);
77 }
78  
79 =head2 checkAccountStatementEnum
80  
81 Checks submitted value is a valid betfair enumerated type, see L<accountStatementEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028861i1028861> for details.
82  
83 =cut
84  
85 2 ▶sub checkAccountStatementEnum {
Subroutine checkAccountStatementEnum: called CC=3 SCAR=11.0
Pod documented
86 2 my ($self, $arg) = @_;
87 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
88 2 ▶ return 1 if grep {/^$arg$/} qw/OK RESULT_ERR RESULT_FIX RESULT_LOST RESULT_NOT_APPLICABLE RESULT_WON COMMISSION_REVERSAL/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "OK", "RESULT_ERR", "RESULT_FIX", "RESULT_LOST", "RESULT_NOT_APPLICABLE", "RESULT_WON", "COMMISSION_REVERSAL" 1 1 2
89 1 return 0;
90 }
91  
92 =head2 checkAccountStatementIncludeEnum
93  
94 Checks submitted value is a valid betfair enumerated type, see L<accountStatementIncludeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#d83e136> for details.
95  
96 =cut
97  
98 2 ▶sub checkAccountStatementIncludeEnum {
Subroutine checkAccountStatementIncludeEnum: called CC=3 SCAR=11.0
Pod documented
99 2 my ($self, $arg) = @_;
100 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
101 2 ▶ return 1 if grep {/^$arg$/} qw/ALL DEPOSITS_WITHDRAWALS EXCHANGE POKER_ROOM/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "ALL", "DEPOSITS_WITHDRAWALS", "EXCHANGE", "POKER_ROOM" 1 1 2
102 1 return 0;
103 }
104  
105 =head2 checkAccountStatusEnum
106  
107 Checks submitted value is a valid betfair enumerated type, see L<accountStatusEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028854i1028854>.
108  
109 =cut
110  
111 2 ▶sub checkAccountStatusEnum {
Subroutine checkAccountStatusEnum: called CC=3 SCAR=11.0
Pod documented
112 2 my ($self, $arg) = @_;
113 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
114 2 ▶ return 1 if grep {/^$arg$/} qw/A C D L P S T X Z/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "A", "C", "D", "L", "P", "S", "T", "X", "Z" 1 1 2
115 1 return 0;
116 }
117  
118 =head2 checkAccountTypeEnum
119  
120 Checks submitted value is a valid betfair enumerated type, see L<accountTypeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1033140i1033140> for details.
121  
122 =cut
123  
124 2 ▶sub checkAccountTypeEnum {
Subroutine checkAccountTypeEnum: called CC=3 SCAR=11.3
Pod documented
125 2 my ($self, $arg) = @_;
126 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 1 2
127 1 ▶ return 1 if grep {/^$arg$/} qw/STANDARD MARGIN TRADING AGENT_CLIENT/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "STANDARD", "MARGIN", "TRADING", "AGENT_CLIENT" 1 0 1
128 0 return 0;
129 }
130  
131 =head2 checkBetCategoryTypeEnum
132  
133 Checks submitted value is a valid betfair enumerated type, see L<betCategoryTypeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#d83e452> for details.
134  
135 =cut
136  
137 2 ▶sub checkBetCategoryTypeEnum {
Subroutine checkBetCategoryTypeEnum: called CC=3 SCAR=11.0
Pod documented
138 2 my ($self, $arg) = @_;
139 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
140 2 ▶ return 1 if grep {/^$arg$/} qw/NONE E M L/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "NONE", "E", "M", "L" 1 1 2
141 1 return 0;
142 }
143  
144 =head2 checkBetPersistenceTypeEnum
145  
146 Checks submitted value is a valid betfair enumerated type, see L<betPersistenceTypeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#d83e531> for details.
147  
148 =cut
149  
150 2 ▶sub checkBetPersistenceTypeEnum {
Subroutine checkBetPersistenceTypeEnum: called CC=3 SCAR=11.0
Pod documented
151 2 my ($self, $arg) = @_;
152 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
153 2 ▶ return 1 if grep {/^$arg$/} qw/NONE IP SP/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "NONE", "IP", "SP" 1 1 2
154 1 return 0;
155 }
156  
157 =head2 checkBetsOrderByEnum
158  
159 Checks submitted value is a valid betfair enumerated type, see L<betsOrderByEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1033170i1033170> for details.
160  
161 =cut
162  
163 2 ▶sub checkBetsOrderByEnum {
Subroutine checkBetsOrderByEnum: called CC=3 SCAR=11.0
Pod documented
164 2 my ($self, $arg) = @_;
165 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
166 2 ▶ return 1 if grep {/^$arg$/} qw/BET_ID CANCELLED_DATE MARKET_NAME MATCHED_DATE NONE PLACED_DATE/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "BET_ID", "CANCELLED_DATE", "MARKET_NAME", "MATCHED_DATE", "NONE", "PLACED_DATE" 1 1 2
167 1 return 0;
168 }
169  
170 =head2 checkBetStatusEnum
171  
172 Checks submitted value is a valid betfair enumerated type, see L<betStatusEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028849i1028849> for details.
173  
174 =cut
175  
176 2 ▶sub checkBetStatusEnum {
Subroutine checkBetStatusEnum: called CC=3 SCAR=11.0
Pod documented
177 2 my ($self, $arg) = @_;
178 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
179 2 ▶ return 1 if grep {/^$arg$/} qw/C L M MU S U V/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "C", "L", "M", "MU", "S", "U", "V" 1 1 2
180 1 return 0;
181 }
182  
183 =head2 checkBetTypeEnum
184  
185 Checks submitted value is a valid betfair enumerated type, see L<betTypeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028850i1028850> for details.
186  
187 =cut
188  
189 3 ▶sub checkBetTypeEnum {
Subroutine checkBetTypeEnum: called CC=3 SCAR=11.3
Pod documented
190 3 my ($self, $arg) = @_;
191 3 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 2 3
192 2 ▶ return 1 if grep {/^$arg$/} qw/B L/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "B", "L" 2 0 2
193 0 return 0;
194 }
195  
196 =head2 checkBillingPeriodEnum
197  
198 Checks submitted value is a valid betfair enumerated type, see L<billingPeriodEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028862i1028862> for details.
199  
200 =cut
201  
202 2 ▶sub checkBillingPeriodEnum {
Subroutine checkBillingPeriodEnum: called CC=3 SCAR=11.0
Pod documented
203 2 my ($self, $arg) = @_;
204 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
205 2 ▶ return 1 if grep {/^$arg$/} qw/WEEKLY MONTHLY QUARTERLY ANNUALLY/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "WEEKLY", "MONTHLY", "QUARTERLY", "ANNUALLY" 1 1 2
206 1 return 0;
207 }
208  
209 =head2 checkCardTypeEnum
210  
211 Checks submitted value is a valid betfair enumerated type, see L<cardTypeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028865i1028865> for details.
212  
213 =cut
214  
215 2 ▶sub checkCardTypeEnum {
Subroutine checkCardTypeEnum: called CC=3 SCAR=11.0
Pod documented
216 2 my ($self, $arg) = @_;
217 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
218 2 ▶ return 1 if grep {/^$arg$/} qw/VISA MASTERCARD VISADELTA SWITCH SOLO ELECTRON LASER MAESTRO INVALID_CARD_TYPE/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "VISA", "MASTERCARD", "VISADELTA", "SWITCH", "SOLO", "ELECTRON", "LASER", "MAESTRO", "INVALID_CARD_TYPE" 1 1 2
219 1 return 0;
220 }
221  
222 =head2 checkGamcareLimitFreqEnum
223  
224 Checks submitted value is a valid betfair enumerated type, see L<gamcareLimitFreqEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028855i1028855> for details.
225  
226 =cut
227  
228 2 ▶sub checkGamcareLimitFreqEnum {
Subroutine checkGamcareLimitFreqEnum: called CC=3 SCAR=11.0
Pod documented
229 2 my ($self, $arg) = @_;
230 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
231 2 ▶ return 1 if grep {/^$arg$/} qw/DAILY WEEKLY MONTHLY YEARLY/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "DAILY", "WEEKLY", "MONTHLY", "YEARLY" 1 1 2
232 1 return 0;
233 }
234  
235 =head2 checkGenderEnum
236  
237 Checks submitted value is a valid betfair enumerated type, see L<genderEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028856i1028856> for details.
238  
239 =cut
240  
241 0 ▶sub checkGenderEnum {
Subroutine checkGenderEnum: not called CC=3 SCAR=24.8
Pod documented
242 0 my ($self, $arg) = @_;
243 0 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 0 0
244 0 ▶ return 1 if grep {/^$arg$/} qw/M F/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "M", "F" 0 0 0
245 0 return 0;
246 }
247  
248 =head2 checkMarketStatusEnum
249  
250 Checks submitted value is a valid betfair enumerated type, see L<marketStatusEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1026626i1026626> for details.
251  
252 =cut
253  
254 2 ▶sub checkMarketStatusEnum {
Subroutine checkMarketStatusEnum: called CC=3 SCAR=12.0
Pod documented
255 2 my ($self, $arg) = @_;
256 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
257 2 ▶ return 1 if grep {/^$arg$/} qw/ACTIVE CLOSED INACTIVE SUSPENDED/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "ACTIVE", "CLOSED", "INACTIVE", "SUSPENDED" 2 0 2
258 0 return 0;
259 }
260  
261  
262 =head2 checkMarketTypeEnum
263  
264 Checks submitted value is a valid betfair enumerated type, see L<marketTypeEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1020360i1020360> for details.
265  
266 =cut
267  
268 8 ▶sub checkMarketTypeEnum {
Subroutine checkMarketTypeEnum: called CC=3 SCAR=11.0
Pod documented
269 8 my ($self, $arg) = @_;
270 8 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 7 8
271 7 ▶ return 1 if grep {/^$arg$/} qw/A L O R NOT_APPLICABLE/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "A", "L", "O", "R", "NOT_APPLICABLE" 6 1 7
272 1 return 0;
273 }
274  
275 =head2 checkArrayMarketTypeEnum
276  
277 Checks the argument is a non-null arrayref containing only valid marketTypeEnum values.
278  
279 =cut
280  
281 3 ▶sub checkArrayMarketTypeEnum {
Subroutine checkArrayMarketTypeEnum: called CC=5 SCAR=16.1
Pod documented
282 3 my ($self, $arg) = @_;
283 3 ▶ return 0 unless @$arg;
Branch: 1 branch
BranchTrueFalseTotal
unless @$arg 1 2 3
284 2 ▶ return 0 unless ref $arg eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $arg eq "ARRAY" 0 2 2
285 2 foreach (@{$arg}) {
286 6 ▶ return 0 unless $self->checkMarketTypeEnum($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->checkMarketTypeEnum($_) 1 5 6
287 }
288 1 return 1;
289 }
290  
291 =head2 checkMarketTypeVariantEnum
292  
293 Checks submitted value is a valid betfair enumerated type, see L<marketTypeVariantEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1026240i1026240> for details.
294  
295 =cut
296  
297 2 ▶sub checkMarketTypeVariantEnum {
Subroutine checkMarketTypeVariantEnum: called CC=3 SCAR=11.0
Pod documented
298 2 my ($self, $arg) = @_;
299 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
300 2 ▶ return 1 if grep {/^$arg$/} qw/D ASL ADL/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "D", "ASL", "ADL" 1 1 2
301 1 return 0;
302 }
303  
304 =head2 checkPaymentCardStatusEnum
305  
306 Checks submitted value is a valid betfair enumerated type, see L<paymentCardStatusEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028846i1028846>.
307  
308 =cut
309  
310 2 ▶sub checkPaymentCardStatusEnum {
Subroutine checkPaymentCardStatusEnum: called CC=3 SCAR=11.0
Pod documented
311 2 my ($self, $arg) = @_;
312 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
313 2 ▶ return 1 if grep {/^$arg$/} qw/LOCKED UNLOCKED/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "LOCKED", "UNLOCKED" 1 1 2
314 1 return 0;
315 }
316  
317 =head2 checkRegionEnum
318  
319 Checks submitted value is a valid betfair enumerated type, see L<regionEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028859i1028859> for details.
320  
321 =cut
322  
323 2 ▶sub checkRegionEnum {
Subroutine checkRegionEnum: called CC=3 SCAR=11.3
Pod documented
324 2 my ($self, $arg) = @_;
325 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 1 2
326 1 ▶ return 1 if grep {/^$arg$/} qw/AUZ_NZL GBR IRL NA NORD ZAF/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "AUZ_NZL", "GBR", "IRL", "NA", "NORD", "ZAF" 1 0 1
327 0 return 0;
328 }
329  
330 =head2 checkSecurityQuestion1Enum
331  
332 Checks submitted value is a valid betfair enumerated type, see L<securityQuestion1Enum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028857i1028857> for details.
333  
334 =cut
335  
336 2 ▶sub checkSecurityQuestion1Enum {
Subroutine checkSecurityQuestion1Enum: called CC=3 SCAR=11.0
Pod documented
337 2 my ($self, $arg) = @_;
338 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
339 2 ▶ return 1 if grep {/^$arg$/} qw/SQ1A SQ1B SQ1C SQ1D/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "SQ1A", "SQ1B", "SQ1C", "SQ1D" 1 1 2
340 1 return 0;
341 }
342  
343 =head2 checkSecurityQuestion2Enum
344  
345 Checks submitted value is a valid betfair enumerated type, see L<securityQuestion2Enum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028858i1028858> for details.
346  
347 =cut
348  
349 2 ▶sub checkSecurityQuestion2Enum {
Subroutine checkSecurityQuestion2Enum: called CC=3 SCAR=11.0
Pod documented
350 2 my ($self, $arg) = @_;
351 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
352 2 ▶ return 1 if grep {/^$arg$/} qw/SQ2A SQ2B SQ2C SQ2S/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "SQ2A", "SQ2B", "SQ2C", "SQ2S" 1 1 2
353 1 return 0;
354 }
355  
356 =head2 checkServiceEnum
357  
358 Checks submitted value is a valid betfair enumerated type, see L<serviceEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028864i1028864>.
359  
360 =cut
361  
362 2 ▶sub checkServiceEnum {
Subroutine checkServiceEnum: called CC=3 SCAR=11.0
Pod documented
363 2 my ($self, $arg) = @_;
364 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
365 2 ▶ return 1 if grep {/^$arg$/} qw/ADD_PAYMENT_CARD CANCEL_BETS CREATE_ACCOUNT CONVERT_CURRENCY DELETE_PAYMENT_CARD DEPOSIT_FROM_PAYMENT_CARD
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "ADD_PAYMENT_CARD", "CANCEL_BETS", "CREATE_ACCOUNT", "CONVERT_CURRENCY", "DELETE_PAYMENT_CARD", "DEPOSIT_FROM_PAYMENT_CARD", "DO_KEEP_ALIVE", "EDIT_BETS", "FORGOT_PASSWORD", "GET_ACCOUNT_STATEMENT", "GET_BET", "GET_CURRENT_BETS", "GET_CURRENCIES", "GET_MARKET_TRADED_VOLUME", "GET_PAYMENT_CARD", "LOAD_BET_HISTORY", "LOAD_DETAILED_AVAIL_MKT_DEPTH", "LOAD_EVENT_TYPES", "LOAD_EVENTS", "LOAD_MARKET", "LOAD_MARKET_PRICES", "LOAD_MARKET_PRICES_COMPRESSED", "LOAD_MARKET_PROFIT_LOSS", "LOAD_SERVICE_ANNOUNCEMENTS", "LOAD_SUBSCRIPTION_INFO", "LOGIN", "LOGOUT", "MODIFY_PASSWORD", "MODIFY_PROFILE", "PLACE_BETS", "RETRIEVE_LIMB_MESSAGE", "SUBMIT_LIMB_MESSAGE", "UPDATE_PAYMENT_CARD", "VIEW_PROFILE", "WITHDRAW_TO_PAYMENT_CARD" 1 1 2
366 DO_KEEP_ALIVE EDIT_BETS FORGOT_PASSWORD GET_ACCOUNT_STATEMENT GET_BET GET_CURRENT_BETS GET_CURRENCIES
367 GET_MARKET_TRADED_VOLUME GET_PAYMENT_CARD LOAD_BET_HISTORY LOAD_DETAILED_AVAIL_MKT_DEPTH LOAD_EVENT_TYPES
368 LOAD_EVENTS LOAD_MARKET LOAD_MARKET_PRICES LOAD_MARKET_PRICES_COMPRESSED LOAD_MARKET_PROFIT_LOSS
369 LOAD_SERVICE_ANNOUNCEMENTS LOAD_SUBSCRIPTION_INFO LOGIN LOGOUT MODIFY_PASSWORD MODIFY_PROFILE PLACE_BETS
370 RETRIEVE_LIMB_MESSAGE SUBMIT_LIMB_MESSAGE UPDATE_PAYMENT_CARD VIEW_PROFILE WITHDRAW_TO_PAYMENT_CARD/;
371 1 return 0;
372 }
373  
374 =head2 checkSortOrderEnum
375  
376 Checks submitted value is a valid betfair enumerated type, see L<sortOrderEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028852i1028852> for details.
377  
378 =cut
379  
380 2 ▶sub checkSortOrderEnum {
Subroutine checkSortOrderEnum: called CC=3 SCAR=12.0
Pod documented
381 2 my ($self, $arg) = @_;
382 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
383 2 ▶ return 1 if grep {/^$arg$/} qw/ASC DESC/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "ASC", "DESC" 2 0 2
384 0 return 0;
385 }
386  
387 =head2 checkSubscriptionStatusEnum
388  
389 Checks submitted value is a valid betfair enumerated type, see L<subscriptionStatusEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1028863i1028863> for details.
390  
391 =cut
392  
393 2 ▶sub checkSubscriptionStatusEnum {
Subroutine checkSubscriptionStatusEnum: called CC=3 SCAR=11.0
Pod documented
394 2 my ($self, $arg) = @_;
395 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 2 2
396 2 ▶ return 1 if grep {/^$arg$/} qw/ACTIVE INACTIVE SUSPENDED/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "ACTIVE", "INACTIVE", "SUSPENDED" 1 1 2
397 1 return 0;
398 }
399  
400 =head2 checkTitleEnum
401  
402 Checks submitted value is a valid betfair enumerated type, see L<titleEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#i1034208i1034208> for details.
403  
404 =cut
405  
406 2 ▶sub checkTitleEnum {
Subroutine checkTitleEnum: called CC=3 SCAR=11.3
Pod documented
407 2 my ($self, $arg) = @_;
408 2 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 1 2
409 1 ▶ return 1 if grep {/^$arg$/} qw/Dr Miss Mr Mrs Ms/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "Dr", "Miss", "Mr", "Mrs", "Ms" 1 0 1
410 0 return 0;
411 }
412  
413 =head2 checkValidationErrorsEnum
414  
415 Checks submitted value is a valid betfair enumerated type, see L<validationErrorsEnum|http://bdp.betfair.com/docs/BetfairSimpleDataTypes.html#d83e2449> for details.
416  
417 =cut
418  
419 5 ▶sub checkValidationErrorsEnum {
Subroutine checkValidationErrorsEnum: called CC=3 SCAR=11.0
Pod documented
420 5 my ($self, $arg) = @_;
421 5 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 5 5
422 5 ▶ return 1 if grep {/^$arg$/} qw/DUPLICATE_USERNAME FUND_TRANSFER_CANCEL FUND_TRANSFER_CURRENCY_MISMATCH INCOMPLETE_DETAILS
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "DUPLICATE_USERNAME", "FUND_TRANSFER_CANCEL", "FUND_TRANSFER_CURRENCY_MISMATCH", "INCOMPLETE_DETAILS", "INSUFFICIENT_FUNDS", "INVALID_ACCOUNT_TYPE", "INVALID_ADDRESS_LINE1", "INVALID_ADDRESS_LINE2", "INVALID_ADDRESS_LINE3", "INVALID_ANSWER1", "INVALID_ANSWER2", "INVALID_BROWSER", "INVALID_CITY", "INVALID_COUNTRY_OF_RESIDENCE", "INVALID_COUNTY_STATE", "INVALID_CURRENCY", "INVALID_DEPOSIT_LIMIT", "INVALID_DEPOSIT_LIMIT_FREQUENCY", "INVALID_DETAILS", "INVALID_DOB", "INVALID_EMAIL", "INVALID_FIRSTNAME", "INVALID_GENDER", "INVALID_HOME_PHONE", "INVALID_IP_ADDRESS", "INVALID_LANGUAGE", "INVALID_LOCALE", "INVALID_LOSS_LIMIT", "INVALID_LOSS_LIMIT_FREQUENCY", "INVALID_MASTER_ID", "INVALID_MOBILE_PHONE", "INVALID_PARTNERID", "INVALID_PASSWORD", "INVALID_POSTCODE", "INVALID_PRIVACY_VERSION", "INVALID_PRODUCT_ID", "INVALID_REFERRER_CODE", "INVALID_REGION", "INVALID_SECURITY_QUESTION1", "INVALID_SECURITY_QUESTION2", "INVALID_SUBPARTNER_ID", "INVALID_SUPERPARTNER_ID", "INVALID_SURNAME", "INVALID_TC_VERSION", "INVALID_TIMEZONE", "INVALID_TITLE", "INVALID_USERNAME", "INVALID_WORK_PHONE", "RESERVED_PASSWORD" 3 2 5
423 INSUFFICIENT_FUNDS INVALID_ACCOUNT_TYPE INVALID_ADDRESS_LINE1 INVALID_ADDRESS_LINE2 INVALID_ADDRESS_LINE3
424 INVALID_ANSWER1 INVALID_ANSWER2 INVALID_BROWSER INVALID_CITY INVALID_COUNTRY_OF_RESIDENCE INVALID_COUNTY_STATE
425 INVALID_CURRENCY INVALID_DEPOSIT_LIMIT INVALID_DEPOSIT_LIMIT_FREQUENCY INVALID_DETAILS INVALID_DOB
426 INVALID_EMAIL INVALID_FIRSTNAME INVALID_GENDER INVALID_HOME_PHONE INVALID_IP_ADDRESS INVALID_LANGUAGE INVALID_LOCALE
427 INVALID_LOSS_LIMIT INVALID_LOSS_LIMIT_FREQUENCY INVALID_MASTER_ID INVALID_MOBILE_PHONE INVALID_PARTNERID
428 INVALID_PASSWORD INVALID_POSTCODE INVALID_PRIVACY_VERSION INVALID_PRODUCT_ID INVALID_REFERRER_CODE
429 INVALID_REGION INVALID_SECURITY_QUESTION1 INVALID_SECURITY_QUESTION2 INVALID_SUBPARTNER_ID INVALID_SUPERPARTNER_ID
430 INVALID_SURNAME INVALID_TC_VERSION INVALID_TIMEZONE INVALID_TITLE INVALID_USERNAME INVALID_WORK_PHONE
431 RESERVED_PASSWORD/;
432 2 return 0;
433 }
434  
435 =head2 checkDecimal
436  
437 Checks the value submitted is a decimal number. Accepts whole numbers with no decimal point and negative numbers with a leading minus ('-').
438  
439 =cut
440  
441 11 ▶sub checkDecimal {
Subroutine checkDecimal: called CC=3 SCAR=11.0
Pod documented
442 11 my ($self, $arg) = @_;
443 11 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 10 11
444 10 ▶ return 1 if $arg =~ qr/^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ qr/^-?(?:\d+(?:\.\d*)?|\.\d+)$/ 8 2 10
445 2 return 0;
446 }
447  
448 =head2 checkExchangeId
449  
450 Checks the exchange id is either 1 (UK), 2 (Australian) or 3 (Global),
451  
452 =cut
453  
454 0 ▶sub checkExchangeId {
Subroutine checkExchangeId: not called CC=3 SCAR=24.8
Pod documented
455 0 my ($self, $arg) = @_;
456 0 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 0 0
457 0 ▶ return 1 if grep { $_ == $arg } qw/1 2/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == $arg;} 1, 2 0 0 0
458 0 return 0;
459 }
460  
461 =head2 checkCurrencyCode
462  
463 Checks the value submitted is a valid currency code accepted by betfair (e.g. 'EUR', 'GBP', 'CAD'). Accepts whole numbers with no decimal point and negative numbers with a leading minus ('-').
464  
465 =cut
466  
467 0 ▶sub checkCurrencyCode {
Subroutine checkCurrencyCode: not called CC=3 SCAR=24.8
Pod documented
468 0 my ($self, $arg) = @_;
469 0 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 0 0
470 0 ▶ return 1 if grep {/^$arg$/} qw/GBP EUR HKD AUD CAD DKK NOK SGD SEK USD/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "GBP", "EUR", "HKD", "AUD", "CAD", "DKK", "NOK", "SGD", "SEK", "USD" 0 0 0
471 0 return 0;
472 }
473  
474 =head2 checkInt
475  
476 Checks the value submitted is a whole number. Accepts negative numbers with a leading minus ('-').
477  
478 =cut
479  
480 16 ▶sub checkInt {
Subroutine checkInt: called CC=3 SCAR=11.0
Pod documented
481 16 my ($self, $arg) = @_;
482 16 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 15 16
483 15 ▶ return 1 if $arg =~ /^$RE{num}{int}$/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^$WWW::betfair::TypeCheck::RE{"num"}{"int"}$/ 11 4 15
484 4 return 0;
485 }
486  
487 =head2 checkArrayInt
488  
489 Checks that the argument is a non-null arrayref containing only integers as defined by the L<checkInt> method.
490  
491 =cut
492  
493 3 ▶sub checkArrayInt {
Subroutine checkArrayInt: called CC=5 SCAR=16.1
Pod documented
494 3 my ($self, $arg) = @_;
495 3 ▶ return 0 unless @$arg;
Branch: 1 branch
BranchTrueFalseTotal
unless @$arg 1 2 3
496 2 ▶ return 0 unless ref $arg eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $arg eq "ARRAY" 0 2 2
497 2 foreach (@{$arg}) {
498 5 ▶ return 0 unless $self->checkInt($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->checkInt($_) 1 4 5
499 }
500 1 return 1;
501 }
502  
503 =head2 checkUsername
504  
505 Checks the username is between 8-20 characters and contains only letters and numbers.
506  
507 =cut
508  
509 9 ▶sub checkUsername {
Subroutine checkUsername: called CC=3 SCAR=11.0
Pod documented
510 9 my ($self, $arg) = @_;
511 9 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 8 9
512 8 ▶ return 1 if $arg =~ qr/^[a-zA-Z0-9]{8,20}$/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ qr/^[a-zA-Z0-9]{8,20}$/ 3 5 8
513 5 return 0;
514 }
515  
516 =head2 checkPassword
517  
518 Checks password is between 8-20 characters. No further checking is done as the password is encrypted. The actual betfair rules are alphanumeric characters plus these valid symbols: $!?()*+,:;=@_./-[]{} with the total length between 8-20 characters.
519  
520 =cut
521  
522 7 ▶sub checkPassword {
Subroutine checkPassword: called CC=3 SCAR=11.0
Pod documented
523 7 my ($self, $arg) = @_;
524 7 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 6 7
525 6 ▶ return 1 if $arg =~ qr/^.{8,20}$/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ qr/^.{8,20}$/ 3 3 6
526 3 return 0;
527 }
528  
529 =head2 checkDate
530  
531 Checks date follows the XML datetime specification. Note that betfair will only accept datetimes not date values and it must be passed as a string. Some valid examples:
532  
533 # standard datetime
534 '2013-01-18T12:30:58'
535
536 # datetime with UTC timezone
537 '2013-01-18T12:30:58Z'
538  
539 # datetime with -5hrs timezone
540 '2013-01-18T12:30:58-05:00'
541  
542 # datetime with +6hrs timezone
543 '2013-01-18T12:30:58+06:00'
544  
545 =cut
546  
547 10 ▶sub checkDate {
Subroutine checkDate: called CC=3 SCAR=11.0
Pod documented
548 10 my ($self, $arg) = @_;
549 10 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 9 10
550 9 ▶ return 1 if $arg =~ qr/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ qr/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}/ 5 4 9
551 4 return 0;
552 }
553  
554 =head2 checkBoolean
555  
556 Checks that value is of a valid boolean type: a string value of either 'true' or 'false'.
557  
558 =cut
559  
560 0 ▶sub checkBoolean {
Subroutine checkBoolean: not called CC=3 SCAR=24.8
Pod documented
561 0 my ($self, $arg) = @_;
562 0 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 0 0
563 0 ▶ return 1 if grep {/^$arg$/} qw/true false/;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$arg$/;} "true", "false" 0 0 0
564 0 return 0;
565 }
566  
567 =head2 checkString
568  
569 Checks that the value is a string with a non-zero length.
570  
571 =cut
572  
573 =head2 checkHash
574  
575 Checks that the argument is a hash.
576  
577 =cut
578  
579 0 ▶sub checkHash {
Subroutine checkHash: not called CC=3 SCAR=24.8
Pod documented
580 0 my ($self, $arg) = @_;
581 0 ▶ return 0 unless @$arg;
Branch: 1 branch
BranchTrueFalseTotal
unless @$arg 0 0 0
582 0 ▶ return 0 unless ref $arg eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $arg eq "HASH" 0 0 0
583 0 return 1;
584 }
585  
586  
587 4 ▶sub checkString {
Subroutine checkString: called CC=3 SCAR=11.0
Pod documented
588 4 my ($self, $arg) = @_;
589 4 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 3 4
590 3 ▶ return 1 if length($arg) > 0;
Branch: 1 branch
BranchTrueFalseTotal
if length $arg > 0 2 1 3
591 1 return 0;
592 }
593  
594 =head2 checkString9
595  
596 Checks that the value is a string with a non-zero length that is less than 10 characters.
597  
598 =cut
599  
600 5 ▶sub checkString9 {
Subroutine checkString9: called CC=4 SCAR=13.9
Pod documented
601 5 my ($self, $arg) = @_;
602 5 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 4 5
603 4 ▶ return 1 if (length($arg) > 0 and length($arg) < 10);
Branch: 1 branch
BranchTrueFalseTotal
if length $arg > 0 and length $arg < 10 2 2 4
Condition100%3/3
length $arg > 0 and length $arg < 10
!ll&&!rl&&r
112
MC/DC100%2/2
length $arg > 0 and length $arg < 10
length $arg > 0 length $arg < 10
Truth table100%3/3
A and B
A= length $arg > 0B= length $arg < 10
ABresult
0X0
100
111
604 2 return 0;
605 }
606  
607 =head2 checkCardDate
608  
609 Checks for a number containing exactly 4 digits. If the number begins with 0, it must be quoted (else Perl will remove the leading 0).
610  
611 =cut
612  
613 7 ▶sub checkCardDate {
Subroutine checkCardDate: called CC=3 SCAR=11.0
Pod documented
614 7 my ($self, $arg) = @_;
615 7 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 1 6 7
616 6 ▶ return 1 if $arg =~ /^[0-9]{4}$/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^[0-9]{4}$/ 2 4 6
617 4 return 0;
618 }
619  
620 =head2 checkCv2
621  
622 Checks for a number containing exactly 3 digits. If the number begins with 0, it must be quoted (else Perl will remove the leading 0).
623  
624 =cut
625  
626 0 ▶sub checkCv2 {
Subroutine checkCv2: not called CC=3 SCAR=24.8
Pod documented
627 0 my ($self, $arg) = @_;
628 0 ▶ return 0 unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 0 0
629 0 ▶ return 1 if $arg =~ /^[0-9]{3}$/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^[0-9]{3}$/ 0 0 0
630 0 return 0;
631 }
632  
633 3 1;
« betfair.pm ↑ Summary betfair/Request.pm »