@@ -112,6 +112,7 @@ class << self
112112
113113 # User configurable options
114114 def_delegators :@config , :api_key , :api_key=
115+ def_delegators :@config , :authenticator , :authenticator=
115116 def_delegators :@config , :api_version , :api_version=
116117 def_delegators :@config , :stripe_account , :stripe_account=
117118 def_delegators :@config , :api_base , :api_base=
@@ -159,6 +160,58 @@ def self.set_app_info(name, partner_id: nil, url: nil, version: nil)
159160 version : version ,
160161 }
161162 end
163+
164+ def self . add_beta_version ( beta_name , version )
165+ unless version . start_with? ( "v" ) && version [ 1 ..] . to_i . to_s == version [ 1 ..]
166+ raise ArgumentError , "Version must be in the format 'v' followed by a number (e.g., 'v3')"
167+ end
168+
169+ if ( index = api_version . index ( "; #{ beta_name } =" ) )
170+ start_index = index + "; #{ beta_name } =" . length
171+ end_index = api_version . index ( ";" , start_index ) || api_version . length
172+ current_version = api_version [ start_index ...end_index ] [ 1 ..] . to_i
173+ new_version = version [ 1 ..] . to_i
174+ return if new_version <= current_version # Keep the higher version, no update needed
175+
176+ self . api_version = api_version [ 0 ...index ] + "; #{ beta_name } =#{ version } " + api_version [ end_index ..]
177+ else
178+ self . api_version = "#{ api_version } ; #{ beta_name } =#{ version } "
179+ end
180+ end
181+
182+ class RawRequest
183+ def initialize
184+ @opts = { }
185+ end
186+
187+ def execute ( method , url , base_address : :api , params : { } , opts : { } , usage : [ ] )
188+ opts = Util . normalize_opts ( opts )
189+ req_opts = RequestOptions . extract_opts_from_hash ( opts )
190+
191+ requestor = APIRequestor . active_requestor
192+ resp , = requestor . send ( :execute_request_internal , method , url , base_address , params , req_opts ,
193+ usage )
194+
195+ requestor . interpret_response ( resp )
196+ end
197+ end
198+
199+ # Sends a request to Stripe REST API
200+ def self . raw_request ( method , url , params = { } , opts = { } , base_address : :api )
201+ req = RawRequest . new
202+ req . execute ( method , url , base_address : base_address , params : params , opts : opts ,
203+ usage : [ "raw_request" ] )
204+ end
205+
206+ def self . deserialize ( data , api_mode : :v1 )
207+ data = JSON . parse ( data ) if data . is_a? ( String )
208+ Util . convert_to_stripe_object ( data , { } , api_mode : api_mode )
209+ end
210+ class << self
211+ extend Gem ::Deprecate
212+ deprecate :raw_request , "StripeClient#raw_request" , 2024 , 9
213+ deprecate :deserialize , "StripeClient#deserialize" , 2024 , 9
214+ end
162215end
163216
164217Stripe . log_level = ENV [ "STRIPE_LOG" ] unless ENV [ "STRIPE_LOG" ] . nil?
0 commit comments