#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2010 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------

package RPS::Import::Spotify::v4;

use strict;

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

use lib '/app/tools/rps/lib';
use base 'RPS::Import::Spotify::Base';

sub _fieldMap {
    {
        #header
        dateBegin => 1,
        dateEnd   => 2,

        #detail
        countryCode => 0,
        formatType  => 1,
        upc         => 3,
        isrc        => 5,
        trackName   => 6,
        artistName  => 7,
        albumName   => 9,
        units       => 10,
        labelName   => 11,
    };
}

sub _unverifiedFieldMap {
    { ean => 4, };
}

# If we have set a currency code use it, otherwise use the base currency code.
sub currencyCode {
    Common::Client::Current()->Locale()->currencyFormat()->currencyCode();
}

#
sub formatType {
    my $self       = shift;
    my $formatType = $self->_getByFieldName('formatType');
    if ( $formatType eq 'A' ) {
        $formatType = RPS::File::Sale::FORMAT_STREAM;
    } elsif ( $formatType eq 'M' ) {
        $formatType = RPS::File::Sale::FORMAT_STREAM;
    } elsif ( $formatType eq 'U' ) {
        $formatType = RPS::File::Sale::FORMAT_STREAM;
    } elsif ( $formatType eq 'P' ) {
        $formatType = RPS::File::Sale::FORMAT_STREAM;
    } elsif ( $formatType eq '1' ) {
        $formatType = RPS::File::Sale::FORMAT_VPD;
    } elsif ( $formatType eq '10' ) {
        $formatType = RPS::File::Sale::FORMAT_VPD;
    } elsif ( $formatType eq '15' ) {
        $formatType = RPS::File::Sale::FORMAT_VPD;
    } elsif ( $formatType eq '40' ) {
        $formatType = RPS::File::Sale::FORMAT_VPD;
    } elsif ( $formatType eq '100' ) {
        $formatType = RPS::File::Sale::FORMAT_VPD;
    }
    return $formatType;
}

sub upc {
    my $self = shift;
    my $upc  = $self->_getByFieldName('upc');

    if ( !$upc ) {
        $upc = $self->_getByFieldName('ean');
    }

    return $upc;
}

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