sendgrid_toolkit 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -3
- data/VERSION +1 -1
- data/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +2 -2
- data/lib/sendgrid_toolkit.rb +9 -0
- data/sendgrid_toolkit.gemspec +2 -2
- data/spec/lib/sendgrid_toolkit/abstract_sendgrid_client_spec.rb +15 -0
- metadata +13 -13
data/README.md
CHANGED
@@ -37,6 +37,18 @@ Contributing
|
|
37
37
|
|
38
38
|
Big thanks to [James Brennan][1] for refactoring old code and writing the Bounces, InvalidEmails and SpamReports modules.
|
39
39
|
|
40
|
+
Setting your API credentials globally
|
41
|
+
-------------------------------------
|
42
|
+
|
43
|
+
Setting your API user and key once globally for all API access:
|
44
|
+
|
45
|
+
SendgridToolkit.api_user = "bob"
|
46
|
+
SendgridToolkit.api_key = "x123y"
|
47
|
+
|
48
|
+
If you do this when you create individual API objects you will not need to pass the `api_user` or `api_key`
|
49
|
+
|
50
|
+
bounces = SendgridToolkit::Bounces.new
|
51
|
+
|
40
52
|
Bounces Module
|
41
53
|
--------------
|
42
54
|
The bounces module provides access to all of your bounces.
|
@@ -116,13 +128,13 @@ The Mail module lets you send email via the web API.
|
|
116
128
|
|
117
129
|
- - -
|
118
130
|
|
119
|
-
Call `:
|
131
|
+
Call `:send_mail` (chosen to avoid conflicts with Object:send) with the standard parameters:
|
120
132
|
|
121
|
-
SendgridToolkit::Mail.new(api_user, api_key).
|
133
|
+
SendgridToolkit::Mail.new(api_user, api_key).send_mail :to => "user@domain.com", :from => "recipient@domain.com", :subject => "Some Subject", :text => "Some text"
|
122
134
|
|
123
135
|
The complete set of "x-smtpapi" options are also supported. You can use them like:
|
124
136
|
|
125
|
-
SendgridToolkit::Mail.new(api_user, api_key).
|
137
|
+
SendgridToolkit::Mail.new(api_user, api_key).send_mail :to => "user@domain.com", :from => "recipient@domain.com", :subject => "Some Subject", :text => "Some text", "x-smtpapi" => {:category => "Retention"}
|
126
138
|
|
127
139
|
SpamReports Module
|
128
140
|
------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
@@ -2,8 +2,8 @@ module SendgridToolkit
|
|
2
2
|
class AbstractSendgridClient
|
3
3
|
|
4
4
|
def initialize(api_user = nil, api_key = nil)
|
5
|
-
@api_user =
|
6
|
-
@api_key =
|
5
|
+
@api_user = api_user || SendgridToolkit.api_user || ENV['SMTP_USERNAME']
|
6
|
+
@api_key = api_key || SendgridToolkit.api_key || ENV['SMTP_PASSWORD']
|
7
7
|
|
8
8
|
raise SendgridToolkit::NoAPIUserSpecified if @api_user.nil? || @api_user.length == 0
|
9
9
|
raise SendgridToolkit::NoAPIKeySpecified if @api_key.nil? || @api_key.length == 0
|
data/lib/sendgrid_toolkit.rb
CHANGED
@@ -12,4 +12,13 @@ require 'sendgrid_toolkit/mail'
|
|
12
12
|
|
13
13
|
module SendgridToolkit
|
14
14
|
BASE_URI = "sendgrid.com/api"
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def api_user=(v); @api_user = v; end
|
18
|
+
def api_user; @api_user; end
|
19
|
+
|
20
|
+
def api_key=(v); @api_key = v; end
|
21
|
+
def api_key; @api_key; end
|
22
|
+
end
|
23
|
+
|
15
24
|
end
|
data/sendgrid_toolkit.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "sendgrid_toolkit"
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.1"
|
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"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2012-02-16"
|
13
13
|
s.description = "A Ruby wrapper and utility library for communicating with the Sendgrid API."
|
14
14
|
s.email = "robby@freerobby.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,6 +33,10 @@ describe SendgridToolkit::AbstractSendgridClient do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "#initialize" do
|
36
|
+
after(:each) do
|
37
|
+
SendgridToolkit.api_user = nil
|
38
|
+
SendgridToolkit.api_key = nil
|
39
|
+
end
|
36
40
|
it "stores api credentials when passed in" do
|
37
41
|
ENV['SMTP_USERNAME'] = "env_username"
|
38
42
|
ENV['SMTP_PASSWORD'] = "env_apikey"
|
@@ -41,6 +45,17 @@ describe SendgridToolkit::AbstractSendgridClient do
|
|
41
45
|
@obj.instance_variable_get("@api_user").should == "username"
|
42
46
|
@obj.instance_variable_get("@api_key").should == "apikey"
|
43
47
|
end
|
48
|
+
it "uses module level user and key if they are set" do
|
49
|
+
SendgridToolkit.api_user = "username"
|
50
|
+
SendgridToolkit.api_key = "apikey"
|
51
|
+
|
52
|
+
SendgridToolkit.api_key.should == "apikey"
|
53
|
+
SendgridToolkit.api_user.should == "username"
|
54
|
+
|
55
|
+
@obj = SendgridToolkit::AbstractSendgridClient.new
|
56
|
+
@obj.instance_variable_get("@api_user").should == "username"
|
57
|
+
@obj.instance_variable_get("@api_key").should == "apikey"
|
58
|
+
end
|
44
59
|
it "resorts to environment variables when no credentials specified" do
|
45
60
|
ENV['SMTP_USERNAME'] = "env_username"
|
46
61
|
ENV['SMTP_PASSWORD'] = "env_apikey"
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70179196616160 !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: *70179196616160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70179196615120 !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: *70179196615120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakeweb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70179196614160 !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: *70179196614160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70179196613020 !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: *70179196613020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70179196612180 !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: *70179196612180
|
69
69
|
description: A Ruby wrapper and utility library for communicating with the Sendgrid
|
70
70
|
API.
|
71
71
|
email: robby@freerobby.com
|
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: 4463895063541210779
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
none: false
|
125
125
|
requirements:
|