sendgrid-ruby
Advanced tools
| name: Lint PR | ||
| on: | ||
| pull_request_target: | ||
| types: [ opened, edited, synchronize, reopened ] | ||
| jobs: | ||
| validate: | ||
| name: Validate title | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: amannn/action-semantic-pull-request@v4 | ||
| with: | ||
| types: chore docs fix feat test misc | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| require 'sendgrid-ruby' | ||
| # Example 1 | ||
| # Sending using "global" data residency | ||
| from = SendGrid::Email.new(email: 'example@abc.com') | ||
| to = SendGrid::Email.new(email: 'example@abc.com') | ||
| subject = 'Sending with Twilio SendGrid is Fun' | ||
| content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
| mail = SendGrid::Mail.new(from, subject, to, content) | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| sg.sendgrid_data_residency(region: "global") | ||
| puts sg.host | ||
| response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
| puts response.status_code | ||
| puts response.body | ||
| puts response.headers | ||
| # Example 2 | ||
| # Sending using "eu" data residency | ||
| from = SendGrid::Email.new(email: 'example@abc.com') | ||
| to = SendGrid::Email.new(email: 'example@abc.com') | ||
| subject = 'Sending with Twilio SendGrid is Fun' | ||
| content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
| mail = SendGrid::Mail.new(from, subject, to, content) | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY_EU']) | ||
| sg.sendgrid_data_residency(region: 'eu') | ||
| puts sg.host | ||
| response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
| puts response.status_code | ||
| puts response.body | ||
| puts response.headers | ||
| # Example 3 | ||
| # Sending using no data residency | ||
| from = SendGrid::Email.new(email: 'example@abc.com') | ||
| to = SendGrid::Email.new(email: 'example@abc.com') | ||
| subject = 'Sending with Twilio SendGrid is Fun' | ||
| content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
| mail = SendGrid::Mail.new(from, subject, to, content) | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| puts sg.host | ||
| response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
| puts response.status_code | ||
| puts response.body | ||
| puts response.headers |
| require_relative '../../../../lib/sendgrid-ruby' | ||
| require 'minitest/autorun' | ||
| class TestDataResidency < Minitest::Test | ||
| include SendGrid | ||
| def setup | ||
| @global_email = 'https://api.sendgrid.com' | ||
| @eu_email = 'https://api.eu.sendgrid.com' | ||
| end | ||
| def test_with_global_data_residency | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| sg.sendgrid_data_residency(region: 'global') | ||
| assert_equal @global_email, sg.host | ||
| end | ||
| def test_with_global_eu_residency | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| sg.sendgrid_data_residency(region: 'eu') | ||
| assert_equal @eu_email, sg.host | ||
| end | ||
| def test_with_global_nil_residency | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| assert_raises(ArgumentError) do | ||
| sg.sendgrid_data_residency(region: nil) | ||
| end | ||
| end | ||
| def test_with_global_invalid_residency | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| assert_raises(ArgumentError) do | ||
| sg.sendgrid_data_residency(region: "abc") | ||
| end | ||
| end | ||
| def test_with_global_empty_residency | ||
| sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
| assert_raises(ArgumentError) do | ||
| sg.sendgrid_data_residency(region: "") | ||
| end | ||
| end | ||
| end |
+12
-0
| # Change Log | ||
| All notable changes to this project will be documented in this file. | ||
| [2023-12-01] Version 6.7.0 | ||
| -------------------------- | ||
| **Library - Feature** | ||
| - [PR #496](https://github.com/sendgrid/sendgrid-ruby/pull/496): geolocation setter in sendgrid-ruby for GDPR compliance. Thanks to [@manisha1997](https://github.com/manisha1997)! | ||
| **Library - Test** | ||
| - [PR #488](https://github.com/sendgrid/sendgrid-ruby/pull/488): Adding misc as PR type. Thanks to [@rakatyal](https://github.com/rakatyal)! | ||
| **Library - Docs** | ||
| - [PR #486](https://github.com/sendgrid/sendgrid-ruby/pull/486): Modify README. Thanks to [@garethpaul](https://github.com/garethpaul)! | ||
| [2022-03-09] Version 6.6.2 | ||
@@ -5,0 +17,0 @@ -------------------------- |
+0
-30
| Hello! Thank you for choosing to help contribute to one of the Twilio SendGrid open-source libraries. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies. | ||
| **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** | ||
| - [Feature Request](#feature-request) | ||
| - [Submit a Bug Report](#submit-a-bug-report) | ||
| - [Please use our Bug Report Template](#please-use-our-bug-report-template) | ||
| - [Improvements to the Codebase](#improvements-to-the-codebase) | ||
@@ -22,29 +19,2 @@ - [Development Environment](#development-environment) | ||
| <a name="feature-request"></a> | ||
| ## Feature Request | ||
| If you'd like to make a feature request, please read this section. | ||
| The GitHub issue tracker is the preferred channel for library feature requests, but please respect the following restrictions: | ||
| - Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests. | ||
| - Please be respectful and considerate of others when commenting on issues | ||
| <a name="submit-a-bug-report"></a> | ||
| ## Submit a Bug Report | ||
| Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public. | ||
| A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report. | ||
| Before you decide to create a new issue, please try the following: | ||
| 1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post. | ||
| 2. Update to the latest version of this code and check if an issue has already been fixed | ||
| 3. Copy and fill in the Bug Report Template we have provided below | ||
| ### Please use our Bug Report Template | ||
| In order to make the process easier, we've included a [sample bug report template](ISSUE_TEMPLATE.md). | ||
| <a name="improvements-to-the-codebase"></a> | ||
@@ -51,0 +21,0 @@ ## Improvements to the Codebase |
+0
-26
@@ -54,27 +54,1 @@ # How To Contribute to Twilio SendGrid Repositories via GitHub | ||
| Before creating a pull request, make sure that you respect the repository's constraints regarding contributions. You can find them in the [CONTRIBUTING.md](CONTRIBUTING.md) file. | ||
| ## Repositories with Open, Easy, Help Wanted, Issue Filters | ||
| * [Python SDK](https://github.com/sendgrid/sendgrid-python/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [PHP SDK](https://github.com/sendgrid/sendgrid-php/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [C# SDK](https://github.com/sendgrid/sendgrid-csharp/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Ruby SDK](https://github.com/sendgrid/sendgrid-ruby/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Node.js SDK](https://github.com/sendgrid/sendgrid-nodejs/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Java SDK](https://github.com/sendgrid/sendgrid-java/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Go SDK](https://github.com/sendgrid/sendgrid-go/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Python SMTPAPI Client](https://github.com/sendgrid/smtpapi-python/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [PHP SMTPAPI Client](https://github.com/sendgrid/smtpapi-php/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [C# SMTPAPI Client](https://github.com/sendgrid/smtpapi-csharp/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Ruby SMTPAPI Client](https://github.com/sendgrid/smtpapi-ruby/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Node.js SMTPAPI Client](https://github.com/sendgrid/smtpapi-nodejs/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Java SMTPAPI Client](https://github.com/sendgrid/smtpapi-java/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Go SMTPAPI Client](https://github.com/sendgrid/smtpapi-go/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Python HTTP Client](https://github.com/sendgrid/python-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [PHP HTTP Client](https://github.com/sendgrid/php-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [C# HTTP Client](https://github.com/sendgrid/csharp-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Java HTTP Client](https://github.com/sendgrid/java-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Ruby HTTP Client](https://github.com/sendgrid/ruby-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Go HTTP Client](https://github.com/sendgrid/rest/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Open API Definition](https://github.com/sendgrid/sendgrid-oai/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [DX Automator](https://github.com/sendgrid/dx-automator/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) | ||
| * [Documentation](https://github.com/sendgrid/docs/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22) |
@@ -40,2 +40,19 @@ require 'ruby_http_client' | ||
| end | ||
| # Client libraries contain setters for specifying region/edge. | ||
| # This supports global and eu regions only. This set will likely expand in the future. | ||
| # Global is the default residency (or region) | ||
| # Global region means the message will be sent through https://api.sendgrid.com | ||
| # EU region means the message will be sent through https://api.eu.sendgrid.com | ||
| # Parameters: | ||
| # - region(String) : specify the region. Currently supports "global" and "eu" | ||
| def sendgrid_data_residency(region:) | ||
| region_host_dict = { "eu" => 'https://api.eu.sendgrid.com', "global" => 'https://api.sendgrid.com' } | ||
| raise ArgumentError, "region can only be \"eu\" or \"global\"" if region.nil? || !region_host_dict.key?(region) | ||
| @host = region_host_dict[region] | ||
| @client = SendGrid::Client.new(host: "#{@host}/#{@version}", | ||
| request_headers: @request_headers, | ||
| http_options: @http_options) | ||
| end | ||
| end |
| module SendGrid | ||
| VERSION = '6.6.2'.freeze | ||
| VERSION = '6.7.0'.freeze | ||
| end |
+1
-1
| MIT License | ||
| Copyright (C) 2022, Twilio SendGrid, Inc. <help@twilio.com> | ||
| Copyright (C) 2023, Twilio SendGrid, Inc. <help@twilio.com> | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
@@ -6,3 +6,3 @@ <!-- | ||
| <type>[!]: <description> | ||
| Where <type> is one of: docs, chore, feat, fix, test. | ||
| Where <type> is one of: docs, chore, feat, fix, test, misc. | ||
| Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). | ||
@@ -9,0 +9,0 @@ |
+5
-10
@@ -10,4 +10,2 @@  | ||
| **The default branch name for this repository has been changed to `main` as of 07/27/2020.** | ||
| **This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via Ruby.** | ||
@@ -19,6 +17,4 @@ | ||
| Please browse the rest of this README for further details. | ||
| **If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).** | ||
| We appreciate your continued support, thank you! | ||
| # Table of Contents | ||
@@ -36,2 +32,3 @@ | ||
| * [About](#about) | ||
| * [Support](#support) | ||
| * [License](#license) | ||
@@ -193,6 +190,4 @@ | ||
| Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-ruby/issues/94). Your support is appreciated! | ||
| All updates to this library are documented in our [CHANGELOG](CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases). | ||
| All updates to this library are documented in our [CHANGELOG](CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/ruby) for releases and breaking changes. | ||
| <a name="contribute"></a> | ||
@@ -218,5 +213,5 @@ # How to Contribute | ||
| If you need help installing or using the library, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com). | ||
| <a name="support"></a> | ||
| If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo! | ||
| If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com). | ||
@@ -223,0 +218,0 @@ <a name="license"></a> |
| contact_links: | ||
| - name: Twilio SendGrid Support | ||
| url: https://support.sendgrid.com | ||
| about: Get Support | ||
| - name: Stack Overflow | ||
| url: https://stackoverflow.com/questions/tagged/sendgrid-ruby+or+sendgrid+ruby | ||
| about: Ask questions on Stack Overflow | ||
| - name: Documentation | ||
| url: https://sendgrid.com/docs/for-developers/ | ||
| about: View Reference Documentation |
| <!-- | ||
| If this is a feature request, make sure you search Issues for an existing request before creating a new one! | ||
| Please utilize the template below to help us resolve your issue. | ||
| Note that many issues can be resolved by updating to the latest version. | ||
| --> | ||
| ### Issue Summary | ||
| A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, or code examples. | ||
| ### Steps to Reproduce | ||
| 1. This is the first step | ||
| 2. This is the second step | ||
| 3. Further steps, etc. | ||
| ### Code Snippet | ||
| ```ruby | ||
| # paste code here | ||
| ``` | ||
| ### Exception/Log | ||
| ``` | ||
| # paste exception/log here | ||
| ``` | ||
| ### Technical details: | ||
| * sendgrid-ruby version: | ||
| * ruby version: | ||
Sorry, the diff of this file is too big to display