const request = require('request')
const fs = require('fs')

const options = {
  method: 'POST',
  url: '{{{service.url}}}',
  headers: {
    'content-type': 'application/json'{{#token}},
    'authorization': '{{token}}'{{/token}}
  },
  body: {{{exampleJSONBareIndented}}},
  json: true{{#hasFileOutput}},
  encoding: null{{/hasFileOutput}}
}

request(options, (error, response, body) => {
  if (error) throw new Error(error)

  {{#hasFileOutput}}fs.writeFileSync('{{output}}', body){{/hasFileOutput}}{{^hasFileOutput}}console.log(body){{/hasFileOutput}}
})
