sendgrid_toolkit 1.0.7 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/VERSION +1 -1
- data/lib/sendgrid_toolkit.rb +1 -0
- data/lib/sendgrid_toolkit/mail.rb +9 -0
- data/lib/sendgrid_toolkit/sendgrid_error.rb +1 -0
- data/sendgrid_toolkit.gemspec +3 -1
- data/spec/lib/sendgrid_toolkit/mail_spec.rb +17 -0
- metadata +14 -12
data/README.md
CHANGED
@@ -10,6 +10,7 @@ SendgridToolkit provides a class for interacting with each of the following Send
|
|
10
10
|
|
11
11
|
- Bounces
|
12
12
|
- InvalidEmails
|
13
|
+
- Mail
|
13
14
|
- SpamReports
|
14
15
|
- Statistics
|
15
16
|
- Unsubscribes
|
@@ -108,6 +109,21 @@ If you believe a once-invalid email address is now valid and would like Sendgrid
|
|
108
109
|
|
109
110
|
invalid_emails.delete :email => "email@address.of.invalid.to.delete"
|
110
111
|
|
112
|
+
Mail Module
|
113
|
+
-----------
|
114
|
+
|
115
|
+
The Mail module lets you send email via the web API.
|
116
|
+
|
117
|
+
- - -
|
118
|
+
|
119
|
+
Call `:send_email` (chosen to avoid conflicts with Object:send) with the standard parameters:
|
120
|
+
|
121
|
+
SendgridToolkit::Mail.new(api_user, api_key).send_email :to => "user@domain.com", :from => "recipient@domain.com", :subject => "Some Subject", :text => "Some text"
|
122
|
+
|
123
|
+
The complete set of "x-smtpapi" options are also supported. You can use them like:
|
124
|
+
|
125
|
+
SendgridToolkit::Mail.new(api_user, api_key).send_email :to => "user@domain.com", :from => "recipient@domain.com", :subject => "Some Subject", :text => "Some text", "x-smtpapi" => {:category => "Retention"}
|
126
|
+
|
111
127
|
SpamReports Module
|
112
128
|
------------------
|
113
129
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/sendgrid_toolkit.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
module SendgridToolkit
|
2
|
+
class Mail < AbstractSendgridClient
|
3
|
+
def send_mail(options = {})
|
4
|
+
response = api_post('mail', 'send', options)
|
5
|
+
raise(SendEmailError, "SendMail API refused to send email: #{response["errors"].inspect}") if response["message"] == "error"
|
6
|
+
response
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -4,6 +4,7 @@ module SendgridToolkit
|
|
4
4
|
class NoAPIUserSpecified < StandardError; end
|
5
5
|
class UnsubscribeEmailAlreadyExists < StandardError; end
|
6
6
|
class UnsubscribeEmailDoesNotExist < StandardError; end
|
7
|
+
class SendEmailError < StandardError; end
|
7
8
|
class EmailDoesNotExist < StandardError; end
|
8
9
|
class SendgridServerError < StandardError; end
|
9
10
|
class APIError < StandardError; end
|
data/sendgrid_toolkit.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "sendgrid_toolkit"
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Robby Grossman"]
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/sendgrid_toolkit/bounces.rb",
|
30
30
|
"lib/sendgrid_toolkit/common.rb",
|
31
31
|
"lib/sendgrid_toolkit/invalid_emails.rb",
|
32
|
+
"lib/sendgrid_toolkit/mail.rb",
|
32
33
|
"lib/sendgrid_toolkit/sendgrid_error.rb",
|
33
34
|
"lib/sendgrid_toolkit/spam_reports.rb",
|
34
35
|
"lib/sendgrid_toolkit/statistics.rb",
|
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
|
|
39
40
|
"spec/lib/sendgrid_toolkit/bounces_spec.rb",
|
40
41
|
"spec/lib/sendgrid_toolkit/common_spec.rb",
|
41
42
|
"spec/lib/sendgrid_toolkit/invalid_emails_spec.rb",
|
43
|
+
"spec/lib/sendgrid_toolkit/mail_spec.rb",
|
42
44
|
"spec/lib/sendgrid_toolkit/spam_reports_spec.rb",
|
43
45
|
"spec/lib/sendgrid_toolkit/statistics_spec.rb",
|
44
46
|
"spec/lib/sendgrid_toolkit/unsubscribes_spec.rb",
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../helper")
|
2
|
+
|
3
|
+
describe SendgridToolkit::Mail do
|
4
|
+
before do
|
5
|
+
FakeWeb.clean_registry
|
6
|
+
@obj = SendgridToolkit::Mail.new("fakeuser", "fakepass")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#send" do
|
10
|
+
it "raises error when sendgrid returns an error" do
|
11
|
+
FakeWeb.register_uri(:post, %r|https://sendgrid\.com/api/mail\.send\.json\?|, :body => '{"message": "error", "errors": ["Missing destination email"]}')
|
12
|
+
lambda {
|
13
|
+
response = @obj.send_mail :from => "testing@fiverr.com", :subject => "Subject", :text => "Text", "x-smtpapi" => {:category => "Testing", :to => ["elad@fiverr.com"]}
|
14
|
+
}.should raise_error SendgridToolkit::SendEmailError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-01 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70223621474660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.7.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70223621474660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70223621472980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70223621472980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakeweb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70223621461680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.3.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70223621461680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70223621460080 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70223621460080
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70223621457860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 2.7.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70223621457860
|
69
69
|
description: A Ruby wrapper and utility library for communicating with the Sendgrid
|
70
70
|
API.
|
71
71
|
email: robby@freerobby.com
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/sendgrid_toolkit/bounces.rb
|
88
88
|
- lib/sendgrid_toolkit/common.rb
|
89
89
|
- lib/sendgrid_toolkit/invalid_emails.rb
|
90
|
+
- lib/sendgrid_toolkit/mail.rb
|
90
91
|
- lib/sendgrid_toolkit/sendgrid_error.rb
|
91
92
|
- lib/sendgrid_toolkit/spam_reports.rb
|
92
93
|
- lib/sendgrid_toolkit/statistics.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- spec/lib/sendgrid_toolkit/bounces_spec.rb
|
98
99
|
- spec/lib/sendgrid_toolkit/common_spec.rb
|
99
100
|
- spec/lib/sendgrid_toolkit/invalid_emails_spec.rb
|
101
|
+
- spec/lib/sendgrid_toolkit/mail_spec.rb
|
100
102
|
- spec/lib/sendgrid_toolkit/spam_reports_spec.rb
|
101
103
|
- spec/lib/sendgrid_toolkit/statistics_spec.rb
|
102
104
|
- spec/lib/sendgrid_toolkit/unsubscribes_spec.rb
|
@@ -117,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
119
|
version: '0'
|
118
120
|
segments:
|
119
121
|
- 0
|
120
|
-
hash: -
|
122
|
+
hash: -3253025820181550713
|
121
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
124
|
none: false
|
123
125
|
requirements:
|