summaryrefslogtreecommitdiff
path: root/lib/Net/Ikano/XMLUtil.pm
blob: 0439a5783cff7057c6e27869f7057a63bac268dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;