28689980212324e400ca187057ee04b29ba1d256
[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 _0x83f2=['code','message','result','catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','attributes','limit','include','map','model','UpdateCmHopperBlack','update','body','stringify','DestroyCmHopperBlack','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','client','http','request','then','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','error'];(function(_0x5894c0,_0x577c35){var _0x31f9aa=function(_0x56a1a8){while(--_0x56a1a8){_0x5894c0['push'](_0x5894c0['shift']());}};_0x31f9aa(++_0x577c35);}(_0x83f2,0x117));var _0x283f=function(_0x5e112f,_0x361e47){_0x5e112f=_0x5e112f-0x0;var _0x45d990=_0x83f2[_0x5e112f];return _0x45d990;};'use strict';var _=require(_0x283f('0x0'));var util=require(_0x283f('0x1'));var moment=require('moment');var BPromise=require(_0x283f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x283f('0x3'));var db=require(_0x283f('0x4'))['db'];var utils=require(_0x283f('0x5'));var logger=require('../../config/logger')(_0x283f('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x283f('0x7')][_0x283f('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x23ab8e,_0x3699f7,_0x15d61a){return new BPromise(function(_0x1ba217,_0x4ce28b){return client[_0x283f('0x9')](_0x23ab8e,_0x15d61a)[_0x283f('0xa')](function(_0x35acd){logger[_0x283f('0xb')](_0x283f('0xc'),_0x3699f7,_0x283f('0xd'));logger[_0x283f('0xe')](_0x283f('0xf'),_0x3699f7,_0x283f('0xd'),JSON['stringify'](_0x35acd));if(_0x35acd[_0x283f('0x10')]){if(_0x35acd[_0x283f('0x10')][_0x283f('0x11')]===0x1f4){logger[_0x283f('0x10')]('CmHopperBlack,\x20%s,\x20%s',_0x3699f7,_0x35acd[_0x283f('0x10')][_0x283f('0x12')]);return _0x4ce28b(_0x35acd[_0x283f('0x10')][_0x283f('0x12')]);}logger[_0x283f('0x10')]('CmHopperBlack,\x20%s,\x20%s',_0x3699f7,_0x35acd['error'][_0x283f('0x12')]);return _0x1ba217(_0x35acd['error']['message']);}else{logger[_0x283f('0xb')](_0x283f('0xc'),_0x3699f7,_0x283f('0xd'));_0x1ba217(_0x35acd[_0x283f('0x13')][_0x283f('0x12')]);}})[_0x283f('0x14')](function(_0xbf76bd){logger[_0x283f('0x10')]('CmHopperBlack,\x20%s,\x20%s',_0x3699f7,_0xbf76bd);_0x4ce28b(_0xbf76bd);});});}exports[_0x283f('0x15')]=function(_0x3d536b){var _0x17eb18=this;return new Promise(function(_0x30ffc8,_0xf8fc9c){return db[_0x283f('0x16')][_0x283f('0x17')]({'raw':_0x3d536b[_0x283f('0x18')]?_0x3d536b[_0x283f('0x18')][_0x283f('0x19')]===undefined?!![]:![]:!![],'where':_0x3d536b['options']?_0x3d536b['options'][_0x283f('0x1a')]||null:null,'attributes':_0x3d536b['options']?_0x3d536b[_0x283f('0x18')][_0x283f('0x1b')]||null:null,'limit':_0x3d536b[_0x283f('0x18')]?_0x3d536b['options'][_0x283f('0x1c')]||null:null,'include':_0x3d536b[_0x283f('0x18')]?_0x3d536b['options'][_0x283f('0x1d')]?_[_0x283f('0x1e')](_0x3d536b['options'][_0x283f('0x1d')],function(_0x358072){return{'model':db[_0x358072[_0x283f('0x1f')]],'as':_0x358072['as'],'attributes':_0x358072[_0x283f('0x1b')],'include':_0x358072[_0x283f('0x1d')]?_[_0x283f('0x1e')](_0x358072[_0x283f('0x1d')],function(_0x2291eb){return{'model':db[_0x2291eb[_0x283f('0x1f')]],'as':_0x2291eb['as'],'attributes':_0x2291eb[_0x283f('0x1b')],'include':_0x2291eb['include']?_[_0x283f('0x1e')](_0x2291eb[_0x283f('0x1d')],function(_0x3a42e4){return{'model':db[_0x3a42e4['model']],'as':_0x3a42e4['as'],'attributes':_0x3a42e4['attributes']};}):[]};}):[]};}):[]:[]})[_0x283f('0xa')](function(_0x3546d3){logger[_0x283f('0xb')]('GetCmHopperBlack',_0x3d536b);logger[_0x283f('0xe')](_0x283f('0x15'),_0x3d536b,JSON['stringify'](_0x3546d3));_0x30ffc8(_0x3546d3);})[_0x283f('0x14')](function(_0x37850d){logger[_0x283f('0x10')](_0x283f('0x15'),_0x37850d[_0x283f('0x12')],_0x3d536b);_0xf8fc9c(_0x17eb18[_0x283f('0x10')](0x1f4,_0x37850d['message']));});});};exports[_0x283f('0x20')]=function(_0x4a555b){var _0x54a66a=this;return new Promise(function(_0x57db9f,_0x3f439b){return db[_0x283f('0x16')][_0x283f('0x21')](_0x4a555b[_0x283f('0x22')],{'raw':_0x4a555b[_0x283f('0x18')]?_0x4a555b[_0x283f('0x18')][_0x283f('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4a555b[_0x283f('0x18')]?_0x4a555b['options']['where']||null:null,'attributes':_0x4a555b['options']?_0x4a555b[_0x283f('0x18')][_0x283f('0x1b')]||null:null,'limit':_0x4a555b[_0x283f('0x18')]?_0x4a555b[_0x283f('0x18')][_0x283f('0x1c')]||null:null})[_0x283f('0xa')](function(_0x1932f5){logger[_0x283f('0xb')](_0x283f('0x20'),_0x4a555b);logger[_0x283f('0xe')]('UpdateCmHopperBlack',_0x4a555b,JSON[_0x283f('0x23')](_0x1932f5));_0x57db9f(_0x1932f5);})['catch'](function(_0x38a46e){logger[_0x283f('0x10')](_0x283f('0x20'),_0x38a46e[_0x283f('0x12')],_0x4a555b);_0x3f439b(_0x54a66a[_0x283f('0x10')](0x1f4,_0x38a46e[_0x283f('0x12')]));});});};exports['DestroyCmHopperBlack']=function(_0x8990d0){var _0x1c33cb=this;return new Promise(function(_0x2e6edc,_0xa793cf){return db[_0x283f('0x16')]['destroy']({'where':_0x8990d0['options']?_0x8990d0[_0x283f('0x18')]['where']||null:null})[_0x283f('0xa')](function(_0x48e7aa){logger['info'](_0x283f('0x24'),_0x8990d0);logger[_0x283f('0xe')](_0x283f('0x24'),_0x8990d0,JSON[_0x283f('0x23')](_0x48e7aa));_0x2e6edc(_0x48e7aa);})[_0x283f('0x14')](function(_0x154ea1){logger[_0x283f('0x10')](_0x283f('0x24'),_0x154ea1[_0x283f('0x12')],_0x8990d0);_0xa793cf(_0x1c33cb[_0x283f('0x10')](0x1f4,_0x154ea1[_0x283f('0x12')]));});});};