sendgrid-ruby 5.3.0 → 6.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/pr-lint.yml +15 -0
  3. data/.github/workflows/test-and-deploy.yml +120 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +8 -0
  6. data/.rubocop_todo.yml +127 -0
  7. data/CHANGELOG.md +261 -8
  8. data/CODE_OF_CONDUCT.md +57 -25
  9. data/CONTRIBUTING.md +24 -71
  10. data/Dockerfile +14 -0
  11. data/FIRST_TIMERS.md +53 -0
  12. data/Gemfile +0 -1
  13. data/LICENSE +21 -0
  14. data/Makefile +14 -0
  15. data/PULL_REQUEST_TEMPLATE.md +31 -0
  16. data/README.md +39 -43
  17. data/Rakefile +3 -4
  18. data/TROUBLESHOOTING.md +41 -21
  19. data/UPGRADE.md +5 -0
  20. data/USAGE.md +1231 -1122
  21. data/examples/accesssettings/accesssettings.rb +9 -12
  22. data/examples/alerts/alerts.rb +8 -11
  23. data/examples/apikeys/apikeys.rb +12 -15
  24. data/examples/asm/asm.rb +27 -30
  25. data/examples/browsers/browsers.rb +0 -3
  26. data/examples/campaigns/campaigns.rb +29 -32
  27. data/examples/categories/categories.rb +0 -3
  28. data/examples/clients/clients.rb +1 -4
  29. data/examples/contactdb/contactdb.rb +63 -66
  30. data/examples/dataresidency/setregion.rb +48 -0
  31. data/examples/devices/devices.rb +0 -3
  32. data/examples/emailactivity/emailactivity.rb +52 -0
  33. data/examples/geo/geo.rb +0 -3
  34. data/examples/helpers/eventwebhook/example.rb +16 -0
  35. data/examples/helpers/mail/example.rb +30 -19
  36. data/examples/helpers/settings/example.rb +1 -1
  37. data/examples/helpers/stats/example.rb +4 -4
  38. data/examples/ips/ips.rb +31 -21
  39. data/examples/mail/mail.rb +73 -76
  40. data/examples/mailboxproviders/mailboxproviders.rb +0 -3
  41. data/examples/mailsettings/mailsettings.rb +21 -24
  42. data/examples/partnersettings/partnersettings.rb +3 -6
  43. data/examples/scopes/scopes.rb +49 -5
  44. data/examples/{whitelabel/whitelabel.rb → senderauthentication/senderauthentication.rb} +68 -71
  45. data/examples/senders/senders.rb +28 -31
  46. data/examples/stats/stats.rb +0 -3
  47. data/examples/subusers/subusers.rb +17 -20
  48. data/examples/suppression/suppression.rb +23 -26
  49. data/examples/templates/templates.rb +29 -31
  50. data/examples/trackingsettings/trackingsettings.rb +14 -17
  51. data/examples/user/user.rb +41 -44
  52. data/lib/rack/sendgrid_webhook_verification.rb +55 -0
  53. data/lib/sendgrid/base_interface.rb +57 -0
  54. data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +50 -0
  55. data/lib/sendgrid/helpers/inbound/README.md +26 -9
  56. data/lib/sendgrid/helpers/inbound/app.rb +15 -3
  57. data/lib/sendgrid/helpers/inbound/public/index.html +2 -2
  58. data/lib/sendgrid/helpers/inbound/sample_data/default_data.txt +2 -2
  59. data/lib/sendgrid/helpers/inbound/sample_data/raw_data.txt +2 -2
  60. data/lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt +2 -2
  61. data/lib/sendgrid/helpers/inbound/send.rb +5 -5
  62. data/lib/sendgrid/helpers/ip_management/ip_management.rb +17 -0
  63. data/lib/sendgrid/helpers/mail/README.md +4 -4
  64. data/lib/sendgrid/helpers/mail/asm.rb +4 -18
  65. data/lib/sendgrid/helpers/mail/attachment.rb +30 -38
  66. data/lib/sendgrid/helpers/mail/bcc_settings.rb +4 -18
  67. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +6 -18
  68. data/lib/sendgrid/helpers/mail/category.rb +2 -12
  69. data/lib/sendgrid/helpers/mail/click_tracking.rb +4 -18
  70. data/lib/sendgrid/helpers/mail/content.rb +4 -18
  71. data/lib/sendgrid/helpers/mail/custom_arg.rb +4 -10
  72. data/lib/sendgrid/helpers/mail/email.rb +10 -20
  73. data/lib/sendgrid/helpers/mail/footer.rb +5 -27
  74. data/lib/sendgrid/helpers/mail/ganalytics.rb +9 -55
  75. data/lib/sendgrid/helpers/mail/header.rb +4 -10
  76. data/lib/sendgrid/helpers/mail/mail.rb +37 -87
  77. data/lib/sendgrid/helpers/mail/mail_settings.rb +7 -25
  78. data/lib/sendgrid/helpers/mail/open_tracking.rb +4 -18
  79. data/lib/sendgrid/helpers/mail/personalization.rb +38 -27
  80. data/lib/sendgrid/helpers/mail/section.rb +4 -10
  81. data/lib/sendgrid/helpers/mail/spam_check.rb +5 -27
  82. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +6 -36
  83. data/lib/sendgrid/helpers/mail/substitution.rb +4 -10
  84. data/lib/sendgrid/helpers/mail/tracking_settings.rb +6 -20
  85. data/lib/sendgrid/helpers/permissions/scope.rb +28 -0
  86. data/lib/sendgrid/helpers/permissions/scopes.yml +309 -0
  87. data/lib/sendgrid/helpers/settings/README.md +3 -3
  88. data/lib/sendgrid/helpers/settings/settings.rb +1 -1
  89. data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
  90. data/lib/sendgrid/helpers/stats/metrics.rb +5 -7
  91. data/lib/sendgrid/helpers/stats/stats_response.rb +1 -3
  92. data/lib/sendgrid/sendgrid.rb +21 -0
  93. data/lib/sendgrid/twilio_email.rb +21 -0
  94. data/lib/sendgrid/version.rb +1 -1
  95. data/lib/sendgrid-ruby.rb +7 -1
  96. data/mail_helper_v3.md +21 -21
  97. data/sendgrid-ruby.gemspec +12 -12
  98. data/spec/fixtures/event_webhook.rb +22 -0
  99. data/spec/rack/sendgrid_webhook_verification_spec.rb +142 -0
  100. data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +105 -0
  101. data/spec/sendgrid/helpers/ip_management/ip_management_spec.rb +12 -0
  102. data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +3 -3
  103. data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +3 -3
  104. data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
  105. data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +3 -3
  106. data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +3 -3
  107. data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
  108. data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
  109. data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
  110. data/spec/sendgrid/sendgrid_spec.rb +11 -0
  111. data/spec/sendgrid/twilio_email_spec.rb +11 -0
  112. data/spec/spec_helper.rb +3 -1
  113. data/static/img/github-fork.png +0 -0
  114. data/static/img/github-sign-up.png +0 -0
  115. data/test/sendgrid/helpers/mail/test_attachment.rb +33 -0
  116. data/test/sendgrid/helpers/mail/test_category.rb +0 -2
  117. data/test/sendgrid/helpers/mail/test_data_residency.rb +44 -0
  118. data/test/sendgrid/helpers/mail/test_email.rb +17 -10
  119. data/test/sendgrid/helpers/mail/test_mail.rb +126 -119
  120. data/test/sendgrid/helpers/mail/test_personalizations.rb +145 -92
  121. data/test/sendgrid/permissions/test_scopes.rb +36 -0
  122. data/test/sendgrid/test_sendgrid-ruby.rb +1961 -1979
  123. data/twilio_sendgrid_logo.png +0 -0
  124. data/use-cases/README.md +17 -0
  125. data/use-cases/domain-authentication.md +5 -0
  126. data/use-cases/email-statistics.md +52 -0
  127. data/use-cases/legacy-templates.md +98 -0
  128. data/use-cases/personalizations.md +34 -0
  129. data/use-cases/sms.md +39 -0
  130. data/use-cases/transactional-templates.md +111 -0
  131. data/use-cases/twilio-email.md +13 -0
  132. data/use-cases/twilio-setup.md +54 -0
  133. metadata +99 -45
  134. data/.codeclimate.yml +0 -21
  135. data/.github/ISSUE_TEMPLATE +0 -17
  136. data/.github/PULL_REQUEST_TEMPLATE +0 -24
  137. data/.travis.yml +0 -29
  138. data/LICENSE.txt +0 -22
  139. data/USE_CASES.md +0 -147
  140. data/docker/Dockerfile +0 -12
  141. data/docker/README.md +0 -30
  142. data/lib/sendgrid/client.rb +0 -35
  143. data/test/prism.sh +0 -42
