Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 4 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,22 @@ on: [push]
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ['3.1', '3.2']
Comment thread
ehimen-io marked this conversation as resolved.

ruby-version: ['3.3', '3.4', '4.0']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- run: bundle install
- run: bundle exec rspec

rubocop:
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ['3.1', '3.2']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
ruby-version: '4.0'
bundler-cache: true
- run: bundle install
- run: bundle exec rubocop
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.4
4.0.1
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.1.0] - 2026-02-11
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Arguably we could do a major version bump since there are breaking changes in here, but i don't feel strongly about it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad idea

Copy link
Copy Markdown
Contributor Author

@ehimen-io ehimen-io Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major version bump sounds good in any other scenario. However, I do like being able to eye-ball a semver across all our ruby repos and see if includes the ruby + faraday upgrade or not. Currently, all gems we maintain with Ruby 4.0 and/or Faraday 2.14 have a semver 1.x

For that selfish reason, I'll keep the semver as is.


### BREAKING CHANGES
- Now requires Faraday 2.x (previously supported Faraday 1.x)
- Dropped support for Ruby versions older than 3.3. Officially supported versions are Ruby 3.3, 3.4, and 4.0.

## [1.0.0] - 2023-10-17

### BREAKING CHANGES
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Client gem for the ENS API to Engaging Networks

