sendgrid-ruby 6.4.0 → 6.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a77256d8db572200bdedd90a2b719d0f36d1a1aecbf17070968b555ed404028
4
- data.tar.gz: 10081de69452a519515b2fe5f086460935cac375e1d3ade7528412477aab38a9
3
+ metadata.gz: 8e118713291ab6d133c75101195e33de03deb99d1e950cb55df8a266df10528d
4
+ data.tar.gz: e444657f217f6d84af54743baa09f145795f9424ac74a6852fc5a73435f18e75
5
5
  SHA512:
6
- metadata.gz: fa4e2a6a2cd904d43f1c32a57ecbc1ea7db0729fed4cab05303566515975661fd12bb0e1d3f92480b3101276019db4a1858dc060ff35a1055ff587dc5582d071
7
- data.tar.gz: 10493d88b4836f3f90a8813dbe3bb6d40e141a3d0f1ed99adc35c34a308c7a149104b7bde9829c8bf5b5b1efb7e855ad1236fc43c5f6c444c656a1e6f740599c
6
+ metadata.gz: f2e41e61bc35633b62734361034a864fac34e6e6351122858d0dfefe9c98b9d7216bc91628d1c68ccc39c83a538e5f019de729102f648164382d8e01e1abed0c
7
+ data.tar.gz: 450c8ea54db164636cf3101080808248a9602689b17c9be9e3e93f138694019d72422d77d273ac1723077e97d12d7f0676ec479e62dfc434f82631e54f2049ab
@@ -0,0 +1,10 @@
1
+ contact_links:
2
+ - name: Twilio SendGrid Support
3
+ url: https://support.sendgrid.com
4
+ about: Get Support
5
+ - name: Stack Overflow
6
+ url: https://stackoverflow.com/questions/tagged/sendgrid-ruby+or+sendgrid+ruby
7
+ about: Ask questions on Stack Overflow
8
+ - name: Documentation
9
+ url: https://sendgrid.com/docs/for-developers/
10
+ about: View Reference Documentation
@@ -0,0 +1,120 @@
1
+ name: Test and Deploy
2
+ on:
3
+ push:
4
+ branches: [ '*' ]
5
+ tags: [ '*' ]
6
+ pull_request:
7
+ branches: [ main ]
8
+ schedule:
9
+ # Run automatically at 8AM PST Monday-Friday
10
+ - cron: '0 15 * * 1-5'
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ test:
15
+ name: Test
16
+ runs-on: ubuntu-latest
17
+ timeout-minutes: 20
18
+ strategy:
19
+ matrix:
20
+ ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', 'jruby-9.2' ]
21
+ env:
22
+ version: ${{ format('ruby:{0}', matrix.ruby) }}
23
+ DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
24
+ steps:
25
+ - name: Revise env version if necessary
26
+ run: echo "version=jruby:9.2" >> $GITHUB_ENV
27
+ if: ${{ matrix.ruby == 'jruby-9.2' }}
28
+
29
+ - name: Checkout sendgrid-ruby
30
+ uses: actions/checkout@v2
31
+ with:
32
+ fetch-depth: 0
33
+
34
+ - name: Login to Docker Hub
35
+ if: env.DOCKER_LOGIN
36
+ uses: docker/login-action@v1
37
+ with:
38
+ username: ${{ secrets.DOCKER_USERNAME }}
39
+ password: ${{ secrets.DOCKER_AUTH_TOKEN }}
40
+
41
+ - name: Set up Ruby
42
+ uses: ruby/setup-ruby@v1
43
+ with:
44
+ ruby-version: ${{ matrix.ruby }}
45
+ bundler-cache: true
46
+
47
+ - run: make install
48
+
49
+ - name: Set up linter
50
+ run: bundle add rubocop --version "~> 1.24.1" --group "development" --skip-install
51
+ if: ${{ matrix.ruby != '2.4' }}
52
+
53
+ - run: bundle install --with development
54
+
55
+ - name: Run linter
56
+ run: bundle exec rubocop
57
+ if: ${{ matrix.ruby != '2.4' }}
58
+
59
+ - name: Run tests
60
+ run: make test-docker
61
+
62
+ deploy:
63
+ name: Deploy
64
+ if: success() && github.ref_type == 'tag'
65
+ needs: [ test ]
66
+ runs-on: ubuntu-latest
67
+ steps:
68
+ - name: Checkout sendgrid-ruby
69
+ uses: actions/checkout@v2
70
+ with:
71
+ fetch-depth: 0
72
+
73
+ - name: Set up Ruby
74
+ uses: ruby/setup-ruby@v1
75
+ with:
76
+ ruby-version: 3.1
77
+ bundler-cache: true
78
+
79
+ - run: make install
80
+
81
+ - name: Create GitHub Release
82
+ uses: sendgrid/dx-automator/actions/release@main
83
+ with:
84
+ footer: '**[RubyGems](https://rubygems.org/gems/sendgrid-ruby/versions/${version})**'
85
+ env:
86
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87
+
88
+ - name: Publish to Rubygems
89
+ env:
90
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
91
+ run: |
92
+ mkdir -p $HOME/.gem
93
+ touch $HOME/.gem/credentials
94
+ chmod 0600 $HOME/.gem/credentials
95
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
96
+ gem build *.gemspec
97
+ gem push *.gem
98
+
99
+ - name: Submit metric to Datadog
100
+ uses: sendgrid/dx-automator/actions/datadog-release-metric@main
101
+ env:
102
+ DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
103
+
104
+ notify-on-failure:
105
+ name: Slack notify on failure
106
+ if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
107
+ needs: [ test, deploy ]
108
+ runs-on: ubuntu-latest
109
+ steps:
110
+ - uses: rtCamp/action-slack-notify@v2
111
+ env:
112
+ SLACK_COLOR: failure
113
+ SLACK_ICON_EMOJI: ':github:'
114
+ SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
115
+ SLACK_TITLE: Action Failure - ${{ github.repository }}
116
+ SLACK_USERNAME: GitHub Actions
117
+ SLACK_MSG_AUTHOR: twilio-dx
118
+ SLACK_FOOTER: Posted automatically using GitHub Actions
119
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
120
+ MSG_MINIMAL: true
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,19 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-09-18 20:20:54 UTC using RuboCop version 0.91.0.
3
+ # on 2022-01-25 23:45:43 UTC using RuboCop version 1.22.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12
+ # Include: **/*.gemfile, **/Gemfile, **/gems.rb
13
+ Bundler/OrderedGems:
14
+ Exclude:
15
+ - 'Gemfile'
16
+
9
17
  # Offense count: 1
