package RPS::Import::iHeartRadio::v1;

use strict;
use warnings;

use lib '/app/tools/rps/lib';
use lib '/app/tools/common/lib';
use Date::Calc qw(Days_in_Month);

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

sub _fieldMap {
    {
        labelName  => 'F',
        artistName => 'C',
        isrc       => 'E',
        trackName  => 'D',
        units      => 'G',
    };
}

sub _headerIdentifier { isrc => 'ISRC' }
sub countryCode       { 'US' }
sub currencyCode      { 'USD' }
sub mediaType         { RPS::DB::Item::MediaType::kMediaTypeAudio }
sub productType       { RPS::File::Sale::TYPE_TRACK }
sub formatType        { RPS::File::Sale::FORMAT_PERFORMANCE }

sub saleDates {
    my $self = shift;

    if ( $self->{_startDate} && $self->{_endDate} ) {
        return $self->{_startDate}, $self->{_endDate};
    }

    if ( $self->filename =~ /^(\d{4})-?(\d{1,2})\s?/ ) {
        return $self->_getDates( date_begin => sprintf "%04d-%02d-%02d", $1, $2, 1 );
    }
}


1;
