sendgrid-ruby 1.1.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE +17 -0
  3. data/.travis.yml +1 -6
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +202 -0
  6. data/Gemfile +3 -5
  7. data/LICENSE.txt +1 -1
  8. data/README.md +74 -248
  9. data/Rakefile +8 -6
  10. data/USAGE.md +4645 -0
  11. data/examples/accesssettings/accesssettings.rb +89 -0
  12. data/examples/apikeys/apikeys.rb +95 -0
  13. data/examples/asm/asm.rb +169 -0
  14. data/examples/browsers/browsers.rb +29 -0
  15. data/examples/campaigns/campaigns.rb +166 -0
  16. data/examples/categories/categories.rb +49 -0
  17. data/examples/clients/clients.rb +40 -0
  18. data/examples/contactdb/contactdb.rb +398 -0
  19. data/examples/devices/devices.rb +29 -0
  20. data/examples/geo/geo.rb +29 -0
  21. data/examples/helpers/mail/example.rb +130 -0
  22. data/examples/ips/ips.rb +167 -0
  23. data/examples/mail/mail.rb +191 -0
  24. data/examples/mailboxproviders/mailboxproviders.rb +29 -0
  25. data/examples/mailsettings/mailsettings.rb +232 -0
  26. data/examples/partnersettings/partnersettings.rb +52 -0
  27. data/examples/scopes/scopes.rb +28 -0
  28. data/examples/stats/stats.rb +29 -0
  29. data/examples/subusers/subusers.rb +182 -0
  30. data/examples/suppression/suppression.rb +186 -0
  31. data/examples/templates/templates.rb +142 -0
  32. data/examples/trackingsettings/trackingsettings.rb +123 -0
  33. data/examples/user/user.rb +256 -0
  34. data/examples/whitelabel/whitelabel.rb +323 -0
  35. data/lib/helpers/mail/README.md +14 -0
  36. data/lib/helpers/mail/mail.rb +999 -0
  37. data/lib/sendgrid-ruby.rb +33 -8
  38. data/sendgrid-ruby.gemspec +5 -17
  39. data/test/helpers/mail/test_mail.rb +122 -0
  40. data/test/test_sendgrid-ruby.rb +2016 -0
  41. metadata +42 -190
  42. data/.env_sample +0 -3
  43. data/.rspec +0 -2
  44. data/.rubocop.yml +0 -30
  45. data/FETCH_HEAD +0 -0
  46. data/Guardfile +0 -10
  47. data/example.rb +0 -41
  48. data/lib/sendgrid/client.rb +0 -62
  49. data/lib/sendgrid/exceptions.rb +0 -7
  50. data/lib/sendgrid/mail.rb +0 -182
  51. data/lib/sendgrid/recipient.rb +0 -29
  52. data/lib/sendgrid/response.rb +0 -14
  53. data/lib/sendgrid/template.rb +0 -26
  54. data/lib/sendgrid/template_mailer.rb +0 -59
  55. data/lib/sendgrid/version.rb +0 -3
  56. data/spec/lib/sendgrid/client_spec.rb +0 -87
  57. data/spec/lib/sendgrid/mail_spec.rb +0 -151
  58. data/spec/lib/sendgrid/recipient_spec.rb +0 -91
  59. data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
  60. data/spec/lib/sendgrid/template_spec.rb +0 -61
  61. data/spec/lib/sendgrid_spec.rb +0 -7
  62. data/spec/spec_helper.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0997af40965b55afccbb2fd70def32ed7c8213a
4
- data.tar.gz: 2453f6b8577c67c463a30260b5e33e05e5d4d4a9
3
+ metadata.gz: cab2df6919ab4b453302538b94b6d995e1436fc5
4
+ data.tar.gz: 0382f6eb11cdf980b235d2e8b72922dfcdd8208f
5
5
  SHA512:
