package BookPub::Import::Importer::Amazon::Version19;

use strict;

use lib '/app/tools/common/lib';
use Common::Country;

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

sub _headerIdentifier { ( dateBegin => 'Ship Date' ) }

sub _fieldMap {
    {
        rAuthor          => 'B',
        serviceProductID => 'C',
        rTitle           => 'D',
        dateBegin        => 'E',
        rUnits           => 'F',
        rListPrice       => 'G',
        rRevenue         => 'I',
    };
}

sub _unverifiedFieldMap {
    { isbnPlusTwo => 'A' };
}

sub _useIsSaleRec { 1 }

sub priceType    { 'rrp' }
sub productType  { BookPub::DB::Item::Sale::kProductTypeEBook }
sub formatType   { BookPub::DB::Item::Sale::kFormatTypePDF }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub countryCode  { 'US' }
sub currencyCode { 'USD' }

sub rIsbn13 {
    my $self = shift;
    my $isbn = $self->_getByFieldName('isbnPlusTwo');

    if ( length($isbn) == 15 ) {
        $isbn = substr( $isbn, 2 );
        return $isbn;
    } else {
        return undef;
    }
}

###
1;    # Play nicely.
###
