| 1 | package Mail::DMARC::Report::Aggregate::Record::Auth_Results; | ||
| 2 | our $VERSION = '2.20260827'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use feature 'signatures'; | ||
| 6 | |||
| 7 | use Carp; | ||
| 8 | require Mail::DMARC::Report::Aggregate::Record::Auth_Results::SPF; | ||
| 9 | require Mail::DMARC::Report::Aggregate::Record::Auth_Results::DKIM; | ||
| 10 | |||
| 11 | sub new( $class, @args ) { | ||
| 12 | croak "invalid arguments" if @args % 2; | ||
| 13 | |||
| 14 | my $self = bless { spf => [], dkim => [] }, $class; | ||
| 15 | return $self if !@args; | ||
| 16 | |||
| 17 | my %args = @args; | ||
| 18 | foreach my $key ( keys %args ) { | ||
| 19 | $self->$key( $args{$key} ); | ||
| 20 | } | ||
| 21 | |||
| 22 | return $self; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub spf( $self, @args ) { | ||
| 26 | return $self->{spf} if !@args; | ||
| 27 | |||
| 28 | # one shot | ||
| 29 | if ( @args == 1 && ref $args[0] eq 'ARRAY' ) { | ||
| 30 | |||
| 31 | #warn "SPF one shot"; | ||
| 32 | my $iter = 0; | ||
| 33 | foreach my $d ( @{ $args[0] } ) { | ||
| 34 | $self->{spf}->[$iter] | ||
| 35 | = Mail::DMARC::Report::Aggregate::Record::Auth_Results::SPF->new( | ||
| 36 | $d); | ||
| 37 | $iter++; | ||
| 38 | } | ||
| 39 | return $self->{spf}; | ||
| 40 | } | ||
| 41 | |||
| 42 | #warn "SPF iterative"; | ||
| 43 | push @{ $self->{spf} }, | ||
| 44 | Mail::DMARC::Report::Aggregate::Record::Auth_Results::SPF->new(@args); | ||
| 45 | |||
| 46 | return $self->{spf}; | ||
| 47 | } | ||
| 48 | |||
| 49 | sub dkim( $self, @args ) { | ||
| 50 | return $self->{dkim} if !@args; | ||
| 51 | |||
| 52 | if ( @args == 1 && ref $args[0] eq 'ARRAY' ) { | ||
| 53 | |||
| 54 | #warn "dkim one shot"; | ||
| 55 | my $iter = 0; | ||
| 56 | foreach my $d ( @{ $args[0] } ) { | ||
| 57 | $self->{dkim}->[$iter] | ||
| 58 | = Mail::DMARC::Report::Aggregate::Record::Auth_Results::DKIM->new( | ||
| 59 | $d); | ||
| 60 | $iter++; | ||
| 61 | } | ||
| 62 | return $self->{dkim}; | ||
| 63 | } | ||
| 64 | |||
| 65 | #warn "dkim iterative"; | ||
| 66 | push @{ $self->{dkim} }, | ||
| 67 | Mail::DMARC::Report::Aggregate::Record::Auth_Results::DKIM->new(@args); | ||
| 68 | |||
| 69 | return $self->{dkim}; | ||
| 70 | } | ||
| 71 | |||
| 72 | 1; | ||
| 73 | |||
| 74 | __END__ | ||
| 75 | |||
| 76 | =pod | ||
| 77 | |||
| 78 | =head1 NAME | ||
| 79 | |||
| 80 | Mail::DMARC::Report::Aggregate::Record::Auth_Results - auth_results section of a DMARC aggregate record | ||
| 81 | |||
| 82 | =head1 VERSION | ||
| 83 | |||
| 84 | version 2.20260827 | ||
| 85 | |||
| 86 | =head1 AUTHORS | ||
| 87 | |||
| 88 | =over 4 | ||
| 89 | |||
| 90 | =item * | ||
| 91 | |||
| 92 | Matt Simerson <msimerson@cpan.org> | ||
| 93 | |||
| 94 | =item * | ||
| 95 | |||
| 96 | Davide Migliavacca <shari@cpan.org> | ||
| 97 | |||
| 98 | =item * | ||
| 99 | |||
| 100 | Marc Bradshaw <marc@marcbradshaw.net> | ||
| 101 | |||
| 102 | =back | ||
| 103 | |||
| 104 | =head1 COPYRIGHT AND LICENSE | ||
| 105 | |||
| 106 | This software is copyright (c) 2026 by Matt Simerson. | ||
| 107 | |||
| 108 | This is free software; you can redistribute it and/or modify it under | ||
| 109 | the same terms as the Perl 5 programming language system itself. | ||
| 110 | |||
| 111 | =cut |