@@ -2,6 +2,8 @@ require 'json'
2
2
 
3
3
  module SendGrid
4
4
  class SubscriptionTracking
5
+ attr_accessor :enable, :text, :html, :substitution_tag
6
+
5
7
  def initialize(enable: nil, text: nil, html: nil, substitution_tag: nil)
6
8
  @enable = enable
7
9
  @text = text
@@ -9,44 +11,12 @@ module SendGrid
9
11
  @substitution_tag = substitution_tag
10
12
  end
11
13
 
12
- def enable=(enable)
13
- @enable = enable
14
- end
15
-
16
- def enable
17
- @enable
18
- end
19
-
20
- def text=(text)
21
- @text = text
22
- end
23
-
24
- def text
25
- @text
26
- end
27
-
28
- def html=(html)
29
- @html = html
30
- end
31
-
32
- def html
33
- @html
34
- end
35
-
36
- def substitution_tag=(substitution_tag)
37
- @substitution_tag = substitution_tag
38
- end
39
-
40
- def substitution_tag
41
- @substitution_tag
42
- end
43
-
44
14
  def to_json(*)
45
15
  {
46
- 'enable' => self.enable,
47
- 'text' => self.text,
48
- 'html' => self.html,
49
- 'substitution_tag' => self.substitution_tag
16
+ 'enable' => enable,
17
+ 'text' => text,
18
+ 'html' => html,
19
+ 'substitution_tag' => substitution_tag
50
20
  }.delete_if { |_, value| value.to_s.strip == '' }
