{"size": 1018, "ext": "js", "max_stars_repo_path": "lib/api/2.0/tasks.js", "max_stars_repo_name": "AlaricChan/on-http", "max_stars_repo_stars_event_min_datetime": "2015-11-03T05:29:52.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-24T22:08:58.000Z", "max_issues_repo_path": "lib/api/2.0/tasks.js", "max_issues_repo_name": "AlaricChan/on-http", "max_issues_repo_issues_event_min_datetime": "2015-11-02T23:26:06.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-06T06:50:04.000Z", "max_forks_repo_path": "lib/api/2.0/tasks.js", "max_forks_repo_name": "AlaricChan/on-http", "max_forks_repo_forks_event_min_datetime": "2015-11-02T23:14:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-27T01:21:57.000Z"}
{"max_stars_count": 16, "max_issues_count": 719, "max_forks_count": 129, "avg_line_length": 31.8125, "max_line_length": 87, "alphanum_fraction": 0.7062868369}
// Copyright 2016, EMC, Inc.

'use strict';

var injector = require('../../../index.js').injector;
var controller = injector.get('Http.Services.Swagger').controller;
var tasksApiService = injector.get('Http.Services.Api.Tasks');
var _ = injector.get('_'); // jshint ignore:line
var Errors = injector.get('Errors');

var getBootstrap = controller( function (req, res) {
    return tasksApiService.getBootstrap(req, res, req.swagger.params.macAddress.value);
});

var getTasksById = controller( function (req){
    return tasksApiService.getTasks(req.swagger.params.identifier.value)
    .catch(function (err) {
        throw new Errors.NotFoundError('Not Found');
    });
});

var postTaskById = controller( {success: 201}, function (req){
    var config = _.defaults(req.swagger.query || {}, req.body || {});
    return tasksApiService.postTasksById(req.swagger.params.identifier.value, config);
});

module.exports = {
    getBootstrap: getBootstrap,
    getTasksById: getTasksById,
    postTaskById: postTaskById
};