[![CI Status](https://github.com/controlshift/engaging-networks-rest/actions/workflows/ci.yml/badge.svg)](https://github.com/controlshift/engaging-networks-rest/actions/workflows/ci.yml)

## Requirements

- Ruby 3.3, 3.4, or 4.0
- Faraday ~> 2.0

## Install

`gem install engaging-networks-rest`
Expand Down
34 changes: 2 additions & 32 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,8 @@
# frozen_string_literal: true

require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end
require 'rake'

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
desc 'Run specs'
RSpec::Core::RakeTask.new do |t|
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
t.rspec_opts = '--color'
end

desc 'Code coverage detail'
task :simplecov do
ENV['COVERAGE'] = 'true'
Rake::Task['test'].execute
end
RSpec::Core::RakeTask.new(:spec)

desc 'Default: run specs'
task default: :spec

require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ''

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "engaging-networks-rest #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
62 changes: 29 additions & 33 deletions engaging-networks-rest.gemspec
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
# frozen_string_literal: true

Gem::Specification.new do |s|
s.name = "engaging-networks-rest".freeze
s.version = "1.0.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Grey Moore".freeze]
s.date = "2023-10-17"
s.description = "Client gem for the ENS API to Engaging Networks".freeze
s.email = "systems@controlshiftlabs.com".freeze
s.extra_rdoc_files = [
"LICENSE",
"LICENSE.txt",
"README.md"
]

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
s.files = Dir.chdir(File.expand_path(__dir__)) do
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = 'engaging-networks-rest'
spec.version = File.read(File.expand_path('VERSION', __dir__)).strip
spec.authors = ['Grey Moore', 'Owens Ehimen', 'Diego Marcet']
spec.email = ['talk@controlshiftlabs.com']

spec.summary = 'Client gem for the ENS API to Engaging Networks'
spec.description = 'Client gem for the ENS API to Engaging Networks'
spec.homepage = 'https://github.com/controlshift/engaging-networks-rest'
spec.license = 'MIT'

spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.require_paths = ['lib']

s.homepage = 'https://github.com/controlshift/engaging-networks-rest'.freeze
s.licenses = ["MIT".freeze]
s.summary = "Client gem for the ENS API to Engaging Networks".freeze
spec.required_ruby_version = ['>= 3.3', '< 5.0']

if s.respond_to? :specification_version then
s.specification_version = 4
end
# Runtime dependencies
spec.add_runtime_dependency 'faraday', '~> 2.0'

s.add_runtime_dependency(%q<faraday>.freeze, [">= 1.0"])
s.add_runtime_dependency(%q<faraday_middleware>.freeze, [">= 0"])
# Development dependencies
spec.add_development_dependency 'bundler', '>= 2.0', '< 5.0'
spec.add_development_dependency 'debug', '~> 1.0'
spec.add_development_dependency 'faker', '~> 3.0'
spec.add_development_dependency 'faraday-detailed_logger', '~> 2.0'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 1.0'
spec.add_development_dependency 'webmock', '~> 3.0'

s.add_development_dependency(%q<faker>.freeze, ["> 2.20.0"])
s.add_development_dependency(%q<faraday-detailed_logger>.freeze, [">= 2.1.2"])
s.add_development_dependency(%q<debug>.freeze, ["> 0"])
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
s.add_development_dependency(%q<webmock>.freeze, ["> 3.4"])
spec.metadata['rubygems_mfa_required'] = 'true'
end
4 changes: 1 addition & 3 deletions lib/engaging_networks_rest/client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'faraday'
require 'faraday_middleware'
require 'engaging_networks_rest/client/pages'
require 'engaging_networks_rest/response/raise_error'

Expand Down Expand Up @@ -53,11 +52,10 @@ def request(method:, path:, params: {}, body: {})
authenticate! unless authenticated?

response = connection.send(method) do |req|
req.headers['Content-Type'] = 'application/json'
req.path = path
req.params = params
req.headers['ens-auth-token'] = ens_auth_key
req.body = ::JSON.generate(body) unless body.empty?
req.body = body unless body.empty?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, we no longer need the JSON.generate and to explicitly set the Content-Type of the request, because the connection setup already specifies :json?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Faraday handles setting the content-type and wiring up the JSON middleware.

end

response.body
Expand Down
2 changes: 1 addition & 1 deletion lib/engaging_networks_rest/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Unauthorized < StandardError; end

class InternalError < StandardError; end

class RaiseError < Faraday::Response::Middleware
class RaiseError < Faraday::Middleware
def on_complete(response)
status_code = response[:status].to_i
if (400...600).include? status_code
Expand Down
9 changes: 5 additions & 4 deletions spec/client/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
let(:host) { 'example.com' }
let(:api_key) { 'abc-123' }
let(:ens_auth_key) { 'tmp-auth-key-456' }
let(:standard_headers) { { 'Content-Type' => 'application/json', 'Ens-Auth-Token' => ens_auth_key } }
let(:standard_headers) { { 'Ens-Auth-Token' => ens_auth_key } }
let(:json_headers) { standard_headers.merge('Content-Type' => 'application/json') }

subject { EngagingNetworksRest::Client.new(api_key:, host:) }

Expand Down Expand Up @@ -77,7 +78,7 @@
stub_request(:post, page_req_url)
.with(body: { 'txn1' => 'foo', 'txn2' => 'bar', 'suppressAutoResponder' => true,
supporter: { 'lastName' => 'Smith', 'emailAddress' => email } }.to_json,
headers: standard_headers)
headers: json_headers)
.to_return(status: '200',
headers: { content_type: 'application/json; charset=utf-8' },
body: response.to_json)
Expand All @@ -91,7 +92,7 @@

it 'should process the page request and return its ID' do
stub_request(:post, page_req_url)
.with(body: { supporter: supporter_hash }.to_json, headers: standard_headers)
.with(body: { supporter: supporter_hash }.to_json, headers: json_headers)
.to_return(status: '200',
headers: { content_type: 'application/json; charset=utf-8' },
body: response.to_json)
Expand All @@ -105,7 +106,7 @@

it 'should raise if response status is not SUCCESS' do
stub_request(:post, page_req_url)
.with(body: { supporter: supporter_hash }.to_json, headers: standard_headers)
.with(body: { supporter: supporter_hash }.to_json, headers: json_headers)
.to_return(status: '200',
headers: { content_type: 'application/json; charset=utf-8' },
body: failure_response.to_json)
Expand Down