#---------------------------------------------------------------
# ____                   _ _         ____  _                    
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___ 
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/                            
#
# Copyright (C) 2015 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#---------------------------------------------------------------
package RPS::Distributor::Command::Search;
use strict;
use warnings;

use lib '/app/tools/common/lib';
use RSApache::Response::XML;

use lib '/app/tools/rps/lib';
use RPS::DistributorList;
use RPS::XMLCommand;
use base 'RPS::XMLCommand';


sub cmd  { return 'search'; }
sub area { return 'service'; }

use constant kTemplate => "/app/tools/rps/templates/service/index.xsl";

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

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

    my $query = $self->getParam('query');
    my $limit = $self->getParam('limit');
    my $client = $self->getParam('client');

    my $list = RPS::DistributorList->new(query => $query, limit => $limit);

    $response = RSApache::Response::XML->new($list);

    return $response;
}


1;
