Built motion from commit 05106a3.|0.0.33
[motion.git] / server / api / fax_business_automation / fax_business_automation.controller.js
index 2f7a289..ea18f4e 100644 (file)
@@ -1,204 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var FaxBusinessAutomation = require('../../models').FaxBusinessAutomation;
-var BusinessCondition = require('../../models').BusinessCondition;
-var BusinessAction = require('../../models').BusinessAction;
-var sequelize = require('../../models').sequelize;
-
-// Get list of fax_business_automations
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  FaxBusinessAutomation
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single fax_business_automation
-exports.show = function(req, res) {
-  FaxBusinessAutomation
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(fax_business_automation) {
-      if (!fax_business_automation) {
-        return res.sendStatus(404);
-      }
-      return res.send(fax_business_automation);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new fax_business_automation in the DB.
-exports.create = function(req, res, next) {
-  return sequelize.transaction(function(t) {
-      return FaxBusinessAutomation
-        .create(req.body, {
-          transaction: t
-        })
-        .then(function(faxBusinessAutomation) {
-          var conditions = [];
-          if (req.body.or) {
-            req.body.or.forEach(function(elm) {
-              elm.FaxBusinessAutomationId = faxBusinessAutomation.id;
-            });
-            conditions = conditions.concat(req.body.or);
-          }
-
-          if (req.body.and) {
-            req.body.and.forEach(function(elm) {
-              elm.FaxBusinessAutomationId = faxBusinessAutomation.id;
-            });
-            conditions = conditions.concat(req.body.and);
-          }
-
-          return BusinessCondition
-            .bulkCreate(conditions, {
-              transaction: t
-            })
-            .then(function(businessCondtions) {
-              if (req.body.actions) {
-                req.body.actions.forEach(function(elm) {
-                  elm.FaxBusinessAutomationId = faxBusinessAutomation.id;
-                });
-              }
-
-              return BusinessAction
-                .bulkCreate(req.body.actions, {
-                  transaction: t
-                });
-            });
-        })
-    })
-    .then(function() {
-      // Transaction has been committed
-      // result is whatever the result of the promise chain returned to the transaction callback
-      return res.sendStatus(201);
-    }).catch(function(err) {
-      // Transaction has been rolled back
-      // err is whatever rejected the promise chain returned to the transaction callback
-      return next(err);
-    });
-};
-
-// Updates an existing fax_business_automation in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FaxBusinessAutomation
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_business_automation) {
-      if (!fax_business_automation) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(fax_business_automation, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(fax_business_automation);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a fax_business_automation from the DB.
-exports.destroy = function(req, res) {
-  FaxBusinessAutomation
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_business_automation) {
-      if (!fax_business_automation) {
-        return res.sendStatus(404);
-      }
-      fax_business_automation.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
+var _0x4103=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x46\x61\x78\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x6F\x72","\x62\x6F\x64\x79","\x46\x61\x78\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x49\x64","\x63\x6F\x6E\x63\x61\x74","\x61\x6E\x64","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x4103[0];var _=require(_0x4103[1]);var util=require(_0x4103[2]);var FaxBusinessAutomation=require(_0x4103[4])[_0x4103[3]];var BusinessCondition=require(_0x4103[4])[_0x4103[5]];var BusinessAction=require(_0x4103[4])[_0x4103[6]];var sequelize=require(_0x4103[4])[_0x4103[7]];exports[_0x4103[8]]=function(_0xa187x7,_0xa187x8,_0xa187x9){var _0xa187xa=[_0x4103[9],_0x4103[10]];var _0xa187xb=_0xa187x7[_0x4103[12]][_0x4103[11]]?parseInt(_0xa187x7[_0x4103[12]][_0x4103[11]],10):100;var _0xa187xc=_0xa187x7[_0x4103[12]][_0x4103[13]]?parseInt(_0xa187x7[_0x4103[12]][_0x4103[13]],10):0;var _0xa187xd={where:{},limit:_0xa187xb,offset:_0xa187xc*_0xa187xb};_[_0x4103[27]](_0xa187x7[_0x4103[12]],function(_0xa187xe,_0xa187xf){switch(_0xa187xf){case _0x4103[11]:;case _0x4103[13]:break ;;case _0x4103[16]:_0xa187xd[_0x4103[14]]=util[_0x4103[19]](_0x4103[15],_0xa187x7[_0x4103[12]][_0x4103[16]],_0xa187x7[_0x4103[12]][_0x4103[17]]||_0x4103[18])||null;break ;;case _0x4103[17]:break ;;case _0x4103[25]:_0xa187xd[_0x4103[21]][_0x4103[20]]=[];_0xa187xa[_0x4103[24]](function(_0xa187x10){var _0xa187x11={};_0xa187x11[_0xa187x10]={$like:_0x4103[22]+_0xa187xe+_0x4103[22]};_0xa187xd[_0x4103[21]][_0x4103[20]][_0x4103[23]](_0xa187x11);});break ;;default:_0xa187xd[_0x4103[21]][_0xa187xf]={$like:{}};_0xa187xd[_0x4103[21]][_0xa187xf][_0x4103[26]]=_0x4103[22]+_0xa187xe+_0x4103[22];;}});FaxBusinessAutomation[_0x4103[42]](_0xa187xd)[_0x4103[41]](function(_0xa187x13){var _0xa187x14=Math[_0x4103[33]](_0xa187x13[_0x4103[32]]/_0xa187xb);var _0xa187x15=_0xa187x14>(_0xa187xd[_0x4103[34]]+1)?util[_0x4103[19]](_0x4103[35],_0xa187x7[_0x4103[36]],_0xa187x7[_0x4103[38]][_0x4103[37]],_0xa187x7[_0x4103[39]],_0xa187xc+1):null;var _0xa187x16=_0xa187xc>0?util[_0x4103[19]](_0x4103[35],_0xa187x7[_0x4103[36]],_0xa187x7[_0x4103[38]][_0x4103[37]],_0xa187x7[_0x4103[39]],_0xa187xc-1):null;_0xa187x8[_0x4103[30]](200)[_0x4103[29]]({count:_0xa187x13[_0x4103[32]],rows:_0xa187x13[_0x4103[40]],next_page:_0xa187x15,previous_page:_0xa187x16,total_pages:_0xa187x14});})[_0x4103[31]](function(_0xa187x12){_0xa187x8[_0x4103[30]](500)[_0x4103[29]]({error:_0x4103[28]})});};exports[_0x4103[43]]=function(_0xa187x7,_0xa187x8){FaxBusinessAutomation[_0x4103[47]](_0xa187x7[_0x4103[46]][_0x4103[45]],{include:[{all:true}]})[_0x4103[41]](function(_0xa187x17){if(!_0xa187x17){return _0xa187x8[_0x4103[44]](404)};return _0xa187x8[_0x4103[29]](_0xa187x17);})[_0x4103[31]](function(_0xa187x12){return handleError(_0xa187x8,_0xa187x12)})};exports[_0x4103[48]]=function(_0xa187x7,_0xa187x8,_0xa187x9){return sequelize[_0x4103[56]](function(_0xa187x18){return FaxBusinessAutomation[_0x4103[48]](_0xa187x7[_0x4103[50]],{transaction:_0xa187x18})[_0x4103[41]](function(_0xa187x19){var _0xa187x1a=[];if(_0xa187x7[_0x4103[50]][_0x4103[49]]){_0xa187x7[_0x4103[50]][_0x4103[49]][_0x4103[24]](function(_0xa187x1b){_0xa187x1b[_0x4103[51]]=_0xa187x19[_0x4103[45]]});_0xa187x1a=_0xa187x1a[_0x4103[52]](_0xa187x7[_0x4103[50]][_0x4103[49]]);};if(_0xa187x7[_0x4103[50]][_0x4103[53]]){_0xa187x7[_0x4103[50]][_0x4103[53]][_0x4103[24]](function(_0xa187x1b){_0xa187x1b[_0x4103[51]]=_0xa187x19[_0x4103[45]]});_0xa187x1a=_0xa187x1a[_0x4103[52]](_0xa187x7[_0x4103[50]][_0x4103[53]]);};return BusinessCondition[_0x4103[55]](_0xa187x1a,{transaction:_0xa187x18})[_0x4103[41]](function(_0xa187x1c){if(_0xa187x7[_0x4103[50]][_0x4103[54]]){_0xa187x7[_0x4103[50]][_0x4103[54]][_0x4103[24]](function(_0xa187x1b){_0xa187x1b[_0x4103[51]]=_0xa187x19[_0x4103[45]]})};return BusinessAction[_0x4103[55]](_0xa187x7[_0x4103[50]][_0x4103[54]],{transaction:_0xa187x18});});})})[_0x4103[41]](function(){return _0xa187x8[_0x4103[44]](201)})[_0x4103[31]](function(_0xa187x12){return _0xa187x9(_0xa187x12)})};exports[_0x4103[57]]=function(_0xa187x7,_0xa187x8){if(_0xa187x7[_0x4103[50]][_0x4103[45]]){delete _0xa187x7[_0x4103[50]][_0x4103[45]]};FaxBusinessAutomation[_0x4103[60]]({where:{id:_0xa187x7[_0x4103[46]][_0x4103[45]]}})[_0x4103[41]](function(_0xa187x17){if(!_0xa187x17){return _0xa187x8[_0x4103[44]](404)};var _0xa187x1d=_[_0x4103[58]](_0xa187x17,_0xa187x7[_0x4103[50]]);_0xa187x1d[_0x4103[59]]()[_0x4103[41]](function(){return _0xa187x8[_0x4103[30]](200)[_0x4103[29]](_0xa187x17)})[_0x4103[31]](function(_0xa187x12){return handleError(_0xa187x8,_0xa187x12)});})[_0x4103[31]](function(_0xa187x12){return handleError(_0xa187x8,_0xa187x12)});};exports[_0x4103[61]]=function(_0xa187x7,_0xa187x8){FaxBusinessAutomation[_0x4103[60]]({where:{id:_0xa187x7[_0x4103[46]][_0x4103[45]]}})[_0x4103[41]](function(_0xa187x17){if(!_0xa187x17){return _0xa187x8[_0x4103[44]](404)};_0xa187x17[_0x4103[61]]()[_0x4103[41]](function(){return _0xa187x8[_0x4103[44]](204)})[_0x4103[31]](function(_0xa187x12){return handleError(_0xa187x8,_0xa187x12)});})[_0x4103[31]](function(_0xa187x12){return handleError(_0xa187x8,_0xa187x12)})};function handleError(_0xa187x8,_0xa187x12){return _0xa187x8[_0x4103[30]](500)[_0x4103[29]](_0xa187x12)}
\ No newline at end of file