#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Product::Command::TogglePriceTier;
use strict;
use warnings;

use lib '/app/tools/rps/lib';

use base 'RSApache::Command::XMLCommand';

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

use lib '/app/tools/rps/lib';
use RPS::Product::PricingTier;

use lib '/app/tools/appuser/lib';
use AppUser::DB::Item::AccessLevel;

sub cmd  { return 'toggle_price_tier'; }
sub area { return 'product'; }

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

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

    my $priceTierID = $self->getParam('pricingTierID');

    my $service_id = $self->getParam('service_id');
    my $product_id = $self->getParam('product_id');

    my $tier = new RPS::Product::PricingTier( servicePriceTierID => $priceTierID );

    my $result = "ERROR";

    if ($tier) {
        $result = "OK"
          if (
            $tier->togglePricingTier(
                service_price_tier_id => $priceTierID,
                service_id            => $service_id,
                product_id            => $product_id
            )
          );
    }

    $response = RSApache::Response::Raw->new($result);

    return $response;
}

1;
