module Stripe::Util

def self.convert_to_stripe_object(data, opts = {})

on subsequent API calls.
* +opts+ - Options for +StripeObject+ like an API key that will be reused
* +data+ - Hash of fields and values to be converted into a StripeObject.

==== Attributes

to being a +StripeObject+.
present or of an unknown type, the newly created instance will fall back
`charge` would create an instance of +Charge+), but if `object` is not
type as dictated by their `object` field (e.g. an `object` value of
array of +StripeObject+s. These new objects will be created as a concrete
Converts a hash of fields or an array of hashes into a +StripeObject+ or
def self.convert_to_stripe_object(data, opts = {})
  opts = normalize_opts(opts)
  case data
  when Array
    data.map { |i| convert_to_stripe_object(i, opts) }
  when Hash
    # Try converting to a known object class.  If none available, fall back
    # to generic StripeObject
    object_classes.fetch(data[:object], StripeObject)
                  .construct_from(data, opts)
  else
    data
  end
end