
#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2011 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------
package BookPub::DB::Item::BestSellerList;

use strict;
use warnings;
use Data::Dumper;

use lib '/app/tools/common/lib';
use lib '/app/tools/bookpub/lib';
use Common::Assert;

use constant kTable => 'best_seller_list';
use constant kDB    => Common::DB::Item::kCommonDB();

use base 'Common::DB::Item';

sub GetListIDByName {
    my ( $class, $listName ) = @_;
    assert( $listName, "ERROR - bestSellerListName is required" );

    my $sql = "SELECT best_seller_list_id FROM " . kTable . " WHERE description='$listName'";

    my $dbo = Common::RSApp::GetCommonDB();
    my $sth = $dbo->DoCmd($sql);
    my $hr  = $sth->fetchrow_hashref();

    return $hr->{best_seller_list_id};
}

sub GetAllIDsAndUrls {
    my $class = shift;
    my %args  = @_;

    my $sql = "SELECT best_seller_list_id,url FROM " . kTable;
    return $class->GetAll($sql);
}

1;
