package RPS::Sale::Match::Result;

use strict;
use warnings;

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my %in    = @_;

    foreach my $key (qw(import_status map_id num_products products rec_products search_products detail)) {
        return undef unless exists $in{$key};
    }

    my $self = {%in};

    bless( $self, $class );

    return $self;
}

sub ImportStatus {
    my $self = shift;
    return $self->{import_status};
}

sub MapID {
    my $self = shift;
    return $self->{map_id};
}

sub NumProducts {
    my $self = shift;
    return $self->{num_products};
}

sub ProductIDs {
    my $self = shift;
    return wantarray ? @{ $self->{products} } : $self->{products};
}

sub RecProductIDs {
    my $self = shift;
    return wantarray ? @{ $self->{rec_products} } : $self->{rec_products};
}

sub SearchProductIDs {
    my $self = shift;
    return wantarray ? @{ $self->{search_products} } : $self->{search_products};
}

sub Level {
    my $self       = shift;
    my $product_id = shift;
    return undef unless defined $product_id;
    return $self->{detail}->{$product_id}->{level};
}

sub Pattern {
    my $self       = shift;
    my $product_id = shift;
    return undef unless defined $product_id;
    return $self->{detail}->{$product_id}->{pattern};
}

sub MatchType {
    my $self       = shift;
    my $product_id = shift;
    return undef unless defined $product_id;
    return $self->{detail}->{$product_id}->{type};
}

sub Detail {
    my $self = shift;
    return $self->{detail};
}

1;
