Built motion from commit d1eab355.|2.6.28
[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 _0x86b2=['debug','stringify','error','code','message','result','GetCmHopperBlack','CmHopperBlack','findAll','options','attributes','limit','map','include','model','UpdateCmHopperBlack','update','body','raw','where','catch','DestroyCmHopperBlack','destroy','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','client','http','request','then','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent'];(function(_0xce79bf,_0x258640){var _0x5e35e3=function(_0x3e9498){while(--_0x3e9498){_0xce79bf['push'](_0xce79bf['shift']());}};_0x5e35e3(++_0x258640);}(_0x86b2,0x189));var _0x286b=function(_0x31a371,_0x50828e){_0x31a371=_0x31a371-0x0;var _0x2a5bd6=_0x86b2[_0x31a371];return _0x2a5bd6;};'use strict';var _=require('lodash');var util=require(_0x286b('0x0'));var moment=require(_0x286b('0x1'));var BPromise=require('bluebird');var rs=require(_0x286b('0x2'));var fs=require('fs');var Redis=require(_0x286b('0x3'));var db=require(_0x286b('0x4'))['db'];var utils=require(_0x286b('0x5'));var logger=require('../../config/logger')(_0x286b('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x286b('0x7')][_0x286b('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x311006,_0xb54d3b,_0x4e348b){return new BPromise(function(_0x3c9494,_0xb851a6){return client[_0x286b('0x9')](_0x311006,_0x4e348b)[_0x286b('0xa')](function(_0x35d3e8){logger[_0x286b('0xb')](_0x286b('0xc'),_0xb54d3b,_0x286b('0xd'));logger[_0x286b('0xe')]('CmHopperBlack,\x20%s,\x20%s,\x20%s',_0xb54d3b,_0x286b('0xd'),JSON[_0x286b('0xf')](_0x35d3e8));if(_0x35d3e8[_0x286b('0x10')]){if(_0x35d3e8[_0x286b('0x10')][_0x286b('0x11')]===0x1f4){logger['error']('CmHopperBlack,\x20%s,\x20%s',_0xb54d3b,_0x35d3e8[_0x286b('0x10')]['message']);return _0xb851a6(_0x35d3e8['error'][_0x286b('0x12')]);}logger[_0x286b('0x10')](_0x286b('0xc'),_0xb54d3b,_0x35d3e8['error'][_0x286b('0x12')]);return _0x3c9494(_0x35d3e8['error'][_0x286b('0x12')]);}else{logger[_0x286b('0xb')](_0x286b('0xc'),_0xb54d3b,'request\x20sent');_0x3c9494(_0x35d3e8[_0x286b('0x13')][_0x286b('0x12')]);}})['catch'](function(_0x9ff281){logger['error'](_0x286b('0xc'),_0xb54d3b,_0x9ff281);_0xb851a6(_0x9ff281);});});}exports[_0x286b('0x14')]=function(_0xb85815){var _0x544228=this;return new Promise(function(_0x31370b,_0x1993c3){return db[_0x286b('0x15')][_0x286b('0x16')]({'raw':_0xb85815[_0x286b('0x17')]?_0xb85815[_0x286b('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0xb85815[_0x286b('0x17')]?_0xb85815[_0x286b('0x17')]['where']||null:null,'attributes':_0xb85815[_0x286b('0x17')]?_0xb85815[_0x286b('0x17')][_0x286b('0x18')]||null:null,'limit':_0xb85815[_0x286b('0x17')]?_0xb85815[_0x286b('0x17')][_0x286b('0x19')]||null:null,'include':_0xb85815['options']?_0xb85815[_0x286b('0x17')]['include']?_[_0x286b('0x1a')](_0xb85815[_0x286b('0x17')][_0x286b('0x1b')],function(_0x198dcd){return{'model':db[_0x198dcd[_0x286b('0x1c')]],'as':_0x198dcd['as'],'attributes':_0x198dcd[_0x286b('0x18')],'include':_0x198dcd['include']?_['map'](_0x198dcd[_0x286b('0x1b')],function(_0x3abe04){return{'model':db[_0x3abe04[_0x286b('0x1c')]],'as':_0x3abe04['as'],'attributes':_0x3abe04[_0x286b('0x18')],'include':_0x3abe04[_0x286b('0x1b')]?_[_0x286b('0x1a')](_0x3abe04['include'],function(_0x543231){return{'model':db[_0x543231[_0x286b('0x1c')]],'as':_0x543231['as'],'attributes':_0x543231['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x3e6230){logger['info'](_0x286b('0x14'),_0xb85815);logger['debug'](_0x286b('0x14'),_0xb85815,JSON[_0x286b('0xf')](_0x3e6230));_0x31370b(_0x3e6230);})['catch'](function(_0x3bead9){logger[_0x286b('0x10')]('GetCmHopperBlack',_0x3bead9[_0x286b('0x12')],_0xb85815);_0x1993c3(_0x544228[_0x286b('0x10')](0x1f4,_0x3bead9[_0x286b('0x12')]));});});};exports[_0x286b('0x1d')]=function(_0x36014c){var _0x5f59a7=this;return new Promise(function(_0x3d3c06,_0x55e70a){return db[_0x286b('0x15')][_0x286b('0x1e')](_0x36014c[_0x286b('0x1f')],{'raw':_0x36014c[_0x286b('0x17')]?_0x36014c[_0x286b('0x17')][_0x286b('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x36014c[_0x286b('0x17')]?_0x36014c[_0x286b('0x17')][_0x286b('0x21')]||null:null,'attributes':_0x36014c['options']?_0x36014c[_0x286b('0x17')][_0x286b('0x18')]||null:null,'limit':_0x36014c[_0x286b('0x17')]?_0x36014c[_0x286b('0x17')][_0x286b('0x19')]||null:null})[_0x286b('0xa')](function(_0x40c9eb){logger[_0x286b('0xb')](_0x286b('0x1d'),_0x36014c);logger[_0x286b('0xe')](_0x286b('0x1d'),_0x36014c,JSON[_0x286b('0xf')](_0x40c9eb));_0x3d3c06(_0x40c9eb);})[_0x286b('0x22')](function(_0xef72a){logger[_0x286b('0x10')](_0x286b('0x1d'),_0xef72a['message'],_0x36014c);_0x55e70a(_0x5f59a7[_0x286b('0x10')](0x1f4,_0xef72a[_0x286b('0x12')]));});});};exports[_0x286b('0x23')]=function(_0x165ede){var _0x1dcf26=this;return new Promise(function(_0x5d4dca,_0x1870a6){return db[_0x286b('0x15')][_0x286b('0x24')]({'where':_0x165ede[_0x286b('0x17')]?_0x165ede[_0x286b('0x17')][_0x286b('0x21')]||null:null})[_0x286b('0xa')](function(_0x19b679){logger[_0x286b('0xb')]('DestroyCmHopperBlack',_0x165ede);logger[_0x286b('0xe')](_0x286b('0x23'),_0x165ede,JSON[_0x286b('0xf')](_0x19b679));_0x5d4dca(_0x19b679);})[_0x286b('0x22')](function(_0x4f9e97){logger[_0x286b('0x10')](_0x286b('0x23'),_0x4f9e97['message'],_0x165ede);_0x1870a6(_0x1dcf26[_0x286b('0x10')](0x1f4,_0x4f9e97[_0x286b('0x12')]));});});};