51
21
  end
52
22
  end
@@ -2,22 +2,16 @@ require 'json'
2
2
 
3
3
  module SendGrid
4
4
  class Substitution
5
+ attr_accessor :substitution
6
+
5
7
  def initialize(key: nil, value: nil)
6
8
  @substitution = {}
7
- (key.nil? || value.nil?) ? @substitution = nil : @substitution[key] = value
8
- end
9
-
10
- def substitution=(substitution)
11
- @substitution = substitution
12
- end
13
-
14
- def substitution
15
- @substitution
9
+ key.nil? || value.nil? ? @substitution = nil : @substitution[key] = value
16
10
  end
17
11
 
18
12
  def to_json(*)
19
13
  {
20
- 'substitution' => self.substitution
14
+ 'substitution' => substitution
21
15
  }.delete_if { |_, value| value.to_s.strip == '' }
22
16
  end
23
17
  end
@@ -2,6 +2,8 @@ require 'json'
2
2
 
3
3
  module SendGrid
4
4
  class TrackingSettings
5
+ attr_writer :click_tracking, :open_tracking, :subscription_tracking, :ganalytics
6
+
5
7
  def initialize
6
8
  @click_tracking = nil
7
9
  @open_tracking = nil
@@ -9,44 +11,28 @@ module SendGrid
9
11
  @ganalytics = nil
