Built motion from commit (unavailable).|2.5.4
[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 _0x2628=['result','catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','attributes','map','include','model','UpdateCmHopperBlack','update','body','limit','destroy','DestroyCmHopperBlack','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','request','then','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error','message','info'];(function(_0x2070da,_0x45e586){var _0x4f9fe1=function(_0x5b6f2a){while(--_0x5b6f2a){_0x2070da['push'](_0x2070da['shift']());}};_0x4f9fe1(++_0x45e586);}(_0x2628,0x171));var _0x8262=function(_0x26798a,_0x491210){_0x26798a=_0x26798a-0x0;var _0x26fbaf=_0x2628[_0x26798a];return _0x26fbaf;};'use strict';var _=require(_0x8262('0x0'));var util=require(_0x8262('0x1'));var moment=require('moment');var BPromise=require(_0x8262('0x2'));var rs=require(_0x8262('0x3'));var fs=require('fs');var Redis=require(_0x8262('0x4'));var db=require(_0x8262('0x5'))['db'];var utils=require(_0x8262('0x6'));var logger=require(_0x8262('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x8262('0x8'));var client=jayson[_0x8262('0x9')][_0x8262('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1b4f7f,_0x3dc630,_0x688ee5){return new BPromise(function(_0x1c87aa,_0xafee3b){return client[_0x8262('0xb')](_0x1b4f7f,_0x688ee5)[_0x8262('0xc')](function(_0x494696){logger['info'](_0x8262('0xd'),_0x3dc630,_0x8262('0xe'));logger[_0x8262('0xf')](_0x8262('0x10'),_0x3dc630,_0x8262('0xe'),JSON[_0x8262('0x11')](_0x494696));if(_0x494696['error']){if(_0x494696[_0x8262('0x12')]['code']===0x1f4){logger[_0x8262('0x12')](_0x8262('0xd'),_0x3dc630,_0x494696[_0x8262('0x12')][_0x8262('0x13')]);return _0xafee3b(_0x494696[_0x8262('0x12')][_0x8262('0x13')]);}logger['error'](_0x8262('0xd'),_0x3dc630,_0x494696[_0x8262('0x12')]['message']);return _0x1c87aa(_0x494696[_0x8262('0x12')][_0x8262('0x13')]);}else{logger[_0x8262('0x14')](_0x8262('0xd'),_0x3dc630,_0x8262('0xe'));_0x1c87aa(_0x494696[_0x8262('0x15')][_0x8262('0x13')]);}})[_0x8262('0x16')](function(_0x5a0abe){logger[_0x8262('0x12')]('CmHopperBlack,\x20%s,\x20%s',_0x3dc630,_0x5a0abe);_0xafee3b(_0x5a0abe);});});}exports[_0x8262('0x17')]=function(_0x21c397){var _0x331d7d=this;return new Promise(function(_0x40f3f9,_0x44d265){return db[_0x8262('0x18')][_0x8262('0x19')]({'raw':_0x21c397['options']?_0x21c397[_0x8262('0x1a')][_0x8262('0x1b')]===undefined?!![]:![]:!![],'where':_0x21c397[_0x8262('0x1a')]?_0x21c397[_0x8262('0x1a')][_0x8262('0x1c')]||null:null,'attributes':_0x21c397['options']?_0x21c397['options'][_0x8262('0x1d')]||null:null,'limit':_0x21c397[_0x8262('0x1a')]?_0x21c397[_0x8262('0x1a')]['limit']||null:null,'include':_0x21c397['options']?_0x21c397[_0x8262('0x1a')]['include']?_[_0x8262('0x1e')](_0x21c397[_0x8262('0x1a')][_0x8262('0x1f')],function(_0x26707f){return{'model':db[_0x26707f['model']],'as':_0x26707f['as'],'attributes':_0x26707f['attributes'],'include':_0x26707f[_0x8262('0x1f')]?_[_0x8262('0x1e')](_0x26707f[_0x8262('0x1f')],function(_0x33fc26){return{'model':db[_0x33fc26[_0x8262('0x20')]],'as':_0x33fc26['as'],'attributes':_0x33fc26[_0x8262('0x1d')],'include':_0x33fc26[_0x8262('0x1f')]?_[_0x8262('0x1e')](_0x33fc26[_0x8262('0x1f')],function(_0x2f6a85){return{'model':db[_0x2f6a85[_0x8262('0x20')]],'as':_0x2f6a85['as'],'attributes':_0x2f6a85['attributes']};}):[]};}):[]};}):[]:[]})[_0x8262('0xc')](function(_0x720a07){logger[_0x8262('0x14')](_0x8262('0x17'),_0x21c397);logger[_0x8262('0xf')](_0x8262('0x17'),_0x21c397,JSON['stringify'](_0x720a07));_0x40f3f9(_0x720a07);})[_0x8262('0x16')](function(_0x452ac8){logger['error'](_0x8262('0x17'),_0x452ac8[_0x8262('0x13')],_0x21c397);_0x44d265(_0x331d7d[_0x8262('0x12')](0x1f4,_0x452ac8[_0x8262('0x13')]));});});};exports[_0x8262('0x21')]=function(_0x3cf4c3){var _0x282df9=this;return new Promise(function(_0x4bccb4,_0xd88a63){return db[_0x8262('0x18')][_0x8262('0x22')](_0x3cf4c3[_0x8262('0x23')],{'raw':_0x3cf4c3[_0x8262('0x1a')]?_0x3cf4c3[_0x8262('0x1a')][_0x8262('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3cf4c3[_0x8262('0x1a')]?_0x3cf4c3['options'][_0x8262('0x1c')]||null:null,'attributes':_0x3cf4c3[_0x8262('0x1a')]?_0x3cf4c3[_0x8262('0x1a')][_0x8262('0x1d')]||null:null,'limit':_0x3cf4c3[_0x8262('0x1a')]?_0x3cf4c3['options'][_0x8262('0x24')]||null:null})['then'](function(_0x4abc06){logger['info'](_0x8262('0x21'),_0x3cf4c3);logger[_0x8262('0xf')]('UpdateCmHopperBlack',_0x3cf4c3,JSON[_0x8262('0x11')](_0x4abc06));_0x4bccb4(_0x4abc06);})[_0x8262('0x16')](function(_0x41ff18){logger[_0x8262('0x12')](_0x8262('0x21'),_0x41ff18[_0x8262('0x13')],_0x3cf4c3);_0xd88a63(_0x282df9[_0x8262('0x12')](0x1f4,_0x41ff18[_0x8262('0x13')]));});});};exports['DestroyCmHopperBlack']=function(_0x3a8521){var _0x85476c=this;return new Promise(function(_0x5f10af,_0x2f0ebf){return db['CmHopperBlack'][_0x8262('0x25')]({'where':_0x3a8521[_0x8262('0x1a')]?_0x3a8521[_0x8262('0x1a')][_0x8262('0x1c')]||null:null})[_0x8262('0xc')](function(_0x550331){logger['info'](_0x8262('0x26'),_0x3a8521);logger[_0x8262('0xf')](_0x8262('0x26'),_0x3a8521,JSON[_0x8262('0x11')](_0x550331));_0x5f10af(_0x550331);})['catch'](function(_0x46c00b){logger[_0x8262('0x12')](_0x8262('0x26'),_0x46c00b['message'],_0x3a8521);_0x2f0ebf(_0x85476c[_0x8262('0x12')](0x1f4,_0x46c00b[_0x8262('0x13')]));});});};