ca87525ae8e7b6a340499f65738ce2c7161547dd
[motion2.git] / server / api / intDeskAccount / intDeskAccount.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 _0xd09c=['find','raw','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','DeskAccount,\x20%s,\x20%s','debug','DeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','DeskAccount','findAll','options','where','limit','include','map','model','attributes','GetDeskAccount','ShowDeskAccount'];(function(_0x36b037,_0x2b234e){var _0x409194=function(_0xddc9dc){while(--_0xddc9dc){_0x36b037['push'](_0x36b037['shift']());}};_0x409194(++_0x2b234e);}(_0xd09c,0x174));var _0xcd09=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xd09c[_0x321bb2];return _0x9c12ed;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xcd09('0x0'));var rs=require(_0xcd09('0x1'));var fs=require('fs');var Redis=require(_0xcd09('0x2'));var db=require(_0xcd09('0x3'))['db'];var utils=require(_0xcd09('0x4'));var logger=require(_0xcd09('0x5'))(_0xcd09('0x6'));var config=require(_0xcd09('0x7'));var jayson=require(_0xcd09('0x8'));var client=jayson[_0xcd09('0x9')][_0xcd09('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x8b883,_0x43ab82,_0x13f3d2){return new BPromise(function(_0x4d7793,_0x2656fb){return client[_0xcd09('0xb')](_0x8b883,_0x13f3d2)[_0xcd09('0xc')](function(_0xbc15e1){logger[_0xcd09('0xd')](_0xcd09('0xe'),_0x43ab82,'request\x20sent');logger[_0xcd09('0xf')](_0xcd09('0x10'),_0x43ab82,_0xcd09('0x11'),JSON[_0xcd09('0x12')](_0xbc15e1));if(_0xbc15e1[_0xcd09('0x13')]){if(_0xbc15e1[_0xcd09('0x13')][_0xcd09('0x14')]===0x1f4){logger[_0xcd09('0x13')]('DeskAccount,\x20%s,\x20%s',_0x43ab82,_0xbc15e1[_0xcd09('0x13')][_0xcd09('0x15')]);return _0x2656fb(_0xbc15e1[_0xcd09('0x13')]['message']);}logger['error'](_0xcd09('0xe'),_0x43ab82,_0xbc15e1[_0xcd09('0x13')][_0xcd09('0x15')]);return _0x4d7793(_0xbc15e1['error']['message']);}else{logger['info'](_0xcd09('0xe'),_0x43ab82,_0xcd09('0x11'));_0x4d7793(_0xbc15e1[_0xcd09('0x16')][_0xcd09('0x15')]);}})[_0xcd09('0x17')](function(_0x5da980){logger[_0xcd09('0x13')](_0xcd09('0xe'),_0x43ab82,_0x5da980);_0x2656fb(_0x5da980);});});}exports['GetDeskAccount']=function(_0x37e5b6){var _0x1442d9=this;return new Promise(function(_0x21dd8b,_0x5dcf56){return db[_0xcd09('0x18')][_0xcd09('0x19')]({'raw':_0x37e5b6['options']?_0x37e5b6[_0xcd09('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x37e5b6[_0xcd09('0x1a')]?_0x37e5b6[_0xcd09('0x1a')][_0xcd09('0x1b')]||null:null,'attributes':_0x37e5b6[_0xcd09('0x1a')]?_0x37e5b6['options']['attributes']||null:null,'limit':_0x37e5b6[_0xcd09('0x1a')]?_0x37e5b6[_0xcd09('0x1a')][_0xcd09('0x1c')]||null:null,'include':_0x37e5b6[_0xcd09('0x1a')]?_0x37e5b6[_0xcd09('0x1a')][_0xcd09('0x1d')]?_[_0xcd09('0x1e')](_0x37e5b6[_0xcd09('0x1a')][_0xcd09('0x1d')],function(_0x27ec0f){return{'model':db[_0x27ec0f[_0xcd09('0x1f')]],'as':_0x27ec0f['as'],'attributes':_0x27ec0f[_0xcd09('0x20')],'include':_0x27ec0f[_0xcd09('0x1d')]?_[_0xcd09('0x1e')](_0x27ec0f[_0xcd09('0x1d')],function(_0x43c11a){return{'model':db[_0x43c11a[_0xcd09('0x1f')]],'as':_0x43c11a['as'],'attributes':_0x43c11a[_0xcd09('0x20')],'include':_0x43c11a[_0xcd09('0x1d')]?_[_0xcd09('0x1e')](_0x43c11a[_0xcd09('0x1d')],function(_0x5608f3){return{'model':db[_0x5608f3[_0xcd09('0x1f')]],'as':_0x5608f3['as'],'attributes':_0x5608f3[_0xcd09('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2dee2b){logger['info'](_0xcd09('0x21'),_0x37e5b6);logger[_0xcd09('0xf')](_0xcd09('0x21'),_0x37e5b6,JSON[_0xcd09('0x12')](_0x2dee2b));_0x21dd8b(_0x2dee2b);})['catch'](function(_0x10c44f){logger[_0xcd09('0x13')](_0xcd09('0x21'),_0x10c44f['message'],_0x37e5b6);_0x5dcf56(_0x1442d9['error'](0x1f4,_0x10c44f[_0xcd09('0x15')]));});});};exports[_0xcd09('0x22')]=function(_0x1b7eee){var _0x3eda85=this;return new Promise(function(_0x238724,_0x494cae){return db[_0xcd09('0x18')][_0xcd09('0x23')]({'raw':_0x1b7eee[_0xcd09('0x1a')]?_0x1b7eee['options'][_0xcd09('0x24')]===undefined?!![]:![]:!![],'where':_0x1b7eee[_0xcd09('0x1a')]?_0x1b7eee[_0xcd09('0x1a')]['where']||null:null,'attributes':_0x1b7eee[_0xcd09('0x1a')]?_0x1b7eee[_0xcd09('0x1a')][_0xcd09('0x20')]||null:null,'include':_0x1b7eee[_0xcd09('0x1a')]?_0x1b7eee[_0xcd09('0x1a')]['include']?_[_0xcd09('0x1e')](_0x1b7eee[_0xcd09('0x1a')][_0xcd09('0x1d')],function(_0x191af0){return{'model':db[_0x191af0['model']],'as':_0x191af0['as'],'attributes':_0x191af0['attributes'],'include':_0x191af0['include']?_['map'](_0x191af0[_0xcd09('0x1d')],function(_0x43285c){return{'model':db[_0x43285c[_0xcd09('0x1f')]],'as':_0x43285c['as'],'attributes':_0x43285c[_0xcd09('0x20')],'include':_0x43285c[_0xcd09('0x1d')]?_['map'](_0x43285c[_0xcd09('0x1d')],function(_0x4d08aa){return{'model':db[_0x4d08aa[_0xcd09('0x1f')]],'as':_0x4d08aa['as'],'attributes':_0x4d08aa[_0xcd09('0x20')]};}):[]};}):[]};}):[]:[]})[_0xcd09('0xc')](function(_0x233e9e){logger[_0xcd09('0xd')](_0xcd09('0x22'),_0x1b7eee);logger[_0xcd09('0xf')](_0xcd09('0x22'),_0x1b7eee,JSON[_0xcd09('0x12')](_0x233e9e));_0x238724(_0x233e9e);})['catch'](function(_0x2e02be){logger[_0xcd09('0x13')]('ShowDeskAccount',_0x2e02be[_0xcd09('0x15')],_0x1b7eee);_0x494cae(_0x3eda85[_0xcd09('0x13')](0x1f4,_0x2e02be[_0xcd09('0x15')]));});});};