sendgrid_toolkit 1.1.0 → 1.1.1

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/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 `:send_email` (chosen to avoid conflicts with Object:send) with the standard parameters:
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).send_email :to => "user@domain.com", :from => "recipient@domain.com", :subject => "Some Subject", :text => "Some text"
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).send_email :to => "user@domain.com", :from => "recipient@domain.com", :subject => "Some Subject", :text => "Some text", "x-smtpapi" => {:category => "Retention"}
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.0
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 = (api_user.nil?) ? ENV['SMTP_USERNAME'] : api_user
6
- @api_key = (api_key.nil?) ? ENV['SMTP_PASSWORD'] : 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
@@ -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
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sendgrid_toolkit"
8
- s.version = "1.1.0"
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 = "2011-11-01"
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.0
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: 2011-11-01 00:00:00.000000000Z
12
+ date: 2012-02-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70223621474660 !ruby/object:Gem::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: *70223621474660
24
+ version_requirements: *70179196616160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70223621472980 !ruby/object:Gem::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: *70223621472980
35
+ version_requirements: *70179196615120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fakeweb
38
- requirement: &70223621461680 !ruby/object:Gem::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: *70223621461680
46
+ version_requirements: *70179196614160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70223621460080 !ruby/object:Gem::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: *70223621460080
57
+ version_requirements: *70179196613020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70223621457860 !ruby/object:Gem::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: *70223621457860
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: -3253025820181550713
122
+ hash: 4463895063541210779
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  none: false
125
125
  requirements: