add class method orderTypes and fix POD nits
[Net-Ikano.git] / lib / Net / Ikano.pm
index c1e4b87..879e8ee 100644 (file)
@@ -24,6 +24,10 @@ our $SCHEMA_ROOT = 'https://orders.value.net/osiriswebservice/schema/v1';
 
 our $API_VERSION = "1.0";
 
+our @orderType = qw( NEW CANCEL CHANGE );
+
+our @orderStatus = qw( NEW PENDING CANCELLED COMPLETED ERROR );
+
 our $AUTOLOAD;
 
 =head1 SYNOPSIS
@@ -34,13 +38,15 @@ our $AUTOLOAD;
               'keyid' => $your_ikano_api_keyid,
               'password'  => $your_ikano_admin_user_password,
               'debug' => 1 # remove this for prod
-              'reqpreviewonly' => 1 # remove this for prod
-              'minimalQualResp' => 1 # on quals, return pairs of ProductCustomId+TermsId only
-              'minimalOrderResp' => 1 # return minimal data on order responses
-                            );
-    
+               'reqpreviewonly' => 1 # remove this for prod
+               'minimalQualResp' => 1 # on quals, return pairs of ProductCustomId+TermsId only
+               'minimalOrderResp' => 1 # return minimal data on order responses
+        );
+
 =head1 SUPPORTED API METHODS
 
+=over 4
+
 =item ORDER
 
 NOTE: supports orders by ProductCustomId only
@@ -122,6 +128,8 @@ $ikano->ACCOUNTSTATUSCHANGE(( {
            DSLServiecId => 123,
        } );
 
+=back
+
 =cut
 
 sub new {
@@ -143,12 +151,10 @@ sub new {
 sub req_ORDER {
    my ($self, $args) = (shift, shift);
 
-   my @validOrderTypes = qw( NEW CHANGE CANCEL );
-
     return "invalid order data" unless defined $args->{orderType}
        && defined $args->{ProductCustomId} && defined $args->{DSLPhoneNumber};
    return "invalid order type ".$args->{orderType}
-    unless grep($_ eq $args->{orderType}, @validOrderTypes);
+    unless grep($_ eq $args->{orderType}, @orderType);
 
     # XXX: rewrite this uglyness?
     my @ignoreFields = qw( orderType ProductCustomId );
@@ -252,9 +258,10 @@ sub req_PASSWORDCHANGE {
 
 sub resp_PASSWORDCHANGE {
    my ($self, $resphash, $reqhash) = (shift, shift);
-   return "invalid change password response" 
-       unless defined $resphash->{ChangePasswordResponse};
-   return $resphash->{ChangePasswordResponse};
+   return "invalid change password response"
+      unless defined $resphash->{ChangePasswordResponse}
+         && defined $resphash->{ChangePasswordResponse}->{Customer};
+   $resphash->{ChangePasswordResponse}->{Customer};
 }
 
 sub req_PREQUAL {
@@ -278,6 +285,10 @@ sub resp_PREQUAL {
     return $resphash->{PreQualResponse};
 }
 
+sub orderTypes {
+  @orderType;
+}
+
 sub AUTOLOAD {
     my $self = shift;
    
@@ -322,7 +333,8 @@ sub AUTOLOAD {
        unless $resp->is_success;
     my $respxml = $resp->decoded_content;
 
-    $xs = new Net::Ikano::XMLUtil(RootName => undef, SuppressEmpty => '');
+    $xs = new Net::Ikano::XMLUtil(RootName => undef, SuppressEmpty => '',
+       ForceArray => [ 'Address', 'Product', 'StaticIp', 'OrderNotes' ] );
     my $resphash = $xs->XMLin($respxml);
 
     warn "DEBUG RESPONSE\n\tHASH:\n ".Dumper($resphash)."\n\tXML:\n $respxml"