Method: Telnyx::Util.flatten_params_array

Defined in:
lib/telnyx/util.rb

.flatten_params_array(value, calculated_key) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/telnyx/util.rb', line 174

def self.flatten_params_array(value, calculated_key)
  result = []
  value.each_with_index do |elem, i|
    if elem.is_a?(Hash)
      result += flatten_params(elem, "#{calculated_key}[#{i}]")
    elsif elem.is_a?(Array)
      result += flatten_params_array(elem, calculated_key)
    else
      result << ["#{calculated_key}[#{i}]", elem]
    end
  end
  result
end