Built motion from commit 44b1f254.|2.6.26
[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 _0x3299=['Campaign,\x20%s,\x20%s,\x20%s','error','code','message','request\x20sent','result','catch','GetCampaign','findAll','options','where','attributes','include','map','model','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Campaign,\x20%s,\x20%s','debug'];(function(_0x3be7fe,_0x315935){var _0x3b3cfa=function(_0x1134ba){while(--_0x1134ba){_0x3be7fe['push'](_0x3be7fe['shift']());}};_0x3b3cfa(++_0x315935);}(_0x3299,0x1bc));var _0x9329=function(_0x33847b,_0x31e38b){_0x33847b=_0x33847b-0x0;var _0x352058=_0x3299[_0x33847b];return _0x352058;};'use strict';var _=require('lodash');var util=require(_0x9329('0x0'));var moment=require(_0x9329('0x1'));var BPromise=require(_0x9329('0x2'));var rs=require(_0x9329('0x3'));var fs=require('fs');var Redis=require(_0x9329('0x4'));var db=require(_0x9329('0x5'))['db'];var utils=require(_0x9329('0x6'));var logger=require(_0x9329('0x7'))(_0x9329('0x8'));var config=require(_0x9329('0x9'));var jayson=require(_0x9329('0xa'));var client=jayson[_0x9329('0xb')][_0x9329('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x14bc45,_0x1fa6c4,_0x218cf3){return new BPromise(function(_0x182d15,_0x531cf1){return client[_0x9329('0xd')](_0x14bc45,_0x218cf3)[_0x9329('0xe')](function(_0x1c1033){logger[_0x9329('0xf')](_0x9329('0x10'),_0x1fa6c4,'request\x20sent');logger[_0x9329('0x11')](_0x9329('0x12'),_0x1fa6c4,'request\x20sent',JSON['stringify'](_0x1c1033));if(_0x1c1033['error']){if(_0x1c1033[_0x9329('0x13')][_0x9329('0x14')]===0x1f4){logger[_0x9329('0x13')](_0x9329('0x10'),_0x1fa6c4,_0x1c1033[_0x9329('0x13')]['message']);return _0x531cf1(_0x1c1033[_0x9329('0x13')][_0x9329('0x15')]);}logger[_0x9329('0x13')]('Campaign,\x20%s,\x20%s',_0x1fa6c4,_0x1c1033[_0x9329('0x13')][_0x9329('0x15')]);return _0x182d15(_0x1c1033['error'][_0x9329('0x15')]);}else{logger[_0x9329('0xf')]('Campaign,\x20%s,\x20%s',_0x1fa6c4,_0x9329('0x16'));_0x182d15(_0x1c1033[_0x9329('0x17')][_0x9329('0x15')]);}})[_0x9329('0x18')](function(_0x4dfbc1){logger[_0x9329('0x13')]('Campaign,\x20%s,\x20%s',_0x1fa6c4,_0x4dfbc1);_0x531cf1(_0x4dfbc1);});});}exports[_0x9329('0x19')]=function(_0x1b5eed){var _0x57718b=this;return new Promise(function(_0x41db73,_0x26a3c2){return db['Campaign'][_0x9329('0x1a')]({'raw':_0x1b5eed['options']?_0x1b5eed[_0x9329('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x1b5eed[_0x9329('0x1b')]?_0x1b5eed['options'][_0x9329('0x1c')]||null:null,'attributes':_0x1b5eed[_0x9329('0x1b')]?_0x1b5eed[_0x9329('0x1b')][_0x9329('0x1d')]||null:null,'limit':_0x1b5eed[_0x9329('0x1b')]?_0x1b5eed[_0x9329('0x1b')]['limit']||null:null,'include':_0x1b5eed[_0x9329('0x1b')]?_0x1b5eed[_0x9329('0x1b')][_0x9329('0x1e')]?_[_0x9329('0x1f')](_0x1b5eed[_0x9329('0x1b')]['include'],function(_0x22caa4){return{'model':db[_0x22caa4[_0x9329('0x20')]],'as':_0x22caa4['as'],'attributes':_0x22caa4['attributes'],'include':_0x22caa4[_0x9329('0x1e')]?_[_0x9329('0x1f')](_0x22caa4[_0x9329('0x1e')],function(_0x2da39d){return{'model':db[_0x2da39d['model']],'as':_0x2da39d['as'],'attributes':_0x2da39d['attributes'],'include':_0x2da39d[_0x9329('0x1e')]?_[_0x9329('0x1f')](_0x2da39d[_0x9329('0x1e')],function(_0x4f5fbf){return{'model':db[_0x4f5fbf[_0x9329('0x20')]],'as':_0x4f5fbf['as'],'attributes':_0x4f5fbf['attributes']};}):[]};}):[]};}):[]:[]})[_0x9329('0xe')](function(_0x192d0a){logger[_0x9329('0xf')]('GetCampaign',_0x1b5eed);logger['debug'](_0x9329('0x19'),_0x1b5eed,JSON['stringify'](_0x192d0a));_0x41db73(_0x192d0a);})[_0x9329('0x18')](function(_0x4a5d27){logger[_0x9329('0x13')]('GetCampaign',_0x4a5d27[_0x9329('0x15')],_0x1b5eed);_0x26a3c2(_0x57718b[_0x9329('0x13')](0x1f4,_0x4a5d27['message']));});});};