Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / squareOdbc / squareOdbc.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 _0x3f8c=['attributes','include','map','model','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','ShowSquareOdbc','SquareOdbc','options','raw'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3f8c,0x16c));var _0xc3f8=function(_0x21c52a,_0xc1b307){_0x21c52a=_0x21c52a-0x0;var _0x3a7718=_0x3f8c[_0x21c52a];return _0x3a7718;};'use strict';var _=require('lodash');var util=require(_0xc3f8('0x0'));var moment=require('moment');var BPromise=require(_0xc3f8('0x1'));var rs=require(_0xc3f8('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc3f8('0x3'))['db'];var utils=require(_0xc3f8('0x4'));var logger=require(_0xc3f8('0x5'))(_0xc3f8('0x6'));var config=require(_0xc3f8('0x7'));var jayson=require(_0xc3f8('0x8'));var client=jayson[_0xc3f8('0x9')][_0xc3f8('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x241946,_0x981e5f,_0x3375d2){return new BPromise(function(_0x956faa,_0x1ff165){return client[_0xc3f8('0xb')](_0x241946,_0x3375d2)['then'](function(_0x38e3e3){logger['info'](_0xc3f8('0xc'),_0x981e5f,_0xc3f8('0xd'));logger[_0xc3f8('0xe')](_0xc3f8('0xf'),_0x981e5f,'request\x20sent',JSON[_0xc3f8('0x10')](_0x38e3e3));if(_0x38e3e3['error']){if(_0x38e3e3[_0xc3f8('0x11')][_0xc3f8('0x12')]===0x1f4){logger[_0xc3f8('0x11')]('SquareOdbc,\x20%s,\x20%s',_0x981e5f,_0x38e3e3[_0xc3f8('0x11')][_0xc3f8('0x13')]);return _0x1ff165(_0x38e3e3[_0xc3f8('0x11')]['message']);}logger[_0xc3f8('0x11')]('SquareOdbc,\x20%s,\x20%s',_0x981e5f,_0x38e3e3[_0xc3f8('0x11')][_0xc3f8('0x13')]);return _0x956faa(_0x38e3e3[_0xc3f8('0x11')][_0xc3f8('0x13')]);}else{logger[_0xc3f8('0x14')](_0xc3f8('0xc'),_0x981e5f,_0xc3f8('0xd'));_0x956faa(_0x38e3e3['result'][_0xc3f8('0x13')]);}})[_0xc3f8('0x15')](function(_0x1dc00c){logger['error'](_0xc3f8('0xc'),_0x981e5f,_0x1dc00c);_0x1ff165(_0x1dc00c);});});}exports[_0xc3f8('0x16')]=function(_0x453c53){var _0x123183=this;return new Promise(function(_0x39ad82,_0x361f41){return db[_0xc3f8('0x17')]['find']({'raw':_0x453c53['options']?_0x453c53[_0xc3f8('0x18')][_0xc3f8('0x19')]===undefined?!![]:![]:!![],'where':_0x453c53[_0xc3f8('0x18')]?_0x453c53[_0xc3f8('0x18')]['where']||null:null,'attributes':_0x453c53[_0xc3f8('0x18')]?_0x453c53[_0xc3f8('0x18')][_0xc3f8('0x1a')]||null:null,'include':_0x453c53[_0xc3f8('0x18')]?_0x453c53[_0xc3f8('0x18')]['include']?_['map'](_0x453c53['options'][_0xc3f8('0x1b')],function(_0x400238){return{'model':db[_0x400238['model']],'as':_0x400238['as'],'attributes':_0x400238[_0xc3f8('0x1a')],'include':_0x400238['include']?_[_0xc3f8('0x1c')](_0x400238[_0xc3f8('0x1b')],function(_0x31e165){return{'model':db[_0x31e165[_0xc3f8('0x1d')]],'as':_0x31e165['as'],'attributes':_0x31e165[_0xc3f8('0x1a')],'include':_0x31e165[_0xc3f8('0x1b')]?_['map'](_0x31e165['include'],function(_0x5f4f65){return{'model':db[_0x5f4f65[_0xc3f8('0x1d')]],'as':_0x5f4f65['as'],'attributes':_0x5f4f65[_0xc3f8('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5d77a9){logger[_0xc3f8('0x14')]('ShowSquareOdbc',_0x453c53);logger[_0xc3f8('0xe')](_0xc3f8('0x16'),_0x453c53,JSON[_0xc3f8('0x10')](_0x5d77a9));_0x39ad82(_0x5d77a9);})[_0xc3f8('0x15')](function(_0x31b810){logger[_0xc3f8('0x11')](_0xc3f8('0x16'),_0x31b810[_0xc3f8('0x13')],_0x453c53);_0x361f41(_0x123183['error'](0x1f4,_0x31b810[_0xc3f8('0x13')]));});});};