sendgrid-ruby 6.2.0 → 6.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/config.yml +10 -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 +147 -9
  8. data/CONTRIBUTING.md +11 -21
  9. data/Dockerfile +14 -0
  10. data/FIRST_TIMERS.md +79 -0
  11. data/Gemfile +0 -1
  12. data/ISSUE_TEMPLATE.md +5 -1
  13. data/{LICENSE.md → LICENSE} +1 -1
  14. data/Makefile +9 -2
  15. data/PULL_REQUEST_TEMPLATE.md +5 -5
  16. data/README.md +23 -31
  17. data/Rakefile +2 -3
  18. data/TROUBLESHOOTING.md +17 -5
  19. data/USAGE.md +146 -39
  20. data/examples/accesssettings/accesssettings.rb +9 -12
  21. data/examples/alerts/alerts.rb +8 -11
  22. data/examples/apikeys/apikeys.rb +12 -15
  23. data/examples/asm/asm.rb +27 -30
  24. data/examples/browsers/browsers.rb +0 -3
  25. data/examples/campaigns/campaigns.rb +29 -32
  26. data/examples/categories/categories.rb +0 -3
  27. data/examples/clients/clients.rb +1 -4
  28. data/examples/contactdb/contactdb.rb +63 -66
  29. data/examples/devices/devices.rb +0 -3
  30. data/examples/emailactivity/emailactivity.rb +52 -0
  31. data/examples/geo/geo.rb +0 -3
  32. data/examples/helpers/eventwebhook/example.rb +16 -0
  33. data/examples/helpers/mail/example.rb +24 -13
  34. data/examples/helpers/settings/example.rb +1 -1
  35. data/examples/helpers/stats/example.rb +4 -4
  36. data/examples/ips/ips.rb +19 -22
  37. data/examples/mail/mail.rb +72 -75
  38. data/examples/mailboxproviders/mailboxproviders.rb +0 -3
  39. data/examples/mailsettings/mailsettings.rb +21 -24
  40. data/examples/partnersettings/partnersettings.rb +3 -6
  41. data/examples/scopes/scopes.rb +8 -10
  42. data/examples/senderauthentication/senderauthentication.rb +41 -44
  43. data/examples/senders/senders.rb +28 -31
  44. data/examples/stats/stats.rb +0 -3
  45. data/examples/subusers/subusers.rb +17 -20
  46. data/examples/suppression/suppression.rb +15 -18
  47. data/examples/templates/templates.rb +29 -31
  48. data/examples/trackingsettings/trackingsettings.rb +14 -17
  49. data/examples/user/user.rb +41 -44
  50. data/lib/rack/sendgrid_webhook_verification.rb +55 -0
  51. data/lib/sendgrid/base_interface.rb +8 -4
  52. data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +50 -0
  53. data/lib/sendgrid/helpers/inbound/README.md +5 -5
  54. data/lib/sendgrid/helpers/inbound/app.rb +2 -2
  55. data/lib/sendgrid/helpers/inbound/public/index.html +1 -1
  56. data/lib/sendgrid/helpers/inbound/send.rb +3 -3
  57. data/lib/sendgrid/helpers/ip_management/ip_management.rb +1 -1
  58. data/lib/sendgrid/helpers/mail/README.md +3 -3
  59. data/lib/sendgrid/helpers/mail/asm.rb +6 -18
  60. data/lib/sendgrid/helpers/mail/attachment.rb +12 -42
  61. data/lib/sendgrid/helpers/mail/bcc_settings.rb +6 -18
  62. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +8 -18
  63. data/lib/sendgrid/helpers/mail/category.rb +2 -2
  64. data/lib/sendgrid/helpers/mail/click_tracking.rb +6 -18
  65. data/lib/sendgrid/helpers/mail/content.rb +4 -3
  66. data/lib/sendgrid/helpers/mail/custom_arg.rb +6 -10
  67. data/lib/sendgrid/helpers/mail/email.rb +10 -5
  68. data/lib/sendgrid/helpers/mail/footer.rb +7 -27
  69. data/lib/sendgrid/helpers/mail/ganalytics.rb +10 -54
  70. data/lib/sendgrid/helpers/mail/header.rb +6 -10
  71. data/lib/sendgrid/helpers/mail/mail.rb +32 -48
  72. data/lib/sendgrid/helpers/mail/mail_settings.rb +9 -25
  73. data/lib/sendgrid/helpers/mail/open_tracking.rb +6 -18
  74. data/lib/sendgrid/helpers/mail/personalization.rb +40 -27
  75. data/lib/sendgrid/helpers/mail/section.rb +6 -10
  76. data/lib/sendgrid/helpers/mail/spam_check.rb +7 -27
  77. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +8 -36
  78. data/lib/sendgrid/helpers/mail/substitution.rb +6 -10
  79. data/lib/sendgrid/helpers/mail/tracking_settings.rb +8 -20
  80. data/lib/sendgrid/helpers/permissions/scope.rb +2 -2
  81. data/lib/sendgrid/helpers/settings/README.md +2 -2
  82. data/lib/sendgrid/helpers/settings/settings.rb +1 -1
  83. data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
  84. data/lib/sendgrid/helpers/stats/metrics.rb +5 -5
  85. data/lib/sendgrid/sendgrid.rb +4 -3
  86. data/lib/sendgrid/twilio_email.rb +1 -1
  87. data/lib/sendgrid/version.rb +1 -1
  88. data/lib/sendgrid-ruby.rb +2 -0
  89. data/mail_helper_v3.md +12 -12
  90. data/sendgrid-ruby.gemspec +8 -8
  91. data/spec/fixtures/event_webhook.rb +22 -0
  92. data/spec/rack/sendgrid_webhook_verification_spec.rb +142 -0
  93. data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +105 -0
  94. data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +3 -3
  95. data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +3 -3
  96. data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
  97. data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +3 -3
  98. data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +3 -3
  99. data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
  100. data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
  101. data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
  102. data/spec/spec_helper.rb +3 -1
  103. data/static/img/github-fork.png +0 -0
  104. data/static/img/github-sign-up.png +0 -0
  105. data/test/sendgrid/helpers/mail/test_attachment.rb +4 -6
  106. data/test/sendgrid/helpers/mail/test_category.rb +0 -2
  107. data/test/sendgrid/helpers/mail/test_email.rb +17 -10
  108. data/test/sendgrid/helpers/mail/test_mail.rb +101 -102
  109. data/test/sendgrid/helpers/mail/test_personalizations.rb +145 -92
  110. data/test/sendgrid/permissions/test_scopes.rb +1 -3
  111. data/test/sendgrid/test_sendgrid-ruby.rb +1964 -1986
  112. data/twilio_sendgrid_logo.png +0 -0
  113. data/use-cases/README.md +17 -0
  114. data/use-cases/domain-authentication.md +5 -0
  115. data/use-cases/email-statistics.md +52 -0
  116. data/use-cases/legacy-templates.md +98 -0
  117. data/use-cases/personalizations.md +34 -0
  118. data/use-cases/sms.md +39 -0
  119. data/use-cases/transactional-templates.md +111 -0
  120. data/use-cases/twilio-email.md +13 -0
  121. data/use-cases/twilio-setup.md +54 -0
  122. metadata +69 -34
  123. data/.codeclimate.yml +0 -21
  124. data/.travis.yml +0 -40
  125. data/USE_CASES.md +0 -405
  126. data/docker/Dockerfile +0 -12
  127. data/docker/README.md +0 -30
  128. data/test/prism.sh +0 -42
@@ -1,5 +1,9 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class MailSettings
5
+ attr_writer :sandbox_mode, :footer, :bcc, :spam_check, :bypass_list_management
6
+
3
7
  def initialize
4
8
  @bcc = nil
5
9
  @bypass_list_management = nil
@@ -8,53 +12,33 @@ module SendGrid
8
12
  @spam_check = nil
9
13
  end
10
14
 
11
- def sandbox_mode=(sandbox_mode)
12
- @sandbox_mode = sandbox_mode
13
- end
14
-
15
15
  def sandbox_mode
16
16
  @sandbox_mode.nil? ? nil : @sandbox_mode.to_json
17
17
  end
18
18
 
19
- def bypass_list_management=(bypass_list_management)
20
- @bypass_list_management = bypass_list_management
21
- end
22
-
23
19
  def bypass_list_management
24
20
  @bypass_list_management.nil? ? nil : @bypass_list_management.to_json
25
21
  end
26
22
 
27
- def footer=(footer)
28
- @footer = footer
29
- end
30
-
31
23
  def footer
32
24
  @footer.nil? ? nil : @footer.to_json
33
25
  end
34
26
 
35
- def bcc=(bcc)
36
- @bcc = bcc
37
- end
38
-
39
27
  def bcc
40
28
  @bcc.nil? ? nil : @bcc.to_json
41
29
  end
42
30
 
43
- def spam_check=(spam_check)
44
- @spam_check = spam_check
45
- end
46
-
47
31
  def spam_check
48
32
  @spam_check.nil? ? nil : @spam_check.to_json
49
33
  end
50
34
 
51
35
  def to_json(*)
52
36
  {
53
- 'bcc' => self.bcc,
54
- 'bypass_list_management' => self.bypass_list_management,
55
- 'footer' => self.footer,
56
- 'sandbox_mode' => self.sandbox_mode,
57
- 'spam_check' => self.spam_check
37
+ 'bcc' => bcc,
38
+ 'bypass_list_management' => bypass_list_management,
39
+ 'footer' => footer,
40
+ 'sandbox_mode' => sandbox_mode,
41
+ 'spam_check' => spam_check
58
42
  }.delete_if { |_, value| value.to_s.strip == '' }
59
43
  end
60
44
  end
@@ -1,30 +1,18 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class OpenTracking
3
- def initialize(enable: nil, substitution_tag: nil)
4
- @enable = enable
5
- @substitution_tag = substitution_tag
6
- end
5
+ attr_accessor :enable, :substitution_tag
7
6
 
8
- def enable=(enable)
7
+ def initialize(enable: nil, substitution_tag: nil)
9
8
  @enable = enable
10
- end
11
-
12
- def enable
13
- @enable
14
- end
15
-
16
- def substitution_tag=(substitution_tag)
17
9
  @substitution_tag = substitution_tag
18
10
  end
19
11
 
20
- def substitution_tag
21
- @substitution_tag
22
- end
23
-
24
12
  def to_json(*)
25
13
  {
26
- 'enable' => self.enable,
27
- 'substitution_tag' => self.substitution_tag
14
+ 'enable' => enable,
15
+ 'substitution_tag' => substitution_tag
28
16
  }.delete_if { |_, value| value.to_s.strip == '' }
29
17
  end
30
18
  end
@@ -1,11 +1,15 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class Personalization
5
+ attr_reader :tos, :from, :ccs, :bccs, :headers, :substitutions, :custom_args,
6
+ :dynamic_template_data
3
7
 
4
- attr_reader :tos, :ccs, :bccs, :headers, :substitutions, :custom_args,
5
- :dynamic_template_data
8
+ attr_accessor :send_at, :subject
6
9
 
7
10
  def initialize
8
11
  @tos = []
12
+ @from = nil
9
13
  @ccs = []
10
14
  @bccs = []
11
15
  @subject = nil
@@ -17,23 +21,25 @@ module SendGrid
17
21
  end
18
22
 
19
23
  def add_to(to)
24
+ raise DuplicatePersonalizationError if duplicate?(to)
25
+
20
26
  @tos << to.to_json
21
27
  end
22
28
 
