def typecast(value, escape = true)
      case value.class.name.to_sym
        when :NilClass    then ''
        when :String      then escape ? uri_escape(value) : value
        when :TrueClass   then 'true'
        when :FalseClass  then 'false'
        when :DateTime    then datetime = value.new_offset(0).iso8601; escape ? uri_escape(datetime) : datetime
        when :Date        then value.strftime("%Y-%m-%d")
        when :Time        then value.strftime("%H:%M")
        # do not convert arrays in put/post requests as squashing arrays is only used in filtering
        when :Array       then escape ? value.map{ |v| typecast(v, escape) }.join(',') : value
        # TODO: temporary for special constructions to update contact details, see Request #1444166
        when :Hash        then escape ? value.to_s : value
        else escape ? value.to_json : value.to_s
      end
    end
def typecast(value, escape = true)
      case value.class.name.to_sym
        when :NilClass    then ''
        when :String      then escape ? uri_escape(value) : value
        when :TrueClass   then 'true'
        when :FalseClass  then 'false'
        when :DateTime    then datetime = value.new_offset(0).iso8601; escape ? uri_escape(datetime) : datetime
        when :Date        then value.strftime("%Y-%m-%d")
        when :Time        then value.strftime("%H:%M")
        # do not convert arrays in put/post requests as squashing arrays is only used in filtering
        when :Array       then escape ? value.map{ |v| typecast(v, escape) }.join(',') : value
        # TODO: temporary for special constructions to update contact details, see Request #1444166
        when :Hash        then escape ? value.to_s : value
        else escape ? value.to_json : value.to_s
      end
    end
Parameter value typecasting