10
18
  # Configuration parameters: Include.
11
19
  # Include: **/*.gemspec
@@ -13,37 +21,37 @@ Gemspec/RequiredRubyVersion:
13
21
  Exclude:
14
22
  - 'sendgrid-ruby.gemspec'
15
23
 
16
- # Offense count: 22
24
+ # Offense count: 1
25
+ # Cop supports --auto-correct.
26
+ # Configuration parameters: EnforcedStyle.
27
+ # SupportedStyles: final_newline, final_blank_line
28
+ Layout/TrailingEmptyLines:
29
+ Exclude:
30
+ - 'Gemfile'
31
+
32
+ # Offense count: 24
17
33
  Lint/UselessAssignment:
18
34
  Exclude:
19
35
  - 'examples/scopes/scopes.rb'
20
36
  - 'spec/rack/sendgrid_webhook_verification_spec.rb'
21
37
 
22
- # Offense count: 8
23
- # Configuration parameters: IgnoredMethods.
38
+ # Offense count: 10
39
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
24
40
  Metrics/AbcSize:
25
- Max: 144
26
-
27
- # Offense count: 9
28
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
29
- # ExcludedMethods: refine
30
- Metrics/BlockLength:
31
- Max: 96
41
+ Max: 134
32
42
 
33
43
  # Offense count: 3
34
44
  # Configuration parameters: CountComments, CountAsOne.
35
45
  Metrics/ClassLength:
36
- Max: 2006
37
- Exclude:
38
- - 'test/sendgrid/test_sendgrid-ruby.rb'
46
+ Max: 2018
39
47
 
40
- # Offense count: 41
41
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
48
+ # Offense count: 45
49
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
42
50
  Metrics/MethodLength:
43
51
  Max: 141
44
52
 