29
+ def add_from(from)
30
+ @from = from.to_json
31
+ end
32
+
23
33
  def add_cc(cc)
34
+ raise DuplicatePersonalizationError if duplicate?(cc)
35
+
24
36
  @ccs << cc.to_json
25
37
  end
26
38
 
27
39
  def add_bcc(bcc)
28
- @bccs << bcc.to_json
29
- end
30
-
31
- def subject=(subject)
32
- @subject = subject
33
- end
40
+ raise DuplicatePersonalizationError if duplicate?(bcc)
34
41
 
35
- def subject
36
- @subject
42
+ @bccs << bcc.to_json
37
43
  end
38
44
 
39
45
  def add_header(header)
@@ -55,26 +61,33 @@ module SendGrid
55
61
  @dynamic_template_data.merge!(dynamic_template_data)
56
62
  end
57
63
 
58
- def send_at=(send_at)
59
- @send_at = send_at
64
+ def to_json(*)
65
+ {
66
+ 'to' => tos,
67
+ 'from' => from,
68
+ 'cc' => ccs,
69
+ 'bcc' => bccs,
70
+ 'subject' => subject,
71
+ 'headers' => headers,
72
+ 'substitutions' => substitutions,
73
+ 'custom_args' => custom_args,
74
+ 'dynamic_template_data' => dynamic_template_data,
75
+ 'send_at' => send_at
76
+ }.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} }
60
77
  end
61
78
 
62
- def send_at
63
- @send_at
64
- end
79
+ private
65
80
 
66
- def to_json(*)
67
- {
68
- 'to' => self.tos,
69
- 'cc' => self.ccs,
70
- 'bcc' => self.bccs,
71
- 'subject' => self.subject,
72
- 'headers' => self.headers,
73
- 'substitutions' => self.substitutions,
74
- 'custom_args' => self.custom_args,
75
- 'dynamic_template_data' => self.dynamic_template_data,
76
- 'send_at' => self.send_at
77
- }.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {}}
81
+ def duplicate?(addition)
82
+ additional_email = addition.email.downcase
83
+
84
+ [@tos, @ccs, @bccs].flatten.each do |elm|
85
+ return true if elm&.dig('email')&.downcase == additional_email
86
+ end
87
+
88
+ false
78
89
  end
79
90
  end
91
+
92
+ class DuplicatePersonalizationError < StandardError; end
80
93
  end
@@ -1,21 +1,17 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class Section
5
+ attr_accessor :section
6
+
3
7
  def initialize(key: nil, value: nil)
4
8
  @section = {}
5
- (key.nil? || value.nil?) ? @section = nil : @section[key] = value
6
- end
7
-
8
- def section=(section)
9
- @section = section
10
- end
11
-
12
- def section
13
- @section
9
+ key.nil? || value.nil? ? @section = nil : @section[key] = value
14
10
  end
15
11
 
16
12
  def to_json(*)
17
13
  {
18
- 'section' => self.section
14
+ 'section' => section
19
15
  }.delete_if { |_, value| value.to_s.strip == '' }
20
16
  end
21
17
  end
@@ -1,40 +1,20 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class SpamCheck
5
+ attr_accessor :enable, :threshold, :post_to_url
6
+
3
7
  def initialize(enable: nil, threshold: nil, post_to_url: nil)
4
8
  @enable = enable
5
9
  @threshold = threshold
6
10
  @post_to_url = post_to_url
7
11
  end
8
12
 
9
- def enable=(enable)
10
- @enable = enable
11
- end
12
-
13
- def enable
14
- @enable
15
- end
16
-
17
- def threshold=(threshold)
18
- @threshold = threshold
19
- end
20
-
21
- def threshold
22
- @threshold
23
- end
24
-
25
- def post_to_url=(post_to_url)
26
- @post_to_url = post_to_url
27
- end
28
-
29
- def post_to_url
30
- @post_to_url
31
- end
32
-
33
13
  def to_json(*)
