 
 class Slack
   constructor: (@token, @domain) ->
-    @apiMode = unless @domain then true else false
+    @apiMode = not @domain?
     @url = @composeUrl()
 
   composeUrl: =>
     return "https://slack.com/api/"
 
   setWebHook: (url) =>
-    return @webhookUrl = url
-    @
+    @webhookUrl = url
+    return this
 
   detectEmoji: (emoji) =>
-    obj = []
+    obj = {}
 
     unless emoji
-      obj["key"] = "icon_emoji"
-      obj["val"] = ""
+      obj.key = "icon_emoji"
+      obj.val = ""
       return obj
 
-    if emoji.match(/^http/)
-      obj["key"] = "icon_url"
-      obj["val"] = emoji
-    else
-      obj["key"] = "icon_emoji"
-      obj["val"] = emoji
-
+    obj.key = if emoji.match(/^http/) then "icon_url" else "icon_emoji"
+    obj.val = emoji
     return obj
 
   webhook: (options, callback) =>

          response: response
        )

      callback err, JSON.parse(response)  if callback
      return

    return @

  _is_post_api: (method) ->
    return true  if method is "files.upload"


module.exports = Slack

        response: response
      }

  api: (method, options = {}, callback) =>

    if typeof options is "function"
      callback = options
      options = {}

    options.token = @token

    url = @url + method

    request_arg = { url: @url + method }

    if @_is_post_api(method)
      request_arg.method = "POST"
      request_arg.form = options
    else
      request_arg.method = "GET"
      request_arg.qs = options

    request request_arg, (err, body, response) ->
      if err
        return callback(err,
