12b7caa8c81473653b8ffe22cc1da75fe7419bd7
[motion2.git] / server / api / campaign / campaign.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x2c6a=['where','attributes','limit','include','model','map','stringify','lodash','util','moment','bluebird','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','request','then','info','Campaign,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','GetCampaign','Campaign','findAll','options','raw'];(function(_0x1211e2,_0x2745a5){var _0x4dbdb5=function(_0xe968fb){while(--_0xe968fb){_0x1211e2['push'](_0x1211e2['shift']());}};_0x4dbdb5(++_0x2745a5);}(_0x2c6a,0xa7));var _0xa2c6=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2c6a[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xa2c6('0x0'));var util=require(_0xa2c6('0x1'));var moment=require(_0xa2c6('0x2'));var BPromise=require(_0xa2c6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa2c6('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa2c6('0x5'))(_0xa2c6('0x6'));var config=require(_0xa2c6('0x7'));var jayson=require(_0xa2c6('0x8'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1a9131,_0x1fa65f,_0x3d1aa0){return new BPromise(function(_0x11aa17,_0x3c2894){return client[_0xa2c6('0x9')](_0x1a9131,_0x3d1aa0)[_0xa2c6('0xa')](function(_0x4b0bdf){logger[_0xa2c6('0xb')](_0xa2c6('0xc'),_0x1fa65f,_0xa2c6('0xd'));logger[_0xa2c6('0xe')]('Campaign,\x20%s,\x20%s,\x20%s',_0x1fa65f,_0xa2c6('0xd'),JSON['stringify'](_0x4b0bdf));if(_0x4b0bdf[_0xa2c6('0xf')]){if(_0x4b0bdf[_0xa2c6('0xf')][_0xa2c6('0x10')]===0x1f4){logger[_0xa2c6('0xf')]('Campaign,\x20%s,\x20%s',_0x1fa65f,_0x4b0bdf[_0xa2c6('0xf')][_0xa2c6('0x11')]);return _0x3c2894(_0x4b0bdf[_0xa2c6('0xf')]['message']);}logger[_0xa2c6('0xf')](_0xa2c6('0xc'),_0x1fa65f,_0x4b0bdf[_0xa2c6('0xf')][_0xa2c6('0x11')]);return _0x11aa17(_0x4b0bdf[_0xa2c6('0xf')]['message']);}else{logger[_0xa2c6('0xb')](_0xa2c6('0xc'),_0x1fa65f,_0xa2c6('0xd'));_0x11aa17(_0x4b0bdf[_0xa2c6('0x12')][_0xa2c6('0x11')]);}})[_0xa2c6('0x13')](function(_0x4fd220){logger[_0xa2c6('0xf')]('Campaign,\x20%s,\x20%s',_0x1fa65f,_0x4fd220);_0x3c2894(_0x4fd220);});});}exports[_0xa2c6('0x14')]=function(_0x114424){var _0x1cf0a9=this;return new Promise(function(_0x2479bd,_0x372ce3){return db[_0xa2c6('0x15')][_0xa2c6('0x16')]({'raw':_0x114424[_0xa2c6('0x17')]?_0x114424['options'][_0xa2c6('0x18')]===undefined?!![]:![]:!![],'where':_0x114424[_0xa2c6('0x17')]?_0x114424[_0xa2c6('0x17')][_0xa2c6('0x19')]||null:null,'attributes':_0x114424[_0xa2c6('0x17')]?_0x114424['options'][_0xa2c6('0x1a')]||null:null,'limit':_0x114424[_0xa2c6('0x17')]?_0x114424['options'][_0xa2c6('0x1b')]||null:null,'include':_0x114424['options']?_0x114424[_0xa2c6('0x17')][_0xa2c6('0x1c')]?_['map'](_0x114424[_0xa2c6('0x17')]['include'],function(_0x19a765){return{'model':db[_0x19a765[_0xa2c6('0x1d')]],'as':_0x19a765['as'],'attributes':_0x19a765[_0xa2c6('0x1a')],'include':_0x19a765[_0xa2c6('0x1c')]?_[_0xa2c6('0x1e')](_0x19a765['include'],function(_0x2ed646){return{'model':db[_0x2ed646['model']],'as':_0x2ed646['as'],'attributes':_0x2ed646[_0xa2c6('0x1a')],'include':_0x2ed646[_0xa2c6('0x1c')]?_['map'](_0x2ed646[_0xa2c6('0x1c')],function(_0x4485d4){return{'model':db[_0x4485d4[_0xa2c6('0x1d')]],'as':_0x4485d4['as'],'attributes':_0x4485d4[_0xa2c6('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xa2c6('0xa')](function(_0x11a72c){logger[_0xa2c6('0xb')](_0xa2c6('0x14'),_0x114424);logger[_0xa2c6('0xe')]('GetCampaign',_0x114424,JSON[_0xa2c6('0x1f')](_0x11a72c));_0x2479bd(_0x11a72c);})[_0xa2c6('0x13')](function(_0x233284){logger[_0xa2c6('0xf')]('GetCampaign',_0x233284['message'],_0x114424);_0x372ce3(_0x1cf0a9['error'](0x1f4,_0x233284['message']));});});};