diff options
Diffstat (limited to 'lib/Net/Ikano/XMLUtil.pm')
-rw-r--r-- | lib/Net/Ikano/XMLUtil.pm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/Net/Ikano/XMLUtil.pm b/lib/Net/Ikano/XMLUtil.pm new file mode 100644 index 0000000..0439a57 --- /dev/null +++ b/lib/Net/Ikano/XMLUtil.pm @@ -0,0 +1,45 @@ +package Net::Ikano::XMLUtil; + +use warnings; +use strict; +use base 'XML::Simple'; +use Data::Dumper; +use Switch; + +=head1 DESCRIPTION + +Unfortunately the Ikano API schema has xs:sequence everywhere, so we need to have most elements in a particular order. +This class solves this problem by extending XML::Simple and overriding sorted_keys to provide the element order for each request. + +IMPORTANT: when using this class, XMLOut must have SuppressEmpty => 1 as an option. +You will break everything otherwise. + +=cut + +sub sorted_keys { + my ($self,$name,$hashref) = @_; + + switch ($name) { + + # quals + return qw( AddressLine1 AddressUnitType AddressUnitValue AddressCity + AddressState ZipCode Country LocationType ) case 'Address'; + return qw( Address PhoneNumber CheckNetworks RequestClientIP ) case 'PreQual'; + + # orders + return qw( type ProductCustomId DSLPhoneNumber VirtualPhoneNumber Password + TermsId PrequalId CompanyName FirstName MiddleName LastName + ContactMethod ContactPhoneNumber ContactEmail ContactFax DateToOrder + RequestClientIP IspChange IspPrevious CurrentProvider ) case 'Order'; + + # password change + return qw( DSLPhoneNumber NewPassword ) case 'PasswordChange'; + + # account status change + return qw( type DSLServiceId DSLPhoneNumber ) case 'AccountStatusChange'; + + } + return $self->SUPER::sorted_keys($name, $hashref); +} + +1; |