Built motion from commit b5996064.|2.6.21
[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 _0x9841=['options','raw','then','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','info','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareRecording,\x20%s,\x20%s','message','result','catch','CreateSquareRecording','SquareRecording','create','body'];(function(_0x421e76,_0x3b8d1f){var _0x5e8cbe=function(_0x1dc135){while(--_0x1dc135){_0x421e76['push'](_0x421e76['shift']());}};_0x5e8cbe(++_0x3b8d1f);}(_0x9841,0x94));var _0x1984=function(_0x4d45a7,_0x1c8df0){_0x4d45a7=_0x4d45a7-0x0;var _0x535a5a=_0x9841[_0x4d45a7];return _0x535a5a;};'use strict';var _=require('lodash');var util=require(_0x1984('0x0'));var moment=require(_0x1984('0x1'));var BPromise=require(_0x1984('0x2'));var rs=require(_0x1984('0x3'));var fs=require('fs');var Redis=require(_0x1984('0x4'));var db=require(_0x1984('0x5'))['db'];var utils=require(_0x1984('0x6'));var logger=require(_0x1984('0x7'))('rpc');var config=require(_0x1984('0x8'));var jayson=require(_0x1984('0x9'));var client=jayson['client'][_0x1984('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2dfe9c,_0x211f31,_0x47ab0d){return new BPromise(function(_0x2bb7b7,_0x594293){return client['request'](_0x2dfe9c,_0x47ab0d)['then'](function(_0x5f3614){logger[_0x1984('0xb')]('SquareRecording,\x20%s,\x20%s',_0x211f31,_0x1984('0xc'));logger[_0x1984('0xd')](_0x1984('0xe'),_0x211f31,_0x1984('0xc'),JSON[_0x1984('0xf')](_0x5f3614));if(_0x5f3614['error']){if(_0x5f3614[_0x1984('0x10')][_0x1984('0x11')]===0x1f4){logger[_0x1984('0x10')](_0x1984('0x12'),_0x211f31,_0x5f3614[_0x1984('0x10')][_0x1984('0x13')]);return _0x594293(_0x5f3614[_0x1984('0x10')][_0x1984('0x13')]);}logger[_0x1984('0x10')](_0x1984('0x12'),_0x211f31,_0x5f3614[_0x1984('0x10')][_0x1984('0x13')]);return _0x2bb7b7(_0x5f3614[_0x1984('0x10')][_0x1984('0x13')]);}else{logger['info'](_0x1984('0x12'),_0x211f31,_0x1984('0xc'));_0x2bb7b7(_0x5f3614[_0x1984('0x14')][_0x1984('0x13')]);}})[_0x1984('0x15')](function(_0x321e3d){logger[_0x1984('0x10')](_0x1984('0x12'),_0x211f31,_0x321e3d);_0x594293(_0x321e3d);});});}exports[_0x1984('0x16')]=function(_0x521e4d){var _0x45eefc=this;return new Promise(function(_0x4487e4,_0x3aeec9){return db[_0x1984('0x17')][_0x1984('0x18')](_0x521e4d[_0x1984('0x19')],{'raw':_0x521e4d[_0x1984('0x1a')]?_0x521e4d[_0x1984('0x1a')][_0x1984('0x1b')]===undefined?!![]:![]:!![]})[_0x1984('0x1c')](function(_0x2eb577){logger[_0x1984('0xb')]('CreateSquareRecording',_0x521e4d);logger['debug']('CreateSquareRecording',_0x521e4d,JSON['stringify'](_0x2eb577));_0x4487e4(_0x2eb577);})[_0x1984('0x15')](function(_0x4d7731){logger['error']('CreateSquareRecording',_0x4d7731[_0x1984('0x13')],_0x521e4d);_0x3aeec9(_0x45eefc[_0x1984('0x10')](0x1f4,_0x4d7731[_0x1984('0x13')]));});});};