34
14
  {
35
- 'enable' => self.enable,
36
- 'threshold' => self.threshold,
37
- 'post_to_url' => self.post_to_url
15
+ 'enable' => enable,
16
+ 'threshold' => threshold,
17
+ 'post_to_url' => post_to_url
38
18
  }.delete_if { |_, value| value.to_s.strip == '' }
39
19
  end
40
20
  end
@@ -1,50 +1,22 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class SubscriptionTracking
3
- def initialize(enable: nil, text: nil, html: nil, substitution_tag: nil)
4
- @enable = enable
5
- @text = text
6
- @html = html
7
- @substitution_tag = substitution_tag
8
- end
5
+ attr_accessor :enable, :text, :html, :substitution_tag
9
6
 
10
- def enable=(enable)
7
+ def initialize(enable: nil, text: nil, html: nil, substitution_tag: nil)
11
8
  @enable = enable
12
- end
13
-
14
- def enable
15
- @enable
16
- end
17
-
18
- def text=(text)
19
9
  @text = text
20
- end
21
-
22
- def text
23
- @text
24
- end
25
-
26
- def html=(html)
27
10
  @html = html
28
- end
29
-
30
- def html
31
- @html
32
- end
33
-
34
- def substitution_tag=(substitution_tag)
35
11
  @substitution_tag = substitution_tag
36
12
  end
37
13
 
38
- def substitution_tag
39
- @substitution_tag
40
- end
41
-
42
14
  def to_json(*)
43
15
  {
44
- 'enable' => self.enable,
45
- 'text' => self.text,
46
- 'html' => self.html,
47
- 'substitution_tag' => self.substitution_tag
16
+ 'enable' => enable,
17
+ 'text' => text,
18
+ 'html' => html,
19
+ 'substitution_tag' => substitution_tag
48
20
  }.delete_if { |_, value| value.to_s.strip == '' }
49
21
  end
50
22
  end
@@ -1,21 +1,17 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class Substitution
5
+ attr_accessor :substitution
6
+
3
7
  def initialize(key: nil, value: nil)
4
8
  @substitution = {}
5
- (key.nil? || value.nil?) ? @substitution = nil : @substitution[key] = value
6
- end
7
-
8
- def substitution=(substitution)
9
- @substitution = substitution
10
- end
11
-
12
- def substitution
13
- @substitution
9
+ key.nil? || value.nil? ? @substitution = nil : @substitution[key] = value
14
10
  end
15
11
 
16
12
  def to_json(*)
17
13
  {
18
- 'substitution' => self.substitution
14
+ 'substitution' => substitution
19
15
  }.delete_if { |_, value| value.to_s.strip == '' }
20
16
  end
21
17
  end
@@ -1,5 +1,9 @@
1
+ require 'json'
2
+
1
3
  module SendGrid
2
4
  class TrackingSettings
5
+ attr_writer :click_tracking, :open_tracking, :subscription_tracking, :ganalytics
6
+
3
7
  def initialize
4
8
  @click_tracking = nil
5
9
  @open_tracking = nil
@@ -7,44 +11,28 @@ module SendGrid
7
11
  @ganalytics = nil
8
12
  end
9
13
 
10
- def click_tracking=(click_tracking)
11
- @click_tracking = click_tracking
12
- end
13
-
14
14
  def click_tracking
15
15
  @click_tracking.nil? ? nil : @click_tracking.to_json
16
16
  end
17
17
 
18
- def open_tracking=(open_tracking)
19
- @open_tracking = open_tracking
20
- end
21
-
22
18
  def open_tracking
23
19
  @open_tracking.nil? ? nil : @open_tracking.to_json
24
20
  end
25
21
 
26
- def subscription_tracking=(subscription_tracking)
27
- @subscription_tracking = subscription_tracking
28
- end
29
-
30
22
  def subscription_tracking
31
23
  @subscription_tracking.nil? ? nil : @subscription_tracking.to_json
32
24
  end
33
25
 
