From 1cafbfafe42a0dca2c215337a3c0c6c939b0fcf0 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Tue, 14 Nov 2023 18:59:46 -0500 Subject: [PATCH 01/30] Initial commit --- .circleci/config.yml | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..5593fae --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,65 @@ +version: 2 +jobs: + build: + parallelism: 1 + docker: + - image: circleci/ruby:2.3 + working_directory: ~/pbxx + steps: + - checkout + + - restore_cache: + keys: + - ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "sendgrid_toolkit.gemspec" }} + - ruby-cache-{{ arch }}-{{ .Branch }} + - ruby-cache + + - run: + name: Download cc-test-reporter + command: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + + - run: + name: Update RubyGems + command: sudo gem update --system 3.3.25 + + - run: + name: Install bundler + command: gem install bundler + + - run: + name: Configure bundler + command: bundle config set --local path 'vendor/bundle' + + - run: + name: Bundle Install + command: bundle check || bundle install --jobs=4 --retry=3 + + - save_cache: + key: ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "sendgrid_toolkit.gemspec" }} + paths: + - vendor/bundle + + - run: + name: Run tests + command: | + ./cc-test-reporter before-build + bundle exec rspec --profile 10 \ + --format RspecJunitFormatter \ + --out test_results/rspec.xml \ + --format progress + ./cc-test-reporter after-build -t simplecov --exit-code $? + + - store_test_results: + path: test_results + + - run: + name: Upload to Gemfury + context: gem + command: | + if [ "${CIRCLE_BRANCH}" == "master" ]; then + gem build sendgrid_toolkit.gemspec + curl -F package=@sendgrid_toolkit-1.4.0.gem q + fi + From 1a5baab1c8dc946d76004cb821a59d1758467f77 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Tue, 14 Nov 2023 20:39:26 -0500 Subject: [PATCH 02/30] gemfile --- Gemfile.lock | 91 +++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2873b4a..38b15f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,59 +1,65 @@ GEM remote: http://rubygems.org/ specs: - addressable (2.3.5) - builder (3.2.2) - coderay (1.1.0) + addressable (2.4.0) + builder (3.2.4) + coderay (1.1.3) + descendants_tracker (0.0.4) + thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.1.3) fakeweb (1.3.0) - faraday (0.8.8) - multipart-post (~> 1.2.0) - git (1.2.6) - github_api (0.10.1) - addressable - faraday (~> 0.8.1) - hashie (>= 1.2) - multi_json (~> 1.4) - nokogiri (~> 1.5.2) - oauth2 - hashie (2.0.5) - highline (1.6.20) - httparty (0.12.0) - json (~> 1.8) + faraday (0.9.2) + multipart-post (>= 1.2, < 3) + git (1.11.0) + rchardet (~> 1.8) + github_api (0.16.0) + addressable (~> 2.4.0) + descendants_tracker (~> 0.0.4) + faraday (~> 0.8, < 0.10) + hashie (>= 3.4) + mime-types (>= 1.16, < 3.0) + oauth2 (~> 1.0) + hashie (5.0.0) + highline (2.1.0) + httparty (0.21.0) + mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - httpauth (0.2.0) - jeweler (1.8.8) + jeweler (2.3.9) builder - bundler (~> 1.0) + bundler git (>= 1.2.5) - github_api (= 0.10.1) + github_api (~> 0.16.0) highline (>= 1.6.15) - nokogiri (= 1.5.10) + nokogiri (>= 1.5.10) + psych rake rdoc - json (1.8.1) - jwt (0.1.8) - multi_json (>= 1.5) + semver2 + jwt (2.3.0) method_source (0.8.2) - multi_json (1.8.2) - multi_xml (0.5.5) - multipart-post (1.2.0) - nokogiri (1.5.10) - oauth2 (0.9.2) - faraday (~> 0.8) - httpauth (~> 0.2) - jwt (~> 0.1.4) - multi_json (~> 1.0) + mime-types (2.99.3) + mini_mime (1.1.2) + mini_portile2 (2.4.0) + multi_json (1.15.0) + multi_xml (0.6.0) + multipart-post (2.3.0) + nokogiri (1.10.10) + mini_portile2 (~> 2.4.0) + oauth2 (1.4.8) + faraday (>= 0.8, < 3.0) + jwt (>= 1.0, < 3.0) + multi_json (~> 1.3) multi_xml (~> 0.5) - rack (~> 1.2) - pry (0.10.3) + rack (>= 1.2, < 3) + pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.5.2) - rake (10.1.0) - rdoc (4.0.1) - json (~> 1.4) + psych (3.1.0) + rack (2.2.8) + rake (13.1.0) + rchardet (1.8.0) + rdoc (6.2.0) rspec (2.7.0) rspec-core (~> 2.7.0) rspec-expectations (~> 2.7.0) @@ -62,10 +68,13 @@ GEM rspec-expectations (2.7.0) diff-lcs (~> 1.1.2) rspec-mocks (2.7.0) + semver2 (3.4.2) slop (3.6.0) + thread_safe (0.3.6) PLATFORMS ruby + x86_64-linux DEPENDENCIES fakeweb (~> 1.3.0) @@ -75,4 +84,4 @@ DEPENDENCIES rspec (~> 2.7.0) BUNDLED WITH - 1.11.2 + 2.3.27 \ No newline at end of file From 7f297b02b0c43cd477bee4a1791bead93ac974d3 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Tue, 14 Nov 2023 21:00:26 -0500 Subject: [PATCH 03/30] formater --- .circleci/config.yml | 3 ++- Gemfile | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5593fae..1471a72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,8 @@ jobs: name: Run tests command: | ./cc-test-reporter before-build - bundle exec rspec --profile 10 \ + bundle exec rspec spec + --profile 10 \ --format RspecJunitFormatter \ --out test_results/rspec.xml \ --format progress diff --git a/Gemfile b/Gemfile index fea4cf8..f5dbd29 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,9 @@ group :development do gem "jeweler" gem "rspec", "~> 2.7.0" gem 'pry', '~> 0.10.3' + gem 'rspec_junit_formatter' end + +group :test do + gem 'rspec_junit_formatter' +end \ No newline at end of file From 7415a5dd6d64a13d04a342bd880b2849d4bb81be Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:02:08 -0800 Subject: [PATCH 04/30] try this out --- lib/sendgrid_toolkit/common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sendgrid_toolkit/common.rb b/lib/sendgrid_toolkit/common.rb index 275f45f..adb0918 100644 --- a/lib/sendgrid_toolkit/common.rb +++ b/lib/sendgrid_toolkit/common.rb @@ -15,7 +15,7 @@ def retrieve_with_timestamps(options = {}) parse_message_time message end else - parse_message_time response + parse_message_time response.parsed_response end response end From f41df47a5eecc9233780b7dd299436a41bd2ba72 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:27:57 -0800 Subject: [PATCH 05/30] should fix some of the tests --- lib/sendgrid_toolkit/common.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sendgrid_toolkit/common.rb b/lib/sendgrid_toolkit/common.rb index adb0918..f845b9d 100644 --- a/lib/sendgrid_toolkit/common.rb +++ b/lib/sendgrid_toolkit/common.rb @@ -10,12 +10,12 @@ def retrieve(options = {}) def retrieve_with_timestamps(options = {}) options.merge! :date => 1 response = retrieve options - if response.is_a? Array + if response.respond_to?(:each) response.each do |message| parse_message_time message end else - parse_message_time response.parsed_response + parse_message_time response end response end From ffde4b3d28a500c43fba7cbd9a754b1d6130ce93 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:42:43 -0800 Subject: [PATCH 06/30] more test fixes --- lib/sendgrid_toolkit/abstract_sendgrid_client.rb | 2 +- lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb | 2 +- .../newsletter/newsletter_sendgrid_client_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb index 49a2d16..5aee161 100644 --- a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb @@ -39,7 +39,7 @@ def compose_base_path(module_name, action_name) private def has_error?(response) - response.kind_of?(Hash) && response.has_key?('error') + response != nil && response.respond_to?(:key?) && response.key?('error') end end end diff --git a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb index b8f6ba5..668d3c5 100644 --- a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb @@ -54,7 +54,7 @@ def credentials end def error?(response) - response.is_a?(Hash) && response.key?('error') + response != nil && response.respond_to?(:key?) && response.key?('error') end end end diff --git a/spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb b/spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb index 9f8c901..5b4ca8d 100644 --- a/spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb +++ b/spec/lib/sendgrid_toolkit/newsletter/newsletter_sendgrid_client_spec.rb @@ -19,7 +19,7 @@ sendgrid_client = SendgridToolkit::NewsletterSendgridClient.new("fakeuser", "fakepass") - sendgrid_client.send(:api_post, "lists", "add", opts).should eql({ 'message' => 'success' }) + sendgrid_client.send(:api_post, "lists", "add", opts).parsed_response.should eql({ 'message' => 'success' }) end end end From ddb01fe9425785275d59451b46869e62f1b5728f Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:58:14 -0800 Subject: [PATCH 07/30] fix --- .circleci/config.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1471a72..bb9559e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,11 +45,10 @@ jobs: name: Run tests command: | ./cc-test-reporter before-build - bundle exec rspec spec - --profile 10 \ - --format RspecJunitFormatter \ - --out test_results/rspec.xml \ - --format progress + bundle exec rspec spec --profile 10 \ + --format RspecJunitFormatter \ + --out test_results/rspec.xml \ + --format progress ./cc-test-reporter after-build -t simplecov --exit-code $? - store_test_results: From a2057a718191d5b33441d0ab25f1cd2a92ef657b Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:06:47 -0800 Subject: [PATCH 08/30] who knows what will ultimately work here --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bb9559e..ddbbc86 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,12 +44,10 @@ jobs: - run: name: Run tests command: | - ./cc-test-reporter before-build bundle exec rspec spec --profile 10 \ --format RspecJunitFormatter \ --out test_results/rspec.xml \ --format progress - ./cc-test-reporter after-build -t simplecov --exit-code $? - store_test_results: path: test_results From 3280ebdf4237b2eb0a61b0354af28afae9a18954 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:08:45 -0800 Subject: [PATCH 09/30] just tests stop with all this other stuff --- .circleci/config.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ddbbc86..83effd4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,10 +44,7 @@ jobs: - run: name: Run tests command: | - bundle exec rspec spec --profile 10 \ - --format RspecJunitFormatter \ - --out test_results/rspec.xml \ - --format progress + bundle exec rspec spec - store_test_results: path: test_results From 6222e92ffc584fe02c5e1062fe853f0e37988e04 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:34:41 -0800 Subject: [PATCH 10/30] try to change the package to a promoboxx one so it doesn't look like we're trying to override the other sendgrid_toolkit --- .circleci/config.yml | 4 ++-- Rakefile | 5 ++--- sendgrid_toolkit.gemspec | 9 +++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1471a72..142134d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,7 +60,7 @@ jobs: context: gem command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then - gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.4.0.gem q + gem build promoboxx_sendgrid_toolkit.gemspec + curl -F package=@promoboxx_sendgrid_toolkit-1.4.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/Rakefile b/Rakefile index bebf02f..4fc6ab4 100644 --- a/Rakefile +++ b/Rakefile @@ -13,13 +13,12 @@ require 'jeweler' Jeweler::Tasks.new do |gem| # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options - gem.name = "sendgrid_toolkit" + gem.name = "promoboxx_sendgrid_toolkit" gem.homepage = "http://github.com/freerobby/sendgrid_toolkit" gem.license = "MIT" gem.summary = "sendgrid_toolkit = Sendgrid + Ruby" gem.description = "A Ruby wrapper and utility library for communicating with the Sendgrid API." - gem.email = "robby@freerobby.com" - gem.authors = ["Robby Grossman"] + gem.authors = ["promoboxx people"] # dependencies defined in Gemfile end Jeweler::RubygemsDotOrgTasks.new diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index 4f0efdf..a288cf1 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -5,14 +5,12 @@ # stub: sendgrid_toolkit 1.4.0 ruby lib Gem::Specification.new do |s| - s.name = "sendgrid_toolkit" + s.name = "promoboxx_sendgrid_toolkit" s.version = "1.4.0" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Robby Grossman"] + s.authors = ["promoboxx people"] s.date = "2014-03-04" s.description = "A Ruby wrapper and utility library for communicating with the Sendgrid API." - s.email = "robby@freerobby.com" s.extra_rdoc_files = [ "LICENSE.txt", "README.md" @@ -43,7 +41,7 @@ Gem::Specification.new do |s| 'lib/sendgrid_toolkit/v3/groups.rb', 'lib/sendgrid_toolkit/v3/unsubscribes.rb', 'lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb', - "sendgrid_toolkit.gemspec", + "promoboxx_sendgrid_toolkit.gemspec", "spec/helper.rb", "spec/lib/sendgrid_toolkit/abstract_sendgrid_client_spec.rb", "spec/lib/sendgrid_toolkit/blocks_spec.rb", @@ -60,7 +58,6 @@ Gem::Specification.new do |s| 'spec/lib/sendgrid_toolkit/v3/abstract_sendgrid_client_spec.rb', 'spec/lib/sendgrid_toolkit/v3/unsubscribes_spec.rb' ] - s.homepage = "http://github.com/freerobby/sendgrid_toolkit" s.licenses = ["MIT"] s.require_paths = ["lib"] s.rubygems_version = "2.1.11" From 012b5cdd76e6fd44b8370de66a7259837840eff4 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:43:29 -0800 Subject: [PATCH 11/30] no message --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cbec1c..0462241 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,7 +54,7 @@ jobs: context: gem command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then - gem build promoboxx_sendgrid_toolkit.gemspec - curl -F package=@promoboxx_sendgrid_toolkit-1.4.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + gem build sendgrid_toolkit.gemspec + curl -F package=@sendgrid_toolkit-1.4.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi From babafea9eca40838f91cd83ef2325a377376d4a7 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:52:22 -0800 Subject: [PATCH 12/30] last reversion --- Rakefile | 2 +- sendgrid_toolkit.gemspec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 4fc6ab4..78744d3 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ require 'jeweler' Jeweler::Tasks.new do |gem| # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options - gem.name = "promoboxx_sendgrid_toolkit" + gem.name = "sendgrid_toolkit" gem.homepage = "http://github.com/freerobby/sendgrid_toolkit" gem.license = "MIT" gem.summary = "sendgrid_toolkit = Sendgrid + Ruby" diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index a288cf1..f4ebabf 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -5,7 +5,7 @@ # stub: sendgrid_toolkit 1.4.0 ruby lib Gem::Specification.new do |s| - s.name = "promoboxx_sendgrid_toolkit" + s.name = "sendgrid_toolkit" s.version = "1.4.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] @@ -41,7 +41,7 @@ Gem::Specification.new do |s| 'lib/sendgrid_toolkit/v3/groups.rb', 'lib/sendgrid_toolkit/v3/unsubscribes.rb', 'lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb', - "promoboxx_sendgrid_toolkit.gemspec", + "sendgrid_toolkit.gemspec", "spec/helper.rb", "spec/lib/sendgrid_toolkit/abstract_sendgrid_client_spec.rb", "spec/lib/sendgrid_toolkit/blocks_spec.rb", From bfd2c79674e7dbd2f7343ba1636f03cf17cbc7b7 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:01:39 -0800 Subject: [PATCH 13/30] Upgrade package --- .circleci/config.yml | 2 +- sendgrid_toolkit.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0462241..d9fdd56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.4.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.5.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index f4ebabf..f5832e9 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.4.0" + s.version = "1.5.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" From 0cafc6293870965efb423480a32e256ad9969535 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:04:22 -0800 Subject: [PATCH 14/30] bane of my existence --- .circleci/config.yml | 2 +- sendgrid_toolkit.gemspec | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d9fdd56..6438e74 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.5.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.6.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index f5832e9..c37c6e9 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.5.0" + s.version = "1.6.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" @@ -29,6 +29,7 @@ Gem::Specification.new do |s| "lib/sendgrid_toolkit/blocks.rb", "lib/sendgrid_toolkit/bounces.rb", "lib/sendgrid_toolkit/common.rb", + "lib/sendgrid_toolkit/http_parser_party.rb", "lib/sendgrid_toolkit/invalid_emails.rb", "lib/sendgrid_toolkit/mail.rb", "lib/sendgrid_toolkit/newsletter/list_emails.rb", From c59b609cb10638689ddafc4a68760b26884bcf9c Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Thu, 25 Jan 2024 09:49:09 -0800 Subject: [PATCH 15/30] merge apikey change, bump package version --- .circleci/config.yml | 2 +- lib/sendgrid_toolkit/abstract_sendgrid_client.rb | 9 +++++++++ sendgrid_toolkit.gemspec | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6438e74..5e9c6ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.6.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.7.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb index 5aee161..1b4f9b5 100644 --- a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb @@ -16,6 +16,15 @@ def api_post(module_name, action_name, opts = {}) response = HTTParserParty.post("https://#{SendgridToolkit.base_uri}/#{base_path}.json", :body => get_credentials.merge(opts), :format => :json) + + base_path = compose_base_path(module_name, action_name) + response = nil + if (@api_user == "apikey") + response = HTTParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => opts, :format => :json, :headers => { "Authorization" => "Bearer #{@api_key}"}) + else + response = HTTParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => get_credentials.merge(opts), :format => :json) + end + if response.code > 401 raise(SendgridToolkit::SendgridServerError, "The SendGrid server returned an error. #{response.inspect}") elsif has_error?(response) and diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index c37c6e9..a21ebd7 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.6.0" + s.version = "1.7.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" From 1f2cd235fbf5fa9955ee65b4c6c53a51e32b7402 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:00:36 -0800 Subject: [PATCH 16/30] remove dupe code --- lib/sendgrid_toolkit/abstract_sendgrid_client.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb index 1b4f9b5..6938fe9 100644 --- a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb @@ -12,11 +12,6 @@ def initialize(api_user = nil, api_key = nil) protected def api_post(module_name, action_name, opts = {}) - base_path = compose_base_path(module_name, action_name) - response = HTTParserParty.post("https://#{SendgridToolkit.base_uri}/#{base_path}.json", - :body => get_credentials.merge(opts), - :format => :json) - base_path = compose_base_path(module_name, action_name) response = nil if (@api_user == "apikey") From a6d625a36a3d59057fed85aee0fc647afcbcc0e1 Mon Sep 17 00:00:00 2001 From: Sean Slattery <30410349+sean-m-slattery@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:24:23 -0800 Subject: [PATCH 17/30] needed the parser party --- lib/sendgrid_toolkit/abstract_sendgrid_client.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb index 6938fe9..54680b9 100644 --- a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb @@ -15,9 +15,9 @@ def api_post(module_name, action_name, opts = {}) base_path = compose_base_path(module_name, action_name) response = nil if (@api_user == "apikey") - response = HTTParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => opts, :format => :json, :headers => { "Authorization" => "Bearer #{@api_key}"}) + response = HTTParserParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => opts, :format => :json, :headers => { "Authorization" => "Bearer #{@api_key}"}) else - response = HTTParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => get_credentials.merge(opts), :format => :json) + response = HTTParserParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => get_credentials.merge(opts), :format => :json) end if response.code > 401 From 8c402224dc7644a3feef3bb0c7b2b7dd116dbf9d Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Wed, 5 Mar 2025 10:45:01 -0500 Subject: [PATCH 18/30] DEV-10737 Add V3 bounces method (#2) --- .circleci/config.yml | 2 +- lib/sendgrid_toolkit.rb | 1 + .../abstract_sendgrid_client.rb | 6 +-- .../v3/abstract_sendgrid_client.rb | 48 +++++++++++++------ lib/sendgrid_toolkit/v3/bounces.rb | 12 +++++ sendgrid_toolkit.gemspec | 2 +- spec/lib/sendgrid_toolkit/v3/bounces_spec.rb | 17 +++++++ 7 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 lib/sendgrid_toolkit/v3/bounces.rb create mode 100644 spec/lib/sendgrid_toolkit/v3/bounces_spec.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index 5e9c6ee..393158f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.7.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.8.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/lib/sendgrid_toolkit.rb b/lib/sendgrid_toolkit.rb index 19d19dd..f225bf1 100644 --- a/lib/sendgrid_toolkit.rb +++ b/lib/sendgrid_toolkit.rb @@ -13,6 +13,7 @@ require 'sendgrid_toolkit/mail' require 'sendgrid_toolkit/v3/abstract_sendgrid_client' +require 'sendgrid_toolkit/v3/bounces' require 'sendgrid_toolkit/v3/groups' require 'sendgrid_toolkit/v3/unsubscribes' diff --git a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb index 54680b9..4657344 100644 --- a/lib/sendgrid_toolkit/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/abstract_sendgrid_client.rb @@ -22,9 +22,9 @@ def api_post(module_name, action_name, opts = {}) if response.code > 401 raise(SendgridToolkit::SendgridServerError, "The SendGrid server returned an error. #{response.inspect}") - elsif has_error?(response) and - response['error'].respond_to?(:has_key?) and - response['error'].has_key?('code') and + elsif has_error?(response) && + response['error'].respond_to?(:has_key?) && + response['error'].has_key?('code') && response['error']['code'].to_i == 401 raise SendgridToolkit::AuthenticationFailed elsif has_error?(response) diff --git a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb index 668d3c5..40dcdaf 100644 --- a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb @@ -2,7 +2,7 @@ module SendgridToolkit module V3 class AbstractSendgridClient - BASE_URI = 'https://api.sendgrid.com/v3/asm' + BASE_URI = 'https://api.sendgrid.com/v3' def initialize(api_user = nil, api_key = nil) @api_user = api_user || SendgridToolkit.api_user || ENV['SMTP_USERNAME'] @@ -15,22 +15,41 @@ def initialize(api_user = nil, api_key = nil) protected def api_post(action_name, options = {}) - response = HTTParserParty.post("#{BASE_URI}/#{action_name}", - body: options.to_json, format: :json, - headers: { 'Authorization' => "Basic #{credentials}" }) + if (@api_user == "apikey") + response = HTTParserParty.post("#{BASE_URI}/#{action_name}", + body: options.to_json, format: :json, + headers: { 'Authorization' => "Bearer #{api_key}" }) + else + response = HTTParserParty.post("#{BASE_URI}/#{action_name}", + body: options.to_json, format: :json, + headers: { 'Authorization' => "Basic #{credentials}" }) + end check_response(response) end def api_get(action_name, options = {}) - response = HTTParserParty.get("#{BASE_URI}/#{action_name}", - query: options, format: :json, headers: { 'Authorization' => "Basic #{credentials}" }) + if (@api_user == "apikey") + response = HTTParserParty.get("#{BASE_URI}/#{action_name}", + query: options, format: :json, + headers: { 'Authorization' => "Bearer #{api_key}" }) + else + response = HTTParserParty.get("#{BASE_URI}/#{action_name}", + query: options, format: :json, + headers: { 'Authorization' => "Basic #{credentials}" }) + end check_response(response) end def api_delete(action_name, options = {}) - response = HTTParserParty.delete("#{BASE_URI}/#{action_name}", - body: options, format: :json, - headers: { 'Authorization' => "Basic #{credentials}" }) + if (@api_user == "apikey") + response = HTTParserParty.delete("#{BASE_URI}/#{action_name}", + body: options, format: :json, + headers: { 'Authorization' => "Bearer #{api_key}" }) + else + response = HTTParserParty.delete("#{BASE_URI}/#{action_name}", + body: options, format: :json, + headers: { 'Authorization' => "Basic #{credentials}" }) + end check_response(response) end @@ -39,11 +58,12 @@ def api_delete(action_name, options = {}) def check_response(response) if response.code > 401 fail(SendgridToolkit::SendgridServerError, "The SendGrid server returned an error. #{response.inspect}") - elsif error?(response) && response['error'].respond_to?(:has_key?) && - response['error'].key?('code') && - response['error']['code'].to_i == 401 + elsif has_error?(response) && + response['error'].respond_to?(:has_key?) && + response['error'].has_key?('code') && + response['error']['code'].to_i == 401 fail SendgridToolkit::AuthenticationFailed - elsif error?(response) + elsif has_error?(response) fail(SendgridToolkit::APIError, response['error']) end response @@ -53,7 +73,7 @@ def credentials Base64.encode64("#{@api_user}:#{@api_key}") end - def error?(response) + def has_error?(response) response != nil && response.respond_to?(:key?) && response.key?('error') end end diff --git a/lib/sendgrid_toolkit/v3/bounces.rb b/lib/sendgrid_toolkit/v3/bounces.rb new file mode 100644 index 0000000..3709513 --- /dev/null +++ b/lib/sendgrid_toolkit/v3/bounces.rb @@ -0,0 +1,12 @@ +module SendgridToolkit + module V3 + class Bounces < SendgridToolkit::V3::AbstractSendgridClient + def get(opts = {}) + action_name = 'supressions/bounces' + response = api_get(action_name, opts) + fail(SendgridToolkit::APIError, response['error']) if response.is_a?(Hash) && response.key?('errors') + response + end + end + end +end diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index a21ebd7..497c160 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.7.0" + s.version = "1.8.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" diff --git a/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb b/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb new file mode 100644 index 0000000..50d65d1 --- /dev/null +++ b/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb @@ -0,0 +1,17 @@ +require File.expand_path("#{File.dirname(__FILE__)}/../../../helper") + +describe SendgridToolkit::V3::Bounces do + before do + FakeWeb.clean_registry + api_name = ENV['TEST_SMTP_USERNAME'] || 'fakeuser' + api_key = ENV['TEST_SMTP_PASSWORD'] || 'fakepass' + @obj = SendgridToolkit::V3::Bounces.new("fakeuser", "fakepass") + end + + describe "#retrieve" do + it "returns array of bounced emails" do + FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/suppressions/bounces", query: {}) + bounces = @obj.get + end + end +end From 6aa2095c0c4202e2606ae901f36726967ab1d322 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Wed, 5 Mar 2025 12:56:07 -0500 Subject: [PATCH 19/30] DEV-10737 Add bounces.rb to gemspec (#3) --- sendgrid_toolkit.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index 497c160..abe82ec 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -39,6 +39,7 @@ Gem::Specification.new do |s| "lib/sendgrid_toolkit/spam_reports.rb", "lib/sendgrid_toolkit/statistics.rb", "lib/sendgrid_toolkit/unsubscribes.rb", + 'lib/sendgrid_toolkit/v3/bounces.rb', 'lib/sendgrid_toolkit/v3/groups.rb', 'lib/sendgrid_toolkit/v3/unsubscribes.rb', 'lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb', From ad9bcdb97ba5fa731a9be1ba281dec505560b795 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Wed, 5 Mar 2025 13:11:38 -0500 Subject: [PATCH 20/30] DEV-10737 Update version to 1.9.0 (#4) --- .circleci/config.yml | 2 +- sendgrid_toolkit.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 393158f..c820acf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.8.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.9.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index abe82ec..5732fc2 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.8.0" + s.version = "1.9.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" From 0a6c5ddcd692892e0ef59f1b60042eba5ecfc0ea Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Thu, 6 Mar 2025 15:56:51 -0500 Subject: [PATCH 21/30] DEV-10737 Update version to 1.10.0. Fix resource path for suppression/bounces. Fix api_key issue. (#5) --- .circleci/config.yml | 2 +- lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb | 6 +++--- lib/sendgrid_toolkit/v3/bounces.rb | 2 +- sendgrid_toolkit.gemspec | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c820acf..c203dcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.9.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.10.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb index 40dcdaf..2bee649 100644 --- a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb @@ -18,7 +18,7 @@ def api_post(action_name, options = {}) if (@api_user == "apikey") response = HTTParserParty.post("#{BASE_URI}/#{action_name}", body: options.to_json, format: :json, - headers: { 'Authorization' => "Bearer #{api_key}" }) + headers: { 'Authorization' => "Bearer #{@api_key}" }) else response = HTTParserParty.post("#{BASE_URI}/#{action_name}", body: options.to_json, format: :json, @@ -31,7 +31,7 @@ def api_get(action_name, options = {}) if (@api_user == "apikey") response = HTTParserParty.get("#{BASE_URI}/#{action_name}", query: options, format: :json, - headers: { 'Authorization' => "Bearer #{api_key}" }) + headers: { 'Authorization' => "Bearer #{@api_key}" }) else response = HTTParserParty.get("#{BASE_URI}/#{action_name}", query: options, format: :json, @@ -44,7 +44,7 @@ def api_delete(action_name, options = {}) if (@api_user == "apikey") response = HTTParserParty.delete("#{BASE_URI}/#{action_name}", body: options, format: :json, - headers: { 'Authorization' => "Bearer #{api_key}" }) + headers: { 'Authorization' => "Bearer #{@api_key}" }) else response = HTTParserParty.delete("#{BASE_URI}/#{action_name}", body: options, format: :json, diff --git a/lib/sendgrid_toolkit/v3/bounces.rb b/lib/sendgrid_toolkit/v3/bounces.rb index 3709513..12b6b70 100644 --- a/lib/sendgrid_toolkit/v3/bounces.rb +++ b/lib/sendgrid_toolkit/v3/bounces.rb @@ -2,7 +2,7 @@ module SendgridToolkit module V3 class Bounces < SendgridToolkit::V3::AbstractSendgridClient def get(opts = {}) - action_name = 'supressions/bounces' + action_name = 'suppression/bounces' response = api_get(action_name, opts) fail(SendgridToolkit::APIError, response['error']) if response.is_a?(Hash) && response.key?('errors') response diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index 5732fc2..52a4d02 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.9.0" + s.version = "1.10.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" From 8cf0d05488a12be410233dcbaa984f561ae5f32c Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Mon, 8 Dec 2025 10:54:04 -0500 Subject: [PATCH 22/30] DEV-11922 Add V3 /mail/send endpoint (#6) --- .circleci/config.yml | 2 +- lib/sendgrid_toolkit.rb | 1 + lib/sendgrid_toolkit/v3/mail.rb | 20 +++++++++++++++++ sendgrid_toolkit.gemspec | 3 ++- spec/lib/sendgrid_toolkit/mail_spec.rb | 2 +- spec/lib/sendgrid_toolkit/v3/mail_spec.rb | 26 +++++++++++++++++++++++ 6 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 lib/sendgrid_toolkit/v3/mail.rb create mode 100644 spec/lib/sendgrid_toolkit/v3/mail_spec.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index c203dcf..9daecda 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,6 @@ jobs: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.10.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.11.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ fi diff --git a/lib/sendgrid_toolkit.rb b/lib/sendgrid_toolkit.rb index f225bf1..3abd768 100644 --- a/lib/sendgrid_toolkit.rb +++ b/lib/sendgrid_toolkit.rb @@ -15,6 +15,7 @@ require 'sendgrid_toolkit/v3/abstract_sendgrid_client' require 'sendgrid_toolkit/v3/bounces' require 'sendgrid_toolkit/v3/groups' +require 'sendgrid_toolkit/v3/mail' require 'sendgrid_toolkit/v3/unsubscribes' require 'sendgrid_toolkit/newsletter/newsletter_sendgrid_client' diff --git a/lib/sendgrid_toolkit/v3/mail.rb b/lib/sendgrid_toolkit/v3/mail.rb new file mode 100644 index 0000000..41a062e --- /dev/null +++ b/lib/sendgrid_toolkit/v3/mail.rb @@ -0,0 +1,20 @@ +require 'json' + +module SendgridToolkit + module V3 + class Mail < SendgridToolkit::V3::AbstractSendgridClient + def send_mail(options = {}) + response = api_post('mail/send', convert_params(options)) + raise(SendEmailError, "SendMail API refused to send email: #{response["errors"].inspect}") if response["message"] == "error" + response + end + + private + + def convert_params(options) + options["x-smtpapi"] = options["x-smtpapi"].to_json if options.has_key?("x-smtpapi") + options + end + end + end +end diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index 52a4d02..c61fbd3 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.10.0" + s.version = "1.11.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = "2014-03-04" @@ -41,6 +41,7 @@ Gem::Specification.new do |s| "lib/sendgrid_toolkit/unsubscribes.rb", 'lib/sendgrid_toolkit/v3/bounces.rb', 'lib/sendgrid_toolkit/v3/groups.rb', + 'lib/sendgrid_toolkit/v3/mail.rb', 'lib/sendgrid_toolkit/v3/unsubscribes.rb', 'lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb', "sendgrid_toolkit.gemspec", diff --git a/spec/lib/sendgrid_toolkit/mail_spec.rb b/spec/lib/sendgrid_toolkit/mail_spec.rb index 969fb10..06fdf68 100644 --- a/spec/lib/sendgrid_toolkit/mail_spec.rb +++ b/spec/lib/sendgrid_toolkit/mail_spec.rb @@ -6,7 +6,7 @@ @obj = SendgridToolkit::Mail.new("fakeuser", "fakepass") end - describe "#send" do + describe "#send_mail" do it "raises error when sendgrid returns an error" do FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI}/mail\.send\.json|, :body => '{"message": "error", "errors": ["Missing destination email"]}') lambda { diff --git a/spec/lib/sendgrid_toolkit/v3/mail_spec.rb b/spec/lib/sendgrid_toolkit/v3/mail_spec.rb new file mode 100644 index 0000000..d8146b1 --- /dev/null +++ b/spec/lib/sendgrid_toolkit/v3/mail_spec.rb @@ -0,0 +1,26 @@ +require File.expand_path("#{File.dirname(__FILE__)}/../../../helper") + +describe SendgridToolkit::V3::Bounces do + before do + FakeWeb.clean_registry + api_name = ENV['TEST_SMTP_USERNAME'] || 'fakeuser' + api_key = ENV['TEST_SMTP_PASSWORD'] || 'fakepass' + @obj = SendgridToolkit::V3::Bounces.new("fakeuser", "fakepass") + end + + describe "#send_mail" do + it "raises error when sendgrid returns an error" do + FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/mail/send|, :body => '{"message": "error", "errors": ["Missing destination email"]}') + lambda { + response = @obj.send_mail :from => "testing@fiverr.com", :subject => "Subject", :text => "Text", "x-smtpapi" => {:category => "Testing", :to => ["elad@fiverr.com"]} + }.should raise_error SendgridToolkit::SendEmailError + end + + it "posts x-smtpapi parameters as json" do + FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/mail/send|, :body => '{"message":"success"}') + xsmtpapi = {:category => "Testing", :to => ["scottb@sendgrid.com"]} + response = @obj.send_mail :to => "scottb@sendgrid.com", :from => "testing@fiverr.com", :subject => "Subject", :text => "Text", "x-smtpapi" => xsmtpapi + response.request.options[:body]["x-smtpapi"].should == xsmtpapi.to_json + end + end +end From 464523b82771d4fa5e0bedb173a83956f0a5ff30 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Fri, 12 Dec 2025 08:43:09 -0500 Subject: [PATCH 23/30] Setup docker for local development and cleanup files (#7) --- .rvmrc | 3 --- .travis.yml | 6 ------ Dockerfile | 35 +++++++++++++++++++++++++++++++++++ Gemfile | 11 ++++++----- Gemfile.lock | 14 +++++++++++--- VERSION | 2 +- docker-compose.yml | 9 +++++++++ sendgrid_toolkit-1.4.0.gem | Bin 18944 -> 0 bytes sendgrid_toolkit.gemspec | 6 +++--- spec/helper.rb | 1 + 10 files changed, 66 insertions(+), 21 deletions(-) delete mode 100644 .rvmrc delete mode 100644 .travis.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml delete mode 100644 sendgrid_toolkit-1.4.0.gem diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index 25649f7..0000000 --- a/.rvmrc +++ /dev/null @@ -1,3 +0,0 @@ -export RUBYOPT="rubygems" -export RUBYLIB="." -rvm 1.9.3@sendgrid_toolkit --create diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 28cf207..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: ruby -rvm: - - 1.9.3 - - jruby-19mode - - 2.0.0 - - 2.1.0 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9df8708 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM pbxx/docker-passenger-ruby-base:ruby-2.7.6-latest + +ARG FOO=bar + +USER root + +RUN apt-get update \ + && apt-get install -y --no-install-recommends --fix-missing \ + wget \ + nano \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Switch to the app user for app installation +USER app + +# Define where our application will live inside the image +ENV HOMEDIR /home/app/ +WORKDIR $HOMEDIR/sendgrid_toolkit + +# Set environment +ENV RUBYOPT='-W:no-deprecated -W:no-experimental' + +COPY --chown=app:app . . + +# Install rubygems and bundler +RUN rm -rf .bundle +RUN gem update --system 3.4.22 +RUN gem install bundler -v 2.4.22 + +# Install gems +ARG CACHEBUST +RUN bundle install --full-index + +USER root diff --git a/Gemfile b/Gemfile index f5dbd29..1fbc263 100644 --- a/Gemfile +++ b/Gemfile @@ -3,13 +3,14 @@ source "http://rubygems.org" gem "httparty", ">= 0.7.6" group :development do - gem "fakeweb", "~> 1.3.0" - gem "jeweler" - gem "rspec", "~> 2.7.0" - gem 'pry', '~> 0.10.3' + gem 'fakeweb', '~> 1.3.0' + gem 'jeweler' + gem 'rspec' + gem 'pry' + gem 'pry-byebug' gem 'rspec_junit_formatter' end group :test do gem 'rspec_junit_formatter' -end \ No newline at end of file +end diff --git a/Gemfile.lock b/Gemfile.lock index 38b15f9..147dafa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ GEM specs: addressable (2.4.0) builder (3.2.4) + byebug (11.1.3) coderay (1.1.3) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) @@ -55,6 +56,9 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + pry-byebug (3.8.0) + byebug (~> 11.0) + pry (~> 0.10) psych (3.1.0) rack (2.2.8) rake (13.1.0) @@ -68,6 +72,8 @@ GEM rspec-expectations (2.7.0) diff-lcs (~> 1.1.2) rspec-mocks (2.7.0) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) semver2 (3.4.2) slop (3.6.0) thread_safe (0.3.6) @@ -80,8 +86,10 @@ DEPENDENCIES fakeweb (~> 1.3.0) httparty (>= 0.7.6) jeweler - pry (~> 0.10.3) - rspec (~> 2.7.0) + pry + pry-byebug + rspec + rspec_junit_formatter BUNDLED WITH - 2.3.27 \ No newline at end of file + 2.3.27 diff --git a/VERSION b/VERSION index e21e727..1cac385 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.0 \ No newline at end of file +1.11.0 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bb045c7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.4' +services: + sendgrid_toolkit: + build: + context: . + environment: + RUBY_OPT: -W:no-deprecated -W:no-experimental + volumes: + - .:/home/app/sendgrid_toolkit diff --git a/sendgrid_toolkit-1.4.0.gem b/sendgrid_toolkit-1.4.0.gem deleted file mode 100644 index 719f452eb55ad16002960a53f0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UKJ~eE z#j97hHutfvDXiPqcc=EurVk@aPL*9nxKNFrF1b= zbvM{{sgR88$5^L@kcQVl@794pi~D*WN7`o5h8h<~#q(eHW3;hN$n;@<3;WFWDu@8F zOL`x1iL_Zu8Hr!jMO3jN>?`dRM7Z`YTp?)3bz0Mfps$4{oQLiAb`q6_h4zw>H2X~f zrx+?}c$|u8T^%|Y>3BXb_e+-Hvmf%6DJ-cROGNA=RY4Or#2so|4dD2w?T3&W8Iosr hkZ4^?iv|CyKEVHqMgH%1{I>=E+XDY>f&T{!{BL5r!>|AV diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index c61fbd3..c97c4d4 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -2,14 +2,14 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- -# stub: sendgrid_toolkit 1.4.0 ruby lib +# stub: sendgrid_toolkit 1.11.0 ruby lib Gem::Specification.new do |s| s.name = "sendgrid_toolkit" s.version = "1.11.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] - s.date = "2014-03-04" + s.date = Time.now.strftime("%Y-%m-%d") s.description = "A Ruby wrapper and utility library for communicating with the Sendgrid API." s.extra_rdoc_files = [ "LICENSE.txt", @@ -63,7 +63,7 @@ Gem::Specification.new do |s| ] s.licenses = ["MIT"] s.require_paths = ["lib"] - s.rubygems_version = "2.1.11" + s.rubygems_version = "2.3.27" s.summary = "sendgrid_toolkit = Sendgrid + Ruby" if s.respond_to? :specification_version then diff --git a/spec/helper.rb b/spec/helper.rb index 4f9070d..b2028f4 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -2,6 +2,7 @@ require 'sendgrid_toolkit' require 'rspec' require 'json' +require 'pry' FakeWeb.allow_net_connect = false From a1b19ac17360a9abf20bfd32893bacec1f6f6257 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Fri, 12 Dec 2025 10:18:56 -0500 Subject: [PATCH 24/30] Cleanup gemspec file (#11) --- sendgrid_toolkit.gemspec | 2 -- 1 file changed, 2 deletions(-) diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index c97c4d4..9f7e7aa 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -16,8 +16,6 @@ Gem::Specification.new do |s| "README.md" ] s.files = [ - ".rvmrc", - ".travis.yml", "Gemfile", "Gemfile.lock", "LICENSE.txt", From f547e9cff5b635bcfdd6089b75e210255bebb767 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Fri, 12 Dec 2025 10:49:58 -0500 Subject: [PATCH 25/30] Add workflow with separate test, build, approval and upload steps (#10) --- .circleci/config.yml | 65 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9daecda..2a2f522 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2 jobs: - build: + test: parallelism: 1 docker: - image: circleci/ruby:2.3 @@ -49,12 +49,67 @@ jobs: - store_test_results: path: test_results + build: + parallelism: 1 + docker: + - image: circleci/ruby:2.3 + working_directory: ~/pbxx + steps: + - checkout + + - restore_cache: + keys: + - ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "sendgrid_toolkit.gemspec" }} + + - run: + name: Build gem + context: gem + command: | + gem build sendgrid_toolkit.gemspec + + - save_cache: + key: ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "sendgrid_toolkit.gemspec" }}-build + paths: + - . + + upload: + parallelism: 1 + docker: + - image: circleci/ruby:2.3 + working_directory: ~/pbxx + steps: + - checkout + + - restore_cache: + keys: + - ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "sendgrid_toolkit.gemspec" }}-build + - run: name: Upload to Gemfury context: gem command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then - gem build sendgrid_toolkit.gemspec - curl -F package=@sendgrid_toolkit-1.11.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ - fi + curl -F package=@sendgrid_toolkit-1.11.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + +workflows: + version: 2 + build_and_upload: + jobs: + - test + - build: + requires: + - test + - ready_to_upload: + type: approval + requires: + - build + filters: + branches: + only: master + - upload: + requires: + - ready_to_upload + filters: + branches: + only: master + From 33b7dfad8c5346a78ddb538c223c121eac1215ea Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Fri, 12 Dec 2025 11:06:31 -0500 Subject: [PATCH 26/30] DEV-11922 Fix V3 tests (#8) --- lib/sendgrid_toolkit/v3/bounces.rb | 4 +-- lib/sendgrid_toolkit/v3/unsubscribes.rb | 6 ++-- spec/helper.rb | 2 +- .../v3/abstract_sendgrid_client_spec.rb | 28 +++++++++---------- spec/lib/sendgrid_toolkit/v3/bounces_spec.rb | 6 ++-- spec/lib/sendgrid_toolkit/v3/groups_spec.rb | 2 +- spec/lib/sendgrid_toolkit/v3/mail_spec.rb | 12 ++++---- .../sendgrid_toolkit/v3/unsubscribes_spec.rb | 6 ++-- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/sendgrid_toolkit/v3/bounces.rb b/lib/sendgrid_toolkit/v3/bounces.rb index 12b6b70..2d074b8 100644 --- a/lib/sendgrid_toolkit/v3/bounces.rb +++ b/lib/sendgrid_toolkit/v3/bounces.rb @@ -1,9 +1,9 @@ module SendgridToolkit module V3 class Bounces < SendgridToolkit::V3::AbstractSendgridClient - def get(opts = {}) + def get(options = {}) action_name = 'suppression/bounces' - response = api_get(action_name, opts) + response = api_get(action_name, options) fail(SendgridToolkit::APIError, response['error']) if response.is_a?(Hash) && response.key?('errors') response end diff --git a/lib/sendgrid_toolkit/v3/unsubscribes.rb b/lib/sendgrid_toolkit/v3/unsubscribes.rb index 2931734..afb8bb6 100644 --- a/lib/sendgrid_toolkit/v3/unsubscribes.rb +++ b/lib/sendgrid_toolkit/v3/unsubscribes.rb @@ -4,7 +4,7 @@ class Unsubscribes < SendgridToolkit::V3::AbstractSendgridClient def add(options = {}) fail NoGroupIdSpecified unless options[:group_id] - response = api_post("groups/#{options[:group_id]}/suppressions", options) + response = api_post("asm/groups/#{options[:group_id]}/suppressions", options) fail APIError if response.is_a?(Hash) && response.key?('errors') response end @@ -12,7 +12,7 @@ def add(options = {}) def delete(options = {}) fail NoGroupIdSpecified unless options[:group_id] - response = api_delete("groups/#{options[:group_id]}/suppressions/#{options[:email]}", options) + response = api_delete("asm/groups/#{options[:group_id]}/suppressions/#{options[:email]}", options) fail APIError if response.is_a?(Hash) && response.key?('errors') response end @@ -20,7 +20,7 @@ def delete(options = {}) def retrieve(options = {}) fail NoGroupIdSpecified unless options[:group_id] - response = api_get("groups/#{options[:group_id]}/suppressions", options) + response = api_get("asm.groups/#{options[:group_id]}/suppressions", options) response end end diff --git a/spec/helper.rb b/spec/helper.rb index b2028f4..67bee3b 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -7,7 +7,7 @@ FakeWeb.allow_net_connect = false REGEX_ESCAPED_BASE_URI = "api\.sendgrid\.com/api" -REGEX_ESCAPED_BASE_URI_V3 = 'api.sendgrid.com/v3/asm' +REGEX_ESCAPED_BASE_URI_V3 = "api.sendgrid.com/v3" def backup_env @env_backup = Hash.new diff --git a/spec/lib/sendgrid_toolkit/v3/abstract_sendgrid_client_spec.rb b/spec/lib/sendgrid_toolkit/v3/abstract_sendgrid_client_spec.rb index fd057e3..5718958 100644 --- a/spec/lib/sendgrid_toolkit/v3/abstract_sendgrid_client_spec.rb +++ b/spec/lib/sendgrid_toolkit/v3/abstract_sendgrid_client_spec.rb @@ -10,32 +10,32 @@ describe '#api_post' do it "throws error when authentication fails" do - FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/profile\.get\.json\?|, :body => '{"error":{"code":401,"message":"Permission denied, wrong credentials"}}') - @obj = SendgridToolkit::AbstractSendgridClient.new("fakeuser", "fakepass") + FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/user/profile", :body => '{"error":{"code":401,"message":"Permission denied, wrong credentials"}}') + @obj = SendgridToolkit::V3::AbstractSendgridClient.new("apikey", "fakepass") lambda { - @obj.send(:api_post, "profile", "get", {}) + @obj.send(:api_get, "user/profile", {}) }.should raise_error SendgridToolkit::AuthenticationFailed end it "thows error when sendgrid response is a server error" do - FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/profile\.get\.json\?|, :body => '{}', :status => ['500', 'Internal Server Error']) - @obj = SendgridToolkit::AbstractSendgridClient.new("someuser", "somepass") + FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/user/profile", :body => '{}', :status => ['500', 'Internal Server Error']) + @obj = SendgridToolkit::V3::AbstractSendgridClient.new("apikey", "fakepass") lambda { - @obj.send(:api_post, "profile", "get", {}) - }.should raise_error SendgridToolkit::AuthenticationFailed + @obj.send(:api_get, "user/profile", {}) + }.should raise_error SendgridToolkit::SendgridServerError end it "handles unexpected error responses gracefully" do - FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI}/profile\.get\.json|, :body => 'Html formatted error', :status => ['500', 'Internal Server Error']) - @obj = SendgridToolkit::AbstractSendgridClient.new("someuser", "somepass") + FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/user/profile", :body => 'Html formatted error', :status => ['500', 'Internal Server Error']) + @obj = SendgridToolkit::V3::AbstractSendgridClient.new("apikey", "fakepass") lambda { - @obj.send(:api_post, "profile", "get", {}) + @obj.send(:api_get, "user/profile", {}) }.should raise_error SendgridToolkit::SendgridServerError, /Html formatted error<\/html> - SendgridToolkit warning/ end it "thows error when sendgrid response is an API error" do - FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/stats\.get\.json\?|, :body => '{"error": "error in end_date: end date is in the future"}', :status => ['400', 'Bad Request']) - @obj = SendgridToolkit::AbstractSendgridClient.new("someuser", "somepass") + FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/stats", :body => '{"error": "error in end_date: end date is in the future"}', :status => ['400', 'Bad Request']) + @obj = SendgridToolkit::V3::AbstractSendgridClient.new("apikey", "fakepass") lambda { - @obj.send(:api_post, "stats", "get", {}) - }.should raise_error SendgridToolkit::SendgridServerError + @obj.send(:api_get, "stats", {}) + }.should raise_error SendgridToolkit::APIError end end diff --git a/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb b/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb index 50d65d1..89ebf60 100644 --- a/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb +++ b/spec/lib/sendgrid_toolkit/v3/bounces_spec.rb @@ -3,14 +3,14 @@ describe SendgridToolkit::V3::Bounces do before do FakeWeb.clean_registry - api_name = ENV['TEST_SMTP_USERNAME'] || 'fakeuser' + api_name = ENV['TEST_SMTP_USERNAME'] || 'apikey' api_key = ENV['TEST_SMTP_PASSWORD'] || 'fakepass' - @obj = SendgridToolkit::V3::Bounces.new("fakeuser", "fakepass") + @obj = SendgridToolkit::V3::Bounces.new(api_name, api_key) end describe "#retrieve" do it "returns array of bounced emails" do - FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/suppressions/bounces", query: {}) + FakeWeb.register_uri(:get, "https://#{REGEX_ESCAPED_BASE_URI_V3}/suppression/bounces", query: {}) bounces = @obj.get end end diff --git a/spec/lib/sendgrid_toolkit/v3/groups_spec.rb b/spec/lib/sendgrid_toolkit/v3/groups_spec.rb index 4010ea5..a6c2055 100644 --- a/spec/lib/sendgrid_toolkit/v3/groups_spec.rb +++ b/spec/lib/sendgrid_toolkit/v3/groups_spec.rb @@ -3,7 +3,7 @@ describe SendgridToolkit::V3::Groups do before do FakeWeb.clean_registry - api_name = ENV['TEST_SMTP_USERNAME'] || 'fakeuser' + api_name = ENV['TEST_SMTP_USERNAME'] || 'apikey' api_key = ENV['TEST_SMTP_PASSWORD'] || 'fakepass' @obj = SendgridToolkit::V3::Groups.new(api_name, api_key) end diff --git a/spec/lib/sendgrid_toolkit/v3/mail_spec.rb b/spec/lib/sendgrid_toolkit/v3/mail_spec.rb index d8146b1..cb37c0d 100644 --- a/spec/lib/sendgrid_toolkit/v3/mail_spec.rb +++ b/spec/lib/sendgrid_toolkit/v3/mail_spec.rb @@ -1,26 +1,26 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../../helper") -describe SendgridToolkit::V3::Bounces do +describe SendgridToolkit::V3::Mail do before do FakeWeb.clean_registry - api_name = ENV['TEST_SMTP_USERNAME'] || 'fakeuser' + api_name = ENV['TEST_SMTP_USERNAME'] || 'apikey' api_key = ENV['TEST_SMTP_PASSWORD'] || 'fakepass' - @obj = SendgridToolkit::V3::Bounces.new("fakeuser", "fakepass") + @obj = SendgridToolkit::V3::Mail.new(api_name, api_key) end describe "#send_mail" do it "raises error when sendgrid returns an error" do - FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/mail/send|, :body => '{"message": "error", "errors": ["Missing destination email"]}') + FakeWeb.register_uri(:post, "https://#{REGEX_ESCAPED_BASE_URI_V3}/mail/send", :body => '{"message": "error", "errors": ["Missing destination email"]}') lambda { response = @obj.send_mail :from => "testing@fiverr.com", :subject => "Subject", :text => "Text", "x-smtpapi" => {:category => "Testing", :to => ["elad@fiverr.com"]} }.should raise_error SendgridToolkit::SendEmailError end it "posts x-smtpapi parameters as json" do - FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI_V3}/mail/send|, :body => '{"message":"success"}') + FakeWeb.register_uri(:post, "https://#{REGEX_ESCAPED_BASE_URI_V3}/mail/send", :body => '{"message":"success"}') xsmtpapi = {:category => "Testing", :to => ["scottb@sendgrid.com"]} response = @obj.send_mail :to => "scottb@sendgrid.com", :from => "testing@fiverr.com", :subject => "Subject", :text => "Text", "x-smtpapi" => xsmtpapi - response.request.options[:body]["x-smtpapi"].should == xsmtpapi.to_json + JSON.parse(response.request.options[:body])["x-smtpapi"].should == xsmtpapi.to_json end end end diff --git a/spec/lib/sendgrid_toolkit/v3/unsubscribes_spec.rb b/spec/lib/sendgrid_toolkit/v3/unsubscribes_spec.rb index be9abc6..42aee2e 100644 --- a/spec/lib/sendgrid_toolkit/v3/unsubscribes_spec.rb +++ b/spec/lib/sendgrid_toolkit/v3/unsubscribes_spec.rb @@ -3,7 +3,7 @@ describe SendgridToolkit::V3::Unsubscribes do before do FakeWeb.clean_registry - api_name = ENV['TEST_SMTP_USERNAME'] || 'fakeuser' + api_name = ENV['TEST_SMTP_USERNAME'] || 'apikey' api_key = ENV['TEST_SMTP_PASSWORD'] || 'fakepass' @obj = SendgridToolkit::V3::Unsubscribes.new(api_name, api_key) end @@ -21,12 +21,12 @@ describe '#add' do xit 'raises no errors on success' do - FakeWeb.register_uri(:post, "https://#{REGEX_ESCAPED_BASE_URI_V3}/suppressions/global", + FakeWeb.register_uri(:post, "https://#{REGEX_ESCAPED_BASE_URI_V3}/asm/suppressions/global", body: '{"recipient_emails":[{"user@domain.com"}]}') -> { @obj.add(recipient_emails: ['user@domain.com']) }.should_not raise_error end xit 'not raises error when email already exists' do - FakeWeb.register_uri(:post, "https://#{REGEX_ESCAPED_BASE_URI_V3}/suppressions/global", + FakeWeb.register_uri(:post, "https://#{REGEX_ESCAPED_BASE_URI_V3}/asm/suppressions/global", body: '{"recipient_emails":[{"user@domain.com"}]}') -> { @obj.add(recipient_emails: ['user@domain.com']) }.should_not raise_error end From 0c328ccac72d2cba3730372e0c1a5a51abb51078 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Fri, 12 Dec 2025 11:12:40 -0500 Subject: [PATCH 27/30] Test and build against Ruby 2.7.6 (#9) --- .circleci/config.yml | 13 +++++++------ .ruby-version | 1 + Gemfile | 2 ++ Gemfile.lock | 5 ++++- 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .ruby-version diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a2f522..5fb152d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,8 @@ jobs: test: parallelism: 1 docker: - - image: circleci/ruby:2.3 + - image: ruby:2.7.6 + working_directory: ~/pbxx steps: - checkout @@ -22,11 +23,11 @@ jobs: - run: name: Update RubyGems - command: sudo gem update --system 3.3.25 + command: gem update --system 3.4.22 - run: name: Install bundler - command: gem install bundler + command: gem install bundler -v 2.4.22 - run: name: Configure bundler @@ -52,11 +53,11 @@ jobs: build: parallelism: 1 docker: - - image: circleci/ruby:2.3 + - image: ruby:2.7.6 working_directory: ~/pbxx steps: - checkout - + - restore_cache: keys: - ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "sendgrid_toolkit.gemspec" }} @@ -75,7 +76,7 @@ jobs: upload: parallelism: 1 docker: - - image: circleci/ruby:2.3 + - image: ruby:2.7.6 working_directory: ~/pbxx steps: - checkout diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..49cdd66 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.6 diff --git a/Gemfile b/Gemfile index 1fbc263..86f8913 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ source "http://rubygems.org" +ruby file: ".ruby-version" + gem "httparty", ">= 0.7.6" group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 147dafa..583a46a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,5 +91,8 @@ DEPENDENCIES rspec rspec_junit_formatter +RUBY VERSION + ruby 2.7.6p219 + BUNDLED WITH - 2.3.27 + 2.4.22 From 96ff7981903f9caf5f87fb4cef7732e2dbf8b1e3 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Mon, 22 Dec 2025 12:27:54 -0500 Subject: [PATCH 28/30] DEV-11922 Set content-type on V3 post calls. Handle HTTParty::Response with errors (#12) --- lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb | 4 ++-- lib/sendgrid_toolkit/v3/bounces.rb | 2 +- lib/sendgrid_toolkit/v3/groups.rb | 6 +++--- lib/sendgrid_toolkit/v3/mail.rb | 2 +- lib/sendgrid_toolkit/v3/unsubscribes.rb | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb index 2bee649..78ecaa3 100644 --- a/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb +++ b/lib/sendgrid_toolkit/v3/abstract_sendgrid_client.rb @@ -18,11 +18,11 @@ def api_post(action_name, options = {}) if (@api_user == "apikey") response = HTTParserParty.post("#{BASE_URI}/#{action_name}", body: options.to_json, format: :json, - headers: { 'Authorization' => "Bearer #{@api_key}" }) + headers: { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{@api_key}" }) else response = HTTParserParty.post("#{BASE_URI}/#{action_name}", body: options.to_json, format: :json, - headers: { 'Authorization' => "Basic #{credentials}" }) + headers: { 'Content-Type' => 'application/json', 'Authorization' => "Basic #{credentials}" }) end check_response(response) end diff --git a/lib/sendgrid_toolkit/v3/bounces.rb b/lib/sendgrid_toolkit/v3/bounces.rb index 2d074b8..842b734 100644 --- a/lib/sendgrid_toolkit/v3/bounces.rb +++ b/lib/sendgrid_toolkit/v3/bounces.rb @@ -4,7 +4,7 @@ class Bounces < SendgridToolkit::V3::AbstractSendgridClient def get(options = {}) action_name = 'suppression/bounces' response = api_get(action_name, options) - fail(SendgridToolkit::APIError, response['error']) if response.is_a?(Hash) && response.key?('errors') + fail(SendgridToolkit::APIError, response['error']) if response.key?('errors') response end end diff --git a/lib/sendgrid_toolkit/v3/groups.rb b/lib/sendgrid_toolkit/v3/groups.rb index 6420c0b..c77f8db 100644 --- a/lib/sendgrid_toolkit/v3/groups.rb +++ b/lib/sendgrid_toolkit/v3/groups.rb @@ -3,14 +3,14 @@ module V3 class Groups < SendgridToolkit::V3::AbstractSendgridClient def add(options = {}) response = api_post('groups', options) - fail GroupsError if response.is_a?(Hash) && response.key?('errors') + fail GroupsError if response.key?('errors') response end def get(group_id = nil) action_name = 'groups' + (group_id ? "/#{group_id}" : '') response = api_get(action_name) - fail GroupsError if response.is_a?(Hash) && response.key?('errors') + fail GroupsError if response.key?('errors') response end @@ -18,7 +18,7 @@ def delete(options = {}) fail NoGroupIdSpecified unless options[:group_id] response = api_delete("groups/#{options[:group_id]}") - fail GroupsError if response.is_a?(Hash) && response.key?('errors') + fail GroupsError if response.key?('errors') response end end diff --git a/lib/sendgrid_toolkit/v3/mail.rb b/lib/sendgrid_toolkit/v3/mail.rb index 41a062e..557ec57 100644 --- a/lib/sendgrid_toolkit/v3/mail.rb +++ b/lib/sendgrid_toolkit/v3/mail.rb @@ -5,7 +5,7 @@ module V3 class Mail < SendgridToolkit::V3::AbstractSendgridClient def send_mail(options = {}) response = api_post('mail/send', convert_params(options)) - raise(SendEmailError, "SendMail API refused to send email: #{response["errors"].inspect}") if response["message"] == "error" + fail(SendgridToolkit::SendEmailError, response['error']) if response.key?('errors') response end diff --git a/lib/sendgrid_toolkit/v3/unsubscribes.rb b/lib/sendgrid_toolkit/v3/unsubscribes.rb index afb8bb6..e522245 100644 --- a/lib/sendgrid_toolkit/v3/unsubscribes.rb +++ b/lib/sendgrid_toolkit/v3/unsubscribes.rb @@ -5,7 +5,7 @@ def add(options = {}) fail NoGroupIdSpecified unless options[:group_id] response = api_post("asm/groups/#{options[:group_id]}/suppressions", options) - fail APIError if response.is_a?(Hash) && response.key?('errors') + fail APIError if response.key?('errors') response end @@ -13,7 +13,7 @@ def delete(options = {}) fail NoGroupIdSpecified unless options[:group_id] response = api_delete("asm/groups/#{options[:group_id]}/suppressions/#{options[:email]}", options) - fail APIError if response.is_a?(Hash) && response.key?('errors') + fail APIError if response.key?('errors') response end From 79ce2c4fb093af1611c9bd78efcfe6fa6f1bb014 Mon Sep 17 00:00:00 2001 From: Joseph Ware Date: Mon, 22 Dec 2025 12:45:04 -0500 Subject: [PATCH 29/30] DEV-11922 Updater version to 1.12.0 (#13) --- .circleci/config.yml | 2 +- VERSION | 2 +- sendgrid_toolkit.gemspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5fb152d..d632254 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -89,7 +89,7 @@ jobs: name: Upload to Gemfury context: gem command: | - curl -F package=@sendgrid_toolkit-1.11.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ + curl -F package=@sendgrid_toolkit-1.12.0.gem https://$GEMFURY_PUSH_TOKEN@push.fury.io/promoboxx/ workflows: version: 2 diff --git a/VERSION b/VERSION index 1cac385..0eed1a2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.0 +1.12.0 diff --git a/sendgrid_toolkit.gemspec b/sendgrid_toolkit.gemspec index 9f7e7aa..f187878 100644 --- a/sendgrid_toolkit.gemspec +++ b/sendgrid_toolkit.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "sendgrid_toolkit" - s.version = "1.11.0" + s.version = "1.12.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["promoboxx people"] s.date = Time.now.strftime("%Y-%m-%d") From 21c9d1a63a030ebc5732b78d4e5a79cd4c065235 Mon Sep 17 00:00:00 2001 From: josephware Date: Thu, 21 May 2026 15:08:09 -0400 Subject: [PATCH 30/30] Don't download cc-test-report since no longer using it --- .circleci/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d632254..c809d5f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,12 +15,6 @@ jobs: - ruby-cache-{{ arch }}-{{ .Branch }} - ruby-cache - - run: - name: Download cc-test-reporter - command: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - - run: name: Update RubyGems command: gem update --system 3.4.22