def convert_to_type(data, return_type)
      return nil if data.nil?
      case return_type
      when 'String'
        data.to_s
      when 'Integer'
        data.to_i
      when 'Float'
        data.to_f
      when 'BOOLEAN'
        data == true
      when 'DateTime'
        # parse date time (expecting ISO 8601 format)
        DateTime.parse data
      when 'Date'
        # parse date time (expecting ISO 8601 format)
        Date.parse data
      when 'Object'
        # generic object (usually a Hash), return directly
        data
      when /\AArray<(.+)>\z/
        # e.g. Array<Pet>
        sub_type = $1
        data.map {|item| convert_to_type(item, sub_type) }
      when /\AHash\<String, (.+)\>\z/
        # e.g. Hash<String, Integer>
        sub_type = $1
        {}.tap do |hash|
          data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
        end
      when 'EventsResponse'
        Clever.const_get(return_type).new.tap do |model|
          resp = model.build_from_hash data
          resps = []
          data[:data].each do |eventResponse|
            singleResp = parse_event_response(eventResponse[:data])
            resps.push(singleResp)
          end
          resp.data = resps
          return resp
        end
      when 'EventResponse'
        parse_event_response data[:data]
      else
        # models, e.g. Pet
        Clever.const_get(return_type).new.tap do |model|
          model.build_from_hash data
        end
      end
    end
def convert_to_type(data, return_type)
      return nil if data.nil?
      case return_type
      when 'String'
        data.to_s
      when 'Integer'
        data.to_i
      when 'Float'
        data.to_f
      when 'BOOLEAN'
        data == true
      when 'DateTime'
        # parse date time (expecting ISO 8601 format)
        DateTime.parse data
      when 'Date'
        # parse date time (expecting ISO 8601 format)
        Date.parse data
      when 'Object'
        # generic object (usually a Hash), return directly
        data
      when /\AArray<(.+)>\z/
        # e.g. Array<Pet>
        sub_type = $1
        data.map {|item| convert_to_type(item, sub_type) }
      when /\AHash\<String, (.+)\>\z/
        # e.g. Hash<String, Integer>
        sub_type = $1
        {}.tap do |hash|
          data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
        end
      when 'EventsResponse'
        Clever.const_get(return_type).new.tap do |model|
          resp = model.build_from_hash data
          resps = []
          data[:data].each do |eventResponse|
            singleResp = parse_event_response(eventResponse[:data])
            resps.push(singleResp)
          end
          resp.data = resps
          return resp
        end
      when 'EventResponse'
        parse_event_response data[:data]
      else
        # models, e.g. Pet
        Clever.const_get(return_type).new.tap do |model|
          model.build_from_hash data
        end
      end
    end
Convert data to the given return type.
 @param [Object] data Data to be converted
 @param [String] return_type Return type
 @return [Mixed] Data in a particular type