File tree Expand file tree Collapse file tree
lib/cloudpayments_ruby/internal
rbi/cloudpayments_ruby/internal
sig/cloudpayments_ruby/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -490,6 +490,37 @@ def writable_enum(&blk)
490490 JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
491491
492492 class << self
493+ # @api private
494+ #
495+ # @param query [Hash{Symbol=>Object}]
496+ #
497+ # @return [Hash{Symbol=>Object}]
498+ def encode_query_params ( query )
499+ out = { }
500+ query . each { write_query_param_element! ( out , _1 , _2 ) }
501+ out
502+ end
503+
504+ # @api private
505+ #
506+ # @param collection [Hash{Symbol=>Object}]
507+ # @param key [String]
508+ # @param element [Object]
509+ #
510+ # @return [nil]
511+ private def write_query_param_element! ( collection , key , element )
512+ case element
513+ in Hash
514+ element . each do |name , value |
515+ write_query_param_element! ( collection , "#{ key } [#{ name } ]" , value )
516+ end
517+ in Array
518+ collection [ key ] = element . map ( &:to_s ) . join ( "," )
519+ else
520+ collection [ key ] = element . to_s
521+ end
522+ end
523+
493524 # @api private
494525 #
495526 # @param y [Enumerator::Yielder]
Original file line number Diff line number Diff line change @@ -301,6 +301,26 @@ module CloudpaymentsRuby
301301 T . let ( %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)} , Regexp )
302302
303303 class << self
304+ # @api private
305+ sig do
306+ params ( query : CloudpaymentsRuby ::Internal ::AnyHash ) . returns (
307+ CloudpaymentsRuby ::Internal ::AnyHash
308+ )
309+ end
310+ def encode_query_params ( query )
311+ end
312+
313+ # @api private
314+ sig do
315+ params (
316+ collection : CloudpaymentsRuby ::Internal ::AnyHash ,
317+ key : String ,
318+ element : T . anything
319+ ) . void
320+ end
321+ private def write_query_param_element! ( collection , key , element )
322+ end
323+
304324 # @api private
305325 sig do
306326 params (
Original file line number Diff line number Diff line change @@ -106,6 +106,16 @@ module CloudpaymentsRuby
106106 JSON_CONTENT: Regexp
107107 JSONL_CONTENT: Regexp
108108
109+ def encode_query_params : (
110+ ::Hash[Symbol, top ] query
111+ ) -> ::Hash[Symbol, top ]
112+
113+ private def write_query_param_element! : (
114+ ::Hash[Symbol, top ] collection,
115+ String key,
116+ top element
117+ ) -> nil
118+
109119 def self?.write_multipart_content : (
110120 Enumerator::Yielder y,
111121 val: top ,
You can’t perform that action at this time.
0 commit comments