fac6ae7db12e89b83a4b0f5ee8890beda3c94424
[motion2.git] / server / api / squareRecording / squareRecording.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 _0x1764=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','then','info','SquareRecording,\x20%s,\x20%s','SquareRecording,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CreateSquareRecording','create','body','options','raw','debug','lodash'];(function(_0x27ec50,_0x1d8698){var _0x2da0f5=function(_0x206a3e){while(--_0x206a3e){_0x27ec50['push'](_0x27ec50['shift']());}};_0x2da0f5(++_0x1d8698);}(_0x1764,0x1cf));var _0x4176=function(_0x2b09f6,_0x51a4a1){_0x2b09f6=_0x2b09f6-0x0;var _0x1deb45=_0x1764[_0x2b09f6];return _0x1deb45;};'use strict';var _=require(_0x4176('0x0'));var util=require(_0x4176('0x1'));var moment=require(_0x4176('0x2'));var BPromise=require(_0x4176('0x3'));var rs=require(_0x4176('0x4'));var fs=require('fs');var Redis=require(_0x4176('0x5'));var db=require(_0x4176('0x6'))['db'];var utils=require(_0x4176('0x7'));var logger=require(_0x4176('0x8'))(_0x4176('0x9'));var config=require(_0x4176('0xa'));var jayson=require(_0x4176('0xb'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x56c21b,_0x3f535b,_0x4ed703){return new BPromise(function(_0x4e8d64,_0x3a90d1){return client['request'](_0x56c21b,_0x4ed703)[_0x4176('0xc')](function(_0x26f2d5){logger[_0x4176('0xd')](_0x4176('0xe'),_0x3f535b,'request\x20sent');logger['debug'](_0x4176('0xf'),_0x3f535b,_0x4176('0x10'),JSON[_0x4176('0x11')](_0x26f2d5));if(_0x26f2d5[_0x4176('0x12')]){if(_0x26f2d5['error'][_0x4176('0x13')]===0x1f4){logger[_0x4176('0x12')](_0x4176('0xe'),_0x3f535b,_0x26f2d5['error'][_0x4176('0x14')]);return _0x3a90d1(_0x26f2d5[_0x4176('0x12')][_0x4176('0x14')]);}logger['error'](_0x4176('0xe'),_0x3f535b,_0x26f2d5[_0x4176('0x12')][_0x4176('0x14')]);return _0x4e8d64(_0x26f2d5['error'][_0x4176('0x14')]);}else{logger['info'](_0x4176('0xe'),_0x3f535b,_0x4176('0x10'));_0x4e8d64(_0x26f2d5[_0x4176('0x15')][_0x4176('0x14')]);}})[_0x4176('0x16')](function(_0x571e03){logger[_0x4176('0x12')](_0x4176('0xe'),_0x3f535b,_0x571e03);_0x3a90d1(_0x571e03);});});}exports[_0x4176('0x17')]=function(_0x48b216){var _0x1f781b=this;return new Promise(function(_0x230fd3,_0x41ea9a){return db['SquareRecording'][_0x4176('0x18')](_0x48b216[_0x4176('0x19')],{'raw':_0x48b216[_0x4176('0x1a')]?_0x48b216[_0x4176('0x1a')][_0x4176('0x1b')]===undefined?!![]:![]:!![]})[_0x4176('0xc')](function(_0x371a9b){logger[_0x4176('0xd')](_0x4176('0x17'),_0x48b216);logger[_0x4176('0x1c')](_0x4176('0x17'),_0x48b216,JSON[_0x4176('0x11')](_0x371a9b));_0x230fd3(_0x371a9b);})['catch'](function(_0x49b63e){logger[_0x4176('0x12')](_0x4176('0x17'),_0x49b63e['message'],_0x48b216);_0x41ea9a(_0x1f781b[_0x4176('0x12')](0x1f4,_0x49b63e[_0x4176('0x14')]));});});};