From 133c62f2328e9b087c5d7ad16a53a41491318c85 Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Thu, 15 May 2025 08:04:46 +0000 Subject: [PATCH 1/8] Add HubSpot API monkey-patch to skip blank hapikey and update gemspec for primeNumber --- config/initializers/hubspot_api_patch.rb | 19 +++++++++++++++++++ hubspot-api-client.gemspec | 6 +++--- lib/hubspot/version.rb | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 config/initializers/hubspot_api_patch.rb diff --git a/config/initializers/hubspot_api_patch.rb b/config/initializers/hubspot_api_patch.rb new file mode 100644 index 00000000..1ec0fdc0 --- /dev/null +++ b/config/initializers/hubspot_api_patch.rb @@ -0,0 +1,19 @@ +# HubSpot API 9.5.1 Monkey-Patch : skip blank hapikey on OAuth +module Hubspot + module Crm + module Schemas + class ApiClient # :nodoc: + alias _orig_update_params_for_auth! update_params_for_auth! + + def update_params_for_auth!(header_params, query_params, auth_names) + # hapikey が空なら除外 + auth_names = Array(auth_names).reject do |name| + name == 'hapikey' && @config.api_key['hapikey'].to_s.strip.empty? + end + + _orig_update_params_for_auth!(header_params, query_params, auth_names) + end + end + end + end +end diff --git a/hubspot-api-client.gemspec b/hubspot-api-client.gemspec index 4976faad..20c5255c 100644 --- a/hubspot-api-client.gemspec +++ b/hubspot-api-client.gemspec @@ -2,12 +2,12 @@ $:.push File.expand_path("../lib", __FILE__) require "hubspot/version" Gem::Specification.new do |s| - s.name = "hubspot-api-client" + s.name = "hubspot-api-client-patched-pn" s.version = Hubspot::VERSION s.platform = Gem::Platform::RUBY - s.authors = ["HubSpot"] + s.authors = ["primeNumber"] s.email = [""] - s.homepage = "https://github.com/HubSpot/hubspot-api-ruby" + s.homepage = "https://github.com/primenumber-dev/hubspot-api-ruby" s.summary = "HubSpot Ruby API Gem" s.description = "HubSpot Ruby API client" s.license = "Unlicense" diff --git a/lib/hubspot/version.rb b/lib/hubspot/version.rb index d3ee3a7b..d50db0d7 100644 --- a/lib/hubspot/version.rb +++ b/lib/hubspot/version.rb @@ -1,3 +1,3 @@ module Hubspot - VERSION = '9.5.1' - end \ No newline at end of file + VERSION = '9.5.1.trocco.0.0.1' + end From 4fb93de64e080ee0a1f26397a725a8aa8c6b91a1 Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Thu, 15 May 2025 09:15:02 +0000 Subject: [PATCH 2/8] Update JSON dependency version constraints in gemspec --- hubspot-api-client.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hubspot-api-client.gemspec b/hubspot-api-client.gemspec index 20c5255c..e85804a3 100644 --- a/hubspot-api-client.gemspec +++ b/hubspot-api-client.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9" s.add_runtime_dependency 'typhoeus', '~> 1.4.0' - s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0' + s.add_runtime_dependency 'json', '>= 2.1', '< 2.7' s.add_runtime_dependency 'require_all', '~> 3.0.0' s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' From 373e32702d5f8c5c43ace820480b9b5745d9a3a4 Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Thu, 15 May 2025 09:16:47 +0000 Subject: [PATCH 3/8] Bump version to 9.5.1.trocco.0.0.2 --- lib/hubspot/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hubspot/version.rb b/lib/hubspot/version.rb index d50db0d7..71e0986d 100644 --- a/lib/hubspot/version.rb +++ b/lib/hubspot/version.rb @@ -1,3 +1,3 @@ module Hubspot - VERSION = '9.5.1.trocco.0.0.1' + VERSION = '9.5.1.trocco.0.0.2' end From c39a91947278caec00305302ff62edb3d800a9bd Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Fri, 16 May 2025 03:26:40 +0000 Subject: [PATCH 4/8] Add ffi runtime dependency and bump version to 9.5.1.trocco.0.0.6 --- hubspot-api-client.gemspec | 1 + lib/hubspot/version.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hubspot-api-client.gemspec b/hubspot-api-client.gemspec index e85804a3..cf1c0538 100644 --- a/hubspot-api-client.gemspec +++ b/hubspot-api-client.gemspec @@ -16,6 +16,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'typhoeus', '~> 1.4.0' s.add_runtime_dependency 'json', '>= 2.1', '< 2.7' s.add_runtime_dependency 'require_all', '~> 3.0.0' + s.add_runtime_dependency 'ffi', '~> 1.15.0' s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1' diff --git a/lib/hubspot/version.rb b/lib/hubspot/version.rb index 71e0986d..ecfeec29 100644 --- a/lib/hubspot/version.rb +++ b/lib/hubspot/version.rb @@ -1,3 +1,3 @@ module Hubspot - VERSION = '9.5.1.trocco.0.0.2' + VERSION = '9.5.1.trocco.0.0.6' end From 41d04810d2d288d4b6df92467e4872384fd56a35 Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Fri, 16 May 2025 04:52:00 +0000 Subject: [PATCH 5/8] Add monkey-patch to skip blank hapikey in HubSpot API OAuth --- .../hubspot_api_patch.rb => lib/hubspot/patch_skip_hapikey.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/initializers/hubspot_api_patch.rb => lib/hubspot/patch_skip_hapikey.rb (100%) diff --git a/config/initializers/hubspot_api_patch.rb b/lib/hubspot/patch_skip_hapikey.rb similarity index 100% rename from config/initializers/hubspot_api_patch.rb rename to lib/hubspot/patch_skip_hapikey.rb From 392575968a138b05a0b712137e1328ccca46e09c Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Fri, 16 May 2025 05:26:34 +0000 Subject: [PATCH 6/8] Add patch to skip blank hapikey in HubSpot API and bump version to 9.5.1.trocco.0.0.8 --- lib/hubspot-api-client.rb | 2 ++ lib/hubspot/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/hubspot-api-client.rb b/lib/hubspot-api-client.rb index fb124a31..c202fac2 100644 --- a/lib/hubspot-api-client.rb +++ b/lib/hubspot-api-client.rb @@ -5,6 +5,8 @@ require_rel 'hubspot/helpers' require_rel 'hubspot' +require_relative 'hubspot/patch_skip_hapikey' + module Hubspot class << self CLIENTS = [ diff --git a/lib/hubspot/version.rb b/lib/hubspot/version.rb index ecfeec29..66314256 100644 --- a/lib/hubspot/version.rb +++ b/lib/hubspot/version.rb @@ -1,3 +1,3 @@ module Hubspot - VERSION = '9.5.1.trocco.0.0.6' + VERSION = '9.5.1.trocco.0.0.8' end From f2aa9278958a867082e90464e8dca2fa21cd8e8b Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Fri, 16 May 2025 06:06:03 +0000 Subject: [PATCH 7/8] Add monkey-patch to skip blank hapikey in OAuth and update version to 9.5.1.trocco.0.0.9 --- lib/hubspot-api-client.rb | 4 ++-- lib/hubspot/version.rb | 2 +- .../patch_skip_hapikey.rb => hubspot_patches/skip_hapikey.rb} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename lib/{hubspot/patch_skip_hapikey.rb => hubspot_patches/skip_hapikey.rb} (100%) diff --git a/lib/hubspot-api-client.rb b/lib/hubspot-api-client.rb index c202fac2..cc5bee0d 100644 --- a/lib/hubspot-api-client.rb +++ b/lib/hubspot-api-client.rb @@ -5,8 +5,6 @@ require_rel 'hubspot/helpers' require_rel 'hubspot' -require_relative 'hubspot/patch_skip_hapikey' - module Hubspot class << self CLIENTS = [ @@ -47,3 +45,5 @@ def configure end end end + +require_relative 'hubspot_patches/skip_hapikey' diff --git a/lib/hubspot/version.rb b/lib/hubspot/version.rb index 66314256..89ed0117 100644 --- a/lib/hubspot/version.rb +++ b/lib/hubspot/version.rb @@ -1,3 +1,3 @@ module Hubspot - VERSION = '9.5.1.trocco.0.0.8' + VERSION = '9.5.1.trocco.0.0.9' end diff --git a/lib/hubspot/patch_skip_hapikey.rb b/lib/hubspot_patches/skip_hapikey.rb similarity index 100% rename from lib/hubspot/patch_skip_hapikey.rb rename to lib/hubspot_patches/skip_hapikey.rb From f3bc77e5da2dae4ddf98762f87a27738af5d407a Mon Sep 17 00:00:00 2001 From: Riku Uehara Date: Fri, 16 May 2025 07:13:13 +0000 Subject: [PATCH 8/8] Update version to 9.5.1.trocco.0.0.10 and refine hapikey handling in OAuth --- lib/hubspot/version.rb | 2 +- lib/hubspot_patches/skip_hapikey.rb | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/hubspot/version.rb b/lib/hubspot/version.rb index 89ed0117..4774ffcf 100644 --- a/lib/hubspot/version.rb +++ b/lib/hubspot/version.rb @@ -1,3 +1,3 @@ module Hubspot - VERSION = '9.5.1.trocco.0.0.9' + VERSION = '9.5.1.trocco.0.0.10' end diff --git a/lib/hubspot_patches/skip_hapikey.rb b/lib/hubspot_patches/skip_hapikey.rb index 1ec0fdc0..8ecb93b7 100644 --- a/lib/hubspot_patches/skip_hapikey.rb +++ b/lib/hubspot_patches/skip_hapikey.rb @@ -1,19 +1,22 @@ -# HubSpot API 9.5.1 Monkey-Patch : skip blank hapikey on OAuth module Hubspot - module Crm - module Schemas - class ApiClient # :nodoc: - alias _orig_update_params_for_auth! update_params_for_auth! + module SkipHapikeyPatch # :nodoc: + def update_params_for_auth!(header, query, auth_names) + filtered = Array(auth_names).reject do |name| + name == 'hapikey' && + (@config.access_token.to_s.strip != '' || + @config.api_key['hapikey'].to_s.strip.empty?) + end + super(header, query, filtered) + end + end - def update_params_for_auth!(header_params, query_params, auth_names) - # hapikey が空なら除外 - auth_names = Array(auth_names).reject do |name| - name == 'hapikey' && @config.api_key['hapikey'].to_s.strip.empty? - end + # CRM 配下にある全ての ApiClient に prepend + module Crm + constants.each do |sub| + mod = const_get(sub) + next unless mod.const_defined?(:ApiClient) - _orig_update_params_for_auth!(header_params, query_params, auth_names) - end - end + mod::ApiClient.prepend SkipHapikeyPatch end end end