const axios = require('axios')

const config = require('../../../config')

function createZenDeskMessage ({
  email,
  title,
  description = '',
  browser,
  feedbackType,
}) {
  return {
    requester: {
      name: 'Data Hub user',
      email,
    },
    subject: title,
    comment: {
      body: description,
    },
    custom_fields: [
      { id: config.zenBrowser, value: browser },
      { id: config.zenService, value: config.zenServiceChannel },
    ],
    tags: [feedbackType],
  }
}

function postToZenDesk (ticket) {
  return axios.post(config.zenUrl, { ticket },
    {
      auth: {
        username: `${config.zenEmail}/token`,
        password: config.zenToken,
      },
    }
  )
}

module.exports = {
  createZenDeskMessage,
  postToZenDesk,
}

const axios = require('axios')
const { get } = require('lodash')

const config = require('../../../config')

function createZenDeskMessage ({
  email,
  title,
  description = '',
  browser,
  feedbackType,
}) {
  return {
    requester: {
      name: 'Data Hub user',
      email,
    },
    subject: title,
    comment: {
      body: description,
    },
    custom_fields: [
      { id: get(config, 'zen.browser'), value: browser },
      { id: get(config, 'zen.service'), value: get(config, 'zen.serviceChannel') },
    ],
    tags: [feedbackType],
  }
}

function postToZenDesk (ticket) {
  return axios.post(config.zen.url, { ticket },
    {
      auth: {
        username: `${config.zen.email}/token`,
        password: config.zen.token,
      },
    }
  )
}

module.exports = {
  createZenDeskMessage,
  postToZenDesk,
}

Add zen object for zendesk config
Add zen object for zendesk config