34
- def ganalytics=(ganalytics)
35
- @ganalytics = ganalytics
36
- end
37
-
38
26
  def ganalytics
39
27
  @ganalytics.nil? ? nil : @ganalytics.to_json
40
28
  end
41
29
 
42
30
  def to_json(*)
43
31
  {
44
- 'click_tracking' => self.click_tracking,
45
- 'open_tracking' => self.open_tracking,
46
- 'subscription_tracking' => self.subscription_tracking,
47
- 'ganalytics' => self.ganalytics
32
+ 'click_tracking' => click_tracking,
33
+ 'open_tracking' => open_tracking,
34
+ 'subscription_tracking' => subscription_tracking,
35
+ 'ganalytics' => ganalytics
48
36
  }.delete_if { |_, value| value.to_s.strip == '' }
49
37
  end
50
38
  end
@@ -3,8 +3,8 @@ require 'yaml'
3
3
 
4
4
  module SendGrid
5
5
  class Scope
6
- SCOPES = YAML.load_file(File.dirname(__FILE__) + '/scopes.yml').freeze
7
-
6
+ SCOPES = YAML.load_file("#{File.dirname(__FILE__)}/scopes.yml").freeze
7
+
8
8
  class << self
9
9
  def admin_permissions
10
10
  SCOPES.values.map(&:values).flatten
@@ -2,7 +2,7 @@
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,12 +1,12 @@
1
1
  module SendGrid
2
2
  class Metrics
3
3
  attr_reader :blocks, :bounce_drops,
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
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
8
8
 
9
- def initialize(args={})
9
+ def initialize(args = {})
10
10
  @date = args['date']
11
11
  @blocks = args['blocks']
12
12
  @bounce_drops = args['bounce_drops']
@@ -9,12 +9,13 @@ module SendGrid
9
9
  # currently only "v3" is supported
10
10
  # - +impersonate_subuser+ -> the subuser to impersonate, will be passed
11
11
  # in the "On-Behalf-Of" header
12
+ # - +http_options+ -> http options that you want to be globally applied to each request
12
13
  #
13
- def initialize(api_key:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil)
14
+ def initialize(api_key:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil, http_options: {})
14
15
  auth = "Bearer #{api_key}"
15
- host = 'https://api.sendgrid.com' unless host
16
+ host ||= 'https://api.sendgrid.com'
16
17
 
17
- super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser)
18
+ super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser, http_options: http_options)
18
19
  end
19
20
  end
20
21
  end
@@ -13,7 +13,7 @@ module TwilioEmail
13
13
  #
14
14
  def initialize(username:, password:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil)
15
15
  auth = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
16
- host = 'https://email.twilio.com' unless host
16
+ host ||= 'https://email.twilio.com'
17
17
 
18
18
  super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser)
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module SendGrid
2
- VERSION = '6.2.0'
2
+ VERSION = '6.6.2'.freeze
3
3
  end
data/lib/sendgrid-ruby.rb CHANGED
@@ -2,6 +2,7 @@ require_relative 'sendgrid/base_interface'
2
2
  require_relative 'sendgrid/sendgrid'
3
3
  require_relative 'sendgrid/twilio_email'
4
4
  require_relative 'sendgrid/version'
5
+ require_relative 'sendgrid/helpers/eventwebhook/eventwebhook'
5
6
  require_relative 'sendgrid/helpers/ip_management/ip_management'
6
7
  require_relative 'sendgrid/helpers/mail/asm'
7
8
  require_relative 'sendgrid/helpers/mail/attachment'
@@ -29,3 +30,4 @@ require_relative 'sendgrid/helpers/stats/email_stats'
29
30
  require_relative 'sendgrid/helpers/stats/stats_response'
30
31
  require_relative 'sendgrid/helpers/stats/metrics'
31
32
  require_relative 'sendgrid/helpers/permissions/scope'
