package RPS::Import::SoundOn::v2;

use strict;
use warnings;

use lib '/app/tools/rps/lib';
use RPS::Import::ServiceMap;
use Date::Calc qw(Days_in_Month Add_Delta_Days Decode_Month);

use parent qw/RPS::Import::SoundOn::v1/;


sub physical { 0 }

sub _fieldMapExtended {
    {
        digital => {
            option1 => {
                serviceID    => 'K',
                countryCode  => 'L',
                dateBegin    => 'A',
                formatType   => 'M',
                artistName   => 'F',
                upc          => 'G',
                albumName    => 'H',
                isrc         => 'E',
                trackName    => 'D',
                units        => 'O',
                currencyCode => 'Q',
                price        => 'T',
            }
        }
    }
}

sub _unverifiedFieldMapExtended { {} }

sub _headerIdentifierExtended {
    {
        digital => {
            option1 => { upc => 'UPC Code' }
        }
    }
}

sub formatType {
    my $self = shift;

    my $type = $self->_getByFieldName('formatType') || '';
    if ( $type =~ /^(?:STREAMING|CREATION|VIDEO_(?:STREAM|VIEW))$/i ) {
        return RPS::File::Sale::FORMAT_STREAM;
    } elsif ( $type =~ /^DOWNLOAD$/i ) {
        return RPS::File::Sale::FORMAT_DOWNLOAD;
    } elsif ( $type =~ /^(?:OTHER|BUSINESSACCOUNT|NONPROMOTIONADVERTISING|PROMOTIONADVERTISING)$/i ) {
        $self->fail("Incorrect format type: '$type'")
    }

    $self->handleError( "Unknown format type: $type", RPS::DB::Item::SaleImportError::kErrorFormatType );
}


1;