#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2013 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------
package RPS::Import::Merlin::v39;

use strict;

use lib '/app/tools/rps/lib';
use RPS::Import::ServiceMap;

use base 'RPS::Import::Importer';

sub _fieldMap {
    {
        labelName     => 'C',
        dateBegin     => 'A',
        countryCode   => 'L',
        formatType    => 'I',
        artistName    => 'D',
        upc           => 'F',
        albumName     => 'E',
        isrc          => 'H',
        trackName     => 'G',
        currencyCode  => 'N',
        units         => 'J',
        price         => 'O'
    }
}

sub _headerIdentifier { ( upc => 'Release ID' ) }
sub mediaType { RPS::DB::Item::MediaType::kMediaTypeAudio; }
sub serviceID { Client::Service::DSP_SAAVN; }
sub productType { RPS::File::Sale::TYPE_TRACK; }

sub formatType {
    my $self = shift;
    my $type = $self->_getByFieldName('formatType');
    if( $type =~ /^(?:Subscription )?Stream$/i )
    {
        return RPS::File::Sale::FORMAT_STREAM;
    }
    $self->fail( "Could not determine format from $type");
}

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