package BookPub::Import::Importer::Blinkist::v4;

use strict;
use warnings;

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


sub _fieldMap {
    {
        dateBegin          => 'C',
        dateEnd            => 'C',
        rAuthor            => 'H',
        rTitle             => 'G',
        rIsbn13            => 'F',
        countryCode        => 'L',
        rUnits             => 'T',
        rListPrice         => 'K',
        rListPriceCurrency => 'D',
        rRevenue           => 'U',
        currencyCode       => 'D',
        rTaxAmount         => 'M',
    };
}

sub _headerIdentifier { rIsbn13 => 'isbn' }

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

sub rUnitPrice {
    my $self = shift;

    return $self->rRevenue / $self->rUnits;
}

sub isFree {
    my $self = shift;

    return !$self->rRevenue && $self->rUnits ? 'Y' : 'N';
}


1;
