sendgrid_toolkit 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +43 -10
- data/README.md +108 -3
- data/Rakefile +6 -1
- data/VERSION +1 -1
- data/lib/sendgrid_toolkit.rb +5 -1
- data/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +8 -1
- data/lib/sendgrid_toolkit/newsletter/list_emails.rb +34 -0
- data/lib/sendgrid_toolkit/newsletter/lists.rb +20 -0
- data/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client.rb +10 -0
- data/sendgrid_toolkit.gemspec +12 -10
- data/spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb +24 -0
- data/spec/webconnect/sendgrid_toolkit_spec.rb +8 -7
- metadata +26 -44
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGYyNTgzNTkxZWQ5MDFjMDZmZTdjZWZhOWU4ZjE2NzVlNTVkZjJiYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmQ5YjIyNDFiNWJhNzRhNmUyNmU2YmI0NmUyYWNlMDg0NWJhYzBhNA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzRjMDM4YmU0ZDQ1YjZhYzEyYTI5ZGIyZGM3NzNmYzVlMjg2NGNiMmRlNDdl
|
10
|
+
NzFjZWE0ZWMyNTI5NTgxZjIwMTIwNTgxNmVhNWM2MzczMTdlZDM0YmQ2ODVk
|
11
|
+
OWIwMTY4YzQwYTMzNDU1MjQ4YjFiMWQwNzgwYTM4ZjdkYTk5OWI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTNlYzY2NmFjOGY0ZWFiNjNjNDY2MjJkZGI4ZGQ2MjY3NjEzMzcyNTY1Zjdj
|
14
|
+
NWU1NWJiMmIxNjY4N2FmOWQ3MWQyY2ZiNDFlNWRjYWI0YTBhMWFmYjVlNjJi
|
15
|
+
NDAwNjVkMzhjN2E4MTJjZDhkYzMxNzUzNTkzOWY5MjgzNzMxZDY=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,53 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.3.5)
|
5
|
+
builder (3.2.2)
|
4
6
|
diff-lcs (1.1.3)
|
5
7
|
fakeweb (1.3.0)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
faraday (0.8.8)
|
9
|
+
multipart-post (~> 1.2.0)
|
10
|
+
git (1.2.6)
|
11
|
+
github_api (0.10.1)
|
12
|
+
addressable
|
13
|
+
faraday (~> 0.8.1)
|
14
|
+
hashie (>= 1.2)
|
15
|
+
multi_json (~> 1.4)
|
16
|
+
nokogiri (~> 1.5.2)
|
17
|
+
oauth2
|
18
|
+
hashie (2.0.5)
|
19
|
+
highline (1.6.20)
|
20
|
+
httparty (0.12.0)
|
21
|
+
json (~> 1.8)
|
22
|
+
multi_xml (>= 0.5.2)
|
23
|
+
httpauth (0.2.0)
|
24
|
+
jeweler (1.8.8)
|
25
|
+
builder
|
11
26
|
bundler (~> 1.0)
|
12
27
|
git (>= 1.2.5)
|
28
|
+
github_api (= 0.10.1)
|
29
|
+
highline (>= 1.6.15)
|
30
|
+
nokogiri (= 1.5.10)
|
13
31
|
rake
|
14
|
-
|
15
|
-
|
16
|
-
|
32
|
+
rdoc
|
33
|
+
json (1.8.1)
|
34
|
+
jwt (0.1.8)
|
35
|
+
multi_json (>= 1.5)
|
36
|
+
multi_json (1.8.2)
|
37
|
+
multi_xml (0.5.5)
|
38
|
+
multipart-post (1.2.0)
|
39
|
+
nokogiri (1.5.10)
|
40
|
+
oauth2 (0.9.2)
|
41
|
+
faraday (~> 0.8)
|
42
|
+
httpauth (~> 0.2)
|
43
|
+
jwt (~> 0.1.4)
|
44
|
+
multi_json (~> 1.0)
|
45
|
+
multi_xml (~> 0.5)
|
46
|
+
rack (~> 1.2)
|
47
|
+
rack (1.5.2)
|
48
|
+
rake (10.1.0)
|
49
|
+
rdoc (4.0.1)
|
50
|
+
json (~> 1.4)
|
17
51
|
rspec (2.7.0)
|
18
52
|
rspec-core (~> 2.7.0)
|
19
53
|
rspec-expectations (~> 2.7.0)
|
@@ -27,8 +61,7 @@ PLATFORMS
|
|
27
61
|
ruby
|
28
62
|
|
29
63
|
DEPENDENCIES
|
30
|
-
bundler (~> 1.0.0)
|
31
64
|
fakeweb (~> 1.3.0)
|
32
65
|
httparty (>= 0.7.6)
|
33
|
-
jeweler
|
66
|
+
jeweler
|
34
67
|
rspec (~> 2.7.0)
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
SendgridToolkit
|
2
2
|
===============
|
3
3
|
|
4
|
+
[![Build Status](https://secure.travis-ci.org/freerobby/sendgrid_toolkit.png)](http://travis-ci.org/freerobby/sendgrid_toolkit)
|
5
|
+
|
4
6
|
SendgridToolkit is a Ruby wrapper for the Sendgrid Web API
|
5
7
|
|
6
8
|
Supported Modules
|
@@ -10,6 +12,8 @@ SendgridToolkit provides a class for interacting with each of the following Send
|
|
10
12
|
|
11
13
|
- Bounces
|
12
14
|
- InvalidEmails
|
15
|
+
- Lists
|
16
|
+
- ListEmails
|
13
17
|
- Mail
|
14
18
|
- SpamReports
|
15
19
|
- Statistics
|
@@ -37,6 +41,17 @@ Contributing
|
|
37
41
|
|
38
42
|
Big thanks to [James Brennan][1] for refactoring old code and writing the Bounces, InvalidEmails and SpamReports modules.
|
39
43
|
|
44
|
+
Install
|
45
|
+
-----------------
|
46
|
+
|
47
|
+
Via rubygems.org:
|
48
|
+
|
49
|
+
$ gem install sendgrid_toolkit
|
50
|
+
|
51
|
+
Or add it to your `Gemfile`
|
52
|
+
|
53
|
+
gem 'sendgrid_toolkit', '>= 1.1.1'
|
54
|
+
|
40
55
|
Setting your API credentials globally
|
41
56
|
-------------------------------------
|
42
57
|
|
@@ -44,7 +59,7 @@ Setting your API user and key once globally for all API access:
|
|
44
59
|
|
45
60
|
SendgridToolkit.api_user = "bob"
|
46
61
|
SendgridToolkit.api_key = "x123y"
|
47
|
-
|
62
|
+
|
48
63
|
If you do this when you create individual API objects you will not need to pass the `api_user` or `api_key`
|
49
64
|
|
50
65
|
bounces = SendgridToolkit::Bounces.new
|
@@ -121,6 +136,96 @@ If you believe a once-invalid email address is now valid and would like Sendgrid
|
|
121
136
|
|
122
137
|
invalid_emails.delete :email => "email@address.of.invalid.to.delete"
|
123
138
|
|
139
|
+
Lists Module
|
140
|
+
------------
|
141
|
+
|
142
|
+
The Lists module lets you manage your recipient lists associated with the marketing email feature via the marketing emails API.
|
143
|
+
|
144
|
+
- - -
|
145
|
+
|
146
|
+
Instantiate the Lists object:
|
147
|
+
|
148
|
+
lists_obj = SendgridToolkit::Lists.new(api_user, api_key)
|
149
|
+
|
150
|
+
- - -
|
151
|
+
|
152
|
+
Retrieve lists:
|
153
|
+
|
154
|
+
lists = lists_obj.get
|
155
|
+
|
156
|
+
`lists` will be an array of hashes, each of which contains a `list` key, which contain the name of the lists.
|
157
|
+
|
158
|
+
- - -
|
159
|
+
|
160
|
+
Create list:
|
161
|
+
|
162
|
+
response = lists_obj.add :list => 'new_list_name'
|
163
|
+
|
164
|
+
`response` will be a hash containing a `message` key, which contains either `success` or `error`. If it is error, it will additionally contain the `errors` key, which contains an array of error messages.
|
165
|
+
|
166
|
+
When creating a list you can also specify a custom column name for the `name` associated with email addresses.
|
167
|
+
|
168
|
+
Example:
|
169
|
+
|
170
|
+
response = lists_obj.add :list => 'new_list_name', :name => 'customer_name'
|
171
|
+
|
172
|
+
|
173
|
+
- - -
|
174
|
+
|
175
|
+
Edit list:
|
176
|
+
|
177
|
+
response = lists_obj.edit :list => 'some_old_name', :new_list => 'some_new_name'
|
178
|
+
|
179
|
+
`response` will be a hash containing a `message` key, which contains either `success` or `error`. If it is error, it will additionally contain the `errors` key, which contains an array of error messages.
|
180
|
+
|
181
|
+
- - -
|
182
|
+
|
183
|
+
Delete list:
|
184
|
+
|
185
|
+
response = lists_obj.delete :list => 'some_list_name'
|
186
|
+
|
187
|
+
`response` will be a hash containing a `message` key, which contains either `success` or `error`. If it is error, it will additionally contain the `errors` key, which contains an array of error messages.
|
188
|
+
|
189
|
+
|
190
|
+
ListEmails Module
|
191
|
+
-----------------
|
192
|
+
|
193
|
+
The ListEmails module lets you manage your emails in your recipient lists associated with the marketing email feature via the marketing emails API.
|
194
|
+
|
195
|
+
- - -
|
196
|
+
|
197
|
+
Instantiate the ListEmails object:
|
198
|
+
|
199
|
+
list_emails_obj = SendgridToolkit::ListEmails.new(api_user, api_key)
|
200
|
+
|
201
|
+
- - -
|
202
|
+
|
203
|
+
Get emails:
|
204
|
+
|
205
|
+
list_emails = list_emails_obj.get :list => 'some_list_name'
|
206
|
+
|
207
|
+
`list_emails` will be an array of hashes, each of which contains the following keys:
|
208
|
+
|
209
|
+
- `email`: The email address of the recipient
|
210
|
+
- `name`: The name of the recipient. This key may be different if you changed the column name
|
211
|
+
|
212
|
+
- - -
|
213
|
+
|
214
|
+
Add email:
|
215
|
+
|
216
|
+
response = list_emails_obj.add :list => 'some_list_name', :data => { :email => 'some_new_email@example.com', :name => 'some_new_person'}
|
217
|
+
|
218
|
+
`response` will be a hash containing a `inserted` key, which contains the number of emails inserted into the list.
|
219
|
+
|
220
|
+
- - -
|
221
|
+
|
222
|
+
Remove email:
|
223
|
+
|
224
|
+
response = list_emails_obj.delete :list => 'some_list_name', :email => 'some_email@example.com'
|
225
|
+
|
226
|
+
`response` will be a hash containing a `removed` key, which contains the number of emails removed from the list.
|
227
|
+
|
228
|
+
|
124
229
|
Mail Module
|
125
230
|
-----------
|
126
231
|
|
@@ -134,7 +239,7 @@ Call `:send_mail` (chosen to avoid conflicts with Object:send) with the standard
|
|
134
239
|
|
135
240
|
The complete set of "x-smtpapi" options are also supported. You can use them like:
|
136
241
|
|
137
|
-
|
242
|
+
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"}
|
138
243
|
|
139
244
|
SpamReports Module
|
140
245
|
------------------
|
@@ -309,4 +414,4 @@ In addition to unit tests, SendgridToolkit comes with a limited suite of "webcon
|
|
309
414
|
Running "spec spec" out of the box will run the standard suite of tests (all network access is stubbed out).
|
310
415
|
|
311
416
|
[1]: http://github.com/jamesBrennan
|
312
|
-
[2]: http://wiki.sendgrid.com/doku.php?id=web_api
|
417
|
+
[2]: http://wiki.sendgrid.com/doku.php?id=web_api
|
data/Rakefile
CHANGED
@@ -7,9 +7,10 @@ rescue Bundler::BundlerError => e
|
|
7
7
|
$stderr.puts "Run `bundle install` to install missing gems"
|
8
8
|
exit e.status_code
|
9
9
|
end
|
10
|
-
require 'rake'
|
11
10
|
|
11
|
+
require 'rake'
|
12
12
|
require 'jeweler'
|
13
|
+
|
13
14
|
Jeweler::Tasks.new do |gem|
|
14
15
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
16
|
gem.name = "sendgrid_toolkit"
|
@@ -22,3 +23,7 @@ Jeweler::Tasks.new do |gem|
|
|
22
23
|
# dependencies defined in Gemfile
|
23
24
|
end
|
24
25
|
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rspec/core/rake_task'
|
28
|
+
task :default => :spec
|
29
|
+
RSpec::Core::RakeTask.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/lib/sendgrid_toolkit.rb
CHANGED
@@ -11,6 +11,10 @@ require 'sendgrid_toolkit/blocks'
|
|
11
11
|
require 'sendgrid_toolkit/invalid_emails'
|
12
12
|
require 'sendgrid_toolkit/mail'
|
13
13
|
|
14
|
+
require 'sendgrid_toolkit/newsletter/newsletter_sendgrid_client'
|
15
|
+
require 'sendgrid_toolkit/newsletter/lists'
|
16
|
+
require 'sendgrid_toolkit/newsletter/list_emails'
|
17
|
+
|
14
18
|
module SendgridToolkit
|
15
19
|
BASE_URI = "sendgrid.com/api"
|
16
20
|
|
@@ -22,4 +26,4 @@ module SendgridToolkit
|
|
22
26
|
def api_key; @api_key; end
|
23
27
|
end
|
24
28
|
|
25
|
-
end
|
29
|
+
end
|
@@ -12,7 +12,10 @@ module SendgridToolkit
|
|
12
12
|
protected
|
13
13
|
|
14
14
|
def api_post(module_name, action_name, opts = {})
|
15
|
-
|
15
|
+
base_path = compose_base_path(module_name, action_name)
|
16
|
+
response = HTTParty.post("https://#{BASE_URI}/#{base_path}.json?",
|
17
|
+
:query => get_credentials.merge(opts),
|
18
|
+
:format => :json)
|
16
19
|
if response.code > 401
|
17
20
|
raise(SendgridToolkit::SendgridServerError, "The sengrid server returned an error. #{response.inspect}")
|
18
21
|
elsif has_error?(response) and
|
@@ -30,6 +33,10 @@ module SendgridToolkit
|
|
30
33
|
{:api_user => @api_user, :api_key => @api_key}
|
31
34
|
end
|
32
35
|
|
36
|
+
def compose_base_path(module_name, action_name)
|
37
|
+
"#{module_name}.#{action_name}"
|
38
|
+
end
|
39
|
+
|
33
40
|
private
|
34
41
|
def has_error?(response)
|
35
42
|
response.kind_of?(Hash) && response.has_key?('error')
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module SendgridToolkit
|
4
|
+
class ListEmails < NewsletterSendgridClient
|
5
|
+
def add(options = {})
|
6
|
+
if options[:data].kind_of?(Hash)
|
7
|
+
options[:data] = options[:data].to_json
|
8
|
+
end
|
9
|
+
|
10
|
+
api_post('email', 'add', options).parsed_response
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(options = {})
|
14
|
+
api_post('email', 'get', options).parsed_response
|
15
|
+
end
|
16
|
+
|
17
|
+
def edit(options = {})
|
18
|
+
api_post('email', 'edit', options).parsed_response
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(options = {})
|
22
|
+
api_post('email', 'delete', options).parsed_response
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def compose_base_path(module_name, action_name)
|
28
|
+
module_name.prepend 'lists/'
|
29
|
+
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SendgridToolkit
|
2
|
+
class Lists < NewsletterSendgridClient
|
3
|
+
def add(options = {})
|
4
|
+
api_post('lists', 'add', options).parsed_response
|
5
|
+
end
|
6
|
+
|
7
|
+
def get(options = {})
|
8
|
+
api_post('lists', 'get', options).parsed_response
|
9
|
+
end
|
10
|
+
|
11
|
+
def edit(options = {})
|
12
|
+
api_post('lists', 'edit', options).parsed_response
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(options = {})
|
16
|
+
api_post('lists', 'delete', options).parsed_response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/sendgrid_toolkit.gemspec
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: sendgrid_toolkit 1.3.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "sendgrid_toolkit"
|
8
|
-
s.version = "1.
|
9
|
+
s.version = "1.3.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
12
|
s.authors = ["Robby Grossman"]
|
12
|
-
s.date = "
|
13
|
+
s.date = "2013-12-10"
|
13
14
|
s.description = "A Ruby wrapper and utility library for communicating with the Sendgrid API."
|
14
15
|
s.email = "robby@freerobby.com"
|
15
16
|
s.extra_rdoc_files = [
|
@@ -31,6 +32,9 @@ Gem::Specification.new do |s|
|
|
31
32
|
"lib/sendgrid_toolkit/common.rb",
|
32
33
|
"lib/sendgrid_toolkit/invalid_emails.rb",
|
33
34
|
"lib/sendgrid_toolkit/mail.rb",
|
35
|
+
"lib/sendgrid_toolkit/newsletter/list_emails.rb",
|
36
|
+
"lib/sendgrid_toolkit/newsletter/lists.rb",
|
37
|
+
"lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client.rb",
|
34
38
|
"lib/sendgrid_toolkit/sendgrid_error.rb",
|
35
39
|
"lib/sendgrid_toolkit/spam_reports.rb",
|
36
40
|
"lib/sendgrid_toolkit/statistics.rb",
|
@@ -43,6 +47,7 @@ Gem::Specification.new do |s|
|
|
43
47
|
"spec/lib/sendgrid_toolkit/common_spec.rb",
|
44
48
|
"spec/lib/sendgrid_toolkit/invalid_emails_spec.rb",
|
45
49
|
"spec/lib/sendgrid_toolkit/mail_spec.rb",
|
50
|
+
"spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb",
|
46
51
|
"spec/lib/sendgrid_toolkit/spam_reports_spec.rb",
|
47
52
|
"spec/lib/sendgrid_toolkit/statistics_spec.rb",
|
48
53
|
"spec/lib/sendgrid_toolkit/unsubscribes_spec.rb",
|
@@ -52,30 +57,27 @@ Gem::Specification.new do |s|
|
|
52
57
|
s.homepage = "http://github.com/freerobby/sendgrid_toolkit"
|
53
58
|
s.licenses = ["MIT"]
|
54
59
|
s.require_paths = ["lib"]
|
55
|
-
s.rubygems_version = "1.
|
60
|
+
s.rubygems_version = "2.1.11"
|
56
61
|
s.summary = "sendgrid_toolkit = Sendgrid + Ruby"
|
57
62
|
|
58
63
|
if s.respond_to? :specification_version then
|
59
|
-
s.specification_version =
|
64
|
+
s.specification_version = 4
|
60
65
|
|
61
66
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
67
|
s.add_runtime_dependency(%q<httparty>, [">= 0.7.6"])
|
63
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
68
|
s.add_development_dependency(%q<fakeweb>, ["~> 1.3.0"])
|
65
|
-
s.add_development_dependency(%q<jeweler>, ["
|
69
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
66
70
|
s.add_development_dependency(%q<rspec>, ["~> 2.7.0"])
|
67
71
|
else
|
68
72
|
s.add_dependency(%q<httparty>, [">= 0.7.6"])
|
69
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
73
|
s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
|
71
|
-
s.add_dependency(%q<jeweler>, ["
|
74
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
72
75
|
s.add_dependency(%q<rspec>, ["~> 2.7.0"])
|
73
76
|
end
|
74
77
|
else
|
75
78
|
s.add_dependency(%q<httparty>, [">= 0.7.6"])
|
76
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
77
79
|
s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
|
78
|
-
s.add_dependency(%q<jeweler>, ["
|
80
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
79
81
|
s.add_dependency(%q<rspec>, ["~> 2.7.0"])
|
80
82
|
end
|
81
83
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../helper")
|
2
|
+
|
3
|
+
describe SendgridToolkit::NewsletterSendgridClient do
|
4
|
+
specify do
|
5
|
+
SendgridToolkit::NewsletterSendgridClient.
|
6
|
+
should be < SendgridToolkit::AbstractSendgridClient
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#api_post' do
|
10
|
+
|
11
|
+
before { FakeWeb.clean_registry }
|
12
|
+
|
13
|
+
it 'prepends newsletter to the base path' do
|
14
|
+
opts = {a: 1}
|
15
|
+
|
16
|
+
FakeWeb.register_uri(:post, %r|https://sendgrid\.com/api/newsletter/lists/add\.json\?.*a=1|,
|
17
|
+
:body => '{"message":"success"}')
|
18
|
+
|
19
|
+
sendgrid_client = SendgridToolkit::NewsletterSendgridClient.new("fakeuser", "fakepass")
|
20
|
+
|
21
|
+
sendgrid_client.send(:api_post, "lists", "add", opts).should eql({ 'message' => 'success' })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -10,18 +10,19 @@ describe SendgridToolkit do
|
|
10
10
|
after :all do
|
11
11
|
FakeWeb.allow_net_connect = false
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
before do
|
15
15
|
backup_env
|
16
|
-
|
16
|
+
|
17
17
|
# Don't let SendgridToolkit fall back to SMTP_USERNAME and SMTP_PASSWORD
|
18
|
-
ENV['SMTP_USERNAME'] = ENV['TEST_SMTP_USERNAME'].
|
19
|
-
ENV['SMTP_PASSWORD'] = ENV['TEST_SMTP_PASSWORD'].
|
18
|
+
ENV['SMTP_USERNAME'] = ENV['TEST_SMTP_USERNAME'].nil? ? "fakeuser" : ENV['TEST_SMTP_USERNAME']
|
19
|
+
ENV['SMTP_PASSWORD'] = ENV['TEST_SMTP_PASSWORD'].nil? ? "fakepass" : ENV['TEST_SMTP_PASSWORD']
|
20
20
|
end
|
21
|
+
|
21
22
|
after do
|
22
23
|
restore_env
|
23
24
|
end
|
24
|
-
|
25
|
+
|
25
26
|
describe "abstract_sendgrid_client i/o" do
|
26
27
|
xit "throws authentication error when authentication fails" do
|
27
28
|
@obj = SendgridToolkit::AbstractSendgridClient.new("fakeuser", "fakepass")
|
@@ -30,7 +31,7 @@ describe SendgridToolkit do
|
|
30
31
|
}.should raise_error SendgridToolkit::AuthenticationFailed
|
31
32
|
end
|
32
33
|
end
|
33
|
-
|
34
|
+
|
34
35
|
describe "statistics i/o" do
|
35
36
|
before do
|
36
37
|
@obj = SendgridToolkit::Statistics.new
|
@@ -71,4 +72,4 @@ describe SendgridToolkit do
|
|
71
72
|
@obj.retrieve.count.should == 0
|
72
73
|
end
|
73
74
|
end
|
74
|
-
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,96 +1,78 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
|
4
|
+
version: !binary |-
|
5
|
+
MS4zLjA=
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Robby Grossman
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
18
|
- - ! '>='
|
20
19
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
20
|
+
version: !binary |-
|
21
|
+
MC43LjY=
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
25
|
requirements:
|
27
26
|
- - ! '>='
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
31
|
-
name: bundler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 1.0.0
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.0.0
|
28
|
+
version: !binary |-
|
29
|
+
MC43LjY=
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: fakeweb
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
33
|
requirements:
|
51
34
|
- - ~>
|
52
35
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
36
|
+
version: !binary |-
|
37
|
+
MS4zLjA=
|
54
38
|
type: :development
|
55
39
|
prerelease: false
|
56
40
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
41
|
requirements:
|
59
42
|
- - ~>
|
60
43
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
44
|
+
version: !binary |-
|
45
|
+
MS4zLjA=
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
47
|
name: jeweler
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
49
|
requirements:
|
67
|
-
- -
|
50
|
+
- - ! '>='
|
68
51
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
52
|
+
version: '0'
|
70
53
|
type: :development
|
71
54
|
prerelease: false
|
72
55
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
56
|
requirements:
|
75
|
-
- -
|
57
|
+
- - ! '>='
|
76
58
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
59
|
+
version: '0'
|
78
60
|
- !ruby/object:Gem::Dependency
|
79
61
|
name: rspec
|
80
62
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
63
|
requirements:
|
83
64
|
- - ~>
|
84
65
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
66
|
+
version: !binary |-
|
67
|
+
Mi43LjA=
|
86
68
|
type: :development
|
87
69
|
prerelease: false
|
88
70
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
71
|
requirements:
|
91
72
|
- - ~>
|
92
73
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
74
|
+
version: !binary |-
|
75
|
+
Mi43LjA=
|
94
76
|
description: A Ruby wrapper and utility library for communicating with the Sendgrid
|
95
77
|
API.
|
96
78
|
email: robby@freerobby.com
|
@@ -114,6 +96,9 @@ files:
|
|
114
96
|
- lib/sendgrid_toolkit/common.rb
|
115
97
|
- lib/sendgrid_toolkit/invalid_emails.rb
|
116
98
|
- lib/sendgrid_toolkit/mail.rb
|
99
|
+
- lib/sendgrid_toolkit/newsletter/list_emails.rb
|
100
|
+
- lib/sendgrid_toolkit/newsletter/lists.rb
|
101
|
+
- lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client.rb
|
117
102
|
- lib/sendgrid_toolkit/sendgrid_error.rb
|
118
103
|
- lib/sendgrid_toolkit/spam_reports.rb
|
119
104
|
- lib/sendgrid_toolkit/statistics.rb
|
@@ -126,6 +111,7 @@ files:
|
|
126
111
|
- spec/lib/sendgrid_toolkit/common_spec.rb
|
127
112
|
- spec/lib/sendgrid_toolkit/invalid_emails_spec.rb
|
128
113
|
- spec/lib/sendgrid_toolkit/mail_spec.rb
|
114
|
+
- spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb
|
129
115
|
- spec/lib/sendgrid_toolkit/spam_reports_spec.rb
|
130
116
|
- spec/lib/sendgrid_toolkit/statistics_spec.rb
|
131
117
|
- spec/lib/sendgrid_toolkit/unsubscribes_spec.rb
|
@@ -134,29 +120,25 @@ files:
|
|
134
120
|
homepage: http://github.com/freerobby/sendgrid_toolkit
|
135
121
|
licenses:
|
136
122
|
- MIT
|
123
|
+
metadata: {}
|
137
124
|
post_install_message:
|
138
125
|
rdoc_options: []
|
139
126
|
require_paths:
|
140
127
|
- lib
|
141
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
-
none: false
|
143
129
|
requirements:
|
144
130
|
- - ! '>='
|
145
131
|
- !ruby/object:Gem::Version
|
146
132
|
version: '0'
|
147
|
-
segments:
|
148
|
-
- 0
|
149
|
-
hash: -2495959361367447687
|
150
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
-
none: false
|
152
134
|
requirements:
|
153
135
|
- - ! '>='
|
154
136
|
- !ruby/object:Gem::Version
|
155
137
|
version: '0'
|
156
138
|
requirements: []
|
157
139
|
rubyforge_project:
|
158
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 2.1.11
|
159
141
|
signing_key:
|
160
|
-
specification_version:
|
142
|
+
specification_version: 4
|
161
143
|
summary: sendgrid_toolkit = Sendgrid + Ruby
|
162
144
|
test_files: []
|