10
12
  end
11
13
 
12
- def click_tracking=(click_tracking)
13
- @click_tracking = click_tracking
14
- end
15
-
16
14
  def click_tracking
17
15
  @click_tracking.nil? ? nil : @click_tracking.to_json
18
16
  end
19
17
 
20
- def open_tracking=(open_tracking)
21
- @open_tracking = open_tracking
22
- end
23
-
24
18
  def open_tracking
25
19
  @open_tracking.nil? ? nil : @open_tracking.to_json
26
20
  end
27
21
 
28
- def subscription_tracking=(subscription_tracking)
29
- @subscription_tracking = subscription_tracking
30
- end
31
-
32
22
  def subscription_tracking
33
23
  @subscription_tracking.nil? ? nil : @subscription_tracking.to_json
34
24
  end
35
25
 
36
- def ganalytics=(ganalytics)
37
- @ganalytics = ganalytics
38
- end
39
-
40
26
  def ganalytics
41
27
  @ganalytics.nil? ? nil : @ganalytics.to_json
42
28
  end
43
29
 
44
30
  def to_json(*)
45
31
  {
46
- 'click_tracking' => self.click_tracking,
47
- 'open_tracking' => self.open_tracking,
48
- 'subscription_tracking' => self.subscription_tracking,
49
- 'ganalytics' => self.ganalytics
32
+ 'click_tracking' => click_tracking,
33
+ 'open_tracking' => open_tracking,
34
+ 'subscription_tracking' => subscription_tracking,
35
+ 'ganalytics' => ganalytics
50
36
  }.delete_if { |_, value| value.to_s.strip == '' }
51
37
  end
52
38
  end