33
+ require_relative 'rack/sendgrid_webhook_verification'
data/mail_helper_v3.md CHANGED
@@ -2,11 +2,11 @@ Hello!
2
2
 
3
3
  It is now time to implement the final piece of our v2 to v3 migration. Before we dig into writing the code, we would love to get feedback on the following proposed interfaces.
4
4
 
5
- We are starting with the use cases below for the first iteration. (we have completed this work on [our C# library](https://github.com/sendgrid/sendgrid-csharp/blob/master/USE_CASES.md), you can check that out for a sneak peek of where we are heading).
5
+ We are starting with the use cases below for the first iteration. (we have completed this work on [our C# library](https://github.com/sendgrid/sendgrid-csharp/blob/HEAD/USE_CASES.md), you can check that out for a sneak peek of where we are heading).
6
6
 
7
7
  # Send a Single Email to a Single Recipient
8
8
 
9
- The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
9
+ The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
10
10
 
11
11
  ```ruby
12
12
  require 'sendgrid-ruby'
@@ -37,7 +37,7 @@ puts response.headers
37
37
 
38
38
  # Send a Single Email to Multiple Recipients
39
39
 
40
- The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
40
+ The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
41
41
 
42
42
  ```ruby
43
43
  require 'sendgrid-ruby'
@@ -72,7 +72,7 @@ puts response.headers
72
72
 
73
73
  # Send Multiple Emails to Multiple Recipients
74
74
 
75
- The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
75
+ The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
76
76
 
77
77
  ```ruby
78
78
  require 'sendgrid-ruby'
@@ -119,7 +119,7 @@ puts response.headers
119
119
 
120
120
  # Kitchen Sink - an example with all settings used
121
121
 
122
- The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
122
+ The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
123
123
 
124
124
  ```ruby
125
125
  client = SendGrid::Client.new(api_key: ENV['SENDGRID_API_KEY'])
@@ -233,7 +233,7 @@ msg.set_send_at(1461775052, 1)
233
233
 
234
234
  msg.set_subject('this subject overrides the Global Subject on the second Personalization', 1)
235
235
 
236
- # The values below this comment are global to entire message
236
+ # The values below this comment are global to the entire message
237
237
 
238
238
  msg.set_from(SendGrid::Email.new('test0@example.com', 'Example User0'))
239
239
 
@@ -263,7 +263,7 @@ attachments = [
263
263
  'base64 encoded content',
264
264
  'image/png',
265
265
  'inline',
266
- 'Banner 2'),
266
+ 'Banner 2'),
267
267
  ]
268
268
  msg.add_attachments(attachments)
269
269
 
@@ -279,7 +279,7 @@ msg.set_global_headers(global_headers)
279
279
  msg.add_section('%section1%', 'Substitution for Section 1 Tag')
280
280
  sections = [
281
281
  '%section2%' => 'Substitution for Section 2 Tag',
282
- '%section3%' => 'Substitution for Section 3 Tag'
282
+ '%section3%' => 'Substitution for Section 3 Tag'
283
283
  ]
284
284
  msg.add_sections(sections)
285
285
 
@@ -295,7 +295,7 @@ puts response.headers
295
295
 
296
296
  # Attachments
297
297
 
298
- The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
298
+ The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
299
299
 
300
300
  ```ruby
301
301
  client = SendGrid::Client.new(api_key: ENV['SENDGRID_API_KEY'])
@@ -326,9 +326,9 @@ puts response.headers
326
326
 
327
327
  # Transactional Templates
328
328
 
329
- The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
329
+ The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
330
330
 
331
- For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
331
+ For this example, we assume you have created a [legacy transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html) in the UI or via the API. Following is the template content we used for testing.
332
332
 
333
333
  Template ID (replace with your own):
334
334
 
@@ -347,7 +347,7 @@ Template Body:
347
347
  ```html
348
348
  <html>
349
349
  <head>
350
- <title></title>
350
+ <title></title>
351
351
  </head>
352
352
  <body>
353
353
  Hello -name-,