package BookPub::Import::Importer::Google::Version3;

use strict;

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

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

sub _fieldMap {
    {
        currencyCode => 'K',
        countryCode  => 'L',
        rState       => 'M',
        rPostalCode  => 'N',
        dateBegin    => 'A',
        rIsbn13      => 'F',
        rTitle       => 'H',
        rAuthor      => 'I',
        rUnits       => 'D',
        rListPrice   => 'J',
        rDiscount    => 'R',
        rRevenue     => 'S',
    };
}

sub priceType    { 'agency' }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType  { BookPub::DB::Item::Sale::kProductTypeEBook }
sub _dateFormat  { [ 'iso', 'us', 'excel' ] }

sub _isValidSaleRecord {
    my $self = shift;

    return $self->rTitle || $self->rIsbn10 || $self->rIsbn13;
}

sub rPostalCode {
    my $self = shift;

    my $code = $self->_getByFieldName('rPostalCode');
    $code =~ s/ /-/g;

    return $code;
}

1;
