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

package RPS::Import::Muzicall::v1;

use strict;

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

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

sub _fieldMap {
    {
        labelName    => 'E',
        serviceID    => 'G',
        countryCode  => 'F',
        dateBegin    => 'B',
        dateEnd      => 'C',
        formatType   => 'D',
        artistName   => 'H',
        isrc         => 'J',
        trackName    => 'I',
        units        => 'R',
        currencyCode => 'Q',
        price        => 'P',
    };
}

sub productType { return RPS::File::Sale::TYPE_TRACK }

sub mediaType { RPS::DB::Item::MediaType::kMediaTypeAudio }

sub _headerIdentifier { ( countryCode => 'Country' ) }

sub currencyCode {
    my $self = shift;
    my $cc = $self->_getByFieldName('currencyCode') || return;

    return 'GBP' if ( $cc =~ m/^pound$/i );

    return $cc;
}

sub formatType {
    my $self = shift;
    my $fmt = $self->_getByFieldName('formatType') || return;
    if ( $fmt =~ /^rbt$/i ) {
        return RPS::File::Sale::FORMAT_RINGTONE;
    } else {
        $self->fail("Unable to determine format from '$fmt'");
    }
}

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