8cf7f5592c268d31a2781428589582e2fb75fdc6
[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 _0x28b6=['options','where','attributes','limit','include','map','model','debug','UpdateCmHopperBlack','raw','destroy','DestroyCmHopperBlack','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetCmHopperBlack','CmHopperBlack','findAll'];(function(_0x51f309,_0x416ab1){var _0x529ea0=function(_0x945dd5){while(--_0x945dd5){_0x51f309['push'](_0x51f309['shift']());}};_0x529ea0(++_0x416ab1);}(_0x28b6,0x7e));var _0x628b=function(_0x1a8c91,_0x591674){_0x1a8c91=_0x1a8c91-0x0;var _0x281a7f=_0x28b6[_0x1a8c91];return _0x281a7f;};'use strict';var _=require('lodash');var util=require(_0x628b('0x0'));var moment=require('moment');var BPromise=require(_0x628b('0x1'));var rs=require(_0x628b('0x2'));var fs=require('fs');var Redis=require(_0x628b('0x3'));var db=require(_0x628b('0x4'))['db'];var utils=require(_0x628b('0x5'));var logger=require(_0x628b('0x6'))(_0x628b('0x7'));var config=require(_0x628b('0x8'));var jayson=require(_0x628b('0x9'));var client=jayson['client'][_0x628b('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x298918,_0x6aad03,_0x47231b){return new BPromise(function(_0x479f95,_0x4965b9){return client[_0x628b('0xb')](_0x298918,_0x47231b)[_0x628b('0xc')](function(_0x21a7ab){logger[_0x628b('0xd')](_0x628b('0xe'),_0x6aad03,_0x628b('0xf'));logger['debug'](_0x628b('0x10'),_0x6aad03,_0x628b('0xf'),JSON[_0x628b('0x11')](_0x21a7ab));if(_0x21a7ab[_0x628b('0x12')]){if(_0x21a7ab[_0x628b('0x12')][_0x628b('0x13')]===0x1f4){logger[_0x628b('0x12')]('CmHopperBlack,\x20%s,\x20%s',_0x6aad03,_0x21a7ab['error'][_0x628b('0x14')]);return _0x4965b9(_0x21a7ab['error'][_0x628b('0x14')]);}logger[_0x628b('0x12')](_0x628b('0xe'),_0x6aad03,_0x21a7ab['error'][_0x628b('0x14')]);return _0x479f95(_0x21a7ab[_0x628b('0x12')][_0x628b('0x14')]);}else{logger[_0x628b('0xd')](_0x628b('0xe'),_0x6aad03,_0x628b('0xf'));_0x479f95(_0x21a7ab[_0x628b('0x15')][_0x628b('0x14')]);}})[_0x628b('0x16')](function(_0x323a5c){logger[_0x628b('0x12')](_0x628b('0xe'),_0x6aad03,_0x323a5c);_0x4965b9(_0x323a5c);});});}exports[_0x628b('0x17')]=function(_0x4975a1){var _0x22e8d2=this;return new Promise(function(_0x317588,_0x3514ff){return db[_0x628b('0x18')][_0x628b('0x19')]({'raw':_0x4975a1['options']?_0x4975a1['options']['raw']===undefined?!![]:![]:!![],'where':_0x4975a1['options']?_0x4975a1[_0x628b('0x1a')][_0x628b('0x1b')]||null:null,'attributes':_0x4975a1['options']?_0x4975a1['options'][_0x628b('0x1c')]||null:null,'limit':_0x4975a1[_0x628b('0x1a')]?_0x4975a1[_0x628b('0x1a')][_0x628b('0x1d')]||null:null,'include':_0x4975a1['options']?_0x4975a1[_0x628b('0x1a')][_0x628b('0x1e')]?_[_0x628b('0x1f')](_0x4975a1['options'][_0x628b('0x1e')],function(_0x2fb08e){return{'model':db[_0x2fb08e[_0x628b('0x20')]],'as':_0x2fb08e['as'],'attributes':_0x2fb08e[_0x628b('0x1c')],'include':_0x2fb08e[_0x628b('0x1e')]?_[_0x628b('0x1f')](_0x2fb08e[_0x628b('0x1e')],function(_0x185e76){return{'model':db[_0x185e76['model']],'as':_0x185e76['as'],'attributes':_0x185e76[_0x628b('0x1c')],'include':_0x185e76[_0x628b('0x1e')]?_[_0x628b('0x1f')](_0x185e76['include'],function(_0x5b67bd){return{'model':db[_0x5b67bd['model']],'as':_0x5b67bd['as'],'attributes':_0x5b67bd[_0x628b('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x628b('0xc')](function(_0x423aef){logger[_0x628b('0xd')](_0x628b('0x17'),_0x4975a1);logger[_0x628b('0x21')](_0x628b('0x17'),_0x4975a1,JSON[_0x628b('0x11')](_0x423aef));_0x317588(_0x423aef);})[_0x628b('0x16')](function(_0x1faee9){logger['error']('GetCmHopperBlack',_0x1faee9['message'],_0x4975a1);_0x3514ff(_0x22e8d2['error'](0x1f4,_0x1faee9[_0x628b('0x14')]));});});};exports[_0x628b('0x22')]=function(_0x41fdf1){var _0x131676=this;return new Promise(function(_0x678439,_0x1b3b84){return db[_0x628b('0x18')]['update'](_0x41fdf1['body'],{'raw':_0x41fdf1[_0x628b('0x1a')]?_0x41fdf1[_0x628b('0x1a')][_0x628b('0x23')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x41fdf1[_0x628b('0x1a')]?_0x41fdf1[_0x628b('0x1a')][_0x628b('0x1b')]||null:null,'attributes':_0x41fdf1[_0x628b('0x1a')]?_0x41fdf1[_0x628b('0x1a')][_0x628b('0x1c')]||null:null,'limit':_0x41fdf1[_0x628b('0x1a')]?_0x41fdf1[_0x628b('0x1a')][_0x628b('0x1d')]||null:null})[_0x628b('0xc')](function(_0x590109){logger[_0x628b('0xd')](_0x628b('0x22'),_0x41fdf1);logger[_0x628b('0x21')]('UpdateCmHopperBlack',_0x41fdf1,JSON[_0x628b('0x11')](_0x590109));_0x678439(_0x590109);})[_0x628b('0x16')](function(_0x335863){logger[_0x628b('0x12')]('UpdateCmHopperBlack',_0x335863['message'],_0x41fdf1);_0x1b3b84(_0x131676[_0x628b('0x12')](0x1f4,_0x335863['message']));});});};exports['DestroyCmHopperBlack']=function(_0x18066c){var _0x2adcf7=this;return new Promise(function(_0x15ac9e,_0x3ff2e2){return db['CmHopperBlack'][_0x628b('0x24')]({'where':_0x18066c[_0x628b('0x1a')]?_0x18066c[_0x628b('0x1a')][_0x628b('0x1b')]||null:null})[_0x628b('0xc')](function(_0x4a7134){logger[_0x628b('0xd')](_0x628b('0x25'),_0x18066c);logger[_0x628b('0x21')](_0x628b('0x25'),_0x18066c,JSON[_0x628b('0x11')](_0x4a7134));_0x15ac9e(_0x4a7134);})[_0x628b('0x16')](function(_0x55af69){logger[_0x628b('0x12')]('DestroyCmHopperBlack',_0x55af69[_0x628b('0x14')],_0x18066c);_0x3ff2e2(_0x2adcf7['error'](0x1f4,_0x55af69[_0x628b('0x14')]));});});};