6
- metadata.gz: 645b595f82306ba093af8d4b6e8465d2e243ca149070a411d5d90295845b8eda5433b6b89c8ffb62db520b949df26a7011d357b978ffa8bce7e1b038b2f0b337
7
- data.tar.gz: 6c982e7e5c6c6c5366cc5332019383114d189b6b4d39092b3c33139e56bed3d85da1596a6a4a9b1fcf3818c7d7f774ea43d7412c0b0cf10f3311d7056b26b652
6
+ metadata.gz: 7bb930d9ee45c99fd20dfe9a95ce3b43852c8b60d6e509243e1177c896b602d80d9ba3cc57ad178be061c6f73e1283f1db5349f4072d0b5f0c7e5711eb10299d
7
+ data.tar.gz: 6ea58deafbf9838e45663df4ebe8a75bbe421563d6c6484559f12796b913c5cd2bd87b44bcf44d4e2ad226ef34b45f650e819b71ef7e86028dbb29c2794fadc1
@@ -0,0 +1,17 @@
1
+ #### Issue Summary
2
+
3
+ A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, code examples.
4
+
5
+
6
+ #### Steps to Reproduce
7
+
8
+ 1. This is the first step
9
+ 2. This is the second step
10
+ 3. Further steps, etc.
11
+
12
+ Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?
13
+
14
+ #### Technical details:
15
+
16
+ * sendgrid-ruby Version: master (latest commit: [commit number])
17
+ * Ruby Version: 2.2
data/.travis.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2
4
- - 2.0
5
- - 1.9.3
6
4
  notifications:
7
5
  hipchat:
8
6
  rooms:
@@ -10,11 +8,8 @@ notifications:
10
8
  template:
11
9
  - '<a href="https://travis-ci.org/%{repository}/builds/%{build_id}">%{repository}
12
10
  Build %{build_number}</a> on branch <i>%{branch}</i> by %{author}: <strong>%{message}</strong>
13
- <a href="https://github.com/sendgrid/docs/commits/%{commit}">View on GitHub</a>'
11
+ <a href="https://github.com/sendgrid/%{repository}/commits/%{commit}">View on GitHub</a>'
14
12
  format: html
15
13
  notify: false
16
- before_script:
17
- - bundle install
18
14
  script:
19
- - rubocop --fail-level=E
20
15
  - rake
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [2.0.0] - 2016-06-13 ##
5
+ ### Added
6
+ - Breaking change to support the v3 Web API
7
+ - New HTTP client
8
+ - v3 Mail Send helper
9
+
4
10
  ## [1.1.6] - 2015-11-26 ##
5
11
  ## Added
