     return callback {message: "Request is not valid"}
 
   url = "/trollmode/#{data.accountId}"
-  deleteReq url, callback
+  deleteReq url, data, callback
 
 getSiteMap = (data, callback)->
   url = data.name

  unless data.id
    return callback { message: "Request is not valid for deleting message"}
  url =  "/message/#{data.id}"
  deleteReq url, callback

likeMessage = (data, callback)->
  unless data.id

post = (url, data, callback)->
  getNextApiURL (err, apiurl)->
    return callback err if err
    reqOptions =
      url    : "#{apiurl}#{url}"
      json   : true
      method : 'POST'

    {reqOptions, data} = setCookieIfRequired reqOptions, data

    reqOptions.body = data

    request reqOptions, wrapCallback callback

deleteReq = (url, data, callback)->
  [data, callback] = [callback, null] unless callback

  getNextApiURL (err, apiurl)->
    return callback err if err

    reqOptions =
      url    : "#{apiurl}#{url}"
      json   : true
      method : 'DELETE'

    {reqOptions, data} = setCookieIfRequired reqOptions, data

    request reqOptions, wrapCallback callback

getXml = (url, data, callback)->
  getNextApiURL (err, apiurl)->
    return callback err if err
    reqOptions =
      url    : "#{apiurl}#{url}"
      method : 'GET'

    {reqOptions, data} = setCookieIfRequired reqOptions, data

    request reqOptions, wrapCallback callback

get = (url, data, callback)->
  getNextApiURL (err, apiurl)->
    return callback err if err
    reqOptions =
      url    : "#{apiurl}#{url}"
      json   : true
      method : 'GET'

    {reqOptions, data} = setCookieIfRequired reqOptions, data

    # finally set query string
    reqOptions.qs = data

    request reqOptions, wrapCallback callback

setCookieIfRequired = (reqOptions, data)->
  # inject clientId cookie if exists
  if data?.sessionToken
    j = request.jar()
    cookie = request.cookie "clientId=#{data.sessionToken}"
    j.setCookie cookie, reqOptions.url
    reqOptions.jar = j

    delete data.sessionToken

  return {reqOptions, data}

module.exports = {
  unmarkAsTroll
