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

package RPS::Import::Spotify::v5;

use strict;

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

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

sub _fieldMap {
    {
        #header
        dateBegin     => 'B',
        dateEnd       => 'C',

        #detail
        countryCode   => 'A',
        labelName     => 'L',
        formatType    => 'B',
        upc           => 'D',
        isrc          => 'F',
        trackName     => 'G',
        artistName    => 'H',
        albumName     => 'J',
        units         => 'K',
        price         => 'M',
    }
}

sub _unverifiedFieldMap {
    {
        ean           => 'E',
    }
}

# Note: the v3 method defaults to the client's base currency code if it can't
# be gleened from the header; in this version we'll force an exception if we
# can't parse the header.
#
sub currencyCode {
    my $self = shift;
    return $self->{_currencyCode};
}

sub _processHeader {
    my $self = shift;
    my $header = $self->_getByFieldName( 'price' );

    if( $header =~ /^Payable (\w+)$/i )
    {
        $self->{_currencyCode} = $1;
    }
    return $self->SUPER::_processHeader(@_);
}

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