package BookPub::Import::Importer::VitalSource::Version1;

use strict;

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

sub _fieldMap {
    {
        rPriceType => 'F',
        dateBegin  => 'A',
        rIsbn13    => 'B',
        rTitle     => 'C',
        rAuthor    => 'D',
        rUnits     => 'H',
        rListPrice => 'I',
        rDiscount  => 'J',
        rRevenue   => 'K',
    };
}

sub _headerIdentifier { ( rTitle => 'TITLE' ) }
sub priceType         { 'rrp' }
sub currencyCode      { 'USD' }
sub countryCode       { 'US' }
sub productType       { BookPub::DB::Item::Sale::kProductTypeEBook }

sub purchaseType {
    my $self = shift;

    my $type = $self->_getByFieldName('rPriceType');
    if ( $type =~ m/VST Bookstore\-Line/ ) {
        return BookPub::DB::Item::Sale::kPurchaseTypeDownload;
    } else {
        $self->fail("Unexpected purchase type: $type");
    }
}

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