@@ -0,0 +1,28 @@
1
+ # This is used for getting scopes
2
+ require 'yaml'
3
+
4
+ module SendGrid
5
+ class Scope
6
+ SCOPES = YAML.load_file("#{File.dirname(__FILE__)}/scopes.yml").freeze
7
+
8
+ class << self
9
+ def admin_permissions
10
+ SCOPES.values.map(&:values).flatten
11
+ end
12
+
13
+ def read_only_permissions
14
+ SCOPES.map { |_, v| v[:read] }.flatten
15
+ end
16
+
17
+ SCOPES.each_key do |endpoint|
18
+ define_method "#{endpoint}_read_only_permissions" do
19
+ SCOPES[endpoint][:read]
20
+ end
21
+
22
+ define_method "#{endpoint}_full_access_permissions" do
23
+ SCOPES[endpoint].values.flatten
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,309 @@
1
+ ---
2
+ :alerts:
3
+ :create:
4
+ - alerts.create
5
+ :delete:
6
+ - alerts.delete
7
+ :read:
8
+ - alerts.read
9
+ :update:
10
+ - alerts.update
11
+ :api_keys:
12
+ :create:
13
+ - api_keys.create
14
+ :delete:
15
+ - api_keys.delete
16
+ :read:
17
+ - api_keys.read
18
+ :update:
19
+ - api_keys.update
20
+ :asm_groups:
21
+ :create:
22
+ - asm.groups.create
23
+ :delete:
24
+ - asm.groups.delete
25
+ :read:
26
+ - asm.groups.read
27
+ :update:
28
+ - asm.groups.update
29
+ :billing:
30
+ :create:
31
+ - billing.create
32
+ :delete:
33
+ - billing.delete
34
+ :read:
35
+ - billing.read
36
+ :update:
37
+ - billing.update
38
+ :categories:
39
+ :create:
40
+ - categories.create
41
+ :delete:
42
+ - categories.delete
43
+ :read:
44
+ - categories.read
45
+ - categories.stats.read
46
+ - categories.stats.sums.read
47
+ :update:
48
+ - categories.update
49
+ :credentials:
50
+ :create:
51
+ - credentials.create
52
+ :delete:
53
+ - credentials.delete
54
+ :read:
55
+ - credentials.read
56
+ :update:
57
+ - credentials.update
58
+ :stats:
59
+ :create: []
60
+ :delete: []
61
+ :read:
62
+ - email_activity.read
63
+ - stats.read
64
+ - stats.global.read
65
+ - browsers.stats.read
66
+ - devices.stats.read
67
+ - geo.stats.read
68
+ - mailbox_providers.stats.read
69
+ - clients.desktop.stats.read
70
+ - clients.phone.stats.read
71
+ - clients.stats.read
72
+ - clients.tablet.stats.read
73
+ - clients.webmail.stats.read
74
+ :update: []
75
+ :ips:
76
+ :create:
77
+ - ips.pools.create
78
+ - ips.pools.ips.create
79
+ - ips.warmup.create
80
+ :delete:
81
+ - ips.pools.delete
82
+ - ips.pools.ips.delete
83
+ - ips.warmup.delete
84
+ :read:
85
+ - ips.assigned.read
86
+ - ips.read
87
+ - ips.pools.read
88
+ - ips.pools.ips.read
89
+ - ips.warmup.read
90
+ :update:
91
+ - ips.pools.update
92
+ - ips.pools.ips.update
93
+ - ips.warmup.update
94
+ :mail_settings:
95
+ :create: []
96
+ :delete: []
97
+ :read:
98
+ - mail_settings.address_whitelist.read
99
+ - mail_settings.bcc.read
100
+ - mail_settings.bounce_purge.read
101
+ - mail_settings.footer.read
102
+ - mail_settings.forward_bounce.read
103
+ - mail_settings.forward_spam.read
104
+ - mail_settings.plain_content.read
105
+ - mail_settings.read
106
+ - mail_settings.spam_check.read
107
+ - mail_settings.template.read
108
+ :update:
109
+ - mail_settings.address_whitelist.update
110
+ - mail_settings.bcc.update
111
+ - mail_settings.bounce_purge.update
112
+ - mail_settings.footer.update
113
+ - mail_settings.forward_bounce.update
114
+ - mail_settings.forward_spam.update
115
+ - mail_settings.plain_content.update
116
+ - mail_settings.spam_check.update
117
+ - mail_settings.template.update
118
+ :mail:
119
+ :create:
120
+ - mail.send
121
+ - mail.batch.create
122
+ :delete:
123
+ - mail.batch.delete
124
+ :read:
125
+ - mail.batch.read
126
+ :update:
127
+ - mail.batch.update
128
+ :marketing_campaigns:
129
+ :create:
130
+ - marketing_campaigns.create
131
+ :delete:
132
+ - marketing_campaigns.delete
133
+ :read:
134
+ - marketing_campaigns.read
135
+ :update:
136
+ - marketing_campaigns.update
137
+ :partner_settings:
138
+ :create: []
139
+ :delete: []
140
+ :read:
141
+ - partner_settings.new_relic.read
142
+ - partner_settings.read
143
+ - partner_settings.sendwithus.read
144
+ :update:
145
+ - partner_settings.new_relic.update
146
+ - partner_settings.sendwithus.update
147
+ :scheduled_sends:
148
+ :create:
149
+ - user.scheduled_sends.create
150
+ :delete:
151
+ - user.scheduled_sends.delete
152
+ :read:
153
+ - user.scheduled_sends.read
154
+ :update:
155
+ - user.scheduled_sends.update
156
+ :subusers:
157
+ :create:
158
+ - subusers.create
159
+ - subusers.credits.create
160
+ - subusers.credits.remaining.create
161
+ - subusers.monitor.create
162
+ :delete:
163
+ - subusers.delete
164
+ - subusers.credits.delete
165
+ - subusers.credits.remaining.delete
166
+ - subusers.monitor.delete
167
+ :read:
168
+ - subusers.read
169
+ - subusers.credits.read
170
+ - subusers.stats.read
171
+ - subusers.credits.remaining.read
172
+ - subusers.monitor.read
173
+ - subusers.reputations.read
174
+ - subusers.stats.monthly.read
175
+ - subusers.stats.sums.read
176
+ - subusers.summary.read
177
+ :update:
178
+ - subusers.update
179
+ - subusers.credits.update
180
+ - subusers.credits.remaining.update
181
+ - subusers.monitor.update
182
+ :suppression:
183
+ :create:
184
+ - suppression.create
185
+ - suppression.bounces.create
186
+ - suppression.blocks.create
187
+ - suppression.invalid_emails.create
188
+ - suppression.spam_reports.create
189
+ - suppression.unsubscribes.create
190
+ :delete:
191
+ - suppression.delete
192
+ - suppression.bounces.delete
193
+ - suppression.blocks.delete
194
+ - suppression.invalid_emails.delete
195
+ - suppression.spam_reports.delete
196
+ - suppression.unsubscribes.delete
197
+ :read:
198
+ - suppression.read
199
+ - suppression.bounces.read
200
+ - suppression.blocks.read
201
+ - suppression.invalid_emails.read
202
+ - suppression.spam_reports.read
203
+ - suppression.unsubscribes.read
204
+ :update:
205
+ - suppression.update
206
+ - suppression.bounces.update
207
+ - suppression.blocks.update
208
+ - suppression.invalid_emails.update
209
+ - suppression.spam_reports.update
210
+ - suppression.unsubscribes.update
211
+ :teammates:
212
+ :create:
213
+ - teammates.create
214
+ :delete:
215
+ - teammates.delete
216
+ :read:
217
+ - teammates.read
218
+ :update:
219
+ - teammates.update
220
+ :templates:
221
+ :create:
222
+ - templates.create
223
+ - templates.versions.activate.create
224
+ - templates.versions.create
225
+ :delete:
226
+ - templates.delete
227
+ - templates.versions.activate.delete
228
+ - templates.versions.delete
229
+ :read:
230
+ - templates.read
231
+ - templates.versions.activate.read
232
+ - templates.versions.read
233
+ :update:
234
+ - templates.update
235
+ - templates.versions.activate.update
236
+ - templates.versions.update
237
+ :tracking_settings:
238
+ :create: []
239
+ :delete: []
240
+ :read:
241
+ - tracking_settings.click.read
242
+ - tracking_settings.google_analytics.read
243
+ - tracking_settings.open.read
244
+ - tracking_settings.read
245
+ - tracking_settings.subscription.read
246
+ :update:
247
+ - tracking_settings.click.update
248
+ - tracking_settings.google_analytics.update
249
+ - tracking_settings.open.update
250
+ - tracking_settings.subscription.update
251
+ :user_settings:
252
+ :create:
253
+ - user.email.create
254
+ - user.multifactor_authentication.create
255
+ :delete:
256
+ - user.email.delete
257
+ - user.multifactor_authentication.delete
258
+ :read:
259
+ - user.account.read
260
+ - user.credits.read
261
+ - user.email.read
262
+ - user.multifactor_authentication.read
263
+ - user.password.read
264
+ - user.profile.read
265
+ - user.timezone.read
266
+ - user.settings.enforced_tls.read
267
+ - user.username.read
268
+ :update:
269
+ - user.email.update
270
+ - user.multifactor_authentication.update
271
+ - user.password.update
272
+ - user.profile.update
273
+ - user.settings.enforced_tls.update
274
+ - user.timezone.update
275
+ - user.username.update
276
+ :webhooks:
277
+ :create:
278
+ - user.webhooks.event.test.create
279
+ - user.webhooks.parse.settings.create
280
+ :delete:
281
+ - user.webhooks.parse.settings.delete
282
+ :read:
283
+ - user.webhooks.event.settings.read
284
+ - user.webhooks.event.test.read
285
+ - user.webhooks.parse.settings.read
286
+ - user.webhooks.parse.stats.read
287
+ :update:
288
+ - user.webhooks.event.settings.update
289
+ - user.webhooks.event.test.update
290
+ - user.webhooks.parse.settings.update
291
+ :whitelabel:
292
+ :create:
293
+ - whitelabel.create
294
+ :delete:
295
+ - whitelabel.delete
296
+ :read:
297
+ - whitelabel.read
298
+ :update:
299
+ - whitelabel.update
300
+ :access_settings:
301
+ :create:
302
+ - access_settings.whitelist.create
303
+ :delete:
304
+ - access_settings.whitelist.delete
305
+ :read:
306
+ - access_settings.activity.read
307
+ - access_settings.whitelist.read
308
+ :update:
309
+ - access_settings.whitelist.update
@@ -1,8 +1,8 @@
1
- **This module allows you to quickly and easily build a Settings object for retrieving or updating you SendGrid Settings.**
1
+ **This module allows you to quickly and easily build a Settings object for retrieving or updating your Twilio SendGrid Settings.**
2
2
 
