import xml2js from 'xml2js';
import goodGuyHttp from 'good-guy-http';

const goodGuy = goodGuyHttp({
  defaultCaching: {
    timeToLive: 60000,
  },
  headers: {
    'User-Agent': 'Department of Commerce Intranet - request',
  },
});
const parseString = xml2js.parseString;

// Commerce Media Releases from the 'Announcements' section of the website
exports.getStatements = function getCommerceNews(request, reply) {
  const newsUrl = 'http://www.commerce.wa.gov.au/announcements/182/all/feed';
  goodGuy(newsUrl).then((response) => {
    parseString(response.body, (err, result) => {
      if (err) {
        throw err;
      }
      reply(result);
    });
  });
};

@@ -627,16 +627,515 @@
  %7D%0A     
+ let statements = %5B%5D;%0A      let rssItems = result.rss.channel%5B0%5D.item;%0A      // console.dir(result.rss.channel%5B0%5D.item);%0A      // console.dir(rssItems);%0A      rssItems.forEach(function(element) %7B%0A        statements.push(%7B%0A          title: element.title,%0A          link: element.link,%0A          description: element.description,%0A          pubdate: element.pubDate,%0A          creator: element%5B'dc:creator'%5D%0A        %7D)%0A      %7D, this);%0A      // console.dir(statements);%0A      reply(statements);%0A      //
  reply(r

improve Commerce media feed formatting