aws-ses 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
- head:
1
+ 0.2.0:
2
+ * Added info support
3
+ * Added send_email
4
+
5
+ 0.1.0:
2
6
  - Initial creation that supports:
3
7
 
4
8
  * addresses.list
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "shoulda", ">= 0"
9
+ gem "shoulda-context", ">= 0"
10
10
  gem "bundler", "~> 1.0.0"
11
11
  gem "jeweler", "~> 1.5.2"
12
12
  gem "rcov", ">= 0"
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GEM
11
11
  mime-types (1.16)
12
12
  rake (0.8.7)
13
13
  rcov (0.9.9)
14
- shoulda (2.11.3)
14
+ shoulda-context (1.0.0.beta1)
15
15
  xml-simple (1.0.13)
16
16
 
17
17
  PLATFORMS
@@ -24,5 +24,5 @@ DEPENDENCIES
24
24
  jeweler (~> 1.5.2)
25
25
  mime-types
26
26
  rcov
27
- shoulda
27
+ shoulda-context
28
28
  xml-simple
data/README CHANGED
@@ -20,7 +20,20 @@ Before you can do anything, you must establish a connection using Base.new. A b
20
20
  The minimum connection options that you must specify are your access key id and your secret access key.
21
21
 
22
22
 
23
- = Addresses
23
+ == Send E-mail
24
+
25
+ Adds functionality for send_email and send_raw_email
26
+ Use the following to send an e-mail:
27
+
28
+ ses = AWS::SES::Base.new( ... connection info ... )
29
+ ses.send_email :to => ['jon@example.com', 'dave@example.com'],
30
+ :source => 'steve@example.com',
31
+ :subject => 'Subject Line'
32
+ :text_body => 'Internal text body'
33
+
34
+
35
+
36
+ == Addresses
24
37
 
25
38
  AWS::SES::Addresses provides for:
26
39
  * Listing verified e-mail addresses
@@ -28,6 +41,11 @@ AWS::SES::Addresses provides for:
28
41
  * Deleting verified e-mail addresses
29
42
 
30
43
 
44
+ == Info
45
+
46
+ Adds functionality for the statistics and info functionality
47
+
48
+
31
49
  == Contributing to aws-ses
32
50
 
33
51
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/README.erb CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  <%= docs_for['AWS::SES'] %>
4
4
 
5
- = Addresses
5
+ == Send E-mail
6
+
7
+ <%= docs_for ['AWS::SES::SendEmail'] %>
8
+
9
+ == Addresses
6
10
 
7
11
  <%= docs_for['AWS::SES::Addresses'] %>
8
12
 
13
+ == Info
14
+
15
+ <%= docs_for['AWS::SES::Info'] %>
16
+
9
17
  == Contributing to aws-ses
10
18
 
11
19
  * 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
@@ -57,7 +57,7 @@ namespace :doc do
57
57
  rdoc.title = "AWS::SES -- Support for Amazon SES's REST api #{version}"
58
58
  rdoc.options << '--line-numbers' << '--inline-source'
59
59
  rdoc.rdoc_files.include('README')
60
- rdoc.rdoc_files.include('COPYING')
60
+ rdoc.rdoc_files.include('LICENSE')
61
61
  rdoc.rdoc_files.include('lib/**/*.rb')
62
62
  end
63
63
 
data/TODO CHANGED
@@ -1,2 +1,2 @@
1
- * Implement the rest of the API
1
+ * Implement the Send Raw E-mail option
2
2
  * Use a better XML parser (and be consistent)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/aws-ses.gemspec ADDED
