import Slack from 'node-slack'

export default class SlackNotifier {
  constructor (config) {
    this.slack = new Slack(config.slack.hook_url)
  }

  success (app) {
    this.slack.send({
        text: 'Application ' + app.name + ' has been sucessfully deployed. It is available at url ' + app.url,
        channel: config.channel,
        username: config.name
    })
  }

  error (app) {
    this.slack.send({
        text: 'Error during deploying application ' + app.name,
        channel: config.channel,
        username: config.name
    })
  }


}

@@ -83,24 +83,50 @@
  (config) %7B%0A
+    if (config.slack) %7B%0A  
     this.sla
@@ -169,28 +169,113 @@
 )%0A  
-%7D%0A%0A  success (app) %7B
+  %7D else %7B%0A      this.slack = null%0A    %7D%0A  %7D%0A%0A  success (app) %7B%0A    if (!this.slack) %7B%0A      return%0A    %7D
 %0A   
@@ -491,24 +491,66 @@
 ror (app) %7B%0A
+    if (!this.slack) %7B%0A      return%0A    %7D%0A
     this.sla

check presence slack hook url