 
 class ParseChannelSchemaToJSONSchema
   constructor: ->
-    @channel_infile = commander.infile
+    @channelFile = commander.infile
     @messageSchemaFile = commander.outfile
     @formFile = commander.form
     @channelConfigFile = commander.channelConfig
 
   channel: =>
-    JSON.parse fs.readFileSync @channel_infile
+    JSON.parse fs.readFileSync @channelFile
 
-  run2: =>
+  run: =>
     channel = @channel()
     messageSchema = @getMessageSchema channel.application.resources
     form = @getForm channel.application.resources


  getChannelConfig: =>
    "I'm empty"
  run: =>
    newForm = []
    newChannel =
      type: 'object'
      properties: {}
    channel = @channel()

    _.each channel.application.resources, (resource) =>
      resource.method = resource.httpMethod.toLocaleUpperCase()

    newChannel.properties.endpoint =
      type: 'string'
      enum: _.map channel.application.resources, (resource) =>
        "#{resource.method}-#{resource.url}"

    newChannel.properties.url =
      type: 'string'
      required: true
      enum: _.uniq _.pluck channel.application.resources, 'url'

    newChannel.properties.method =
      type: 'string'
      required: true
      enum: _.uniq _.pluck channel.application.resources, 'method'

    form =
      key: 'endpoint'
      title: 'Endpoint'
      titleMap: []

    _.each channel.application.resources, (resource) =>
      form.titleMap.push {value: "#{resource.method}-#{resource.url}", name: resource.displayName}

    newForm.push form

    _.each channel.application.resources, (resource) =>
      newForm.push
        type: "help"
        helpvalue: "#{resource.method.toLocaleUpperCase()} #{resource.url}"
        condition: "model.url === '#{resource.url}' && model.method === '#{resource.method}'"

      _.each resource.params, (param) =>
        newName = "#{@sanitizeParam param.name}"
        newForm.push @convertFormParam param, resource.url, resource.method
        newChannel.properties[newName] = @convertParam param

    @writeOutput newChannel
    @writeForm newForm

  convertParam: (param) =>
    resourceParam =

    messageSchema

  getForm: (resources) =>
    form = [
      key: 'action'
      title: 'Action'
      titleMap: @getActionTitleMap resources
    ]

    resourceForms = _.flatten( _.map resources, @getFormFromResource )

    form.concat resourceForms

  getFormFromResource: (resource) =>
    form = [
      key: "#{resource.action}"
      notitle: true
      condition: "model.action === '#{resource.action}'"
    ]

    _.each resource.params, (param) =>
      form.push(@getFormFromParam resource.action, param)

    form

  getFormFromParam: (action, param) =>
    formParam =
      key: "#{action}.#{@sanitizeParam param.name}"
      title: "#{action}.#{@sanitizeParam param.name}"
      condition: "model.action === '#{action}'"
    if param.hidden?
      formParam.type = 'hidden'
      formParam.notitle = true

    formParam


  getActionTitleMap: (resources) =>
