stripe-ruby/lib/stripe/request_params.rb
helenye-stripe bc1d5a8721
Add method parameter type classes to all resources and services (#1505)
* barebones request params

* fixes

* manual changes

* Generated changes

* Add search params

* manual change - update to cast params

* add more test

* add newliens (generated)
2024-12-20 10:39:59 -08:00

25 lines
756 B
Ruby

# frozen_string_literal: true
# typed: true
module Stripe
# For internal use only. Does not provide a stable API and may be broken
# with future non-major changes.
class RequestParams
def to_h
instance_variables.each_with_object({}) do |var, hash|
key = var.to_s.delete("@").to_sym
value = instance_variable_get(var)
hash[key] = if value.is_a?(RequestParams)
value.to_h
# Check if value is an array and contains RequestParams objects
elsif value.is_a?(Array)
value.map { |item| item.is_a?(RequestParams) ? item.to_h : item }
else
value
end
end
end
end
end