Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1cafbfa
Initial commit
josephware Nov 14, 2023
1a5baab
gemfile
josephware Nov 15, 2023
7f297b0
formater
josephware Nov 15, 2023
7415a5d
try this out
sean-m-slattery Jan 24, 2024
f41df47
should fix some of the tests
sean-m-slattery Jan 24, 2024
ffde4b3
more test fixes
sean-m-slattery Jan 24, 2024
ddb01fe
fix
sean-m-slattery Jan 24, 2024
a2057a7
who knows what will ultimately work here
sean-m-slattery Jan 24, 2024
3280ebd
just tests stop with all this other stuff
sean-m-slattery Jan 24, 2024
6222e92
try to change the package to a promoboxx one so it doesn't look like …
sean-m-slattery Jan 24, 2024
37921f1
Merge branch 'httparty_upgrade_working'
sean-m-slattery Jan 24, 2024
012b5cd
no message
sean-m-slattery Jan 24, 2024
babafea
last reversion
sean-m-slattery Jan 24, 2024
bfd2c79
Upgrade package
sean-m-slattery Jan 24, 2024
0cafc62
bane of my existence
sean-m-slattery Jan 24, 2024
c59b609
merge apikey change, bump package version
sean-m-slattery Jan 25, 2024
1f2cd23
remove dupe code
sean-m-slattery Jan 25, 2024
a6d625a
needed the parser party
sean-m-slattery Jan 25, 2024
8c40222
DEV-10737 Add V3 bounces method (#2)
josephware Mar 5, 2025
6aa2095
DEV-10737 Add bounces.rb to gemspec (#3)
josephware Mar 5, 2025
ad9bcdb
DEV-10737 Update version to 1.9.0 (#4)
josephware Mar 5, 2025
0a6c5dd
DEV-10737 Update version to 1.10.0. Fix resource path for suppression…
josephware Mar 6, 2025
8cf0d05
DEV-11922 Add V3 /mail/send endpoint (#6)
josephware Dec 8, 2025
464523b
Setup docker for local development and cleanup files (#7)
josephware Dec 12, 2025
a1b19ac
Cleanup gemspec file (#11)
josephware Dec 12, 2025
f547e9c
Add workflow with separate test, build, approval and upload steps (#10)
josephware Dec 12, 2025
33b7dfa
DEV-11922 Fix V3 tests (#8)
josephware Dec 12, 2025
0c328cc
Test and build against Ruby 2.7.6 (#9)
josephware Dec 12, 2025
96ff798
DEV-11922 Set content-type on V3 post calls. Handle HTTParty::Respons…
josephware Dec 22, 2025
79ce2c4
DEV-11922 Updater version to 1.12.0 (#13)
josephware Dec 22, 2025
21c9d1a
Don't download cc-test-report since no longer using it
josephware May 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
version: 2
jobs:
test:
parallelism: 1
docker:
- image: ruby:2.7.6

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: Update RubyGems
command: gem update --system 3.4.22

- run:
name: Install bundler
command: gem install bundler -v 2.4.22

- 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: |
bundle exec rspec spec

- store_test_results:
path: test_results

build:
parallelism: 1
docker:
- image: ruby:2.7.6
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: ruby:2.7.6
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: |
curl -F package=@sendgrid_toolkit-1.12.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


1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.6
3 changes: 0 additions & 3 deletions .rvmrc

This file was deleted.

6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
16 changes: 12 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
source "http://rubygems.org"

ruby file: ".ruby-version"

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
106 changes: 63 additions & 43 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,59 +1,69 @@
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)
byebug (11.1.3)
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)
pry-byebug (3.8.0)
byebug (~> 11.0)
pry (~> 0.10)
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)
Expand All @@ -62,17 +72,27 @@ 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)

PLATFORMS
ruby
x86_64-linux

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

RUBY VERSION
ruby 2.7.6p219

BUNDLED WITH
1.11.2
2.4.22
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Jeweler::Tasks.new do |gem|
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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.12.0
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions lib/sendgrid_toolkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
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/mail'
require 'sendgrid_toolkit/v3/unsubscribes'

require 'sendgrid_toolkit/newsletter/newsletter_sendgrid_client'
Expand Down
18 changes: 11 additions & 7 deletions lib/sendgrid_toolkit/abstract_sendgrid_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ def initialize(api_user = nil, api_key = nil)

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)
response = nil
if (@api_user == "apikey")
response = HTTParserParty.post("https://#{BASE_URI}/#{base_path}.json?", :body => opts, :format => :json, :headers => { "Authorization" => "Bearer #{@api_key}"})
else
response = HTTParserParty.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
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)
Expand All @@ -39,7 +43,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
Loading