From a450f6e5b9790eb9b188d3976a9917de8725ea1d Mon Sep 17 00:00:00 2001 From: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:21:01 -0700 Subject: [PATCH] Add `meter_events_base` as a StripeClient option and mark some things internal/deprecated (#1461) * Add meter events base as an option * Deprecate raw_request * Mark APIRequestor.request as deprecated as well * Untype to pass sorbet for now * ignore rubocop --- lib/stripe/api_requestor.rb | 5 +++++ lib/stripe/stripe_client.rb | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/stripe/api_requestor.rb b/lib/stripe/api_requestor.rb index 52e782b36..33eef40c5 100644 --- a/lib/stripe/api_requestor.rb +++ b/lib/stripe/api_requestor.rb @@ -191,6 +191,8 @@ def request self.class.current_thread_context.last_responses.delete(object_id) end end + extend Gem::Deprecate + deprecate :request, "StripeClient#raw_request", 2024, 9 def execute_request(method, path, base_address, params: {}, opts: {}, usage: []) @@ -212,6 +214,9 @@ def execute_request(method, path, base_address, end # Execute request without instantiating a new object if the relevant object's name matches the class + # + # For internal use only. Does not provide a stable API and may be broken + # with future non-major changes. def execute_request_initialize_from(method, path, base_address, object, params: {}, opts: {}, usage: []) opts = RequestOptions.combine_opts(object.instance_variable_get(:@opts), opts) diff --git a/lib/stripe/stripe_client.rb b/lib/stripe/stripe_client.rb index a8ec97b79..734f71929 100644 --- a/lib/stripe/stripe_client.rb +++ b/lib/stripe/stripe_client.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -# typed: true require "json" @@ -12,13 +11,14 @@ class StripeClient # attr_readers: The end of the section generated from our OpenAPI spec # Initializes a new StripeClient - def initialize(api_key, + def initialize(api_key, # rubocop:todo Metrics/ParameterLists stripe_account: nil, stripe_context: nil, stripe_version: nil, api_base: nil, uploads_base: nil, connect_base: nil, + meter_events_base: nil, client_id: nil) unless api_key raise AuthenticationError, "No API key provided. " \ @@ -36,6 +36,7 @@ def initialize(api_key, api_base: api_base, uploads_base: uploads_base, connect_base: connect_base, + meter_events_base: meter_events_base, client_id: client_id, }.reject { |_k, v| v.nil? } @@ -47,10 +48,11 @@ def initialize(api_key, # top-level services: The end of the section generated from our OpenAPI spec end - # TODO: thread safety investigate def request(&block) @requestor.request(&block) end + extend Gem::Deprecate + deprecate :request, :raw_request, 2024, 9 def parse_thin_event(payload, sig_header, secret, tolerance: Webhook::DEFAULT_TOLERANCE) payload = payload.force_encoding("UTF-8") if payload.respond_to?(:force_encoding)