sendgrid-ruby 4.3.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/CHANGELOG.md +20 -1
  4. data/README.md +4 -4
  5. data/USE_CASES.md +5 -5
  6. data/examples/helpers/mail/example.rb +37 -37
  7. data/lib/sendgrid-ruby.rb +20 -0
  8. data/lib/sendgrid/helpers/mail/asm.rb +33 -0
  9. data/lib/sendgrid/helpers/mail/attachment.rb +63 -0
  10. data/lib/sendgrid/helpers/mail/bcc_settings.rb +33 -0
  11. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +43 -0
  12. data/lib/sendgrid/helpers/mail/category.rb +28 -0
  13. data/lib/sendgrid/helpers/mail/click_tracking.rb +33 -0
  14. data/lib/sendgrid/helpers/mail/content.rb +33 -0
  15. data/lib/sendgrid/helpers/mail/custom_arg.rb +24 -0
  16. data/lib/sendgrid/helpers/mail/email.rb +33 -0
  17. data/lib/sendgrid/helpers/mail/footer.rb +43 -0
  18. data/lib/sendgrid/helpers/mail/ganalytics.rb +74 -0
  19. data/lib/sendgrid/helpers/mail/header.rb +24 -0
  20. data/lib/sendgrid/helpers/mail/mail.rb +30 -857
  21. data/lib/sendgrid/helpers/mail/mail_settings.rb +63 -0
  22. data/lib/sendgrid/helpers/mail/open_tracking.rb +33 -0
  23. data/lib/sendgrid/helpers/mail/personalization.rb +75 -0
  24. data/lib/sendgrid/helpers/mail/section.rb +24 -0
  25. data/lib/sendgrid/helpers/mail/spam_check.rb +43 -0
  26. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +53 -0
  27. data/lib/sendgrid/helpers/mail/substitution.rb +24 -0
  28. data/lib/sendgrid/helpers/mail/tracking_settings.rb +53 -0
  29. data/lib/sendgrid/version.rb +1 -1
  30. data/test/sendgrid/helpers/mail/test_category.rb +27 -0
  31. data/test/sendgrid/helpers/mail/test_mail.rb +170 -52
  32. data/test/sendgrid/helpers/mail/test_personalizations.rb +146 -0
  33. data/test/sendgrid/test_sendgrid-ruby.rb +1 -1
  34. metadata +27 -3
@@ -0,0 +1,146 @@
1
+ require_relative '../../../../lib/sendgrid/helpers/mail/personalization'
2
+ require 'minitest/autorun'
3
+
4
+ class TestPersonalization < Minitest::Test
5
+
6
+ include SendGrid
7
+
8
+ def test_add_to
9
+ @personalization = Personalization.new()
10
+ @personalization.add_to(Email.new(email: 'test1@example.com', name: 'Example User'))
11
+ expected_json = {
12
+ "to"=>[
13
+ {
14
+ "email"=>"test1@example.com",
15
+ "name"=>"Example User"
16
+ }
17
+ ]
18
+ }
19
+ @personalization.add_to(Email.new(email: 'test2@example.com', name: 'Example User 2'))
20
+ expected_json = {
21
+ "to"=>[
22
+ {
23
+ "email"=>"test1@example.com",
24
+ "name"=>"Example User"
25
+ },
26
+ {
27
+ "email"=>"test2@example.com",
28
+ "name"=>"Example User 2"
29
+ }
30
+ ]
31
+ }
32
+ assert_equal @personalization.to_json, expected_json
33
+ end
34
+
35
+ def test_add_cc
36
+ @personalization = Personalization.new()
37
+ @personalization.add_cc(Email.new(email: 'test1@example.com', name: 'Example User'))
38
+ expected_json = {
39
+ "cc"=>[
40
+ {
41
+ "email"=>"test1@example.com",
42
+ "name"=>"Example User"
43
+ }
44
+ ]
45
+ }
46
+ @personalization.add_cc(Email.new(email: 'test2@example.com', name: 'Example User 2'))
47
+ expected_json = {
48
+ "cc"=>[
49
+ {
50
+ "email"=>"test1@example.com",
51
+ "name"=>"Example User"
52
+ },
53
+ {
54
+ "email"=>"test2@example.com",
55
+ "name"=>"Example User 2"
56
+ }
57
+ ]
58
+ }
59
+ assert_equal @personalization.to_json, expected_json
60
+ end
61
+
62
+ def test_add_bcc
63
+ @personalization = Personalization.new()
64
+ @personalization.add_bcc(Email.new(email: 'test1@example.com', name: 'Example User'))
65
+ expected_json = {
66
+ "bcc"=>[
67
+ {
68
+ "email"=>"test1@example.com",
69
+ "name"=>"Example User"
70
+ }
71
+ ]
72
+ }
73
+ @personalization.add_bcc(Email.new(email: 'test2@example.com', name: 'Example User 2'))
74
+ expected_json = {
75
+ "bcc"=>[
76
+ {
77
+ "email"=>"test1@example.com",
78
+ "name"=>"Example User"
79
+ },
80
+ {
81
+ "email"=>"test2@example.com",
82
+ "name"=>"Example User 2"
83
+ }
84
+ ]
85
+ }
86
+ assert_equal @personalization.to_json, expected_json
87
+ end
88
+
89
+ def test_add_header
90
+ @personalization = Personalization.new()
91
+ @personalization.add_header(Header.new(key: 'X-Test', value: 'True'))
92
+ expected_json = {
93
+ "headers"=>{
94
+ "X-Test"=>"True"
95
+ }
96
+ }
97
+ assert_equal @personalization.to_json, expected_json
98
+ @personalization.add_header(Header.new(key: 'X-Test 1', value: 'False'))
99
+ expected_json = {
100
+ "headers"=>{
101
+ "X-Test"=>"True",
102
+ "X-Test 1"=>"False"
103
+ }
104
+ }
105
+ assert_equal @personalization.to_json, expected_json
106
+ end
107
+
108
+ def test_add_substitution
109
+ @personalization = Personalization.new()
110
+ @personalization.add_substitution(Substitution.new(key: '%name%', value: 'Example User'))
111
+ expected_json = {
112
+ "substitutions"=>{
113
+ "%name%"=>"Example User"
114
+ }
115
+ }
116
+ assert_equal @personalization.to_json, expected_json
117
+ @personalization.add_substitution(Substitution.new(key: '%name 1%', value: 'Example User 1'))
118
+ expected_json = {
119
+ "substitutions"=>{
120
+ "%name%"=>"Example User",
121
+ "%name 1%"=>"Example User 1"
122
+ }
123
+ }
124
+ assert_equal @personalization.to_json, expected_json
125
+ end
126
+
127
+ def test_add_custom_arg
128
+ @personalization = Personalization.new()
129
+ @personalization.add_custom_arg(CustomArg.new(key: 'user_id', value: '343'))
130
+ expected_json = {
131
+ "custom_args"=>{
132
+ "user_id"=>"343"
133
+ }
134
+ }
135
+ assert_equal @personalization.to_json, expected_json
136
+ @personalization.add_custom_arg(CustomArg.new(key: 'city', value: 'denver'))
137
+ expected_json = {
138
+ "custom_args"=>{
139
+ "user_id"=>"343",
140
+ "city"=>"denver"
141
+ }
142
+ }
143
+ assert_equal @personalization.to_json, expected_json
144
+ end
145
+
146
+ end
@@ -55,7 +55,7 @@ class TestAPI < MiniTest::Test
55
55
  ')
