| 1 | package SNS::Notification; | ||
| 2 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use Types::Standard qw/Str/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | our $VERSION = '0.03'; | |
| 6 | |||
| 7 | 1 | has Timestamp => (is => 'ro', isa => Str, required => 1); | |
| 8 | 1 | has TopicArn => (is => 'ro', isa => Str, required => 1); | |
| 9 | 1 | has Type => (is => 'ro', isa => Str, required => 1); | |
| 10 | 1 | has MessageId => (is => 'ro', isa => Str, required => 1); | |
| 11 | 1 | has Message => (is => 'ro', isa => Str, required => 1); | |
| 12 | 1 | has UnsubscribeURL => (is => 'ro', isa => Str, required => 1); | |
| 13 | 1 | has Signature => (is => 'ro', isa => Str, required => 1); | |
| 14 | 1 | has SignatureVersion => (is => 'ro', isa => Str, required => 1); | |
| 15 | 1 | has Subject => (is => 'ro', isa => Str); | |
| 16 | 1 | has SigningCertURL => (is => 'ro', isa => Str, required => 1); | |
| 17 | |||
| 18 | |||
| 19 | 1 | ▶ | no Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 1 | ▶ | no Types::Standard; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | 1 | 1; | |
| 23 | ### main pod documentation begin ### | ||
| 24 | |||
| 25 | =encoding UTF-8 | ||
| 26 | |||
| 27 | =head1 NAME | ||
| 28 | |||
| 29 | SNS::Notification - An object for representing SNS Notifications | ||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | use SNS::Notification; | ||
| 34 | my $not = SNS::Notification->new( | ||
| 35 | Timestamp => ... | ||
| 36 | ... required attributes ... | ||
| 37 | ); | ||
| 38 | #do something with $obj | ||
| 39 | |||
| 40 | my $body = decode_json($sns_message); | ||
| 41 | my $sns = eval { SNS::Notification->new($body) }; | ||
| 42 | if ($@) { | ||
| 43 | die "Doesn't look like an SNS::Message to me"; | ||
| 44 | } | ||
| 45 | print $sns->Message; | ||
| 46 | |||
| 47 | =head1 DESCRIPTION | ||
| 48 | |||
| 49 | This module holds an object for representing an SNS messsage. It tries | ||
| 50 | to validate that all appropiate fields are present. | ||
| 51 | |||
| 52 | This is really just a module for other modules that work with SNS to | ||
| 53 | depend on (and not reimplement it constantly). | ||
| 54 | |||
| 55 | =head1 SEE ALSO | ||
| 56 | |||
| 57 | L<http://docs.aws.amazon.com/sns/latest/dg/json-formats.html> | ||
| 58 | |||
| 59 | L<http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html> | ||
| 60 | |||
| 61 | L<http://docs.aws.amazon.com/sns/latest/dg/SendMessageToSQS.html> | ||
| 62 | |||
| 63 | =head1 COPYRIGHT and LICENSE | ||
| 64 | |||
| 65 | Copyright (c) 2020 by Jose Luis Martinez | ||
| 66 | |||
| 67 | This code is distributed under the Apache 2 License. The full text of the license can be found in the LICENSE file included with this module. | ||
| 68 | |||
| 69 | =cut | ||