'use strict';

var url = require('url');


var Store = require('./StoreService');


module.exports.getInventory = function getInventory(req, res, next) {


    var result = Store.getInventory();

    if (typeof result !== 'undefined') {
        res.setHeader('Content-Type', 'application/json');
        res.end(JSON.stringify(result || {}, null, 2));
    }
    else
        res.end();
};

module.exports.placeOrder = function placeOrder(req, res, next) {
    var body = req.swagger.params['body'].value;


    var result = Store.placeOrder(body);

    if (typeof result !== 'undefined') {
        res.setHeader('Content-Type', 'application/json');
        res.end(JSON.stringify(result || {}, null, 2));
    }
    else
        res.end();
};

module.exports.getOrderById = function getOrderById(req, res, next) {
    var orderId = req.swagger.params['orderId'].value;


    var result = Store.getOrderById(orderId);

    if (typeof result !== 'undefined') {
        res.setHeader('Content-Type', 'application/json');
        res.end(JSON.stringify(result || {}, null, 2));
    }
    else
        res.end();
};

module.exports.deleteOrder = function deleteOrder(req, res, next) {
    var orderId = req.swagger.params['orderId'].value;


    var result = Store.deleteOrder(orderId);

    if (typeof result !== 'undefined') {
        res.setHeader('Content-Type', 'application/json');
        res.end(JSON.stringify(result || {}, null, 2));
    }
    else
        res.end();
};