3
3
  # Quick Start
4
4
 
5
- Run the [example](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples/helpers/settings) (make sure you have set your environment variable to include your SENDGRID_API_KEY).
5
+ Run the [example](../../../../examples/helpers/settings) (make sure you have set your environment variable to include your SENDGRID_API_KEY).
6
6
 
7
7
  ```bash
8
8
  ruby examples/helpers/settings/example.rb
@@ -10,5 +10,5 @@ ruby examples/helpers/settings/example.rb
10
10
 
11
11
  ## Usage
12
12
 
13
- - See the [example](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples/helpers/settings) for a complete working example.
13
+ - See the [example](../../../../examples/helpers/settings) for a complete working example.
14
14
  - [Documentation](https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/index.html)
@@ -8,7 +8,7 @@ module SendGrid
8
8
  attr_accessor :sendgrid_client
9
9
 
10
10
  SETTING_TYPES = [SendGrid::MailSettingsDto, SendGrid::TrackingSettingsDto,
11
- SendGrid::PartnerSettingsDto, SendGrid::UserSettingsDto]
11
+ SendGrid::PartnerSettingsDto, SendGrid::UserSettingsDto].freeze
12
12
 
13
13
  def initialize(sendgrid_client:)
14
14
  @sendgrid_client = sendgrid_client
@@ -1,9 +1,9 @@
1
1
  module SendGrid
2
2
  class TrackingSettingsDto
3
3
  attr_reader :open, :click, :google_analytics, :subscription
4
- alias :click_tracking :click
5
- alias :open_tracking :open
6
- alias :subscription_tracking :subscription
4
+ alias click_tracking click
5
+ alias open_tracking open
6
+ alias subscription_tracking subscription
7
7
 
8
8
  def self.fetch(sendgrid_client:, name:, query_params:)
9
9
  name = scrub_alias_names(name.to_s)
@@ -15,8 +15,6 @@ module SendGrid
15
15
  sendgrid_client.tracking_settings.public_send(name).patch(request_body: request_body)
16
16
  end
17
17
 
18
- private
19
-
20
18
  def self.scrub_alias_names(name)
21
19
  name.gsub(/_tracking/, '')
22
20
  end
@@ -1,14 +1,12 @@
1
- require 'json'
2
-
3
1
  module SendGrid
4
2
  class Metrics
5
3
  attr_reader :blocks, :bounce_drops,
6
- :bounces, :clicks, :deferred, :delivered,
7
- :invalid_emails, :opens, :processed, :requests,
8
- :spam_report_drops, :spam_reports, :unique_clicks,
9
- :unique_opens, :unsubscribe_drops, :unsubscribes
4
+ :bounces, :clicks, :deferred, :delivered,
5
+ :invalid_emails, :opens, :processed, :requests,
6
+ :spam_report_drops, :spam_reports, :unique_clicks,
7
+ :unique_opens, :unsubscribe_drops, :unsubscribes
10
8
 
11
- def initialize(args={})
9
+ def initialize(args = {})
12
10
  @date = args['date']
13
11
  @blocks = args['blocks']
14
12
  @bounce_drops = args['bounce_drops']
@@ -1,5 +1,3 @@
1
- require 'json'
2
-
3
1
  module SendGrid
4
2
  class StatsResponse
5
3
  def initialize(args)
@@ -22,7 +20,7 @@ module SendGrid
22
20
  starting_date = stat['date']
23
21
  all_stats_for_date = stat['stats']
24
22
 
25
- metrics = all_stats_for_date.map do |metric|
23
+ all_stats_for_date.map do |metric|
26
24
  Metrics.new(metric['metrics'].merge('date' => starting_date))
27
25
  end
28
26
  end
@@ -0,0 +1,21 @@
1
+ # Quickly and easily access the Twilio SendGrid API.
2
+ module SendGrid
3
+ class API < BaseInterface
4
+ # * *Args* :
5
+ # - +api_key+ -> your Twilio SendGrid API key
6
+ # - +host+ -> the base URL for the API
7
+ # - +request_headers+ -> any headers that you want to be globally applied
8
+ # - +version+ -> the version of the API you wish to access,
9
+ # currently only "v3" is supported
10
+ # - +impersonate_subuser+ -> the subuser to impersonate, will be passed
11
+ # in the "On-Behalf-Of" header
12
+ # - +http_options+ -> http options that you want to be globally applied to each request
13
+ #
14
+ def initialize(api_key:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil, http_options: {})
15
+ auth = "Bearer #{api_key}"
16
+ host ||= 'https://api.sendgrid.com'
17
+
18
+ super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser, http_options: http_options)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # Quickly and easily access the Twilio Email API.
2
+ module TwilioEmail
3
+ class API < BaseInterface
4
+ # * *Args* :
5
+ # - +username+ -> your Twilio Email API key SID or Account SID
6
+ # - +password+ -> your Twilio Email API key secret or Account Auth Token
7
+ # - +host+ -> the base URL for the API
8
+ # - +request_headers+ -> any headers that you want to be globally applied
9
+ # - +version+ -> the version of the API you wish to access,
10
+ # currently only "v3" is supported
11
+ # - +impersonate_subuser+ -> the subuser to impersonate, will be passed
12
+ # in the "On-Behalf-Of" header
13
+ #
14
+ def initialize(username:, password:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil)
15
+ auth = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
16
+ host ||= 'https://email.twilio.com'
17
+
18
+ super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser)
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module SendGrid
2
- VERSION = '5.3.0'
2
+ VERSION = '6.7.0'.freeze
3
3
  end
data/lib/sendgrid-ruby.rb CHANGED
@@ -1,5 +1,9 @@
1
- require_relative 'sendgrid/client'
1
+ require_relative 'sendgrid/base_interface'
2
+ require_relative 'sendgrid/sendgrid'
3
+ require_relative 'sendgrid/twilio_email'
2
4
  require_relative 'sendgrid/version'
5
+ require_relative 'sendgrid/helpers/eventwebhook/eventwebhook'
6
+ require_relative 'sendgrid/helpers/ip_management/ip_management'
3
7
  require_relative 'sendgrid/helpers/mail/asm'
4
8
  require_relative 'sendgrid/helpers/mail/attachment'
5
9
  require_relative 'sendgrid/helpers/mail/bcc_settings'
@@ -25,3 +29,5 @@ require_relative 'sendgrid/helpers/settings/settings'
25
29
  require_relative 'sendgrid/helpers/stats/email_stats'
26
30
  require_relative 'sendgrid/helpers/stats/stats_response'
27
31
  require_relative 'sendgrid/helpers/stats/metrics'
32
+ require_relative 'sendgrid/helpers/permissions/scope'
33
+ require_relative 'rack/sendgrid_webhook_verification'