Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / api / cmHopperBlack / cmHopperBlack.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 _0xacec=['catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','attributes','limit','include','map','model','UpdateCmHopperBlack','body','DestroyCmHopperBlack','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','then','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error','message','result'];(function(_0x1b714f,_0x2a8fce){var _0x46df2a=function(_0x57e774){while(--_0x57e774){_0x1b714f['push'](_0x1b714f['shift']());}};_0x46df2a(++_0x2a8fce);}(_0xacec,0x153));var _0xcace=function(_0x3c6835,_0x952d5c){_0x3c6835=_0x3c6835-0x0;var _0x1adeb9=_0xacec[_0x3c6835];return _0x1adeb9;};'use strict';var _=require('lodash');var util=require(_0xcace('0x0'));var moment=require(_0xcace('0x1'));var BPromise=require(_0xcace('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcace('0x3'));var db=require(_0xcace('0x4'))['db'];var utils=require(_0xcace('0x5'));var logger=require(_0xcace('0x6'))(_0xcace('0x7'));var config=require('../../config/environment');var jayson=require(_0xcace('0x8'));var client=jayson[_0xcace('0x9')][_0xcace('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x39cdd3,_0x17173c,_0x4e57b3){return new BPromise(function(_0x3182f5,_0x11a8d2){return client['request'](_0x39cdd3,_0x4e57b3)[_0xcace('0xb')](function(_0x2f39e3){logger[_0xcace('0xc')](_0xcace('0xd'),_0x17173c,_0xcace('0xe'));logger[_0xcace('0xf')](_0xcace('0x10'),_0x17173c,_0xcace('0xe'),JSON[_0xcace('0x11')](_0x2f39e3));if(_0x2f39e3[_0xcace('0x12')]){if(_0x2f39e3[_0xcace('0x12')]['code']===0x1f4){logger[_0xcace('0x12')]('CmHopperBlack,\x20%s,\x20%s',_0x17173c,_0x2f39e3['error'][_0xcace('0x13')]);return _0x11a8d2(_0x2f39e3['error']['message']);}logger[_0xcace('0x12')](_0xcace('0xd'),_0x17173c,_0x2f39e3[_0xcace('0x12')]['message']);return _0x3182f5(_0x2f39e3[_0xcace('0x12')][_0xcace('0x13')]);}else{logger[_0xcace('0xc')](_0xcace('0xd'),_0x17173c,_0xcace('0xe'));_0x3182f5(_0x2f39e3[_0xcace('0x14')]['message']);}})[_0xcace('0x15')](function(_0x16105d){logger[_0xcace('0x12')]('CmHopperBlack,\x20%s,\x20%s',_0x17173c,_0x16105d);_0x11a8d2(_0x16105d);});});}exports[_0xcace('0x16')]=function(_0x54bdd1){var _0x56ef47=this;return new Promise(function(_0x3ac27f,_0x8e62b5){return db[_0xcace('0x17')][_0xcace('0x18')]({'raw':_0x54bdd1[_0xcace('0x19')]?_0x54bdd1[_0xcace('0x19')][_0xcace('0x1a')]===undefined?!![]:![]:!![],'where':_0x54bdd1['options']?_0x54bdd1['options'][_0xcace('0x1b')]||null:null,'attributes':_0x54bdd1[_0xcace('0x19')]?_0x54bdd1[_0xcace('0x19')][_0xcace('0x1c')]||null:null,'limit':_0x54bdd1[_0xcace('0x19')]?_0x54bdd1['options'][_0xcace('0x1d')]||null:null,'include':_0x54bdd1[_0xcace('0x19')]?_0x54bdd1[_0xcace('0x19')][_0xcace('0x1e')]?_[_0xcace('0x1f')](_0x54bdd1[_0xcace('0x19')][_0xcace('0x1e')],function(_0x3620b4){return{'model':db[_0x3620b4[_0xcace('0x20')]],'as':_0x3620b4['as'],'attributes':_0x3620b4[_0xcace('0x1c')],'include':_0x3620b4[_0xcace('0x1e')]?_['map'](_0x3620b4['include'],function(_0x26e5d5){return{'model':db[_0x26e5d5[_0xcace('0x20')]],'as':_0x26e5d5['as'],'attributes':_0x26e5d5['attributes'],'include':_0x26e5d5[_0xcace('0x1e')]?_['map'](_0x26e5d5[_0xcace('0x1e')],function(_0x4a45d4){return{'model':db[_0x4a45d4[_0xcace('0x20')]],'as':_0x4a45d4['as'],'attributes':_0x4a45d4['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x184de){logger[_0xcace('0xc')](_0xcace('0x16'),_0x54bdd1);logger[_0xcace('0xf')](_0xcace('0x16'),_0x54bdd1,JSON[_0xcace('0x11')](_0x184de));_0x3ac27f(_0x184de);})[_0xcace('0x15')](function(_0x16b0cd){logger[_0xcace('0x12')](_0xcace('0x16'),_0x16b0cd[_0xcace('0x13')],_0x54bdd1);_0x8e62b5(_0x56ef47[_0xcace('0x12')](0x1f4,_0x16b0cd['message']));});});};exports[_0xcace('0x21')]=function(_0x506ec0){var _0x539816=this;return new Promise(function(_0x126b42,_0x3b5ab4){return db[_0xcace('0x17')]['update'](_0x506ec0[_0xcace('0x22')],{'raw':_0x506ec0[_0xcace('0x19')]?_0x506ec0[_0xcace('0x19')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x506ec0[_0xcace('0x19')]?_0x506ec0[_0xcace('0x19')]['where']||null:null,'attributes':_0x506ec0[_0xcace('0x19')]?_0x506ec0[_0xcace('0x19')][_0xcace('0x1c')]||null:null,'limit':_0x506ec0[_0xcace('0x19')]?_0x506ec0[_0xcace('0x19')][_0xcace('0x1d')]||null:null})[_0xcace('0xb')](function(_0xe2d49a){logger['info']('UpdateCmHopperBlack',_0x506ec0);logger['debug'](_0xcace('0x21'),_0x506ec0,JSON[_0xcace('0x11')](_0xe2d49a));_0x126b42(_0xe2d49a);})['catch'](function(_0x16fb7d){logger[_0xcace('0x12')](_0xcace('0x21'),_0x16fb7d[_0xcace('0x13')],_0x506ec0);_0x3b5ab4(_0x539816[_0xcace('0x12')](0x1f4,_0x16fb7d[_0xcace('0x13')]));});});};exports[_0xcace('0x23')]=function(_0x701351){var _0x1cfe1=this;return new Promise(function(_0x27fdd8,_0x34d1f0){return db['CmHopperBlack']['destroy']({'where':_0x701351[_0xcace('0x19')]?_0x701351['options'][_0xcace('0x1b')]||null:null})['then'](function(_0x28636e){logger[_0xcace('0xc')](_0xcace('0x23'),_0x701351);logger[_0xcace('0xf')](_0xcace('0x23'),_0x701351,JSON[_0xcace('0x11')](_0x28636e));_0x27fdd8(_0x28636e);})[_0xcace('0x15')](function(_0x3704b4){logger[_0xcace('0x12')](_0xcace('0x23'),_0x3704b4[_0xcace('0x13')],_0x701351);_0x34d1f0(_0x1cfe1[_0xcace('0x12')](0x1f4,_0x3704b4[_0xcace('0x13')]));});});};