| 1 | package WWW::betfair::Template; | ||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | =head2 populate | ||||||||||||||
| 6 | |||||||||||||||
| 7 | Returns the XML message required for the betfair API | ||||||||||||||
| 8 | |||||||||||||||
| 9 | =cut | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 0 | ▶ | sub populate { | ||||||||||||
|
Subroutine
populate: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 12 | 0 | my ($uri, $action, $params) = @_; | |||||||||||||
| 13 | |||||||||||||||
| 14 | #handle getAccountStatement betfair syntax exception | ||||||||||||||
| 15 | 0 | ▶ | my $req = $action eq 'getAccountStatement' ? 'req' : 'request'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | 0 | my $templateHeader = qq~<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><$action xmlns="$uri"><$req>~; | |||||||||||||
| 18 | |||||||||||||||
| 19 | 0 | my $templateBody = ''; | |||||||||||||
| 20 | 0 | $templateBody .= markup_data(undef,$params); | |||||||||||||
| 21 | 0 | my $templateFooter = "</$req></$action></soap:Body></soap:Envelope>"; | |||||||||||||
| 22 | 0 | return $templateHeader . $templateBody . $templateFooter; | |||||||||||||
| 23 | } | ||||||||||||||
| 24 | |||||||||||||||
| 25 | =head2 markup_data | ||||||||||||||
| 26 | |||||||||||||||
| 27 | Recursive tagging subroutine for a Perl data structure | ||||||||||||||
| 28 | |||||||||||||||
| 29 | =cut | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 0 | ▶ | sub markup_data { | ||||||||||||
|
Subroutine
markup_data: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||
| 32 | 0 | my ($key, $data) = @_; | |||||||||||||
| 33 | 0 | my $string = ''; | |||||||||||||
| 34 | 0 | ▶ | if (ref($data) eq 'HASH') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 35 | 0 | ▶ | $string .= "<$key>" if $key; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | 0 | foreach (keys %{$data}) { | |||||||||||||
| 37 | 0 | $string .= markup_data($_, $data->{$_}); | |||||||||||||
| 38 | } | ||||||||||||||
| 39 | 0 | ▶ | $string .= "</$key>" if $key; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 0 | return $string; | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | elsif (ref($data) eq 'ARRAY') { | ||||||||||||||
| 43 | 0 | my $string = ''; | |||||||||||||
| 44 | 0 | foreach (@{$data}) { | |||||||||||||
| 45 | 0 | $string .= markup_data($key, $_); | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | 0 | return $string; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | else { | ||||||||||||||
| 50 | 0 | return "<$key>$data</$key>"; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | } | ||||||||||||||
| 53 | 2 | 1; | |||||||||||||