56
56
  assert_equal(test_headers, sg.request_headers)
57
57
  assert_equal("v3", sg.version)
58
- assert_equal("4.3.3", SendGrid::VERSION)
58
+ assert_equal("5.0.0", SendGrid::VERSION)
59
59
  assert_instance_of(SendGrid::Client, sg.client)
60
60
  end
61
61
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.3
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elmer Thomas
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-05-02 00:00:00.000000000 Z
13
+ date: 2017-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_http_client
@@ -175,7 +175,27 @@ files:
175
175
  - lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt
176
176
  - lib/sendgrid/helpers/inbound/send.rb
177
177
  - lib/sendgrid/helpers/mail/README.md
178
+ - lib/sendgrid/helpers/mail/asm.rb
179
+ - lib/sendgrid/helpers/mail/attachment.rb
180
+ - lib/sendgrid/helpers/mail/bcc_settings.rb
181
+ - lib/sendgrid/helpers/mail/bypass_list_management.rb
182
+ - lib/sendgrid/helpers/mail/category.rb
183
+ - lib/sendgrid/helpers/mail/click_tracking.rb
184
+ - lib/sendgrid/helpers/mail/content.rb
185
+ - lib/sendgrid/helpers/mail/custom_arg.rb
186
+ - lib/sendgrid/helpers/mail/email.rb
187
+ - lib/sendgrid/helpers/mail/footer.rb
188
+ - lib/sendgrid/helpers/mail/ganalytics.rb
189
+ - lib/sendgrid/helpers/mail/header.rb
178
190
  - lib/sendgrid/helpers/mail/mail.rb
191
+ - lib/sendgrid/helpers/mail/mail_settings.rb
192
+ - lib/sendgrid/helpers/mail/open_tracking.rb
193
+ - lib/sendgrid/helpers/mail/personalization.rb
194
+ - lib/sendgrid/helpers/mail/section.rb
195
+ - lib/sendgrid/helpers/mail/spam_check.rb
196
+ - lib/sendgrid/helpers/mail/subscription_tracking.rb
197
+ - lib/sendgrid/helpers/mail/substitution.rb
198
+ - lib/sendgrid/helpers/mail/tracking_settings.rb
179
199
  - lib/sendgrid/helpers/settings/README.md
180
200
  - lib/sendgrid/helpers/settings/mail_settings_dto.rb
181
201
  - lib/sendgrid/helpers/settings/partner_settings_dto.rb
@@ -191,7 +211,9 @@ files:
191
211
  - spec/sendgrid/helpers/settings/user_settings_dto_spec.rb
192
212
  - spec/spec_helper.rb
193
213
  - test/prism.sh
214
+ - test/sendgrid/helpers/mail/test_category.rb
194
215
  - test/sendgrid/helpers/mail/test_mail.rb
216
+ - test/sendgrid/helpers/mail/test_personalizations.rb
195
217
  - test/sendgrid/test_sendgrid-ruby.rb
196
218
  homepage: http://github.com/sendgrid/sendgrid-ruby
197
219
  licenses:
@@ -213,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
235
  version: '0'
214
236
  requirements: []
215
237
  rubyforge_project:
216
- rubygems_version: 2.6.10
238
+ rubygems_version: 2.6.8
217
239
  signing_key:
218
240
  specification_version: 4
219
241
  summary: Official SendGrid Gem
@@ -225,5 +247,7 @@ test_files:
225
247
  - spec/sendgrid/helpers/settings/user_settings_dto_spec.rb
226
248
  - spec/spec_helper.rb
227
249
  - test/prism.sh
250
+ - test/sendgrid/helpers/mail/test_category.rb
228
251
  - test/sendgrid/helpers/mail/test_mail.rb
252
+ - test/sendgrid/helpers/mail/test_personalizations.rb
229
253
  - test/sendgrid/test_sendgrid-ruby.rb