package BookPub::Import::Importer::WeRead4You::Version1;

use strict;

use Common::Country;

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

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

sub _fieldMap {
    {
        countryCode => 'D',
        isbn        => 'B',
        rTitle      => 'C',
        rUnits      => 'A',
        rListPrice  => 'E',
        rRevenue    => 'F',
    };
}

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

sub _getDateBegin {
    my $self     = shift;
    my $filename = $self->filename;

    if ( $filename =~ /(\w{3} \d{4})\./ ) {
        return $1 = $1;
    } else {
        die "Unable to determine date from filename";
    }

    return;
}

sub _getDateEnd {
    shift->_getDateBegin();
}

sub _dateNormalization { 'month' }
1;
