amazon_ses 0.2.0 → 1.0.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 1.0.0
data/amazon_ses.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{amazon_ses}
8
- s.version = "0.2.0"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jeff durand"]
12
- s.date = %q{2011-02-19}
12
+ s.date = %q{2011-02-20}
13
13
  s.description = %q{wrapper for the simple email service api}
14
14
  s.email = %q{jeff.durand@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -3,11 +3,20 @@ module AmazonSES
3
3
  class AmzMail
4
4
 
5
5
  def self.send(source,to_addresses,subject,body,secret,key)
6
- AmazonSES::Base.make_request({"Action"=>"SendEmail",
6
+ if AmazonSES::StatObject.new(secret,key).reached_quota?
7
+ raise "Sorry you have reached your quota."
8
+ else
9
+ begin
10
+ AmazonSES::Base.make_request({"Action"=>"SendEmail",
7
11
  "Source"=>source,
8
12
  "Destination.ToAddresses.member.1"=>to_addresses,
9
13
  "Message.Subject.Data"=>subject,
10
14
  "Message.Body.Text.Data"=>body},secret,key)
15
+ rescue Exception=>e
16
+ #puts "Error in AmazonSES::AmzMail.send"+e.to_s
17
+ raise e.to_s
18
+ end
19
+ end
11
20
  end
12
21
  # This will construct and send a raw email message will send unless
13
22
  # quota is reached. If quota is reached it will raise an exception.
@@ -16,18 +25,32 @@ module AmazonSES
16
25
  if AmazonSES::StatObject.new(secret,key).reached_quota?
17
26
  raise "Sorry you have reached your quota."
18
27
  else
19
- mail = Mail.new do
20
- to to_addresses
21
- from source
22
- subject subject_txt
23
- html_part do
24
- content_type 'text/html; charset=UTF-8'
25
- body body_txt
28
+ begin
29
+ mail = Mail.new do
30
+ to to_addresses
31
+ from source
32
+ subject subject_txt
33
+ html_part do
34
+ content_type 'text/html; charset=UTF-8'
35
+ body body_txt
36
+ end
26
37
  end
38
+ str=mail.to_s.gsub("multipart/alternative","multipart/mixed")
39
+ encoded = Base64.encode64(str)
40
+ AmazonSES::Base.make_request({"Action"=>"SendRawEmail", "RawMessage.Data"=>encoded},secret,key)
41
+ rescue Exception=>e
42
+ #puts "Errror in AmazonSES:AmzMail.send_html "+e.to_s
43
+ raise e.to_s
27
44
  end
28
- str=mail.to_s.gsub("multipart/alternative","multipart/mixed")
29
- encoded = Base64.encode64(str)
45
+ end
46
+ end
47
+ # will take a raw mail string encode it an send it.
48
+ def self.send_raw(mail_string,secret,key)
49
+ begin
50
+ encoded = Base64.encode64(mail_string)
30
51
  AmazonSES::Base.make_request({"Action"=>"SendRawEmail", "RawMessage.Data"=>encoded},secret,key)
52
+ rescue Exception=>e
53
+ raise e.to_s
31
54
  end
32
55
  end
33
56
  end
@@ -19,7 +19,13 @@ module AmazonSES
19
19
  request.add_field("Date",date)
20
20
  request.add_field("X-Amzn-Authorization",AmazonSES::Base.sign_https_request(request,date,secret,key))
21
21
  response = http.request(request)
22
- return response
22
+ case response
23
+ when Net::HTTPSuccess then return response
24
+ when Net::HTTPClientError then raise response.body
25
+ when Net::HTTPServerError then raise response.body
26
+ else raise response.body
27
+ end
28
+ #return response
23
29
  end
24
30
 
25
31
  end
@@ -2,10 +2,18 @@ module AmazonSES
2
2
 
3
3
  class Stats
4
4
  def self.send_quota(secret,key)
5
- AmazonSES::Base.make_request({"Action"=>"GetSendQuota"},secret,key)
5
+ begin
6
+ AmazonSES::Base.make_request({"Action"=>"GetSendQuota"},secret,key)
7
+ rescue Exception=>e
8
+ raise e.to_s
9
+ end
6
10
  end
7
11
  def self.send_stats(secret,key)
8
- AmazonSES::Base.make_request({"Action"=>"GetSendStatistics"},secret,key)
12
+ begin
13
+ AmazonSES::Base.make_request({"Action"=>"GetSendStatistics"},secret,key)
14
+ rescue Exception=>e
15
+ raise e.to_s
16
+ end
9
17
  end
10
18
  end
11
19
  class StatObject
@@ -3,7 +3,25 @@ module AmazonSES
3
3
  class Verify
4
4
  # returns the response object
5
5
  def self.address(emailaddress,secret,key)
6
- AmazonSES::Base.make_request({"Action"=>"VerifyEmailAddress","EmailAddress"=>emailaddress},secret,key)
6
+ begin
7
+ AmazonSES::Base.make_request({"Action"=>"VerifyEmailAddress","EmailAddress"=>emailaddress},secret,key)
8
+ rescue Exception=>e
9
+ raise e.to_s
10
+ end
11
+ end
12
+ def self.list(secret,key)
13
+ begin
14
+ AmazonSES::Base.make_request({"Action"=>"ListVerifiedEmailAddresses"},secret,key)
15
+ rescue Exception =>e
16
+ raise e.to_s
17
+ end
18
+ end
19
+ def self.address_remove(email,secret,key)
20
+ begin
21
+ AmazonSES::Base.make_request({"Action"=>"DeleteVerifiedEmailAddress","Emailaddress"=>email},secret,key)
22
+ rescue Exception=>e
23
+ raise e.to_s
24
+ end
7
25
  end
8
26
 
9
27
  end
@@ -5,21 +5,8 @@ class TestAmazonSes < Test::Unit::TestCase
5
5
  setup do
6
6
  YAML.load_file("./test/credentials.yml").each { |key,value| instance_variable_set("@#{key}", value) }
7
7
  end
8
- #should "Be able to verify address" do
9
- # resp = AmazonSES::Verify.address("admin@flickaday.com",@aws_secret,@aws_key)
10
- #end
11
- #should "Get some stats" do
12
- # resp = AmazonSES::Stats.send_quota(@aws_secret,@aws_key)
13
- # puts resp.body
14
- #end
15
- #should "Send an email" do
16
- # resp = AmazonSES::AmzMail.send_html("admin@flickaday.com","admin@flickaday.com","hey how are you doing","<h1>Just wanted</h1><p> to send you a quick message.</p>",@aws_secret,@aws_key)
17
- # puts resp.body
18
- #end
19
- #should ""
20
- should "not be at quota" do
21
- statobj = AmazonSES::StatObject.new(@aws_secret,@aws_key)
22
- assert !statobj.reached_quota?
8
+ should "list verified addresses" do
9
+ puts AmazonSES::Verify.list(@aws_secret,@aws_key).body
23
10
  end
24
11
  end
25
12
  end
metadata CHANGED
@@ -3,10 +3,10 @@ name: amazon_ses
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
+ - 1
6
7
  - 0
7
- - 2
8
8
  - 0
9
- version: 0.2.0
9
+ version: 1.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - jeff durand
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-19 00:00:00 -05:00
17
+ date: 2011-02-20 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency