package BookPub::Import::Importer::Scribd;

use strict;

use lib '/app/tools/bookpub/lib';
use base 'BookPub::Import::Importer';

sub _headerIdentifier { ( rIsbn13 => 'ISBN' ) }
sub _useIsSaleRec { 1 }
sub _autoParseTitleAndSubtitle { 1 }

sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub priceType    { 'rrp' }
sub rServiceName { 'Scribd' }
sub currencyCode { 'USD' }
sub productType  { BookPub::DB::Item::Sale::kProductTypeEBook }
sub rUnits       { 1 }

# map version num to the field order
sub _fieldMap {
    my $self = shift;

    my %fieldMap = (
        7 => {
            countryCode => 'G',
            dateBegin   => 'A',
            rIsbn13     => 'C',
            rTitle      => 'B',
            rListPrice  => 'D',
            rRevenue    => 'E',
        },
    );

    return $fieldMap{ $self->_version() };
}

sub rRevenue {
    my $self    = shift;
    my $revenue = $self->SUPER::rRevenue();

    $revenue =~ s/,|\$//g;

    return $revenue;
}

sub rListPrice {
    my $self = shift;

    my $listPrice = $self->SUPER::rListPrice();

    $listPrice =~ s/,|\$//g;

    return $listPrice;
}

1;