45
- # Offense count: 2
46
- # Configuration parameters: CountKeywordArgs.
53
+ # Offense count: 4
54
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
47
55
  Metrics/ParameterLists:
48
56
  Max: 7
49
57
 
@@ -76,15 +84,15 @@ Naming/PredicateName:
76
84
  - 'examples/helpers/eventwebhook/example.rb'
77
85
 
78
86
  # Offense count: 35
87
+ # Configuration parameters: AllowedConstants.
79
88
  Style/Documentation:
80
89
  Enabled: false
81
90
 
82
- # Offense count: 4
83
- # Configuration parameters: EnforcedStyle.
91
+ # Offense count: 3
92
+ # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
84
93
  # SupportedStyles: annotated, template, unannotated
85
94
  Style/FormatStringToken:
86
- Exclude:
87
- - 'examples/emailactivity/emailactivity.rb'
95
+ EnforcedStyle: unannotated
88
96
 
89
97
  # Offense count: 97
90
98
  # Cop supports --auto-correct.
@@ -93,6 +101,14 @@ Style/FormatStringToken:
93
101
  Style/FrozenStringLiteralComment:
94
102
  Enabled: false
95
103
 
104
+ # Offense count: 1
105
+ # Cop supports --auto-correct.
106
+ # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
107
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
108
+ Style/HashSyntax:
109
+ Exclude:
110
+ - 'Gemfile'
111
+
96
112
  # Offense count: 6
97
113
  Style/MixinUsage:
98
114
  Exclude:
@@ -103,9 +119,9 @@ Style/MixinUsage:
103
119
  - 'test/sendgrid/helpers/mail/test_attachment.rb'
104
120
  - 'test/sendgrid/helpers/mail/test_mail.rb'
105
121
 
106
- # Offense count: 55
122
+ # Offense count: 54
107
123
  # Cop supports --auto-correct.
108
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
124
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
109
125
  # URISchemes: http, https
110
126
  Layout/LineLength:
