aws-ses 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +11 -0
- data/README +35 -0
- data/README.erb +14 -0
- data/Rakefile +3 -0
- data/TODO +0 -1
- data/VERSION +1 -1
- data/aws-ses.gemspec +5 -3
- data/lib/aws/ses.rb +1 -2
- data/lib/aws/ses/addresses.rb +13 -0
- data/lib/aws/ses/base.rb +33 -77
- data/lib/aws/ses/response.rb +18 -8
- data/lib/aws/ses/send_email.rb +40 -0
- data/lib/aws/ses/version.rb +1 -1
- data/test/base_test.rb +31 -0
- data/test/helper.rb +2 -2
- data/test/response_test.rb +0 -8
- data/test/send_email_test.rb +40 -9
- metadata +36 -21
- data/lib/aws/ses/exceptions.rb +0 -41
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,27 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (3.0.3)
|
4
5
|
builder (3.0.0)
|
5
6
|
flexmock (0.8.11)
|
6
7
|
git (1.2.5)
|
8
|
+
i18n (0.5.0)
|
7
9
|
jeweler (1.5.2)
|
8
10
|
bundler (~> 1.0.0)
|
9
11
|
git (>= 1.2.5)
|
10
12
|
rake
|
13
|
+
mail (2.2.15)
|
14
|
+
activesupport (>= 2.3.6)
|
15
|
+
i18n (>= 0.4.0)
|
16
|
+
mime-types (~> 1.16)
|
17
|
+
treetop (~> 1.4.8)
|
11
18
|
mime-types (1.16)
|
19
|
+
polyglot (0.3.1)
|
12
20
|
rake (0.8.7)
|
13
21
|
rcov (0.9.9)
|
14
22
|
shoulda-context (1.0.0.beta1)
|
23
|
+
treetop (1.4.9)
|
24
|
+
polyglot (>= 0.3.1)
|
15
25
|
xml-simple (1.0.13)
|
16
26
|
|
17
27
|
PLATFORMS
|
@@ -22,6 +32,7 @@ DEPENDENCIES
|
|
22
32
|
bundler (~> 1.0.0)
|
23
33
|
flexmock (~> 0.8.11)
|
24
34
|
jeweler (~> 1.5.2)
|
35
|
+
mail (~> 2.2.15)
|
25
36
|
mime-types
|
26
37
|
rcov
|
27
38
|
shoulda-context
|
data/README
CHANGED
@@ -31,6 +31,12 @@ Use the following to send an e-mail:
|
|
31
31
|
:subject => 'Subject Line'
|
32
32
|
:text_body => 'Internal text body'
|
33
33
|
|
34
|
+
You can also send Mail objects using send_raw_email:
|
35
|
+
|
36
|
+
m = Mail.new( :to => ..., :from => ... )
|
37
|
+
ses.send_raw_email(m)
|
38
|
+
|
39
|
+
send_raw_email will also take a hash and pass it through Mail.new automatically as well.
|
34
40
|
|
35
41
|
|
36
42
|
== Addresses
|
@@ -40,11 +46,40 @@ AWS::SES::Addresses provides for:
|
|
40
46
|
* Adding new e-mail addresses to verify
|
41
47
|
* Deleting verified e-mail addresses
|
42
48
|
|
49
|
+
You can access these methods as follows:
|
50
|
+
|
51
|
+
ses = AWS::SES::Base.new( ... connection info ... )
|
52
|
+
|
53
|
+
# Get a list of verified addresses
|
54
|
+
ses.addresses.list.result
|
55
|
+
|
56
|
+
# Add a new e-mail address to verify
|
57
|
+
ses.addresses.verify('jon@example.com')
|
58
|
+
|
59
|
+
# Delete an e-mail address
|
60
|
+
ses.addresses.delete('jon@example.com')
|
61
|
+
|
43
62
|
|
44
63
|
== Info
|
45
64
|
|
46
65
|
Adds functionality for the statistics and info functionality
|
47
66
|
|
67
|
+
You can call 'quota' or 'statistics'
|
68
|
+
|
69
|
+
|
70
|
+
== Rails
|
71
|
+
|
72
|
+
This gem is compatible with Rails. Simply add this to your `config/environments/*.rb` as appropriate:
|
73
|
+
|
74
|
+
ses = AWS::SES::Base.new(
|
75
|
+
:access_key_id => 'abc',
|
76
|
+
:secret_access_key => '123'
|
77
|
+
)
|
78
|
+
config.action_mailer.deliver_method = ses
|
79
|
+
|
80
|
+
== Source
|
81
|
+
|
82
|
+
Available at: https://github.com/drewblas/aws-ses
|
48
83
|
|
49
84
|
== Contributing to aws-ses
|
50
85
|
|
data/README.erb
CHANGED
@@ -14,6 +14,20 @@
|
|
14
14
|
|
15
15
|
<%= docs_for['AWS::SES::Info'] %>
|
16
16
|
|
17
|
+
== Rails
|
18
|
+
|
19
|
+
This gem is compatible with Rails. Simply add this to your `config/environments/*.rb` as appropriate:
|
20
|
+
|
21
|
+
ses = AWS::SES::Base.new(
|
22
|
+
:access_key_id => 'abc',
|
23
|
+
:secret_access_key => '123'
|
24
|
+
)
|
25
|
+
config.action_mailer.deliver_method = ses
|
26
|
+
|
27
|
+
== Source
|
28
|
+
|
29
|
+
Available at: https://github.com/drewblas/aws-ses
|
30
|
+
|
17
31
|
== Contributing to aws-ses
|
18
32
|
|
19
33
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/Rakefile
CHANGED
@@ -58,6 +58,9 @@ namespace :doc do
|
|
58
58
|
rdoc.options << '--line-numbers' << '--inline-source'
|
59
59
|
rdoc.rdoc_files.include('README')
|
60
60
|
rdoc.rdoc_files.include('LICENSE')
|
61
|
+
rdoc.rdoc_files.include('CHANGELOG')
|
62
|
+
rdoc.rdoc_files.include('TODO')
|
63
|
+
rdoc.rdoc_files.include('VERSION')
|
61
64
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
62
65
|
end
|
63
66
|
|
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/aws-ses.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{aws-ses}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Drew Blas", "Marcel Molina Jr."]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-31}
|
13
13
|
s.description = %q{Client library for Amazon's Simple Email Service's REST API}
|
14
14
|
s.email = %q{drew.blas@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,7 +33,6 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/aws/ses.rb",
|
34
34
|
"lib/aws/ses/addresses.rb",
|
35
35
|
"lib/aws/ses/base.rb",
|
36
|
-
"lib/aws/ses/exceptions.rb",
|
37
36
|
"lib/aws/ses/extensions.rb",
|
38
37
|
"lib/aws/ses/info.rb",
|
39
38
|
"lib/aws/ses/response.rb",
|
@@ -69,6 +68,7 @@ Gem::Specification.new do |s|
|
|
69
68
|
s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
|
70
69
|
s.add_runtime_dependency(%q<builder>, [">= 0"])
|
71
70
|
s.add_runtime_dependency(%q<mime-types>, [">= 0"])
|
71
|
+
s.add_runtime_dependency(%q<mail>, ["~> 2.2.15"])
|
72
72
|
s.add_development_dependency(%q<shoulda-context>, [">= 0"])
|
73
73
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
74
74
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -81,6 +81,7 @@ Gem::Specification.new do |s|
|
|
81
81
|
s.add_dependency(%q<xml-simple>, [">= 0"])
|
82
82
|
s.add_dependency(%q<builder>, [">= 0"])
|
83
83
|
s.add_dependency(%q<mime-types>, [">= 0"])
|
84
|
+
s.add_dependency(%q<mail>, ["~> 2.2.15"])
|
84
85
|
s.add_dependency(%q<shoulda-context>, [">= 0"])
|
85
86
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
86
87
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -94,6 +95,7 @@ Gem::Specification.new do |s|
|
|
94
95
|
s.add_dependency(%q<xml-simple>, [">= 0"])
|
95
96
|
s.add_dependency(%q<builder>, [">= 0"])
|
96
97
|
s.add_dependency(%q<mime-types>, [">= 0"])
|
98
|
+
s.add_dependency(%q<mail>, ["~> 2.2.15"])
|
97
99
|
s.add_dependency(%q<shoulda-context>, [">= 0"])
|
98
100
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
99
101
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
data/lib/aws/ses.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
%w[ base64 cgi openssl digest/sha1 net/https net/http rexml/document time ostruct ].each { |f| require f }
|
1
|
+
%w[ base64 cgi openssl digest/sha1 net/https net/http rexml/document time ostruct mail].each { |f| require f }
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'URI' unless defined? URI
|
@@ -19,6 +19,5 @@ require 'ses/response'
|
|
19
19
|
require 'ses/send_email'
|
20
20
|
require 'ses/info'
|
21
21
|
require 'ses/base'
|
22
|
-
require 'ses/exceptions'
|
23
22
|
require 'ses/version'
|
24
23
|
require 'ses/addresses'
|
data/lib/aws/ses/addresses.rb
CHANGED
@@ -4,6 +4,19 @@ module AWS
|
|
4
4
|
# * Listing verified e-mail addresses
|
5
5
|
# * Adding new e-mail addresses to verify
|
6
6
|
# * Deleting verified e-mail addresses
|
7
|
+
#
|
8
|
+
# You can access these methods as follows:
|
9
|
+
#
|
10
|
+
# ses = AWS::SES::Base.new( ... connection info ... )
|
11
|
+
#
|
12
|
+
# # Get a list of verified addresses
|
13
|
+
# ses.addresses.list.result
|
14
|
+
#
|
15
|
+
# # Add a new e-mail address to verify
|
16
|
+
# ses.addresses.verify('jon@example.com')
|
17
|
+
#
|
18
|
+
# # Delete an e-mail address
|
19
|
+
# ses.addresses.delete('jon@example.com')
|
7
20
|
class Addresses < Base
|
8
21
|
def initialize(ses)
|
9
22
|
@ses = ses
|
data/lib/aws/ses/base.rb
CHANGED
@@ -117,48 +117,48 @@ module AWS #:nodoc:
|
|
117
117
|
|
118
118
|
end
|
119
119
|
|
120
|
+
attr_accessor :settings
|
121
|
+
|
120
122
|
def connection
|
121
123
|
@http
|
122
124
|
end
|
123
125
|
|
124
|
-
# Make the connection to AWS
|
126
|
+
# Make the connection to AWS passing in our request.
|
125
127
|
# allow us to have a one line call in each method which will do all of the work
|
126
128
|
# in making the actual request to AWS.
|
127
129
|
def request(action, params = {})
|
130
|
+
# remove any keys that have nil or empty values
|
131
|
+
params.reject! { |key, value| value.nil? or value.empty?}
|
132
|
+
|
133
|
+
timestamp = Time.now.getutc
|
128
134
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
query = params.sort.collect do |param|
|
143
|
-
CGI::escape(param[0]) + "=" + CGI::escape(param[1])
|
144
|
-
end.join("&")
|
145
|
-
|
146
|
-
req = Net::HTTP::Post.new(@path)
|
147
|
-
req.content_type = 'application/x-www-form-urlencoded'
|
148
|
-
req['X-Amzn-Authorization'] = get_aws_auth_param(timestamp.httpdate, @secret_access_key)
|
149
|
-
req['Date'] = timestamp.httpdate
|
150
|
-
req['User-Agent'] = "github-aws-ses-ruby-gem"
|
151
|
-
|
152
|
-
response = connection.request(req, query)
|
153
|
-
|
154
|
-
# Make a call to see if we need to throw an error based on the response given by EC2
|
155
|
-
# All error classes are defined in EC2/exceptions.rb
|
156
|
-
aws_error?(response)
|
157
|
-
|
158
|
-
response_class = AWS::SES.const_get( "#{action}Response" )
|
159
|
-
return response_class.new(action, response)
|
160
|
-
end
|
135
|
+
params.merge!( {"Action" => action,
|
136
|
+
"SignatureVersion" => "2",
|
137
|
+
"SignatureMethod" => 'HmacSHA256',
|
138
|
+
"AWSAccessKeyId" => @access_key_id,
|
139
|
+
"Version" => API_VERSION,
|
140
|
+
"Timestamp" => timestamp.iso8601 } )
|
141
|
+
|
142
|
+
query = params.sort.collect do |param|
|
143
|
+
CGI::escape(param[0]) + "=" + CGI::escape(param[1])
|
144
|
+
end.join("&")
|
145
|
+
|
146
|
+
req = {}
|
161
147
|
|
148
|
+
req['X-Amzn-Authorization'] = get_aws_auth_param(timestamp.httpdate, @secret_access_key)
|
149
|
+
req['Date'] = timestamp.httpdate
|
150
|
+
req['User-Agent'] = "github-aws-ses-ruby-gem"
|
151
|
+
|
152
|
+
response = connection.post(@path, query, req)
|
153
|
+
|
154
|
+
response_class = AWS::SES.const_get( "#{action}Response" )
|
155
|
+
result = response_class.new(action, response)
|
156
|
+
|
157
|
+
if result.error?
|
158
|
+
raise ResponseError.new(result)
|
159
|
+
end
|
160
|
+
|
161
|
+
result
|
162
162
|
end
|
163
163
|
|
164
164
|
# Set the Authorization header using AWS signed header authentication
|
@@ -166,50 +166,6 @@ module AWS #:nodoc:
|
|
166
166
|
encoded_canonical = SES.encode(secret_access_key, timestamp, false)
|
167
167
|
SES.authorization_header(@access_key_id, 'HmacSHA256', encoded_canonical)
|
168
168
|
end
|
169
|
-
|
170
|
-
# Raises the appropriate error if the specified Net::HTTPResponse object
|
171
|
-
# contains an AWS error; returns +false+ otherwise.
|
172
|
-
def aws_error?(response)
|
173
|
-
# return false if we got a HTTP 200 code,
|
174
|
-
# otherwise there is some type of error (40x,50x) and
|
175
|
-
# we should try to raise an appropriate exception
|
176
|
-
# from one of our exception classes defined in
|
177
|
-
# exceptions.rb
|
178
|
-
return false if response.is_a?(Net::HTTPSuccess)
|
179
|
-
|
180
|
-
raise AWS::Error, "Unexpected server error. response.body is: #{response.body}" if response.is_a?(Net::HTTPServerError)
|
181
|
-
|
182
|
-
# parse the XML document so we can walk through it
|
183
|
-
doc = REXML::Document.new(response.body)
|
184
|
-
|
185
|
-
# Check that the Error element is in the place we would expect.
|
186
|
-
# and if not raise a generic error exception
|
187
|
-
unless doc.root.elements['Error'].name == 'Error'
|
188
|
-
raise Error, "Unexpected error format. response.body is: #{response.body}"
|
189
|
-
end
|
190
|
-
|
191
|
-
# An valid error response looks like this:
|
192
|
-
# <?xml version="1.0"?><Response><Errors><Error><Code>InvalidParameterCombination</Code><Message>Unknown parameter: foo</Message></Error></Errors><RequestID>291cef62-3e86-414b-900e-17246eccfae8</RequestID></Response>
|
193
|
-
# AWS throws some exception codes that look like Error.SubError. Since we can't name classes this way
|
194
|
-
# we need to strip out the '.' in the error 'Code' and we name the error exceptions with this
|
195
|
-
# non '.' name as well.
|
196
|
-
error_code = doc.root.elements['Error'].elements['Code'].text.gsub('.', '')
|
197
|
-
error_message = doc.root.elements['Error'].elements['Message'].text
|
198
|
-
|
199
|
-
# Raise one of our specific error classes if it exists.
|
200
|
-
# otherwise, throw a generic EC2 Error with a few details.
|
201
|
-
if AWS.const_defined?(error_code)
|
202
|
-
raise AWS.const_get(error_code), error_message
|
203
|
-
else
|
204
|
-
raise AWS::Error, error_message + error_code
|
205
|
-
end
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
class << self
|
210
|
-
|
211
|
-
|
212
|
-
end # class methods
|
213
169
|
end # class Base
|
214
170
|
end # Module SES
|
215
171
|
end # Module AWS
|
data/lib/aws/ses/response.rb
CHANGED
@@ -42,11 +42,11 @@ module AWS
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def error?
|
45
|
-
!success? && response['content-type'] == 'application/xml'
|
45
|
+
!success? && (response['content-type'] == 'application/xml' || response['content-type'] == 'text/xml')
|
46
46
|
end
|
47
47
|
|
48
48
|
def error
|
49
|
-
Error
|
49
|
+
parsed['Error']
|
50
50
|
end
|
51
51
|
memoized :error
|
52
52
|
|
@@ -55,7 +55,7 @@ module AWS
|
|
55
55
|
# parse_options = { 'suppressempty' => nil, 'keeproot' => false }
|
56
56
|
|
57
57
|
xml = XmlSimple.xml_in(body, parse_options)
|
58
|
-
xml["#{@action}Result"]
|
58
|
+
xml["#{@action}Result"] || xml
|
59
59
|
end
|
60
60
|
memoized :parsed
|
61
61
|
|
@@ -83,15 +83,25 @@ module AWS
|
|
83
83
|
# exception.response.error
|
84
84
|
# # => <Error>
|
85
85
|
# end
|
86
|
-
class
|
87
|
-
|
88
|
-
|
86
|
+
class ResponseError < StandardError
|
87
|
+
attr_reader :response
|
88
|
+
def initialize(response)
|
89
|
+
@response = response
|
90
|
+
super("AWS::SES Response Error: #{message}")
|
91
|
+
end
|
92
|
+
|
93
|
+
def code
|
94
|
+
@response.code
|
95
|
+
end
|
96
|
+
|
97
|
+
def message
|
98
|
+
@response.error['Code'] + @response.error['Message']
|
89
99
|
end
|
90
100
|
|
91
101
|
def inspect
|
92
|
-
"#<%s:0x%s %s
|
102
|
+
"#<%s:0x%s %s '%s'>" % [self.class.name, object_id, code, message]
|
93
103
|
end
|
94
104
|
end
|
95
|
-
end #module SES
|
105
|
+
end # module SES
|
96
106
|
end # module AWS
|
97
107
|
|
data/lib/aws/ses/send_email.rb
CHANGED
@@ -9,6 +9,12 @@ module AWS
|
|
9
9
|
# :subject => 'Subject Line'
|
10
10
|
# :text_body => 'Internal text body'
|
11
11
|
#
|
12
|
+
# You can also send Mail objects using send_raw_email:
|
13
|
+
#
|
14
|
+
# m = Mail.new( :to => ..., :from => ... )
|
15
|
+
# ses.send_raw_email(m)
|
16
|
+
#
|
17
|
+
# send_raw_email will also take a hash and pass it through Mail.new automatically as well.
|
12
18
|
module SendEmail
|
13
19
|
|
14
20
|
# Sends an email through SES
|
@@ -55,6 +61,36 @@ module AWS
|
|
55
61
|
request('SendEmail', package)
|
56
62
|
end
|
57
63
|
|
64
|
+
# Sends using the SendRawEmail method
|
65
|
+
# This gives the most control and flexibility
|
66
|
+
#
|
67
|
+
# This uses the underlying Mail object from the mail gem
|
68
|
+
# You can pass in a Mail object, a Hash of params that will be parsed by Mail.new, or just a string
|
69
|
+
#
|
70
|
+
# Note that the params are different from send_email
|
71
|
+
# Specifically, the following fields from send_email will NOT work:
|
72
|
+
#
|
73
|
+
# * :source
|
74
|
+
# * :html_body
|
75
|
+
# * :text_body
|
76
|
+
#
|
77
|
+
# send_email accepts the aliases of :from & :body in order to be more compatible with the Mail gem
|
78
|
+
#
|
79
|
+
# This method is aliased as deliver and deliver! for compatibility (especially with Rails)
|
80
|
+
#
|
81
|
+
# @option mail [String] A raw string that is a properly formatted e-mail message
|
82
|
+
# @option mail [Hash] A hash that will be parsed by Mail.new
|
83
|
+
# @option mail [Mail] A mail object, ready to be encoded
|
84
|
+
# @return [Response]
|
85
|
+
def send_raw_email(mail)
|
86
|
+
message = mail.is_a?(Hash) ? Mail.new(mail).to_s : mail.to_s
|
87
|
+
package = { 'RawMessage.Data' => Base64::encode64(message) }
|
88
|
+
request('SendRawEmail', package)
|
89
|
+
end
|
90
|
+
|
91
|
+
alias :deliver! :send_raw_email
|
92
|
+
alias :deliver :send_raw_email
|
93
|
+
|
58
94
|
private
|
59
95
|
|
60
96
|
# Adds all elements of the ary with the appropriate member elements
|
@@ -70,5 +106,9 @@ module AWS
|
|
70
106
|
class SendEmailResponse < AWS::SES::Response
|
71
107
|
|
72
108
|
end
|
109
|
+
|
110
|
+
class SendRawEmailResponse < AWS::SES::Response
|
111
|
+
|
112
|
+
end
|
73
113
|
end
|
74
114
|
end
|
data/lib/aws/ses/version.rb
CHANGED
data/test/base_test.rb
CHANGED
@@ -6,4 +6,35 @@ class BaseTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
assert_not_nil instance.instance_variable_get("@http")
|
8
8
|
end
|
9
|
+
|
10
|
+
def test_failed_response
|
11
|
+
@base = generate_base
|
12
|
+
mock_connection(@base, {:code => 403, :body => %{
|
13
|
+
<ErrorResponse>
|
14
|
+
<Error>
|
15
|
+
<Type>
|
16
|
+
Sender
|
17
|
+
</Type>
|
18
|
+
<Code>
|
19
|
+
ValidationError
|
20
|
+
</Code>
|
21
|
+
<Message>
|
22
|
+
Value null at 'message.subject' failed to satisfy constraint: Member must not be null
|
23
|
+
</Message>
|
24
|
+
</Error>
|
25
|
+
<RequestId>
|
26
|
+
42d59b56-7407-4c4a-be0f-4c88daeea257
|
27
|
+
</RequestId>
|
28
|
+
</ErrorResponse>
|
29
|
+
}})
|
30
|
+
|
31
|
+
assert_raises ResponseError do
|
32
|
+
result = @base.request('', {})
|
33
|
+
end
|
34
|
+
|
35
|
+
# assert !result.success?
|
36
|
+
# assert result.error?
|
37
|
+
# assert result.error.error?
|
38
|
+
# assert_equal 'ValidationError', result.error.code
|
39
|
+
end
|
9
40
|
end
|
data/test/helper.rb
CHANGED
@@ -41,8 +41,8 @@ class Test::Unit::TestCase
|
|
41
41
|
abort "Response data for mock connection must be a Hash or an Array. Was #{data.inspect}."
|
42
42
|
end
|
43
43
|
|
44
|
-
connection = flexmock(Net::HTTP.new) do |mock|
|
45
|
-
mock.should_receive(:
|
44
|
+
connection = flexmock('Net::HTTP.new') do |mock|
|
45
|
+
mock.should_receive(:post).and_return(*return_values).at_least.once
|
46
46
|
end
|
47
47
|
|
48
48
|
mock = flexmock(object)
|
data/test/response_test.rb
CHANGED
@@ -22,12 +22,4 @@ class BaseResponseTest < Test::Unit::TestCase
|
|
22
22
|
@base_response.each {|k,v| new_headers[k] = v}
|
23
23
|
assert_equal original_headers, new_headers
|
24
24
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class ErrorResponseTest < Test::Unit::TestCase
|
28
|
-
def test_error_responses_are_always_in_error
|
29
|
-
assert Error.new('ErrorAction', FakeResponse.new).error?
|
30
|
-
assert Error.new('ErrorAction', FakeResponse.new(:code => 200)).error?
|
31
|
-
assert Error.new('ErrorAction', FakeResponse.new(:headers => {'content-type' => 'text/plain'})).error?
|
32
|
-
end
|
33
25
|
end
|
data/test/send_email_test.rb
CHANGED
@@ -4,6 +4,10 @@ class SendEmailTest < Test::Unit::TestCase
|
|
4
4
|
context "when sending email" do
|
5
5
|
setup do
|
6
6
|
@base = generate_base
|
7
|
+
@basic_email = { :from => 'jon@example.com',
|
8
|
+
:to => 'dave@example.com',
|
9
|
+
:subject => 'Subject1',
|
10
|
+
:text_body => 'Body1' }
|
7
11
|
end
|
8
12
|
|
9
13
|
context "adding to a hash" do
|
@@ -24,14 +28,41 @@ class SendEmailTest < Test::Unit::TestCase
|
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
should "send an e-mail" do
|
32
|
+
mock_connection(@base)
|
33
|
+
|
34
|
+
result = @base.send_email @basic_email
|
35
|
+
assert result.success?
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'send a raw e-mail with a mail object' do
|
39
|
+
mock_connection(@base, {:body => %{
|
40
|
+
<SendRawEmailRequest>
|
41
|
+
<SendRawEmailResponse>
|
42
|
+
<MessageId>abc-123</MessageId>
|
43
|
+
</SendRawEmailResponse>
|
44
|
+
</SendRawEmailRequest>
|
45
|
+
}})
|
46
|
+
|
47
|
+
mail = Mail.new @basic_email
|
48
|
+
|
49
|
+
result = @base.send_raw_email(mail)
|
50
|
+
|
51
|
+
assert result.success?
|
52
|
+
end
|
53
|
+
|
54
|
+
should 'send a raw e-mail with a hash object' do
|
55
|
+
mock_connection(@base, {:body => %{
|
56
|
+
<SendRawEmailRequest>
|
57
|
+
<SendRawEmailResponse>
|
58
|
+
<MessageId>abc-123</MessageId>
|
59
|
+
</SendRawEmailResponse>
|
60
|
+
</SendRawEmailRequest>
|
61
|
+
}})
|
62
|
+
|
63
|
+
result = @base.send_raw_email(@basic_email)
|
64
|
+
|
65
|
+
assert result.success?
|
66
|
+
end
|
36
67
|
end
|
37
68
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-ses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Drew Blas
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-01-
|
19
|
+
date: 2011-01-31 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -61,11 +61,27 @@ dependencies:
|
|
61
61
|
- 0
|
62
62
|
version: "0"
|
63
63
|
requirement: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
prerelease: false
|
66
|
+
name: mail
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 25
|
74
|
+
segments:
|
75
|
+
- 2
|
76
|
+
- 2
|
77
|
+
- 15
|
78
|
+
version: 2.2.15
|
79
|
+
requirement: *id004
|
64
80
|
- !ruby/object:Gem::Dependency
|
65
81
|
prerelease: false
|
66
82
|
name: shoulda-context
|
67
83
|
type: :development
|
68
|
-
version_requirements: &
|
84
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
69
85
|
none: false
|
70
86
|
requirements:
|
71
87
|
- - ">="
|
@@ -74,12 +90,12 @@ dependencies:
|
|
74
90
|
segments:
|
75
91
|
- 0
|
76
92
|
version: "0"
|
77
|
-
requirement: *
|
93
|
+
requirement: *id005
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
prerelease: false
|
80
96
|
name: bundler
|
81
97
|
type: :development
|
82
|
-
version_requirements: &
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
83
99
|
none: false
|
84
100
|
requirements:
|
85
101
|
- - ~>
|
@@ -90,12 +106,12 @@ dependencies:
|
|
90
106
|
- 0
|
91
107
|
- 0
|
92
108
|
version: 1.0.0
|
93
|
-
requirement: *
|
109
|
+
requirement: *id006
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
prerelease: false
|
96
112
|
name: jeweler
|
97
113
|
type: :development
|
98
|
-
version_requirements: &
|
114
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
99
115
|
none: false
|
100
116
|
requirements:
|
101
117
|
- - ~>
|
@@ -106,12 +122,12 @@ dependencies:
|
|
106
122
|
- 5
|
107
123
|
- 2
|
108
124
|
version: 1.5.2
|
109
|
-
requirement: *
|
125
|
+
requirement: *id007
|
110
126
|
- !ruby/object:Gem::Dependency
|
111
127
|
prerelease: false
|
112
128
|
name: rcov
|
113
129
|
type: :development
|
114
|
-
version_requirements: &
|
130
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
115
131
|
none: false
|
116
132
|
requirements:
|
117
133
|
- - ">="
|
@@ -120,12 +136,12 @@ dependencies:
|
|
120
136
|
segments:
|
121
137
|
- 0
|
122
138
|
version: "0"
|
123
|
-
requirement: *
|
139
|
+
requirement: *id008
|
124
140
|
- !ruby/object:Gem::Dependency
|
125
141
|
prerelease: false
|
126
142
|
name: flexmock
|
127
143
|
type: :development
|
128
|
-
version_requirements: &
|
144
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
129
145
|
none: false
|
130
146
|
requirements:
|
131
147
|
- - ~>
|
@@ -136,12 +152,12 @@ dependencies:
|
|
136
152
|
- 8
|
137
153
|
- 11
|
138
154
|
version: 0.8.11
|
139
|
-
requirement: *
|
155
|
+
requirement: *id009
|
140
156
|
- !ruby/object:Gem::Dependency
|
141
157
|
prerelease: false
|
142
158
|
name: xml-simple
|
143
159
|
type: :runtime
|
144
|
-
version_requirements: &
|
160
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
145
161
|
none: false
|
146
162
|
requirements:
|
147
163
|
- - ">="
|
@@ -150,12 +166,12 @@ dependencies:
|
|
150
166
|
segments:
|
151
167
|
- 0
|
152
168
|
version: "0"
|
153
|
-
requirement: *
|
169
|
+
requirement: *id010
|
154
170
|
- !ruby/object:Gem::Dependency
|
155
171
|
prerelease: false
|
156
172
|
name: builder
|
157
173
|
type: :runtime
|
158
|
-
version_requirements: &
|
174
|
+
version_requirements: &id011 !ruby/object:Gem::Requirement
|
159
175
|
none: false
|
160
176
|
requirements:
|
161
177
|
- - ">="
|
@@ -164,12 +180,12 @@ dependencies:
|
|
164
180
|
segments:
|
165
181
|
- 0
|
166
182
|
version: "0"
|
167
|
-
requirement: *
|
183
|
+
requirement: *id011
|
168
184
|
- !ruby/object:Gem::Dependency
|
169
185
|
prerelease: false
|
170
186
|
name: mime-types
|
171
187
|
type: :runtime
|
172
|
-
version_requirements: &
|
188
|
+
version_requirements: &id012 !ruby/object:Gem::Requirement
|
173
189
|
none: false
|
174
190
|
requirements:
|
175
191
|
- - ">="
|
@@ -178,7 +194,7 @@ dependencies:
|
|
178
194
|
segments:
|
179
195
|
- 0
|
180
196
|
version: "0"
|
181
|
-
requirement: *
|
197
|
+
requirement: *id012
|
182
198
|
description: Client library for Amazon's Simple Email Service's REST API
|
183
199
|
email: drew.blas@gmail.com
|
184
200
|
executables: []
|
@@ -205,7 +221,6 @@ files:
|
|
205
221
|
- lib/aws/ses.rb
|
206
222
|
- lib/aws/ses/addresses.rb
|
207
223
|
- lib/aws/ses/base.rb
|
208
|
-
- lib/aws/ses/exceptions.rb
|
209
224
|
- lib/aws/ses/extensions.rb
|
210
225
|
- lib/aws/ses/info.rb
|
211
226
|
- lib/aws/ses/response.rb
|
data/lib/aws/ses/exceptions.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# AWS ERROR CODES
|
3
|
-
# AWS can throw error exceptions that contain a '.' in them.
|
4
|
-
# since we can't name an exception class with that '.' I compressed
|
5
|
-
# each class name into the non-dot version which allows us to retain
|
6
|
-
# the granularity of the exception.
|
7
|
-
#++
|
8
|
-
|
9
|
-
module AWS
|
10
|
-
|
11
|
-
# All AWS errors are superclassed by Error < RuntimeError
|
12
|
-
class Error < RuntimeError; end
|
13
|
-
|
14
|
-
# CLIENT : A client side argument error
|
15
|
-
class ArgumentError < Error; end
|
16
|
-
|
17
|
-
# Server Error Codes
|
18
|
-
###
|
19
|
-
|
20
|
-
# Server : Internal Error.
|
21
|
-
class InternalError < Error; end
|
22
|
-
|
23
|
-
# Server : The server is overloaded and cannot handle the request.
|
24
|
-
class Unavailable < Error; end
|
25
|
-
|
26
|
-
# API Errors
|
27
|
-
############################
|
28
|
-
|
29
|
-
# Server : Invalid AWS Account
|
30
|
-
class InvalidClientTokenId < Error; end
|
31
|
-
|
32
|
-
# Server : The provided signature does not match.
|
33
|
-
class SignatureDoesNotMatch < Error; end
|
34
|
-
|
35
|
-
# SES Errors
|
36
|
-
############################
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|