File Coverage

blib/lib/Net/Ikano/XMLUtil.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Net::Ikano::XMLUtil;
2              
3 1     1   13 use warnings;
  1         2  
  1         31  
4 1     1   5 use strict;
  1         2  
  1         33  
5 1     1   7 use base 'XML::Simple';
  1         2  
  1         821  
6             use Data::Dumper;
7             use Switch;
8              
9             =head1 DESCRIPTION
10            
11             Unfortunately the Ikano API schema has xs:sequence everywhere, so we need to have most elements in a particular order.
12             This class solves this problem by extending XML::Simple and overriding sorted_keys to provide the element order for each request.
13              
14             This is a helper class which should not be used directly. It requires particular options in the constructor (SuppressEmpty) which differ for XMLin and XMLout.
15              
16             =cut
17              
18             sub sorted_keys {
19             my ($self,$name,$hashref) = @_;
20              
21             switch ($name) {
22              
23             # quals
24             return qw( AddressLine1 AddressUnitType AddressUnitValue AddressCity
25             AddressState ZipCode Country LocationType ) case 'Address';
26             return qw( Address PhoneNumber CheckNetworks RequestClientIP ) case 'PreQual';
27              
28             # orders
29             return qw( type ProductCustomId DSLPhoneNumber VirtualPhoneNumber Password
30             TermsId PrequalId CompanyName FirstName MiddleName LastName
31             ContactMethod ContactPhoneNumber ContactEmail ContactFax DateToOrder
32             RequestClientIP IspChange IspPrevious CurrentProvider ) case 'Order';
33              
34             # password change
35             return qw( DSLPhoneNumber NewPassword ) case 'PasswordChange';
36              
37             # account status change
38             return qw( type DSLServiceId DSLPhoneNumber ) case 'AccountStatusChange';
39              
40             }
41             return $self->SUPER::sorted_keys($name, $hashref);
42             }
43              
44             1;