111
- Max: 3211
127
+ Max: 381
data/CHANGELOG.md CHANGED
@@ -1,6 +1,47 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ [2022-03-09] Version 6.6.2
5
+ --------------------------
6
+ **Library - Chore**
7
+ - [PR #483](https://github.com/sendgrid/sendgrid-ruby/pull/483): push Datadog Release Metric upon deploy success. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
8
+
9
+
10
+ [2022-02-09] Version 6.6.1
11
+ --------------------------
12
+ **Library - Chore**
13
+ - [PR #482](https://github.com/sendgrid/sendgrid-ruby/pull/482): upgrade supported language versions. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
14
+ - [PR #480](https://github.com/sendgrid/sendgrid-ruby/pull/480): add gh release to workflow. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
15
+ - [PR #478](https://github.com/sendgrid/sendgrid-ruby/pull/478): migrate to gh actions. Thanks to [@beebzz](https://github.com/beebzz)!
16
+
17
+ **Library - Fix**
18
+ - [PR #479](https://github.com/sendgrid/sendgrid-ruby/pull/479): set version env var for tests. Thanks to [@beebzz](https://github.com/beebzz)!
19
+
20
+
21
+ [2021-11-03] Version 6.6.0
22
+ --------------------------
23
+ **Library - Feature**
24
+ - [PR #473](https://github.com/sendgrid/sendgrid-ruby/pull/473): update tests, use-cases, examples and implementation for From personalization. Thanks to [@beebzz](https://github.com/beebzz)!
25
+
26
+
27
+ [2021-10-18] Version 6.5.2
28
+ --------------------------
29
+ **Library - Docs**
30
+ - [PR #472](https://github.com/sendgrid/sendgrid-ruby/pull/472): improve signed webhook event validation docs. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
31
+
32
+
33
+ [2021-09-08] Version 6.5.1
34
+ --------------------------
35
+ **Library - Chore**
36
+ - [PR #470](https://github.com/sendgrid/sendgrid-ruby/pull/470): add support for ruby 3.0. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
37
+
38
+
39
+ [2021-08-11] Version 6.5.0
40
+ --------------------------
41
+ **Library - Feature**
42
+ - [PR #466](https://github.com/sendgrid/sendgrid-ruby/pull/466): Add From address to personalization. Thanks to [@grin](https://github.com/grin)!
43
+
44
+
4
45
  [2021-02-10] Version 6.4.0
5
46
  --------------------------
6
47
  **Library - Feature**
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (C) 2021, Twilio SendGrid, Inc. <help@twilio.com>
3
+ Copyright (C) 2022, Twilio SendGrid, Inc. <help@twilio.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/Makefile CHANGED
@@ -5,7 +5,6 @@ install:
5
5
 
6
6
  test:
7
7
  bundle exec rake
8
- rubocop
9
8
 
10
9
  test-integ: test
11
10
 
data/README.md CHANGED
@@ -1,15 +1,12 @@
1
1
  ![Twilio SendGrid Logo](twilio_sendgrid_logo.png)
2
2
 
3
- [![Travis Badge](https://travis-ci.com/sendgrid/sendgrid-ruby.svg?branch=main)](https://travis-ci.com/sendgrid/sendgrid-ruby)
3
+ [![Travis Badge](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
5
- [![Email Notifications Badge](https://dx.sendgrid.com/badge/ruby)](https://dx.sendgrid.com/newsletter/ruby)
6
5
  [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
6
  [![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
8
7
  [![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-ruby.svg)](https://github.com/sendgrid/sendgrid-ruby/graphs/contributors)
9
8
  [![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-ruby/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-ruby)
10
9
 
11
- **NEW:** Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/ruby) for releases and breaking changes.
12
-
13
10
  **The default branch name for this repository has been changed to `main` as of 07/27/2020.**
14
11
 
15
12
  **This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via Ruby.**
data/TROUBLESHOOTING.md CHANGED
@@ -17,6 +17,7 @@ If you can't find a solution below, please open an [issue](https://github.com/se
17
17
  * [Rails Specifics](#rails-specifics)
18
18
  * [Ruby Versions](#ruby-versions)
19
19
  * [Viewing the Request Body](#viewing-the-request-body)
20
+ * [Verifying Event Webhooks](#signed-webhooks)
20
21
 
21
22
  <a name="migrating"></a>
22
23
  ## Migrating from v2 to v3
@@ -137,3 +138,14 @@ You can do this before `response = sg.client.mail._('send').post(request_body: m
137
138
  ```ruby
138
139
  puts mail.to_json
139
140
  ```
141
+
142
+ <a name="signed-webhooks"></a>
143
+ ## Signed Webhook Verification
144
+
145
+ Twilio SendGrid's Event Webhook will notify a URL via HTTP POST with information about events that occur as your mail is processed. [This](https://docs.sendgrid.com/for-developers/tracking-events/getting-started-event-webhook-security-features) article covers all you need to know to secure the Event Webhook, allowing you to verify that incoming requests originate from Twilio SendGrid. The sendgrid-ruby library can help you verify these Signed Event Webhooks.
146
+
147
+ You can find the usage example [here](examples/helpers/eventwebhook/example.rb) and the tests [here](spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb).
148
+ If you are still having trouble getting the validation to work, follow the following instructions:
149
+ - Be sure to use the *raw* payload for validation
150
+ - Be sure to include a trailing carriage return and newline in your payload
151
+ - In case of multi-event webhooks, make sure you include the trailing newline and carriage return after *each* event
@@ -18,6 +18,7 @@ def hello_world
18
18
  puts response.headers
19
19
  end
20
20
 
21
+ # rubocop:disable Metrics/AbcSize
21
22
  def kitchen_sink
22
23
  mail = SendGrid::Mail.new
23
24
  mail.from = Email.new(email: 'test@example.com')
@@ -29,6 +30,9 @@ def kitchen_sink
29
30
  personalization.add_cc(Email.new(email: 'test4@example.com', name: 'Example User'))
30
31
  personalization.add_bcc(Email.new(email: 'test5@example.com', name: 'Example User'))
31
32
  personalization.add_bcc(Email.new(email: 'test6@example.com', name: 'Example User'))
33
+ # Note, the domain of the from email property specified in any personalization must
34
+ # match the domain of the from email property specified at root level
35
+ personalization.add_from(Email.new(email: 'alias@example.com', name: "My alias"))
32
36
  personalization.subject = 'Hello World from the Personalized Twilio SendGrid Ruby Library'
33
37
  personalization.add_header(Header.new(key: 'X-Test', value: 'True'))
34
38
  personalization.add_header(Header.new(key: 'X-Mock', value: 'False'))
@@ -124,6 +128,7 @@ def kitchen_sink
124
128
  puts response.body
125
129
  puts response.headers
126
130
  end
131
+ # rubocop:enable Metrics/AbcSize
127
132
 
128
133
  def dynamic_template_data_hello_world
129
134
  mail = Mail.new
@@ -2,13 +2,14 @@ require 'json'
2
2
 
3
3
  module SendGrid
4
4
  class Personalization
5
- attr_reader :tos, :ccs, :bccs, :headers, :substitutions, :custom_args,
5
+ attr_reader :tos, :from, :ccs, :bccs, :headers, :substitutions, :custom_args,
6
6
  :dynamic_template_data
7
7
 
8
8
  attr_accessor :send_at, :subject
9
9
 
10
10
  def initialize
11
11
  @tos = []
12
+ @from = nil
12
13
  @ccs = []
13
14
  @bccs = []
14
15
  @subject = nil
@@ -25,6 +26,10 @@ module SendGrid
25
26
  @tos << to.to_json
26
27
  end
27
28
 
29
+ def add_from(from)
30
+ @from = from.to_json
31
+ end
32
+
28
33
  def add_cc(cc)
29
34
  raise DuplicatePersonalizationError if duplicate?(cc)
30
35
 
@@ -59,6 +64,7 @@ module SendGrid
59
64
  def to_json(*)
60
65
  {
61
66
  'to' => tos,
67
+ 'from' => from,
62
68
  'cc' => ccs,
63
69
  'bcc' => bccs,
64
70
  'subject' => subject,
@@ -1,3 +1,3 @@
1
1
  module SendGrid
2
- VERSION = '6.4.0'.freeze
2
+ VERSION = '6.6.2'.freeze
3
3
  end
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rack'
26
26
  spec.add_development_dependency 'rake', '~> 13.0'
27
27
  spec.add_development_dependency 'rspec'
28
- spec.add_development_dependency 'rubocop'
29
28
  spec.add_development_dependency 'simplecov', '~> 0.18.5'
30
29
  spec.add_development_dependency 'sinatra', '>= 1.4.7', '< 3'
31
30
  end
@@ -19,14 +19,14 @@ describe SendGrid::MailSettingsDto do
19
19
  describe '.fetch' do
20
20
  it 'calls get on sendgrid_client' do
21
21
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
22
- expect(mail_settings.fetch(args)).to be_a SendGrid::Response
22
+ expect(mail_settings.fetch(**args)).to be_a SendGrid::Response
23
23
  end
24
24
  end
25
25
 
26
26
  describe '.update' do
27
27
  it 'calls patch on sendgrid_client' do
28
28
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
29
- expect(mail_settings.update(args)).to be_a SendGrid::Response
29
+ expect(mail_settings.update(**args)).to be_a SendGrid::Response
30
30
  end
31
31
  end
32
32
  end
@@ -11,14 +11,14 @@ describe SendGrid::PartnerSettingsDto do
11
11
  describe '.fetch' do
12
12
  it 'calls get on sendgrid_client' do
13
13
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
14
- expect(partner_settings.fetch(args)).to be_a SendGrid::Response
14
+ expect(partner_settings.fetch(**args)).to be_a SendGrid::Response
15
15
  end
16
16
  end
17
17
 
18
18
  describe '.update' do
19
19
  it 'calls patch on sendgrid_client' do
20
20
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
21
- expect(partner_settings.update(args)).to be_a SendGrid::Response
21
+ expect(partner_settings.update(**args)).to be_a SendGrid::Response
22
22
  end
23
23
  end
24
24
  end
@@ -14,14 +14,14 @@ describe SendGrid::TrackingSettingsDto do
14
14
  describe '.fetch' do
15
15
  it 'calls get on sendgrid_client' do
16
16
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
17
- expect(tracking_settings.fetch(args)).to be_a SendGrid::Response
17
+ expect(tracking_settings.fetch(**args)).to be_a SendGrid::Response
18
18
  end
19
19
  end
20
20
 
21
21
  describe '.update' do
22
22
  it 'calls patch on sendgrid_client' do
23
23
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
24
- expect(tracking_settings.update(args)).to be_a SendGrid::Response
24
+ expect(tracking_settings.update(**args)).to be_a SendGrid::Response
25
25
  end
26
26
  end
27
27
  end
@@ -11,14 +11,14 @@ describe SendGrid::UserSettingsDto do
11
11
  describe '.fetch' do
12
12
  it 'calls get on sendgrid_client' do
13
13
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
14
- expect(user_settings.fetch(args)).to be_a SendGrid::Response
14
+ expect(user_settings.fetch(**args)).to be_a SendGrid::Response
15
15
  end
16
16
  end
17
17
 
18
18
  describe '.update' do
19
19
  it 'calls patch on sendgrid_client' do
20
20
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
21
- expect(user_settings.update(args)).to be_a SendGrid::Response
21
+ expect(user_settings.update(**args)).to be_a SendGrid::Response
22
22
  end
23
23
  end
24
24
  end
@@ -45,6 +45,19 @@ class TestPersonalization < Minitest::Test
45
45
  end
46
46
  end
47
47
 
48
+ def test_add_from
49
+ @personalization = Personalization.new
50
+ @personalization.add_from(Email.new(email: 'from1@example.com', name: 'Example Sender'))
51
+ expected_json = {
52
+ 'from' => {
53
+ 'email' => 'from1@example.com',
54
+ 'name' => 'Example Sender'
55
+ }
56
+ }
57
+
58
+ assert_equal @personalization.to_json, expected_json
59
+ end
60
+
48
61
  def test_add_cc
49
62
  @personalization = Personalization.new
50
63
  @personalization.add_cc(Email.new(email: 'test1@example.com', name: 'Example User'))
@@ -33,7 +33,7 @@ class TestAPI < MiniTest::Test
33
33
  assert_equal(test_headers, sg.request_headers)
34
34
  assert_equal('v3', sg.version)
35
35
  assert_equal(subuser, sg.impersonate_subuser)
36
- assert_equal('6.4.0', SendGrid::VERSION)
36
+ assert_equal('6.6.2', SendGrid::VERSION)
37
37
  assert_instance_of(SendGrid::Client, sg.client)
38
38
  assert_equal({}, sg.http_options)
39
39
  end
@@ -2683,12 +2683,8 @@ class TestAPI < MiniTest::Test
2683
2683
  assert(File.file?('./.gitignore'))
2684
2684
  end
2685
2685
 
2686
- def test_travis_exists
2687
- assert(File.file?('./.travis.yml'))
2688
- end
2689
-
2690
- def test_codeclimate_exists
2691
- assert(File.file?('./.codeclimate.yml'))
2686
+ def test_gh_actions_exists
2687
+ assert(File.file?('./.github/workflows/test-and-deploy.yml'))
2692
2688
  end
2693
2689
 
2694
2690
  def test_changelog_exists
data/use-cases/README.md CHANGED
@@ -5,6 +5,7 @@ Please [open an issue](https://github.com/sendgrid/sendgrid-ruby/issues) or [mak
5
5
  # Email Use Cases
6
6
  * [Transactional Templates](transactional-templates.md)
7
7
  * [Legacy Templates](legacy-templates.md)
8
+ * [Personalizations](personalizations.md)
8
9
 
9
10
  # Twilio Use Cases
10
11
  * [Twilio Setup](twilio-setup.md)
@@ -0,0 +1,34 @@
1
+ # Personalizations
2
+
3
+ This example demonstrates how to send multiple emails with personalizations. For further documentation, refer to [the SendGrid docs](https://docs.sendgrid.com/for-developers/sending-email/personalizations).
4
+
5
+ ```ruby
6
+ require 'sendgrid-ruby'
7
+ include SendGrid
8
+
9
+ # Note that the domain for all From addresses must match
10
+ mail = Mail.new
11
+ mail.from = Email.new(email: 'test@example.com')
12
+ mail.add_content(Content.new(type: 'text/plain', value: 'Some test text'))
13
+ mail.subject = 'Personalized Test Email'
14
+
15
+ personalization = Personalization.new
16
+ personalization.add_to(Email.new(email: 'test1@example.com'))
17
+ mail.add_personalization(personalization)
18
+
19
+ personalization2 = Personalization.new
20
+ personalization2.add_to(Email.new(email: 'test2@example.com'))
21
+ personalization2.add_from(Email.new(email: 'test3@example.com'))
22
+ mail.add_personalization(personalization2)
23
+
24
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
25
+ begin
26
+ response = sg.client.mail._("send").post(request_body: mail.to_json)
27
+ rescue Exception => e
28
+ puts e.message
29
+ end
30
+
31
+ puts response.status_code
32
+ puts response.body
33
+ puts response.headers
34
+ ```
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: 6.4.0
4
+ version: 6.6.2
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: 2021-02-10 00:00:00.000000000 Z
13
+ date: 2022-03-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_http_client
@@ -110,20 +110,6 @@ dependencies:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
- - !ruby/object:Gem::Dependency
114
- name: rubocop
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
113
  - !ruby/object:Gem::Dependency
128
114
  name: simplecov
129
115
  requirement: !ruby/object:Gem::Requirement
@@ -165,12 +151,12 @@ executables: []
165
151
  extensions: []
166
152
  extra_rdoc_files: []
167
153
  files:
168
- - ".codeclimate.yml"
169
154
  - ".env_sample"
155
+ - ".github/ISSUE_TEMPLATE/config.yml"
156
+ - ".github/workflows/test-and-deploy.yml"
170
157
  - ".gitignore"
171
158
  - ".rubocop.yml"
172
159
  - ".rubocop_todo.yml"
173
- - ".travis.yml"
174
160
  - CHANGELOG.md
175
161
  - CODE_OF_CONDUCT.md
176
162
  - CONTRIBUTING.md
@@ -299,6 +285,7 @@ files:
299
285
  - use-cases/domain-authentication.md
300
286
  - use-cases/email-statistics.md
301
287
  - use-cases/legacy-templates.md
288
+ - use-cases/personalizations.md
302
289
  - use-cases/sms.md
303
290
  - use-cases/transactional-templates.md
304
291
  - use-cases/twilio-email.md
@@ -322,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
309
  - !ruby/object:Gem::Version
323
310
  version: '0'
324
311
  requirements: []
325
- rubygems_version: 3.0.8
312
+ rubygems_version: 3.3.7
326
313
  signing_key:
327
314
  specification_version: 4
328
315
  summary: Official Twilio SendGrid Gem
data/.codeclimate.yml DELETED
@@ -1,21 +0,0 @@
1
- ---
2
- engines:
3
- duplication:
4
- enabled: true
5
- config:
6
- languages:
7
- - ruby
8
- fixme:
9
- enabled: true
10
- rubocop:
11
- enabled: true
12
- bundler-audit:
13
- enabled: true
14
- ratings:
15
- paths:
16
- - "**.rb"
17
- exclude_paths:
18
- - examples/
19
- - gemfiles/
20
- - spec/
21
- - test/
data/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- language: ruby
2
- env:
3
- - version=ruby:2.7
4
- - version=ruby:2.6
5
- - version=ruby:2.5
6
- - version=ruby:2.4
7
- - version=jruby:9.2
8
-
9
- gemfile:
10
- - gemfiles/Sinatra_1.gemfile
11
- - gemfiles/Sinatra_2.gemfile
12
-
13
- script: make test-docker
14
-
15
- deploy:
16
- provider: rubygems
17
- api_key: $RUBYGEMS_API_KEY
18
- gem: sendgrid-ruby
19
- on:
20
- tags: true
21
- condition: $version = ruby:2.4 && $BUNDLE_GEMFILE = *"gemfiles/Sinatra_1.gemfile"
22
-
23
- notifications:
24
- slack:
25
- if: branch = main
26
- on_pull_requests: false
27
- on_success: never
28
- on_failure: change
29
- rooms:
30
- - secure: QwoVrGveeA1bo/26fO2A+OQHmUX69NLaC214qd18C1Z8ztYMHkd05/9+k9HFb+PSdPkGLSeYOPWAKJUqJWB7HfGINNGpRGIPFcmfB7vhvvLFnhud/SAdQPRZ+SCeZPdpZcjpVRLYENKv259ucGPBCPFXh1HfJF92R0IrKeW5CII=