From 58d8ce0c959833e9404d042db9b0ddc336881209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C3=A9dney=20Lima?= Date: Wed, 8 Jul 2015 12:46:36 -0300 Subject: [PATCH] Adding DeleteEndpoint, GetEndpointAttributes and SetEndpointAttributes --- lib/Amazon/SNS.pm | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/Amazon/SNS.pm b/lib/Amazon/SNS.pm index 286dd34..db65274 100644 --- a/lib/Amazon/SNS.pm +++ b/lib/Amazon/SNS.pm @@ -73,6 +73,16 @@ sub DeleteTopic }); } +sub DeleteEndpoint +{ + my ($self, $endpointarn) = @_; + + return $self->dispatch({ + 'Action' => 'DeleteEndpoint', + 'EndpointArn' => $endpointarn, + }); +} + sub ListTopics { my ($self, $name) = @_; @@ -251,6 +261,52 @@ use JSON; __PACKAGE__->mk_accessors(qw/ sns arn /); +sub GetEndpointAttributes +{ + my ($self) = @_; + + my $r = $self->sns->dispatch({ + 'Action' => 'GetEndpointAttributes', + 'EndpointArn' => $self->arn, + }); + + my $entry = $r->{'GetEndpointAttributesResult'}{'Attributes'}{'entry'}; + + my %attributes = map { + $_ => $entry->{$_}->{value} + } keys %{$entry}; + + return \%attributes; +} + +sub SetEndpointAttributes +{ + my ($self, $attr) = @_; + + my $attributes = undef; + + if (defined($attr) and ref($attr) eq 'HASH') { + my $i = 1; + + foreach my $key (keys %$attr) { + + $attributes->{"Attributes.entry.$i.key"} = $key; + $attributes->{"Attributes.entry.$i.value"} = $attr->{$key}; + + $i++; + } + } + + my $r = $self->sns->dispatch({ + 'Action' => 'SetEndpointAttributes', + 'Attributes' => $attributes, + 'EndpointArn' => $self->arn, + }); + + # return message id on success, undef on error + return $r ? $r->{'ResponseMetadata'}{'RequestId'} : undef; +} + sub Publish { my ($self, $msg, $subj, $attr) = @_;