line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::AWS::SES::Response;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::AWS::SES::Response - Perl class that represents a response from AWS SES
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNPOSIS
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# see Net::AWS::SES
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This class is not meant to be used directly, but through L. First you should be familiar with L and only then come back to this class for new information
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
20
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
21
|
1
|
|
|
1
|
|
5
|
use Carp ('croak');
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
22
|
1
|
|
|
1
|
|
392
|
use XML::Simple;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.03';
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new {
|
27
|
|
|
|
|
|
|
my $class = shift;
|
28
|
|
|
|
|
|
|
my ( $response, $action ) = @_;
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
unless ( $response
|
31
|
|
|
|
|
|
|
&& ref($response)
|
32
|
|
|
|
|
|
|
&& $response->isa("HTTP::Response")
|
33
|
|
|
|
|
|
|
&& $action )
|
34
|
|
|
|
|
|
|
{
|
35
|
|
|
|
|
|
|
croak "new(): usage error";
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
my $self = bless { __response => $response, data => {}, action => $action },
|
38
|
|
|
|
|
|
|
$class;
|
39
|
|
|
|
|
|
|
$self->__parse_response;
|
40
|
|
|
|
|
|
|
return $self;
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub __parse_response {
|
44
|
|
|
|
|
|
|
my $self = shift;
|
45
|
|
|
|
|
|
|
$self->{data} = XMLin(
|
46
|
|
|
|
|
|
|
$self->raw_content,
|
47
|
|
|
|
|
|
|
GroupTags => {
|
48
|
|
|
|
|
|
|
Identities => 'member',
|
49
|
|
|
|
|
|
|
DkimTokens => 'member'
|
50
|
|
|
|
|
|
|
},
|
51
|
|
|
|
|
|
|
KeepRoot => 0,
|
52
|
|
|
|
|
|
|
ForceArray => [ 'member', 'DkimAttributes' ]
|
53
|
|
|
|
|
|
|
);
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 message_id()
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns a message id for successfully sent e-mails. Only valid for successful requests.
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub message_id {
|
63
|
|
|
|
|
|
|
my $self = shift;
|
64
|
|
|
|
|
|
|
my $action = $self->{action};
|
65
|
|
|
|
|
|
|
return unless $self->result;
|
66
|
|
|
|
|
|
|
return $self->result->{'MessageId'};
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 result()
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns parsed contents of the response. This is usually the contents of C<*Result> element. Exception is the error response, in which case it returns the ontents of C element.
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub result {
|
76
|
|
|
|
|
|
|
my $self = shift;
|
77
|
|
|
|
|
|
|
my $action = $self->{action};
|
78
|
|
|
|
|
|
|
if ( $self->is_error ) {
|
79
|
|
|
|
|
|
|
return $self->{data}; # error response do not have *Result containers
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
return $self->{data}->{ $action . 'Result' };
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 result_as_json()
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Same as C, except converts the data into JSON notation
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub result_as_json {
|
91
|
|
|
|
|
|
|
my $self = shift;
|
92
|
|
|
|
|
|
|
require JSON;
|
93
|
|
|
|
|
|
|
return JSON::to_json( $self->result, { pretty => 1 } );
|
94
|
|
|
|
|
|
|
}
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 raw_content()
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This is the raw (unparsed) by decoded HTTP content as returned from the AWS SES. Usually you do not need it. If you think you need it just knock yourself out!
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub raw_content {
|
103
|
|
|
|
|
|
|
return $_[0]->{__response}->decoded_content;
|
104
|
|
|
|
|
|
|
}
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 is_success()
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 is_error()
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is the first thing you should check after each request().
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub is_success {
|
115
|
|
|
|
|
|
|
return $_[0]->{__response}->is_success;
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub is_error {
|
119
|
|
|
|
|
|
|
return $_[0]->{__response}->is_error;
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 http_code()
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Since all the api request/response happens using HTTP Query actions, this code returns the HTTP response code. For all successfull response it returns C<200>, errors usually return C<400>. This is here just in case
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub http_code {
|
129
|
|
|
|
|
|
|
return $_[0]->{__response}->code;
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 error_code()
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns an error code from AWS SES. Unlik C, this is a short error message, as documented in AWS SES API reference
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 error_message()
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Returns more descriptive error message from AWS SES
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 error_type()
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns the type of the error. Most of the time in my experience it returns C.
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub error_code {
|
149
|
|
|
|
|
|
|
my $self = shift;
|
150
|
|
|
|
|
|
|
return $self->{data}->{Error}->{Code};
|
151
|
|
|
|
|
|
|
}
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub error_message {
|
154
|
|
|
|
|
|
|
my $self = shift;
|
155
|
|
|
|
|
|
|
return $self->{data}->{Error}->{Message};
|
156
|
|
|
|
|
|
|
}
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub error_type {
|
159
|
|
|
|
|
|
|
my $self = shift;
|
160
|
|
|
|
|
|
|
return $self->{data}->{Error}->{Type};
|
161
|
|
|
|
|
|
|
}
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 request_id()
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns an ID of the request. All response, including the ones resulting in error, contain a RequestId.
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub request_id {
|
170
|
|
|
|
|
|
|
my $self = shift;
|
171
|
|
|
|
|
|
|
return $self->{data}->{RequestId} if $self->{data}->{RequestId};
|
172
|
|
|
|
|
|
|
my $action = $self->{action};
|
173
|
|
|
|
|
|
|
return $self->{data}->{'ResponseMetadata'}->{RequestId};
|
174
|
|
|
|
|
|
|
}
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 dkim_attributes()
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
The same as
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$response->result->{DkimAttributes}
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Only meaning for get_dkim_attributes() api call
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub dkim_attributes {
|
187
|
|
|
|
|
|
|
my $self = shift;
|
188
|
|
|
|
|
|
|
if ( my $attributes = $self->result->{DkimAttributes}->[0]->{entry} ) {
|
189
|
|
|
|
|
|
|
return $self->result->{DkimAttributes};
|
190
|
|
|
|
|
|
|
}
|
191
|
|
|
|
|
|
|
return;
|
192
|
|
|
|
|
|
|
}
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SEE ALSO
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
L
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 AUTHOR
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Sherzod B. Ruzmetov Esherzodr@cpan.orgE
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Copyright (C) 2013 by L
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
207
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.14.2 or,
|
208
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available.
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1;
|