Skip to content

Commit

Permalink
Add meter_events_base as a StripeClient option and mark some things…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
helenye-stripe authored Oct 1, 2024
1 parent 806141e commit a450f6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/stripe/api_requestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: [])
Expand All @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions lib/stripe/stripe_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
# typed: true

require "json"

Expand All @@ -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. " \
Expand All @@ -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? }

Expand All @@ -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)
Expand Down

0 comments on commit a450f6e

Please sign in to comment.