#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package MediaServe::WebService::Command::ClientInfo;
use strict;
use warnings;

use lib '/app/tools/common/lib';
use RSApache::Command::InternalCommand;
use RSApache::Response::XML;
use Common::Client::ClientList;

use base 'RSApache::Command::InternalCommand';

sub cmd  { return 'clientinfo'; }
sub area { return 'clientinfo'; }

sub execute {
    my ($self) = @_;

    my $response = $self->SUPER::execute();
    return $response if $response;

    # Let's have the type mask be a parameter
    # Rather than 'expose' the bit mask scheme, we'll accept multiple
    # 'type=x' cgi parameters, where type is the type from Common::DB::Item::ClientType.
    # We'll mask them together here.
    #
    my $typeMask;
    my $types = $self->getParam('type');
    if ( defined $types ) {
        $types = [$types] unless ref $types;
        foreach my $type (@$types) {
            $typeMask += ( 1 << ( $type - 1 ) );
        }
    }

    my $clientList = Common::Client::ClientList->new( typeMask => $typeMask );

    $response = RSApache::Response::XML->new($clientList);
    return $response;
}

1;