6
12
  Support for cc_name and bcc_name via [#31](https://github.com/sendgrid/sendgrid-ruby/pull/31)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,202 @@
1
+ Hello! Thank you for choosing to help contribute to one of the SendGrid open source libraries. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies.
2
+
3
+ - [CLAs and CCLAs](#cla)
4
+ - [Roadmap & Milestones](#roadmap)
5
+ - [Feature Request](#feature_request)
6
+ - [Submit a Bug Report](#submit_a_bug_report)
7
+ - [Improvements to the Codebase](#improvements_to_the_codebase)
8
+ - [Understanding the Code Base](#understanding_the_codebase)
9
+ - [Testing](#testing)
10
+ - [Style Guidelines & Naming Conventions](#style_guidelines_and_naming_conventions)
11
+ - [Creating a Pull Request](#creating_a_pull_request)
12
+
13
+ <a name="roadmap"></a>
14
+ We use [Milestones](https://github.com/sendgrid/sendgrid-ruby/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
15
+
16
+ <a name="cla"></a>
17
+ ## CLAs and CCLAs
18
+
19
+ Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) or a SendGrid Company Contributor Licensing Agreement (CCLA) be filled out by every contributor to a SendGrid open source project.
20
+
21
+ Our goal with the CLA and CCLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA and CCLA encourage broad participation by our open source community and help us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution.
22
+
23
+ SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA (or CCLA). Copies of the CLA and CCLA are available [here](https://drive.google.com/a/sendgrid.com/file/d/0B0PlcM9qA91LN2VEUTJWU2RIVXc/view).
24
+
25
+ You may submit your completed [CLA or CCLA](https://drive.google.com/a/sendgrid.com/file/d/0B0PlcM9qA91LN2VEUTJWU2RIVXc/view) to SendGrid at [dx@sendgrid.com](mailto:dx@sendgrid.com). SendGrid will then confirm you are ready to begin making contributions.
26
+
27
+ There are a few ways to contribute, which we'll enumerate below:
28
+
29
+ <a name="feature_request"></a>
30
+ ## Feature Request
31
+
32
+ If you'd like to make a feature request, please read this section.
33
+
34
+ The GitHub issue tracker is the preferred channel for library feature requests, but please respect the following restrictions:
35
+
36
+ - Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests.
37
+ - Please be respectful and considerate of others when commenting on issues
38
+
39
+ <a name="submit_a_bug_report"></a>
40
+ ## Submit a Bug Report
41
+
42
+ Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
43
+
44
+ A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report.
45
+
46
+ Before you decide to create a new issue, please try the following:
47
+
48
+ 1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post.
49
+ 2. Update to the latest version of this code and check if issue has already been fixed
50
+ 3. Copy and fill in the Bug Report Template we have provided below
51
+
52
+ ### Please use our Bug Report Template
53
+
54
+ In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-ruby/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
55
+
56
+ <a name="improvements_to_the_codebase"></a>
57
+ ## Improvements to the Codebase
58
+
59
+ We welcome direct contributions to the sendgrid-ruby code base. Thank you!
60
+
61
+ ### Development Environment ###
62
+
63
+ #### Install and Run Locally ####
64
+
65
+ ##### Prerequisites #####
66
+
67
+ - Ruby 2.2
68
+ - [ruby_http_client](https://github.com/sendgrid/ruby-http-client)
69
+
70
+ ##### Initial setup: #####
71
+
72
+ ```bash
73
+ git clone https://github.com/sendgrid/sendgrid-ruby.git
74
+ cd sendgrid-ruby
75
+ bundle install
76
+ ```
77
+
78
+ ## Environment Variables
79
+
80
+ First, get your free SendGrid account [here](https://sendgrid.com/free?source=sendgrid-ruby).
81
+
82
+ Next, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).
83
+
84
+ ```bash
85
+ echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
86
+ echo "sendgrid.env" >> .gitignore
87
+ source ./sendgrid.env
88
+ ```
89
+
90
+ ##### Execute: #####
91
+
92
+ See the [examples folder](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples) to get started quickly.
93
+
94
+ To run the examples using the local version of this library from the root directory of this repo, please replace:
95
+
96
+ `require 'sendgrid-ruby'`
97
+
98
+ with:
99
+
100
+ `require_relative './lib/sendgrid-ruby.rb'`
101
+
102
+ Then run using:
103
+
104
+ ```bash
105
+ ruby example.rb
106
+ ```
107
+
108
+ <a name="understanding_the_codebase"></a>
109
+ ## Understanding the Code Base
110
+
111
+ **/examples**
112
+
113
+ Working examples that demonstrate usage.
114
+
115
+ **/test**
116
+
117
+ Tests for the mail send and Web API v3 endpoints.
118
+
119
+ **/lib**
120
+
121
+ The Web API v3 client is `sendgrid-ruby.rb`
122
+
123
+ <a name="testing"></a>
124
+ ## Testing
125
+
126
+ All PRs require passing tests before the PR will be reviewed.
127
+
128
+ All test files are in the [`tests`](https://github.com/sendgrid/sendgrid-ruby/tree/master/test) directory.
129
+
130
+ For the purposes of contributing to this repo, please update the [`test_sendgrid-ruby.rb`](https://github.com/sendgrid/sendgrid-ruby/blob/master/test/test_sendgrid-ruby.rb) file with unit tests as you modify the code.
131
+
132
+ To run the tests:
133
+
134
+ ```bash
135
+ rake
136
+ ```
137
+
138
+ <a name="style_guidelines_and_naming_conventions"></a>
139
+ ## Style Guidelines & Naming Conventions
140
+
141
+ Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning.
142
+
143
+ - [Community Driven Style Guide](https://github.com/bbatsov/ruby-style-guide)
144
+
145
+ Please run your code through:
146
+
147
+ - [rubocop](https://github.com/bbatsov/rubocop).
148
+
149
+ ## Creating a Pull Request<a name="creating_a_pull_request"></a>
150
+
151
+ 1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork,
152
+ and configure the remotes:
153
+
154
+ ```bash
155
+ # Clone your fork of the repo into the current directory
156
+ git clone https://github.com/sendgrid/sendgrid-ruby
157
+ # Navigate to the newly cloned directory
158
+ cd sendgrid-python
159
+ # Assign the original repo to a remote called "upstream"
160
+ git remote add upstream https://github.com/sendgrid/sendgrid-ruby
161
+ ```
162
+
163
+ 2. If you cloned a while ago, get the latest changes from upstream:
164
+
165
+ ```bash
166
+ git checkout <dev-branch>
167
+ git pull upstream <dev-branch>
168
+ ```
169
+
170
+ 3. Create a new topic branch (off the main project development branch) to
171
+ contain your feature, change, or fix:
172
+
173
+ ```bash
174
+ git checkout -b <topic-branch-name>
175
+ ```
176
+
177
+ 4. Commit your changes in logical chunks. Please adhere to these [git commit
178
+ message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
179
+ or your code is unlikely be merged into the main project. Use Git's
180
+ [interactive rebase](https://help.github.com/articles/interactive-rebase)
181
+ feature to tidy up your commits before making them public.
182
+
183
+ 4a. Create tests.
184
+
185
+ 4b. Create or update the example code that demonstrates the functionality of this change to the code.
186
+
187
+ 5. Locally merge (or rebase) the upstream development branch into your topic branch:
188
+
189
+ ```bash
190
+ git pull [--rebase] upstream master
191
+ ```
192
+
193
+ 6. Push your topic branch up to your fork:
194
+
195
+ ```bash
196
+ git push origin <topic-branch-name>
197
+ ```
198
+
199
+ 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
200
+ with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.
201
+
202
+ If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo.
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
- gem 'dotenv-rails'
2
- gem 'smtpapi'
3
- gem 'rest-client'
4
- source 'https://rubygems.org'
5
- gemspec
1
+ source 'http://rubygems.org'
2
+
3
+ gem "ruby_http_client"
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 SendGrid Inc.
1
+ Copyright (c) 2014-2016 SendGrid, Inc.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,296 +1,122 @@
1
- # SendGrid::Ruby
1
+ [![Travis Badge](https://travis-ci.org/sendgrid/sendgrid-ruby.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-ruby)
2
2
 
3
- This Gem allows you to quickly and easily send emails through SendGrid's Web API using native Ruby.
4
3
 
5
- You can read our official documentation on the Web API's Mail feature [here](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
4
+ **This library allows you to quickly and easily use the SendGrid Web API via Ruby.**
6
5
 
7
- [![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-ruby.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-ruby)
6
+ # Announcements
8
7
 
8
+ **BREAKING CHANGE as of 2016.06.14**
9
9
 
10
- ## Installation
10
+ Version `2.0.0` is a breaking change for the entire library.
11
11
 
12
- Add this line to your application's Gemfile:
13
-
14
- gem 'sendgrid-ruby'
15
-
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself using:
21
-
22
- $ gem install sendgrid-ruby
23
-
24
- ## Usage
25
-
26
- Create a new client with your SendGrid Username and Password.
27
-
28
- ```ruby
29
- require 'sendgrid-ruby'
30
-
31
- # As a hash
32
- client = SendGrid::Client.new(api_user: 'SENDGRID_USERNAME', api_key: 'SENDGRID_PASSWORD')
33
-
34
- # Or as a block
35
- client = SendGrid::Client.new do |c|
36
- c.api_user = 'SENDGRID_USERNAME'
37
- c.api_key = 'SENDGRID_PASSWORD'
38
- end
39
-
40
- # or as a block with the API key only #
41
- client = SendGrid::Client.new do |c|
42
- c.api_key = 'SENDGRID_APIKEY'
43
- end
44
- ```
45
-
46
- Create a new Mail object and send:
47
- ```ruby
48
- mail = SendGrid::Mail.new do |m|
49
- m.to = 'test@sendgrid.com'
50
- m.from = 'taco@cat.limo'
51
- m.subject = 'Hello world!'
52
- m.text = 'I heard you like pineapple.'
53
- end
54
-
55
- res = client.send(mail)
56
- puts res.code
57
- puts res.body
58
- # 200
59
- # {"message"=>"success"}
60
- ```
61
-
62
- You can also create a Mail object with a hash:
63
- ```ruby
64
- res = client.send(SendGrid::Mail.new(to: 'example@example.com', from: 'taco@cat.limo', subject: 'Hello world!', text: 'Hi there!', html: '<b>Hi there!</b>'))
65
- puts res.code
66
- puts res.body
67
- # 200
68
- # {"message"=>"success"}
69
- ```
70
-
71
- #### Attachments
72
-
73
- Attachments can be added to a Mail object with the `add_attachment` method. The first parameter is the path to the file, the second (optional) parameter is the desired name of the file. If a file name is not provided, it will use the original filename.
74
- ```ruby
75
- mail.add_attachment('/tmp/report.pdf', 'july_report.pdf')
76
- ```
77
-
78
- #### Inline Content
79
-
80
- Inline content can be added to a Mail object with the `add_content` method. The first parameter is the path to the file, the second parameter is the cid to be referenced in the html.
81
- ```ruby
82
- mail = SendGrid::Mail.new do |m|
83
- m.to = 'test@sendgrid.com'
84
- m.from = 'taco@cat.limo'
85
- m.subject = 'Hello world!'
86
- m.text = 'I heard you like the beach.'
87
- m.html = 'I heard you like the beach <div><img src="cid:beach"></div>'
88
- end
89
- mail.add_content('/tmp/beach.jpg', 'beach')
90
- result = client.send(mail)
91
- ```
92
-
93
- #### Available Params
94
-
95
- ```ruby
96
- params = {
97
- :to,
98
- :to_name,
99
- :from,
100
- :from_name,
101
- :subject,
102
- :text,
103
- :html,
104
- :cc,
105
- :cc_name,
106
- :bcc,
107
- :bcc_name,
108
- :reply_to,
109
- :date,
110
- :smtpapi,
111
- :attachments,
112
- :template
113
- }
114
- ```
115
-
116
- #### Setting Params
117
-
118
- Params can be set in the usual Ruby ways, including a block or a hash.
119
-
120
- ````ruby
121
- mail = SendGrid::Mail.new do |m|
122
- m.to = 'rbin@sendgrid.com'
123
- m.from = 'taco@rbin.codes'
124
- end
12
+ Version 2.0.0 brings you full support for all Web API v3 endpoints. We
13
+ have the following resources to get you started quickly:
125
14
 
126
- client.send(SendGrid::Mail.new(to: 'rbin@sendgrid.com', from: 'taco@cat.limo'))
127
- ````
15
+ - [SendGrid
16
+ Documentation](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html)
17
+ - [Usage
18
+ Documentation](https://github.com/sendgrid/sendgrid-ruby/tree/master/USAGE.md)
19
+ - [Example
20
+ Code](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples)
128
21
 
129
- #### :to
22
+ Thank you for your continued support!
130
23
 
131
- Using the **:to** param, we can pass a single email address as a string, or an array of email address strings.
24
+ All updates to this library is documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-ruby/blob/master/CHANGELOG.md).
132
25
 
133
- ````ruby
134
- mail = SendGrid::Mail.new
135
- mail.to = 'taco@rbin.codes'
136
- # or
137
- mail.to = ['Example Dude <example@email.com>', 'john@email.com']
138
- # or
139
- mail.to = ['rbin@sendgrid.com', 'taco@cat.limo']
140
- ````
26
+ # Installation
141
27
 
142
- #### :from
28
+ ## Setup Environment Variables
143
29
 
144
- ```ruby
145
- mail = SendGrid::Mail.new
146
- mail.from = 'me@sendgrid.com'
147
- ```
148
-
149
- #### :cc
150
-
151
- As with **:to**, **:cc** can take a single string or an array of strings.
152
-
153
- ```ruby
154
- mail = SendGrid::Mail.new
155
- mail.cc = ['robin@sendgrid.com', 'taco@cat.limo']
156
- ```
157
-
158
- #### :bcc
30
+ First, get your free SendGrid account [here](https://sendgrid.com/free?source=sendgrid-ruby).
159
31
 
160
- As with **:to** and **:cc**, **:bcc** can take a single string or an array of strings.
32
+ Next, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).
161
33
 
162
- ```ruby
163
- mail = SendGrid::Mail.new
164
- mail.bcc = ['robin@sendgrid.com', 'taco@cat.limo']
34
+ ```bash
35
+ echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
36
+ echo "sendgrid.env" >> .gitignore
37
+ source ./sendgrid.env
165
38
  ```
39
+ ## Install Package
166
40
 
167
- #### :subject
168
-
169
- ```ruby
170
- mail = SendGrid::Mail.new
171
- mail.subject = 'This is a subject string'
172
- ```
173
-
174
- ### Email Bodies:
175
- #### :text
176
-
177
- Using the **:text** param allows us to add plain text to our email body.
41
+ Add this line to your application's Gemfile:
178
42
 
179
- ```ruby
180
- mail = SendGrid::Mail.new
181
- mail.text = 'WHATTUP KITTY CAT!?'
43
+ ```bash
44
+ gem 'sendgrid-ruby'
182
45
  ```
183
46
 
184
- #### :html
47
+ And then execute:
185
48
 
186
- Using the **:html** param allows us to add html content to our email body.
187
- ```ruby
188
- mail = SendGrid::Mail.new
189
- mail.html = '<html><body>Stuff in here, yo!</body></html>'
49
+ ```bash
50
+ bundle
190
51
  ```
191
52
 
192
- #### :template
193
-
194
- The **:template** param allows us to specify a template object for this email to use. The initialized `Template` will automatically be included in the `smtpapi` header and passed to SendGrid.
53
+ Or install it yourself using:
195
54
 
196
- ```ruby
197
- template = SendGrid::Template.new('MY_TEMPLATE_ID')
198
- mail.template = template
55
+ ```bash
56
+ gem install sendgrid-ruby
199
57
  ```
200
58
 
201
- ## Working with Templates
202
-
203
- Another easy way to use the [SendGrid Templating](https://sendgrid.com/docs/API_Reference/Web_API_v3/Template_Engine/index.html) system is with the `Recipient`, `Mail`, `Template`, and `TemplateMailer` objects.
204
-
205
- Create some `Recipients`
206
-
207
- ```ruby
208
- users = User.where(email: ['first@gmail.com', 'second@gmail.com'])
209
-
210
- recipients = []
59
+ ## Dependencies
211
60
 
212
- users.each do |user|
213
- recipient = SendGrid::Recipient.new(user.email)
214
- recipient.add_substitution('first_name', user.first_name)
215
- recipient.add_substitution('city', user.city)
61
+ - The SendGrid Service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-ruby))
62
+ - [Ruby-HTTP-Client](https://github.com/sendgrid/ruby-http-client)
216
63
 
217
- recipients << recipient
218
- end
219
- ```
64
+ # Quick Start
220
65
 
221
- Create a `Template`
66
+ ## Hello Email
222
67
 
223
68
  ```ruby
224
- template = SendGrid::Template.new('MY_TEMPLATE_ID')
225
- ```
226
-
227
- Create a `Client`
228
-
229
- ```ruby
230
- client = SendGrid::Client.new(api_user: my_user, api_key: my_key)
231
- ```
69
+ require 'sendgrid-ruby'
232
70
 
233
- Initialize mail defaults and create the `TemplateMailer`
71
+ from = Email.new(email: 'test@example.com')
72
+ subject = 'Hello World from the SendGrid Ruby Library'
73
+ to = Email.new(email: 'test@example.com')
74
+ content = Content.new(type: 'text/plain', value: 'some text here')
75
+ mail = Mail.new(from, subject, to, content)
234
76
 
235
- ```ruby
236
- mail_defaults = {
237
- from: 'admin@email.com',
238
- html: '<h1>I like email</h1>',
239
- text: 'I like email',
240
- subject: 'Email is great',
241
- }
242
-
243
- mailer = SendGrid::TemplateMailer.new(client, template, recipients)
77
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
78
+ response = sg.client.mail._('send').post(request_body: mail.to_json)
79
+ puts response.status_code
80
+ puts response.body
81
+ puts response.headers
244
82
  ```
245
83
 
246
- Mail it!
84
+ ## General v3 Web API Usage
247
85
 
248
86
  ```ruby
249
- mailer.mail(mail_defaults)
87
+ require 'sendgrid-ruby'
88
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
89
+ response = sg.client.api_keys.get()
90
+ puts response.status_code
91
+ puts response.body
92
+ puts response.headers
250
93
  ```
251
94
 
252
- ## Using SendGrid's X-SMTPAPI Header
253
-
254
- <blockquote>
255
- To utilize the X-SMTPAPI header, we have directly integrated the <a href="https://github.com/SendGridJP/smtpapi-ruby">SendGridJP/smtpapi-ruby</a> gem.
256
- For more information, view our <a href=https://sendgrid.com/docs/API_Reference/SMTP_API/index.html>SMTPAPI docs page</a>.
257
- </blockquote>
95
+ # Usage
258
96
 
259
- ```ruby
97
+ - [SendGrid Docs](https://sendgrid.com/docs/API_Reference/index.html)
98
+ - [Usage Docs](https://github.com/sendgrid/sendgrid-ruby/tree/master/USAGE.md)
99
+ - [Example Code](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples)
260
100
 
261
- header = Smtpapi::Header.new
262
- header.add_to(['john.doe@example.com', 'jane.doe@example.com'])
263
- header.add_substitution('keep', ['secret']) # sub = {keep: ['secret']}
264
- header.add_substitution('other', ['one', 'two']) # sub = {keep: ['secret'], other: ['one', 'two']}
265
- header.add_unique_arg("unique_code", "8675309")
266
- header.add_category("Newsletter")
267
- header.add_filter('templates', 'enable', 1) # necessary for each time the template engine is used
268
- header.add_filter('templates', 'template_id', '1234-5678-9100-abcd')
269
- header.set_ip_pool("marketing_ip_pool")
270
- mail.smtpapi = header
101
+ ## Roadmap
271
102
 
272
- ```
273
- ## Testing ##
103
+ If you are interested in the future direction of this project, please take a look at our [milestones](
104
+ ). We would love to hear your feedback.
274
105
 
275
- `bundle exec rake test`
106
+ ## How to Contribute
276
107
 
277
- ## Deploying ##
108
+ We encourage contribution to our libraries, please see our [CONTRIBUTING](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md) guide for details.
278
109
 
279
- 1. Confirm tests pass `bundle exec rake test`
280
- 2. Bump the version in `lib/sendgrid/version.rb` and `spec/lib/sendgrid_spec.rb`
281
- 3. Update CHANGELOG.md
282
- 4. Commit Version bump vX.X.X
283
- 5. `rake release`
284
- 6. Push changes to GitHub
285
- 7. Release tag on GitHub vX.X.X
110
+ - [Feature Request](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#feature_request)
111
+ - [Bug Reports](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#submit_a_bug_report)
112
+ - [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#cla)
113
+ - [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#improvements_to_the_codebase)
286
114
 
287
- ## Contributing ##
115
+ # About
288
116
 
289
- 1. Fork it ( https://github.com/[my-github-username]/sendgrid-ruby/fork )
290
- 2. Create your feature branch (`git checkout -b my-new-feature`)
291
- 3. Commit your changes (`git commit -am 'Add some feature'`)
292
- 4. Push to the branch (`git push origin my-new-feature`)
293
- 5. Create a new Pull Request
117
+ sendgrid-ruby is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
294
118
 
295
- ***Hit up [@rbin](http://twitter.com/rbin) or [@sendgrid](http://twitter.com/sendgrid) on Twitter with any issues.***
119
+ sendgrid-ruby is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-ruby are trademarks of SendGrid, Inc.
296
120
 
121
+ ![SendGrid Logo]
122
+ (https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)