f8a36d8e4c9e936ca6d44792c5c913b3b88ec653
[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 _0xb4c8=['CmHopperBlack,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','CmHopperBlack,\x20%s,\x20%s','message','result','catch','GetCmHopperBlack','CmHopperBlack','options','where','attributes','limit','include','map','model','UpdateCmHopperBlack','body','raw','DestroyCmHopperBlack','destroy','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','request','then','info','debug'];(function(_0x4897c3,_0x2fdcf2){var _0x2797b0=function(_0x57f2d5){while(--_0x57f2d5){_0x4897c3['push'](_0x4897c3['shift']());}};_0x2797b0(++_0x2fdcf2);}(_0xb4c8,0x83));var _0x8b4c=function(_0x1d9815,_0x4fdf00){_0x1d9815=_0x1d9815-0x0;var _0x3d2966=_0xb4c8[_0x1d9815];return _0x3d2966;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x8b4c('0x0'));var BPromise=require(_0x8b4c('0x1'));var rs=require(_0x8b4c('0x2'));var fs=require('fs');var Redis=require(_0x8b4c('0x3'));var db=require(_0x8b4c('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x8b4c('0x5'))(_0x8b4c('0x6'));var config=require(_0x8b4c('0x7'));var jayson=require(_0x8b4c('0x8'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1915b8,_0x212d5a,_0x232040){return new BPromise(function(_0x3d63bc,_0x3fc088){return client[_0x8b4c('0x9')](_0x1915b8,_0x232040)[_0x8b4c('0xa')](function(_0x1cdbd2){logger[_0x8b4c('0xb')]('CmHopperBlack,\x20%s,\x20%s',_0x212d5a,'request\x20sent');logger[_0x8b4c('0xc')](_0x8b4c('0xd'),_0x212d5a,_0x8b4c('0xe'),JSON[_0x8b4c('0xf')](_0x1cdbd2));if(_0x1cdbd2[_0x8b4c('0x10')]){if(_0x1cdbd2[_0x8b4c('0x10')][_0x8b4c('0x11')]===0x1f4){logger['error'](_0x8b4c('0x12'),_0x212d5a,_0x1cdbd2[_0x8b4c('0x10')][_0x8b4c('0x13')]);return _0x3fc088(_0x1cdbd2[_0x8b4c('0x10')][_0x8b4c('0x13')]);}logger['error'](_0x8b4c('0x12'),_0x212d5a,_0x1cdbd2[_0x8b4c('0x10')][_0x8b4c('0x13')]);return _0x3d63bc(_0x1cdbd2[_0x8b4c('0x10')][_0x8b4c('0x13')]);}else{logger['info']('CmHopperBlack,\x20%s,\x20%s',_0x212d5a,'request\x20sent');_0x3d63bc(_0x1cdbd2[_0x8b4c('0x14')]['message']);}})[_0x8b4c('0x15')](function(_0x3d1b4e){logger[_0x8b4c('0x10')](_0x8b4c('0x12'),_0x212d5a,_0x3d1b4e);_0x3fc088(_0x3d1b4e);});});}exports[_0x8b4c('0x16')]=function(_0x1c37ec){var _0x398c94=this;return new Promise(function(_0x3fb5d1,_0x587a52){return db[_0x8b4c('0x17')]['findAll']({'raw':_0x1c37ec['options']?_0x1c37ec[_0x8b4c('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x1c37ec[_0x8b4c('0x18')]?_0x1c37ec[_0x8b4c('0x18')][_0x8b4c('0x19')]||null:null,'attributes':_0x1c37ec[_0x8b4c('0x18')]?_0x1c37ec[_0x8b4c('0x18')][_0x8b4c('0x1a')]||null:null,'limit':_0x1c37ec['options']?_0x1c37ec[_0x8b4c('0x18')][_0x8b4c('0x1b')]||null:null,'include':_0x1c37ec[_0x8b4c('0x18')]?_0x1c37ec[_0x8b4c('0x18')][_0x8b4c('0x1c')]?_[_0x8b4c('0x1d')](_0x1c37ec['options'][_0x8b4c('0x1c')],function(_0x1e0778){return{'model':db[_0x1e0778[_0x8b4c('0x1e')]],'as':_0x1e0778['as'],'attributes':_0x1e0778['attributes'],'include':_0x1e0778[_0x8b4c('0x1c')]?_[_0x8b4c('0x1d')](_0x1e0778[_0x8b4c('0x1c')],function(_0x1d9013){return{'model':db[_0x1d9013[_0x8b4c('0x1e')]],'as':_0x1d9013['as'],'attributes':_0x1d9013[_0x8b4c('0x1a')],'include':_0x1d9013[_0x8b4c('0x1c')]?_['map'](_0x1d9013[_0x8b4c('0x1c')],function(_0x3d6d1b){return{'model':db[_0x3d6d1b[_0x8b4c('0x1e')]],'as':_0x3d6d1b['as'],'attributes':_0x3d6d1b['attributes']};}):[]};}):[]};}):[]:[]})[_0x8b4c('0xa')](function(_0x25410d){logger[_0x8b4c('0xb')]('GetCmHopperBlack',_0x1c37ec);logger[_0x8b4c('0xc')](_0x8b4c('0x16'),_0x1c37ec,JSON[_0x8b4c('0xf')](_0x25410d));_0x3fb5d1(_0x25410d);})[_0x8b4c('0x15')](function(_0x185631){logger[_0x8b4c('0x10')]('GetCmHopperBlack',_0x185631['message'],_0x1c37ec);_0x587a52(_0x398c94[_0x8b4c('0x10')](0x1f4,_0x185631[_0x8b4c('0x13')]));});});};exports[_0x8b4c('0x1f')]=function(_0x50fa47){var _0xf88c30=this;return new Promise(function(_0x4bf60b,_0x32794e){return db[_0x8b4c('0x17')]['update'](_0x50fa47[_0x8b4c('0x20')],{'raw':_0x50fa47[_0x8b4c('0x18')]?_0x50fa47['options'][_0x8b4c('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x50fa47[_0x8b4c('0x18')]?_0x50fa47['options']['where']||null:null,'attributes':_0x50fa47['options']?_0x50fa47[_0x8b4c('0x18')]['attributes']||null:null,'limit':_0x50fa47[_0x8b4c('0x18')]?_0x50fa47[_0x8b4c('0x18')]['limit']||null:null})[_0x8b4c('0xa')](function(_0x8cb907){logger['info'](_0x8b4c('0x1f'),_0x50fa47);logger[_0x8b4c('0xc')](_0x8b4c('0x1f'),_0x50fa47,JSON[_0x8b4c('0xf')](_0x8cb907));_0x4bf60b(_0x8cb907);})[_0x8b4c('0x15')](function(_0x44ad15){logger[_0x8b4c('0x10')]('UpdateCmHopperBlack',_0x44ad15['message'],_0x50fa47);_0x32794e(_0xf88c30[_0x8b4c('0x10')](0x1f4,_0x44ad15[_0x8b4c('0x13')]));});});};exports[_0x8b4c('0x22')]=function(_0x3c2442){var _0x4c9dc0=this;return new Promise(function(_0x34f5ed,_0x583174){return db[_0x8b4c('0x17')][_0x8b4c('0x23')]({'where':_0x3c2442['options']?_0x3c2442[_0x8b4c('0x18')][_0x8b4c('0x19')]||null:null})[_0x8b4c('0xa')](function(_0x27916b){logger[_0x8b4c('0xb')](_0x8b4c('0x22'),_0x3c2442);logger[_0x8b4c('0xc')]('DestroyCmHopperBlack',_0x3c2442,JSON[_0x8b4c('0xf')](_0x27916b));_0x34f5ed(_0x27916b);})[_0x8b4c('0x15')](function(_0x1a1f45){logger[_0x8b4c('0x10')](_0x8b4c('0x22'),_0x1a1f45[_0x8b4c('0x13')],_0x3c2442);_0x583174(_0x4c9dc0[_0x8b4c('0x10')](0x1f4,_0x1a1f45[_0x8b4c('0x13')]));});});};