class Stripe::MultipartEncoder

def encode(params)

`Util.flatten_params` first before handing it off to this method.
appropriately Stripe-encoded. Pass a complex structure through
that complex substructures like hashes and arrays have already been
Note that parameters are expected to be a hash, but a "flat" hash such

Encodes a set of parameters to the body.
def encode(params)
  raise "no more parameters can be written to closed object" if @closed
  params.each do |name, val|
    if val.is_a?(::File) || val.is_a?(::Tempfile)
      write_field(name, val.read, filename: ::File.basename(val.path))
    elsif val.respond_to?(:read)
      write_field(name, val.read, filename: "blob")
    else
      write_field(name, val, filename: nil)
    end
  end
  nil
end