@@ -0,0 +1,107 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{aws-ses}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Drew Blas", "Marcel Molina Jr."]
12
+ s.date = %q{2011-01-26}
13
+ s.description = %q{Client library for Amazon's Simple Email Service's REST API}
14
+ s.email = %q{drew.blas@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README",
18
+ "README.erb",
19
+ "TODO"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "CHANGELOG",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE",
27
+ "README",
28
+ "README.erb",
29
+ "Rakefile",
30
+ "TODO",
31
+ "VERSION",
32
+ "aws-ses.gemspec",
33
+ "lib/aws/ses.rb",
34
+ "lib/aws/ses/addresses.rb",
35
+ "lib/aws/ses/base.rb",
36
+ "lib/aws/ses/exceptions.rb",
37
+ "lib/aws/ses/extensions.rb",
38
+ "lib/aws/ses/info.rb",
39
+ "lib/aws/ses/response.rb",
40
+ "lib/aws/ses/send_email.rb",
41
+ "lib/aws/ses/version.rb",
42
+ "test/base_test.rb",
43
+ "test/extensions_test.rb",
44
+ "test/fixtures.rb",
45
+ "test/helper.rb",
46
+ "test/mocks/fake_response.rb",
47
+ "test/response_test.rb",
48
+ "test/send_email_test.rb"
49
+ ]
50
+ s.homepage = %q{http://github.com/drewblas/aws-ses}
51
+ s.licenses = ["MIT"]
52
+ s.require_paths = ["lib"]
53
+ s.rubygems_version = %q{1.4.2}
54
+ s.summary = %q{Client library for Amazon's Simple Email Service's REST API}
55
+ s.test_files = [
56
+ "test/base_test.rb",
57
+ "test/extensions_test.rb",
58
+ "test/fixtures.rb",
59
+ "test/helper.rb",
60
+ "test/mocks/fake_response.rb",
61
+ "test/response_test.rb",
62
+ "test/send_email_test.rb"
63
+ ]
64
+
65
+ if s.respond_to? :specification_version then
66
+ s.specification_version = 3
67
+
68
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
70
+ s.add_runtime_dependency(%q<builder>, [">= 0"])
71
+ s.add_runtime_dependency(%q<mime-types>, [">= 0"])
72
+ s.add_development_dependency(%q<shoulda-context>, [">= 0"])
73
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
74
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
75
+ s.add_development_dependency(%q<rcov>, [">= 0"])
76
+ s.add_development_dependency(%q<flexmock>, ["~> 0.8.11"])
77
+ s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
78
+ s.add_runtime_dependency(%q<builder>, [">= 0"])
79
+ s.add_runtime_dependency(%q<mime-types>, [">= 0"])
80
+ else
81
+ s.add_dependency(%q<xml-simple>, [">= 0"])
82
+ s.add_dependency(%q<builder>, [">= 0"])
83
+ s.add_dependency(%q<mime-types>, [">= 0"])
84
+ s.add_dependency(%q<shoulda-context>, [">= 0"])
85
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
86
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
87
+ s.add_dependency(%q<rcov>, [">= 0"])
88
+ s.add_dependency(%q<flexmock>, ["~> 0.8.11"])
89
+ s.add_dependency(%q<xml-simple>, [">= 0"])
90
+ s.add_dependency(%q<builder>, [">= 0"])
91
+ s.add_dependency(%q<mime-types>, [">= 0"])
92
+ end
93
+ else
94
+ s.add_dependency(%q<xml-simple>, [">= 0"])
95
+ s.add_dependency(%q<builder>, [">= 0"])
96
+ s.add_dependency(%q<mime-types>, [">= 0"])
97
+ s.add_dependency(%q<shoulda-context>, [">= 0"])
98
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
99
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
100
+ s.add_dependency(%q<rcov>, [">= 0"])
101
+ s.add_dependency(%q<flexmock>, ["~> 0.8.11"])
102
+ s.add_dependency(%q<xml-simple>, [">= 0"])
103
+ s.add_dependency(%q<builder>, [">= 0"])
104
+ s.add_dependency(%q<mime-types>, [">= 0"])
105
+ end
106
+ end
107
+
data/lib/aws/ses.rb CHANGED
@@ -15,8 +15,10 @@ end
15
15
  $:.unshift(File.dirname(__FILE__))
16
16
  require 'ses/extensions'
17
17
 
18
- require 'ses/base'
19
18
  require 'ses/response'
19
+ require 'ses/send_email'
20
+ require 'ses/info'
21
+ require 'ses/base'
20
22
  require 'ses/exceptions'
21
23
  require 'ses/version'
22
24
  require 'ses/addresses'
data/lib/aws/ses/base.rb CHANGED
@@ -56,6 +56,8 @@ module AWS #:nodoc:
56
56
 
57
57
  # AWS::SES::Base is the abstract super class of all classes who make requests against SES
58
58
  class Base
59
+ include SendEmail
60
+ include Info
59
61
 
60
62
  attr_reader :use_ssl, :server, :proxy_server, :port
61
63
 
@@ -199,7 +201,7 @@ module AWS #:nodoc:
199
201
  if AWS.const_defined?(error_code)
200
202
  raise AWS.const_get(error_code), error_message
201
203
  else
202
- raise AWS::Error, error_message
204
+ raise AWS::Error, error_message + error_code
203
205
  end
204
206
 
205
207
  end
@@ -20,15 +20,6 @@ module AWS
20
20
  # Server : Internal Error.
21
21
  class InternalError < Error; end
22
22
 
23
- # Server : Not enough available addresses to satisfy your minimum request.
24
- class InsufficientAddressCapacity < Error; end
25
-
26
- # Server : There are not enough available instances to satisfy your minimum request.
27
- class InsufficientInstanceCapacity < Error; end
28
-
29
- # Server : There are not enough available reserved instances to satisfy your minimum request.
30
- class InsufficientReservedInstanceCapacity < Error; end
31
-
32
23
  # Server : The server is overloaded and cannot handle the request.
33
24
  class Unavailable < Error; end
34
25
 
@@ -0,0 +1,26 @@
1
+ module AWS
2
+ module SES
3
+ # Adds functionality for the statistics and info functionality
4
+ #
5
+ # You can call 'quota' or 'statistics'
6
+ module Info
7
+ # Returns quota information provided by SES
8
+ #
9
+ # The return format inside the response result will look like:
10
+ # {"SentLast24Hours"=>"0.0", "MaxSendRate"=>"1.0", "Max24HourSend"=>"200.0"}
11
+ def quota
12
+ request('GetSendQuota')
13
+ end
14
+
15
+ def statistics
16
+ request('GetSendStatistics')
17
+ end
18
+ end
19
+
20
+ class GetSendQuotaResponse < AWS::SES::Response
21
+ end
22
+
23
+ class GetSendStatisticsResponse < AWS::SES::Response
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,74 @@
1
+ module AWS
2
+ module SES
3
+ # Adds functionality for send_email and send_raw_email
4
+ # Use the following to send an e-mail:
5
+ #
6
+ # ses = AWS::SES::Base.new( ... connection info ... )
7
+ # ses.send_email :to => ['jon@example.com', 'dave@example.com'],
8
+ # :source => 'steve@example.com',
9
+ # :subject => 'Subject Line'
10
+ # :text_body => 'Internal text body'
11
+ #
12
+ module SendEmail
13
+
14
+ # Sends an email through SES
15
+ #
16
+ # the destination parameters can be:
17
+ #
18
+ # [A single e-mail string] "jon@example.com"
19
+ # [A array of e-mail addresses] ['jon@example.com', 'dave@example.com']
20
+ #
21
+ # ---
22
+ # = "Email address is not verified.MessageRejected (AWS::Error)"
23
+ # If you are receiving this message and you HAVE verified the [source] please <b>check to be sure you are not in sandbox mode!</b>
24
+ # If you have not been granted production access, you will have to <b>verify all recipients</b as well.
25
+ # http://docs.amazonwebservices.com/ses/2010-12-01/DeveloperGuide/index.html?InitialSetup.Customer.html
26
+ # ---
27
+ #
28
+ # @option options [String] :source Source e-mail (from)
29
+ # @option options [String] :from alias for :source
30
+ # @option options [String] :to Destination e-mails
31
+ # @option options [String] :cc Destination e-mails
32
+ # @option options [String] :bcc Destination e-mails
33
+ # @option options [String] :subject
34
+ # @option options [String] :html_body
35
+ # @option options [String] :text_body
36
+ # @option options [String] :return_path The email address to which bounce notifications are to be forwarded. If the message cannot be delivered to the recipient, then an error message will be returned from the recipient's ISP; this message will then be forwarded to the email address specified by the ReturnPath parameter.
37
+ # @option options
38
+ # @return [Response] the response to sending this e-mail
39
+ def send_email(options = {})
40
+ package = {}
41
+
42
+ package['Source'] = options[:source] || options[:from]
43
+
44
+ add_array_to_hash!(package, 'Destination.ToAddresses', options[:to]) if options[:to]
45
+ add_array_to_hash!(package, 'Destination.CcAddresses', options[:cc]) if options[:cc]
46
+ add_array_to_hash!(package, 'Destination.BccAddresses', options[:bcc]) if options[:bcc]
47
+
48
+ package['Message.Subject.Data'] = options[:subject]
49
+
50
+ package['Message.Body.Html.Data'] = options[:html_body] if options[:html_body]
51
+ package['Message.Body.Text.Data'] = options[:text_body] || options[:body] if options[:text_body] || options[:body]
52
+
53
+ package['ReturnPath'] = options[:return_path] if options[:return_path]
54
+
55
+ request('SendEmail', package)
56
+ end
57
+
58
+ private
59
+
60
+ # Adds all elements of the ary with the appropriate member elements
61
+ def add_array_to_hash!(hash, key, ary)
62
+ cnt = 1
63
+ [*ary].each do |o|
64
+ hash["#{key}.member.#{cnt}"] = o
65
+ cnt += 1
66
+ end
67
+ end
68
+ end
69
+
70
+ class SendEmailResponse < AWS::SES::Response
71
+
72
+ end
73
+ end
74
+ end
@@ -2,7 +2,7 @@ module AWS
2
2
  module SES
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = '0'
5
- MINOR = '1'
5
+ MINOR = '2'
6
6
  TINY = '0'
7
7
  BETA = Time.now.to_i.to_s
8
8
  end
data/test/helper.rb CHANGED
@@ -8,7 +8,7 @@ rescue Bundler::BundlerError => e
8
8
  exit e.status_code
9
9
  end
10
10
  require 'test/unit'
11
- require 'shoulda'
11
+ require 'shoulda-context'
12
12
 
13
13
  begin
14
14
  require 'ruby-debug'
@@ -26,10 +26,12 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
26
26
  require 'aws/ses'
27
27
 
28
28
  class Test::Unit::TestCase
29
+ require 'net/http'
30
+ require 'net/https'
31
+
29
32
  include AWS::SES
30
33
 
31
- def mock_connection_for(instance, klass, options = {})
32
- data = options[:returns]
34
+ def mock_connection(object, data = {})
33
35
  return_values = case data
34
36
  when Hash
35
37
  FakeResponse.new(data)
@@ -39,10 +41,16 @@ class Test::Unit::TestCase
39
41
  abort "Response data for mock connection must be a Hash or an Array. Was #{data.inspect}."
40
42
  end
41
43
 
42
- connection = flexmock('Mock connection') do |mock|
44
+ connection = flexmock(Net::HTTP.new) do |mock|
43
45
  mock.should_receive(:request).and_return(*return_values).at_least.once
44
46
  end
45
47
 
46
- instance.should_receive(:connection).and_return(connection)
48
+ mock = flexmock(object)
49
+ mock.should_receive(:connection).and_return(connection)
50
+ mock
51
+ end
52
+
53
+ def generate_base
54
+ Base.new(:access_key_id=>'123', :secret_access_key=>'abc')
47
55
  end
48
56
  end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class SendEmailTest < Test::Unit::TestCase
4
+ context "when sending email" do
5
+ setup do
6
+ @base = generate_base
7
+ end
8
+
9
+ context "adding to a hash" do
10
+ should 'add array elements to the hash' do
11
+ hash = {}
12
+ ary = ['x', 'y']
13
+ @base.send(:add_array_to_hash!, hash, 'SomeKey', ary)
14
+ expected = {'SomeKey.member.1' => 'x', 'SomeKey.member.2' => 'y'}
15
+ assert_equal expected, hash
16
+ end
17
+
18
+ should 'add singular elements to the hash' do
19
+ hash = {}
20
+ ary = 'z'
21
+ @base.send(:add_array_to_hash!, hash, 'SomeKey', ary)
22
+ expected = {'SomeKey.member.1' => 'z'}
23
+ assert_equal expected, hash
24
+ end
25
+ end
26
+
27
+ # should "send an e-mail" do
28
+ # mock_connection(@base)
29
+ #
30
+ # result = @base.send_email :from => 'jon@example.com',
31
+ # :to => 'dave@example.com',
32
+ # :subject => 'Subject1',
33
+ # :text_body => 'Body1'
34
+ # assert result.success?
35
+ # end
36
+ end
37
+ 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: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Drew Blas
@@ -63,7 +63,7 @@ dependencies:
63
63
  requirement: *id003
64
64
  - !ruby/object:Gem::Dependency
65
65
  prerelease: false
66
- name: shoulda
66
+ name: shoulda-context
67
67
  type: :development
68
68
  version_requirements: &id004 !ruby/object:Gem::Requirement
69
69
  none: false
@@ -201,12 +201,15 @@ files:
201
201
  - Rakefile
202
202
  - TODO
203
203
  - VERSION
204
+ - aws-ses.gemspec
204
205
  - lib/aws/ses.rb
205
206
  - lib/aws/ses/addresses.rb
206
207
  - lib/aws/ses/base.rb
207
208
  - lib/aws/ses/exceptions.rb
208
209
  - lib/aws/ses/extensions.rb
210
+ - lib/aws/ses/info.rb
209
211
  - lib/aws/ses/response.rb
212
+ - lib/aws/ses/send_email.rb
210
213
  - lib/aws/ses/version.rb
211
214
  - test/base_test.rb
212
215
  - test/extensions_test.rb
@@ -214,6 +217,7 @@ files:
214
217
  - test/helper.rb
215
218
  - test/mocks/fake_response.rb
216
219
  - test/response_test.rb
220
+ - test/send_email_test.rb
217
221
  has_rdoc: true
218
222
  homepage: http://github.com/drewblas/aws-ses
219
223
  licenses:
@@ -255,3 +259,4 @@ test_files:
255
259
  - test/helper.rb
256
260
  - test/mocks/fake_response.rb
257
261
  - test/response_test.rb
262
+ - test/send_email_test.rb