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

package RPS::Import::Spotify::v1;

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,
        labelName     => 1,
        serviceID     => 3,
        upc           => 4,
        isrc          => 5,
        trackName     => 6,
        artistName    => 7,
        albumName     => 9,
        units         => 10,
        price         => 11,
	}
}

# If we have set a currency code use it, otherwise use the base currency code.
sub currencyCode {
	my $self = shift;
	return $self->{_currencyCode} ? $self->{_currencyCode} :
	       Common::Client::Current()->Locale()->currencyFormat()->currencyCode();
}

# For this version we need to check the header for a 'USD Payable' column.  If it
# exists our currency is USD.  Case 11968.
sub _processHeader {
	my $self = shift;

	my $header = $self->_getByFieldName( 'price' );

	$self->{_currencyCode} = 'USD' if( $header && $header eq 'USD Payable' );

	return $self->SUPER::_processHeader(@_);
}

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