package BookPub::Import::Importer::Audiobooks::Version1;

use strict;

use Common::Country;

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

sub _headerIdentifier { ( rTitle => 'Title' ) }

sub _fieldMap {
    {
        dateBegin  => 'A',
        rIsbn13    => 'D',
        rTitle     => 'F',
        rAuthor    => 'B',
        rListPrice => 'I',
        rRevenue   => 'J',
    };
}

sub priceType    { 'rrp' }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType  { BookPub::DB::Item::Sale::kProductTypeAudioBook }

sub currencyCode { 'USD' }
sub countryCode  { 'US' }

# if negative revenue, return a negative unit, otherwise a positive one
sub units {
    my $self = shift;
    my $rev  = $self->_getByFieldName('rRevenue');

    return $rev < 0 ? -1 : 1;
}

sub rIsbn13 {
    my $isbn = shift->SUPER::rIsbn13();
    $isbn =~ s/D?_D// if ($isbn);

    return $isbn;
}

1;
