parity-sendgrid-api 0.0.4
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.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/.travis.yml +3 -0
- data/.yardopts +6 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +67 -0
- data/LICENSE +22 -0
- data/README.md +261 -0
- data/Rakefile +12 -0
- data/lib/sendgrid/api.rb +7 -0
- data/lib/sendgrid/api/client.rb +43 -0
- data/lib/sendgrid/api/entities/category.rb +13 -0
- data/lib/sendgrid/api/entities/email.rb +13 -0
- data/lib/sendgrid/api/entities/entity.rb +83 -0
- data/lib/sendgrid/api/entities/list.rb +30 -0
- data/lib/sendgrid/api/entities/marketing_email.rb +20 -0
- data/lib/sendgrid/api/entities/profile.rb +14 -0
- data/lib/sendgrid/api/entities/response.rb +21 -0
- data/lib/sendgrid/api/entities/response_insert.rb +23 -0
- data/lib/sendgrid/api/entities/response_remove.rb +23 -0
- data/lib/sendgrid/api/entities/schedule.rb +13 -0
- data/lib/sendgrid/api/entities/sender_address.rb +13 -0
- data/lib/sendgrid/api/entities/stats.rb +14 -0
- data/lib/sendgrid/api/newsletter/categories.rb +74 -0
- data/lib/sendgrid/api/newsletter/emails.rb +69 -0
- data/lib/sendgrid/api/newsletter/lists.rb +64 -0
- data/lib/sendgrid/api/newsletter/marketing_emails.rb +72 -0
- data/lib/sendgrid/api/newsletter/recipients.rb +55 -0
- data/lib/sendgrid/api/newsletter/schedule.rb +70 -0
- data/lib/sendgrid/api/newsletter/sender_addresses.rb +80 -0
- data/lib/sendgrid/api/newsletter/utils.rb +34 -0
- data/lib/sendgrid/api/rest/errors/error.rb +66 -0
- data/lib/sendgrid/api/rest/resource.rb +58 -0
- data/lib/sendgrid/api/rest/response/parse_error.rb +19 -0
- data/lib/sendgrid/api/rest/response/parse_json.rb +24 -0
- data/lib/sendgrid/api/service.rb +23 -0
- data/lib/sendgrid/api/version.rb +5 -0
- data/lib/sendgrid/api/web/mail.rb +44 -0
- data/lib/sendgrid/api/web/profile.rb +38 -0
- data/lib/sendgrid/api/web/stats.rb +36 -0
- data/sendgrid-api.gemspec +23 -0
- data/spec/fixtures/categories.json +11 -0
- data/spec/fixtures/emails/email.json +6 -0
- data/spec/fixtures/emails/emails.json +10 -0
- data/spec/fixtures/errors/already_exists.json +3 -0
- data/spec/fixtures/errors/bad_request.json +6 -0
- data/spec/fixtures/errors/database_error.json +3 -0
- data/spec/fixtures/errors/does_not_exist.json +3 -0
- data/spec/fixtures/errors/forbidden.json +3 -0
- data/spec/fixtures/errors/invalid_fields.json +3 -0
- data/spec/fixtures/errors/not_scheduled.json +3 -0
- data/spec/fixtures/errors/unauthorized.json +6 -0
- data/spec/fixtures/lists/list.json +5 -0
- data/spec/fixtures/lists/lists.json +11 -0
- data/spec/fixtures/marketing_emails/marketing_email.json +19 -0
- data/spec/fixtures/marketing_emails/marketing_emails.json +10 -0
- data/spec/fixtures/profile.json +18 -0
- data/spec/fixtures/recipients.json +8 -0
- data/spec/fixtures/schedule.json +3 -0
- data/spec/fixtures/sender_addresses/sender_address.json +11 -0
- data/spec/fixtures/sender_addresses/sender_addresses.json +11 -0
- data/spec/fixtures/stats.json +50 -0
- data/spec/fixtures/success.json +3 -0
- data/spec/sendgrid/api/client_spec.rb +38 -0
- data/spec/sendgrid/api/entities/category_spec.rb +14 -0
- data/spec/sendgrid/api/entities/email_spec.rb +15 -0
- data/spec/sendgrid/api/entities/entity_spec.rb +279 -0
- data/spec/sendgrid/api/entities/list_spec.rb +34 -0
- data/spec/sendgrid/api/entities/marketing_email_spec.rb +31 -0
- data/spec/sendgrid/api/entities/profile_spec.rb +26 -0
- data/spec/sendgrid/api/entities/response_insert_spec.rb +28 -0
- data/spec/sendgrid/api/entities/response_remove_spec.rb +28 -0
- data/spec/sendgrid/api/entities/response_spec.rb +28 -0
- data/spec/sendgrid/api/entities/schedule_spec.rb +14 -0
- data/spec/sendgrid/api/entities/sender_address_spec.rb +21 -0
- data/spec/sendgrid/api/entities/stats_spec.rb +25 -0
- data/spec/sendgrid/api/newsletter/categories_spec.rb +247 -0
- data/spec/sendgrid/api/newsletter/emails_spec.rb +265 -0
- data/spec/sendgrid/api/newsletter/lists_spec.rb +307 -0
- data/spec/sendgrid/api/newsletter/marketing_emails_spec.rb +306 -0
- data/spec/sendgrid/api/newsletter/recipients_spec.rb +252 -0
- data/spec/sendgrid/api/newsletter/schedule_spec.rb +263 -0
- data/spec/sendgrid/api/newsletter/sender_addresses_spec.rb +300 -0
- data/spec/sendgrid/api/rest/errors/error_spec.rb +121 -0
- data/spec/sendgrid/api/rest/resource_spec.rb +145 -0
- data/spec/sendgrid/api/rest/response/parse_error_spec.rb +39 -0
- data/spec/sendgrid/api/rest/response/parse_json_spec.rb +45 -0
- data/spec/sendgrid/api/service_spec.rb +44 -0
- data/spec/sendgrid/api/version_spec.rb +11 -0
- data/spec/sendgrid/api/web/mail_spec.rb +111 -0
- data/spec/sendgrid/api/web/profile_spec.rb +110 -0
- data/spec/sendgrid/api/web/stats_spec.rb +94 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/helpers.rb +23 -0
- data/spec/support/mock.rb +30 -0
- data/spec/support/online.rb +114 -0
- data/spec/support/shared_examples.rb +104 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7667aa5a9c1bbc7db7e2d0b1dac3d61a20798195
|
4
|
+
data.tar.gz: b0cb8c9b31b18db1915b317783d065d3ae0de5bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c6db8b6ee18cc0cb47c2e7670217b5350ce4e2b3424a11afd2b8445799321dd2d99b44ebab807a7a964eec29ab55e3ab9af9555170fa93258036584fcbc83c85
|
7
|
+
data.tar.gz: cecb3a41646d40e3f8110c405def712cdc8840378abac7f9722bfbb8f83105dcf1858c13cbba773322f22df0e682d3c3cd2720e96d3cb372167574f448f479b7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem "bundler", "~> 1.6.2"
|
5
|
+
gem "rake", "~> 10.3.2"
|
6
|
+
gem "yard", "~> 0.8.7.4"
|
7
|
+
gem "redcarpet", "~> 3.1.2"
|
8
|
+
end
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem "rspec", "~> 2.14.1"
|
12
|
+
gem "coveralls", "~> 0.7.0", :require => false
|
13
|
+
gem "simplecov", "~> 0.8.2", :require => false
|
14
|
+
gem "webmock", "~> 1.18.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sendgrid-api (0.0.4)
|
5
|
+
faraday (~> 0.9.0)
|
6
|
+
json (~> 1.8.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.6)
|
12
|
+
coveralls (0.7.0)
|
13
|
+
multi_json (~> 1.3)
|
14
|
+
rest-client
|
15
|
+
simplecov (>= 0.7)
|
16
|
+
term-ansicolor
|
17
|
+
thor
|
18
|
+
crack (0.4.2)
|
19
|
+
safe_yaml (~> 1.0.0)
|
20
|
+
diff-lcs (1.2.5)
|
21
|
+
docile (1.1.3)
|
22
|
+
faraday (0.9.0)
|
23
|
+
multipart-post (>= 1.2, < 3)
|
24
|
+
json (1.8.1)
|
25
|
+
mime-types (2.0)
|
26
|
+
multi_json (1.10.1)
|
27
|
+
multipart-post (2.0.0)
|
28
|
+
rake (10.3.2)
|
29
|
+
redcarpet (3.1.2)
|
30
|
+
rest-client (1.6.7)
|
31
|
+
mime-types (>= 1.16)
|
32
|
+
rspec (2.14.1)
|
33
|
+
rspec-core (~> 2.14.0)
|
34
|
+
rspec-expectations (~> 2.14.0)
|
35
|
+
rspec-mocks (~> 2.14.0)
|
36
|
+
rspec-core (2.14.7)
|
37
|
+
rspec-expectations (2.14.3)
|
38
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
39
|
+
rspec-mocks (2.14.4)
|
40
|
+
safe_yaml (1.0.3)
|
41
|
+
simplecov (0.8.2)
|
42
|
+
docile (~> 1.1.0)
|
43
|
+
multi_json
|
44
|
+
simplecov-html (~> 0.8.0)
|
45
|
+
simplecov-html (0.8.0)
|
46
|
+
term-ansicolor (1.2.2)
|
47
|
+
tins (~> 0.8)
|
48
|
+
thor (0.18.1)
|
49
|
+
tins (0.12.0)
|
50
|
+
webmock (1.18.0)
|
51
|
+
addressable (>= 2.3.6)
|
52
|
+
crack (>= 0.3.2)
|
53
|
+
yard (0.8.7.4)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 1.6.2)
|
60
|
+
coveralls (~> 0.7.0)
|
61
|
+
rake (~> 10.3.2)
|
62
|
+
redcarpet (~> 3.1.2)
|
63
|
+
rspec (~> 2.14.1)
|
64
|
+
sendgrid-api!
|
65
|
+
simplecov (~> 0.8.2)
|
66
|
+
webmock (~> 1.18.0)
|
67
|
+
yard (~> 0.8.7.4)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Renato Neves
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
# Sendgrid::API
|
2
|
+
|
3
|
+
[][gem]
|
4
|
+
[][codeclimate]
|
5
|
+
[][coveralls]
|
6
|
+
|
7
|
+
[gem]: http://travis-ci.org/renatosnrg/sendgrid-api
|
8
|
+
[codeclimate]: https://codeclimate.com/github/renatosnrg/sendgrid-api
|
9
|
+
[coveralls]: https://coveralls.io/r/renatosnrg/sendgrid-api
|
10
|
+
|
11
|
+
A Ruby interface to the SendGrid API.
|
12
|
+
|
13
|
+
## API Coverage
|
14
|
+
|
15
|
+
Check which SendGrid APIs are currently being covered by this gem:
|
16
|
+
|
17
|
+
[https://github.com/renatosnrg/sendgrid-api/wiki/SendGrid-API-Coverage][coverage]
|
18
|
+
|
19
|
+
[coverage]: https://github.com/renatosnrg/sendgrid-api/wiki/SendGrid-API-Coverage
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'sendgrid-api'
|
27
|
+
```
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ bundle
|
33
|
+
```
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
$ gem install sendgrid-api
|
39
|
+
```
|
40
|
+
|
41
|
+
## Configuration
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
client = Sendgrid::API::Client.new('YOUR_USER', 'YOUR_KEY')
|
45
|
+
```
|
46
|
+
|
47
|
+
## Web API
|
48
|
+
|
49
|
+
### Profile
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
# create a profile object
|
53
|
+
profile = Sendgrid::API::Entities::Profile.new(:first_name => 'Your first name',
|
54
|
+
:last_name => 'Your last name')
|
55
|
+
# get your profile
|
56
|
+
profile = client.profile.get
|
57
|
+
# modify your profile
|
58
|
+
response = client.profile.set(profile)
|
59
|
+
```
|
60
|
+
|
61
|
+
### Mail
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
# send basic text email
|
65
|
+
response = client.mail.send(:to => 'johndoe@example.com',
|
66
|
+
:from => 'brian@example.com',
|
67
|
+
:subject => 'test using sendgrid api',
|
68
|
+
:text => 'this is a test')
|
69
|
+
# set SMTP API headers
|
70
|
+
x_smtpapi = {:category => ['sendgrid-api test']}
|
71
|
+
response = client.mail.send(:to => 'johndoe@example.com',
|
72
|
+
:from => 'brian@example.com',
|
73
|
+
:subject => 'test using sendgrid api',
|
74
|
+
:text => 'this is a test',
|
75
|
+
:x_smtpapi => x_smtpapi)
|
76
|
+
# send files attached
|
77
|
+
text = StringIO.new("This is my file content")
|
78
|
+
file = Faraday::UploadIO.new(text, 'plain/text', 'sample.txt')
|
79
|
+
response = client.mail.send(:to => 'johndoe@example.com',
|
80
|
+
:from => 'brian@example.com',
|
81
|
+
:subject => 'test using sendgrid api',
|
82
|
+
:text => 'this is a test',
|
83
|
+
:files => {'sample.txt' => file})
|
84
|
+
```
|
85
|
+
|
86
|
+
### Statistics
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
# get advanced statistics
|
90
|
+
stats = client.stats.advanced(:start_date => '2013-01-01', :data_type => 'global')
|
91
|
+
```
|
92
|
+
|
93
|
+
## Marketing Email API
|
94
|
+
|
95
|
+
### Lists
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
# create a list object
|
99
|
+
list = Sendgrid::API::Entities::List.new(:list => 'sendgrid-api list test')
|
100
|
+
# add a new list
|
101
|
+
response = client.lists.add(list)
|
102
|
+
# edit an existing list
|
103
|
+
response = client.lists.edit(list, 'new name')
|
104
|
+
# get an existing list
|
105
|
+
selected_list = client.lists.get(list)
|
106
|
+
# get all lists
|
107
|
+
all_lists = client.lists.get
|
108
|
+
# delete a list
|
109
|
+
response = client.lists.delete(list)
|
110
|
+
```
|
111
|
+
|
112
|
+
### Emails
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
# create email objects
|
116
|
+
email1 = Sendgrid::API::Entities::Email.new(
|
117
|
+
:email => 'johndoe@example.com',
|
118
|
+
:name => 'John Doe'
|
119
|
+
)
|
120
|
+
email2 = Sendgrid::API::Entities::Email.new(
|
121
|
+
:email => 'brian@example.com',
|
122
|
+
:name => 'Brian'
|
123
|
+
)
|
124
|
+
emails = [email1, email2]
|
125
|
+
listname = 'sendgrid-api list test'
|
126
|
+
# add emails to a list
|
127
|
+
response = client.emails.add(listname, emails)
|
128
|
+
# get all emails from a list
|
129
|
+
all_emails = client.emails.get(listname)
|
130
|
+
# get a specific email from a list
|
131
|
+
selected_emails = client.emails.get(listname, email1)
|
132
|
+
# delete an email from a list
|
133
|
+
response = client.emails.delete(listname, email1)
|
134
|
+
```
|
135
|
+
|
136
|
+
### Sender Adresses
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
# create sender address object
|
140
|
+
address = Sendgrid::API::Entities::SenderAddress.new(
|
141
|
+
:identity => 'sendgrid-api sender address test',
|
142
|
+
:name => 'Sendgrid',
|
143
|
+
:email => 'contact@sendgrid.com',
|
144
|
+
:address => '1065 N Pacificenter Drive, Suite 425',
|
145
|
+
:city => 'Anaheim',
|
146
|
+
:state => 'CA',
|
147
|
+
:zip => '92806',
|
148
|
+
:country => 'US'
|
149
|
+
)
|
150
|
+
# add a sender address
|
151
|
+
response = client.sender_addresses.add(address)
|
152
|
+
# edit a sender address
|
153
|
+
address.city = 'Pleasanton'
|
154
|
+
response = client.sender_addresses.edit(address, 'new identity')
|
155
|
+
# get all sender addresses
|
156
|
+
addresses = client.sender_addresses.list
|
157
|
+
# get a sender address
|
158
|
+
address = client.sender_addresses.get(address)
|
159
|
+
# delete a sender address
|
160
|
+
response = client.sender_addresses.delete(address)
|
161
|
+
```
|
162
|
+
|
163
|
+
### Marketing Emails
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
# create marketing email object
|
167
|
+
marketing_email = Sendgrid::API::Entities::MarketingEmail.new(
|
168
|
+
:identity => 'sendgrid-api sender address test',
|
169
|
+
:name => 'sendgrid-api marketing email test',
|
170
|
+
:subject => 'My Marketing Email Test',
|
171
|
+
:text => 'My text',
|
172
|
+
:html => 'My HTML'
|
173
|
+
)
|
174
|
+
# add a marketing email
|
175
|
+
response = client.marketing_emails.add(marketing_email)
|
176
|
+
# edit a marketing email
|
177
|
+
marketing_email.html = 'My new HTML'
|
178
|
+
response = client.marketing_emails.edit(marketing_email, 'new name')
|
179
|
+
# get a marketing email
|
180
|
+
newsletter = client.marketing_emails.get(marketing_email)
|
181
|
+
# get all marketing emails
|
182
|
+
newsletters = client.marketing_emails.list
|
183
|
+
# delete a marketing email
|
184
|
+
response = client.marketing_emails.delete(marketing_email)
|
185
|
+
```
|
186
|
+
|
187
|
+
### Categories
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
# create category object
|
191
|
+
category = Sendgrid::API::Entities::Category.new(:category => 'sendgrid-api test')
|
192
|
+
marketing_email = 'sendgrid-api marketing email test'
|
193
|
+
# add category
|
194
|
+
response = client.categories.create(category)
|
195
|
+
# add category to a marketing email
|
196
|
+
response = client.categories.add(marketing_email, category)
|
197
|
+
# remove category from a marketing email
|
198
|
+
response = client.categories.remove(marketing_email, category)
|
199
|
+
# get all categories
|
200
|
+
categories = client.categories.list
|
201
|
+
```
|
202
|
+
|
203
|
+
### Recipients
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
listname = 'sendgrid-api list test'
|
207
|
+
marketing_email = 'sendgrid-api marketing email test'
|
208
|
+
# assign a recipient list to a marketing email
|
209
|
+
response = client.recipients.add(listname, marketing_email)
|
210
|
+
# get all lists assigned to a marketing email
|
211
|
+
lists = client.recipients.get(marketing_email)
|
212
|
+
# delete an assigned list from a marketing email
|
213
|
+
response = client.recipients.delete(listname, marketing_email)
|
214
|
+
```
|
215
|
+
|
216
|
+
### Schedule
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
marketing_email = 'sendgrid-api marketing email test'
|
220
|
+
# schedule a delivery time for a marketing email
|
221
|
+
response = client.schedule.add(marketing_email) # imediately
|
222
|
+
response = client.schedule.add(marketing_email, :after => 20) # 20 minutes from now
|
223
|
+
response = client.schedule.add(marketing_email, :at => (Time.now + 10*60)) # 10 minutes from now
|
224
|
+
# retrieve the scheduled delivery time for a marketing email
|
225
|
+
schedule = client.schedule.get(marketing_email)
|
226
|
+
# cancel a scheduled delivery time for a marketing email
|
227
|
+
response = client.schedule.delete(marketing_email)
|
228
|
+
```
|
229
|
+
|
230
|
+
## Tests
|
231
|
+
|
232
|
+
This gem has offline and online tests written using RSpec. Offline tests use Webmock to stub HTTP requests, while online tests performs the requests to Sendgrid to ensure all the calls and responses are correctly.
|
233
|
+
|
234
|
+
The online tests are written in a way that they don't change the state of the objects already existing on SendGrid account. It means if something is added, it's removed at the end of the test. If something is changed, it's changed back after the test finishes. If it's necessary to remove something, it's added before the test starts.
|
235
|
+
|
236
|
+
Use the SENDGRID_USER and SENDGRID_KEY environment variables to authenticate the online tests.
|
237
|
+
|
238
|
+
To run all tests (both offline and online):
|
239
|
+
```bash
|
240
|
+
$ ALL=1 SENDGRID_USER=your_user SENDGRID_KEY=your_key bundle exec rake spec
|
241
|
+
```
|
242
|
+
|
243
|
+
To run only online tests:
|
244
|
+
```bash
|
245
|
+
$ SENDGRID_USER=your_user SENDGRID_KEY=your_key bundle exec rake spec[online]
|
246
|
+
```
|
247
|
+
|
248
|
+
To run only offline tests (default):
|
249
|
+
```bash
|
250
|
+
$ bundle exec rake spec
|
251
|
+
```
|
252
|
+
|
253
|
+
## Contributing
|
254
|
+
|
255
|
+
If you want to contribute to cover more APIs or improve something already implemented, follow these steps:
|
256
|
+
|
257
|
+
1. Fork it
|
258
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
259
|
+
3. Commit your changes - do not forget tests (`git commit -am 'Add some feature'`)
|
260
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
261
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "yard"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args|
|
6
|
+
t.rspec_opts = "--tag #{task_args[:tag]}" if task_args[:tag]
|
7
|
+
end
|
8
|
+
|
9
|
+
YARD::Rake::YardocTask.new
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
task :test => :spec
|
data/lib/sendgrid/api.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'sendgrid/api/rest/resource'
|
2
|
+
require 'sendgrid/api/web/profile'
|
3
|
+
require 'sendgrid/api/web/stats'
|
4
|
+
require 'sendgrid/api/web/mail'
|
5
|
+
require 'sendgrid/api/newsletter/lists'
|
6
|
+
require 'sendgrid/api/newsletter/emails'
|
7
|
+
require 'sendgrid/api/newsletter/sender_addresses'
|
8
|
+
require 'sendgrid/api/newsletter/categories'
|
9
|
+
require 'sendgrid/api/newsletter/marketing_emails'
|
10
|
+
require 'sendgrid/api/newsletter/recipients'
|
11
|
+
require 'sendgrid/api/newsletter/schedule'
|
12
|
+
|
13
|
+
module Sendgrid
|
14
|
+
module API
|
15
|
+
class Client
|
16
|
+
|
17
|
+
include Web::Profile
|
18
|
+
include Web::Stats
|
19
|
+
include Web::Mail
|
20
|
+
include Newsletter::Lists
|
21
|
+
include Newsletter::Emails
|
22
|
+
include Newsletter::SenderAddresses
|
23
|
+
include Newsletter::Categories
|
24
|
+
include Newsletter::MarketingEmails
|
25
|
+
include Newsletter::Recipients
|
26
|
+
include Newsletter::Schedule
|
27
|
+
|
28
|
+
attr_reader :user, :key
|
29
|
+
|
30
|
+
def initialize(user, key)
|
31
|
+
@user = user
|
32
|
+
@key = key
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def resource
|
38
|
+
@resource ||= REST::Resource.new(user, key)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|