Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / api / squareProject / squareProject.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 _0x9458=['moment','bluebird','randomstring','ioredis','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','request','then','info','debug','SquareProject,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','SquareProject,\x20%s,\x20%s','result','catch','ShowSquareProject','SquareProject','find','options','raw','where','include','model','map','attributes','lodash'];(function(_0x2f50db,_0x29205b){var _0x345e51=function(_0x511551){while(--_0x511551){_0x2f50db['push'](_0x2f50db['shift']());}};_0x345e51(++_0x29205b);}(_0x9458,0x15d));var _0x8945=function(_0x1ba81f,_0x3e65d0){_0x1ba81f=_0x1ba81f-0x0;var _0x2aa9aa=_0x9458[_0x1ba81f];return _0x2aa9aa;};'use strict';var _=require(_0x8945('0x0'));var util=require('util');var moment=require(_0x8945('0x1'));var BPromise=require(_0x8945('0x2'));var rs=require(_0x8945('0x3'));var fs=require('fs');var Redis=require(_0x8945('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x8945('0x5'));var jayson=require(_0x8945('0x6'));var client=jayson[_0x8945('0x7')][_0x8945('0x8')]({'port':0x232a});config['redis']=_[_0x8945('0x9')](config[_0x8945('0xa')],{'host':_0x8945('0xb'),'port':0x18eb});var socket=require(_0x8945('0xc'))(new Redis(config[_0x8945('0xa')]));require('./squareProject.socket')['register'](socket);function respondWithRpcPromise(_0x4e2963,_0xd9e101,_0x1173e7){return new BPromise(function(_0xe18176,_0x4a8aa0){return client[_0x8945('0xd')](_0x4e2963,_0x1173e7)[_0x8945('0xe')](function(_0x4ec002){logger[_0x8945('0xf')]('SquareProject,\x20%s,\x20%s',_0xd9e101,'request\x20sent');logger[_0x8945('0x10')](_0x8945('0x11'),_0xd9e101,_0x8945('0x12'),JSON[_0x8945('0x13')](_0x4ec002));if(_0x4ec002[_0x8945('0x14')]){if(_0x4ec002['error']['code']===0x1f4){logger[_0x8945('0x14')]('SquareProject,\x20%s,\x20%s',_0xd9e101,_0x4ec002[_0x8945('0x14')][_0x8945('0x15')]);return _0x4a8aa0(_0x4ec002[_0x8945('0x14')][_0x8945('0x15')]);}logger[_0x8945('0x14')](_0x8945('0x16'),_0xd9e101,_0x4ec002[_0x8945('0x14')][_0x8945('0x15')]);return _0xe18176(_0x4ec002[_0x8945('0x14')][_0x8945('0x15')]);}else{logger['info'](_0x8945('0x16'),_0xd9e101,_0x8945('0x12'));_0xe18176(_0x4ec002[_0x8945('0x17')]['message']);}})[_0x8945('0x18')](function(_0x2e4bb0){logger[_0x8945('0x14')](_0x8945('0x16'),_0xd9e101,_0x2e4bb0);_0x4a8aa0(_0x2e4bb0);});});}exports[_0x8945('0x19')]=function(_0x1b55ad){var _0x578fc2=this;return new Promise(function(_0x5f986e,_0x4b79d9){return db[_0x8945('0x1a')][_0x8945('0x1b')]({'raw':_0x1b55ad[_0x8945('0x1c')]?_0x1b55ad[_0x8945('0x1c')][_0x8945('0x1d')]===undefined?!![]:![]:!![],'where':_0x1b55ad['options']?_0x1b55ad[_0x8945('0x1c')][_0x8945('0x1e')]||null:null,'attributes':_0x1b55ad['options']?_0x1b55ad[_0x8945('0x1c')]['attributes']||null:null,'include':_0x1b55ad[_0x8945('0x1c')]?_0x1b55ad['options'][_0x8945('0x1f')]?_['map'](_0x1b55ad['options'][_0x8945('0x1f')],function(_0x50d4d3){return{'model':db[_0x50d4d3[_0x8945('0x20')]],'as':_0x50d4d3['as'],'attributes':_0x50d4d3['attributes'],'include':_0x50d4d3[_0x8945('0x1f')]?_[_0x8945('0x21')](_0x50d4d3['include'],function(_0x23cd7d){return{'model':db[_0x23cd7d[_0x8945('0x20')]],'as':_0x23cd7d['as'],'attributes':_0x23cd7d['attributes'],'include':_0x23cd7d['include']?_[_0x8945('0x21')](_0x23cd7d[_0x8945('0x1f')],function(_0x3a7b6a){return{'model':db[_0x3a7b6a[_0x8945('0x20')]],'as':_0x3a7b6a['as'],'attributes':_0x3a7b6a[_0x8945('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2ce9ab){logger[_0x8945('0xf')](_0x8945('0x19'),_0x1b55ad);logger[_0x8945('0x10')](_0x8945('0x19'),_0x1b55ad,JSON[_0x8945('0x13')](_0x2ce9ab));_0x5f986e(_0x2ce9ab);})[_0x8945('0x18')](function(_0x1313ed){logger[_0x8945('0x14')](_0x8945('0x19'),_0x1313ed[_0x8945('0x15')],_0x1b55ad);_0x4b79d9(_0x578fc2['error'](0x1f4,_0x1313ed[_0x8945('0x15')]));});});};